1 51 package org.apache.fop.fo.pagination; 52 53 import org.apache.fop.fo.FObj; 55 import org.apache.fop.fo.PropertyList; 56 import org.apache.fop.apps.FOPException; 57 import org.apache.fop.layout.RegionArea; 58 59 62 public abstract class Region extends FObj { 63 public static final String PROP_REGION_NAME = "region-name"; 64 65 private SimplePageMaster _layoutMaster; 66 private String _regionName; 67 68 protected Region(FObj parent, PropertyList propertyList, 69 String systemId, int line, int column) 70 throws FOPException { 71 super(parent, propertyList, systemId, line, column); 72 73 if (null == this.properties.get(PROP_REGION_NAME)) { 75 setRegionName(getDefaultRegionName()); 76 } else if (this.properties.get(PROP_REGION_NAME).getString().equals("")) { 77 setRegionName(getDefaultRegionName()); 78 } else { 79 setRegionName(this.properties.get(PROP_REGION_NAME).getString()); 80 if (isReserved(getRegionName()) 82 &&!getRegionName().equals(getDefaultRegionName())) { 83 throw new FOPException(PROP_REGION_NAME + " '" + _regionName 84 + "' for " + this.getName() 85 + " not permitted.", systemId, line, column); 86 } 87 } 88 89 if (parent.getName().equals("fo:simple-page-master")) { 90 _layoutMaster = (SimplePageMaster)parent; 91 getPageMaster().addRegion(this); 92 } else { 93 throw new FOPException(getName() + " must be child " 94 + "of simple-page-master, not " 95 + parent.getName(), systemId, line, column); 96 } 97 } 98 99 102 abstract RegionArea makeRegionArea(int allocationRectangleXPosition, 103 int allocationRectangleYPosition, 104 int allocationRectangleWidth, 105 int allocationRectangleHeight); 106 107 111 protected abstract String getDefaultRegionName(); 112 113 public abstract String getRegionClass(); 114 115 116 119 public String getRegionName() { 120 return _regionName; 121 } 122 123 private void setRegionName(String name) { 124 _regionName = name; 125 } 126 127 protected SimplePageMaster getPageMaster() { 128 return _layoutMaster; 129 } 130 131 137 protected boolean isReserved(String name) throws FOPException { 138 return (name.equals("xsl-region-before") 139 || name.equals("xsl-region-start") 140 || name.equals("xsl-region-end") 141 || name.equals("xsl-region-after") 142 || name.equals("xsl-before-float-separator") 143 || name.equals("xsl-footnote-separator")); 144 } 145 146 public boolean generatesReferenceAreas() { 147 return true; 148 } 149 150 } 151 | Popular Tags |