}
/**
- * Section 7.33.15: check to see that if a region-name is a
- * duplicate, that it maps to the same region-class.
+ * Section 7.25.7: check to see that if a region-name is a
+ * duplicate, that it maps to the same fo region-class.
* @throws FOPException if there's a name duplication
*/
public void checkRegionNames() throws FOPException {
+ // (user-entered) region-name to default region map.
Map allRegions = new java.util.HashMap();
for (Iterator spm = simplePageMasters.values().iterator();
spm.hasNext();) {
Map spmRegions = simplePageMaster.getRegions();
for (Iterator e = spmRegions.values().iterator();
e.hasNext();) {
- Region region = (Region)e.next();
+ Region region = (Region) e.next();
if (allRegions.containsKey(region.getRegionName())) {
- String localClass =
- (String)allRegions.get(region.getRegionName());
- if (!localClass.equals(region.getRegionClass())) {
- throw new FOPException("Duplicate region-names ("
+ String defaultRegionName =
+ (String) allRegions.get(region.getRegionName());
+ if (!defaultRegionName.equals(region.getDefaultRegionName())) {
+ throw new FOPException("Region-name ("
+ region.getRegionName()
- + ") must map "
- + "to the same region-class ("
- + localClass + "!="
- + region.getRegionClass()
+ + ") is being mapped to multiple "
+ + "region-classes ("
+ + defaultRegionName + " and "
+ + region.getDefaultRegionName()
+ ")");
}
}
allRegions.put(region.getRegionName(),
- region.getRegionClass());
+ region.getDefaultRegionName());
}
}
}
*/
public abstract class Region extends FObj {
- /** Key for before regions */
- public static final String BEFORE = "before";
- /** Key for start regions */
- public static final String START = "start";
- /** Key for end regions */
- public static final String END = "end";
- /** Key for after regions */
- public static final String AFTER = "after";
- /** Key for body regions */
- public static final String BODY = "body";
-
/* The following codes correspond to those found in area/RegionReference */
/** Integer Code for before regions */
public static final int BEFORE_CODE = 0;
public static final int AFTER_CODE = 4;
private SimplePageMaster layoutMaster;
+ private int regionId = -1;
private String regionName;
/** Holds the overflow attribute */
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
- protected Region(FONode parent) {
+ protected Region(FONode parent, int id) {
super(parent);
+ regionId = id;
}
/**
*/
protected abstract String getDefaultRegionName();
-
- /**
- * Returns the region class name.
- * @return the region class name
- */
- public abstract String getRegionClass();
-
/**
* Returns the region class code.
* @return the region class code
* @param regionClass the class of the requested region
* @return the requested region
*/
- protected Region getSiblingRegion(String regionClass) {
+ protected Region getSiblingRegion(int regionId) {
// Ask parent for region
- return layoutMaster.getRegion(regionClass);
+ return layoutMaster.getRegion(regionId);
}
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionAfter(FONode parent) {
- super(parent);
+ super(parent, Region.AFTER_CODE);
}
/**
return "xsl-region-after";
}
- /**
- * @see org.apache.fop.fo.pagination.Region#getRegionClass()
- */
- public String getRegionClass() {
- return Region.AFTER;
- }
-
/**
* @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
*/
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
- protected RegionBA(FONode parent) {
- super(parent);
+ protected RegionBA(FONode parent, int regionId) {
+ super(parent, regionId);
}
/**
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
- protected RegionBASE(FONode parent) {
- super(parent);
+ protected RegionBASE(FONode parent, int regionId) {
+ super(parent, regionId);
}
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionBefore(FONode parent) {
- super(parent);
+ super(parent, Region.BEFORE_CODE);
}
/**
return "xsl-region-before";
}
- /**
- * @see org.apache.fop.fo.pagination.Region#getRegionClass()
- */
- public String getRegionClass() {
- return Region.BEFORE;
- }
-
/**
* @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
*/
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionBody(FONode parent) {
- super(parent);
+ super(parent, Region.BODY_CODE);
}
/**
return "xsl-region-body";
}
- /**
- * @see org.apache.fop.fo.pagination.Region#getRegionClass()
- */
- public String getRegionClass() {
- return Region.BODY;
- }
-
/**
* @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
*/
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionEnd(FONode parent) {
- super(parent);
+ super(parent, Region.END_CODE);
}
/**
return "xsl-region-end";
}
- /**
- * @see org.apache.fop.fo.pagination.Region#getRegionClass()
- */
- public String getRegionClass() {
- return Region.END;
- }
-
/**
* @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
*/
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
- protected RegionSE(FONode parent) {
- super(parent);
+ protected RegionSE(FONode parent, int regionId) {
+ super(parent, regionId);
}
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionStart(FONode parent) {
- super(parent);
+ super(parent, Region.START_CODE);
}
/**
return "xsl-region-start";
}
- /**
- * @see org.apache.fop.fo.pagination.Region#getRegionClass()
- */
- public String getRegionClass() {
- return Region.START;
- }
-
/**
* @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
*/
* @param region region to add
*/
protected void addRegion(Region region) {
- String key = region.getRegionClass();
+ String key = String.valueOf(region.getRegionClassCode());
if (regions.containsKey(key)) {
- getLogger().error("Only one region of class " + key
+ getLogger().error("Only one region of class " + region.getRegionName()
+ " allowed within a simple-page-master. The duplicate"
+ " region (" + region.getName() + ") is ignored.");
} else {
* @param regionClass region class to lookup
* @return the region, null if it doesn't exist
*/
- public Region getRegion(String regionClass) {
- return (Region)regions.get(regionClass);
+ public Region getRegion(int regionId) {
+ return (Region) regions.get(String.valueOf(regionId));
}
/**
}
// Layout static content into the regions
// Need help from pageseq for this
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.BEFORE),
+ layoutStaticContent(currentSimplePageMaster.getRegion(Region.BEFORE_CODE),
Region.BEFORE_CODE);
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.AFTER),
+ layoutStaticContent(currentSimplePageMaster.getRegion(Region.AFTER_CODE),
Region.AFTER_CODE);
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.START),
+ layoutStaticContent(currentSimplePageMaster.getRegion(Region.START_CODE),
Region.START_CODE);
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.END),
+ layoutStaticContent(currentSimplePageMaster.getRegion(Region.END_CODE),
Region.END_CODE);
// Queue for ID resolution and rendering
areaTree.addPage(curPage);
private PageViewport createPage(boolean bIsBlank, boolean bIsLast)
throws FOPException {
currentSimplePageMaster = getSimplePageMasterToUse(bIsBlank);
- Region body = currentSimplePageMaster.getRegion(Region.BODY);
+ Region body = currentSimplePageMaster.getRegion(Region.BODY_CODE);
if (!pageSequence.getMainFlow().getFlowName().equals(body.getRegionName())) {
throw new FOPException("Flow '" + pageSequence.getMainFlow().getFlowName()
+ "' does not map to the region-body in page-master '"
Property p = null;
Float f = null;
- Region before = pagemaster.getRegion("before");
- Region body = pagemaster.getRegion("body");
- Region after = pagemaster.getRegion("after");
+ Region before = pagemaster.getRegion(Region.BEFORE_CODE);
+ Region body = pagemaster.getRegion(Region.BODY_CODE);
+ Region after = pagemaster.getRegion(Region.AFTER_CODE);
//page attributes
props = pagemaster.propertyList;