diff options
author | Glen Mazza <gmazza@apache.org> | 2004-05-09 20:45:15 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-05-09 20:45:15 +0000 |
commit | 240bcc0c6d3af5ce0e8f9d2c2ca40f0d546f5b9f (patch) | |
tree | ae4d5e5f84d2281ea5e61949178de03aede5d000 /src/java/org/apache/fop | |
parent | 3d81811b573c812279c1a328f6aa132ea8cad2ab (diff) | |
download | xmlgraphics-fop-240bcc0c6d3af5ce0e8f9d2c2ca40f0d546f5b9f.tar.gz xmlgraphics-fop-240bcc0c6d3af5ce0e8f9d2c2ca40f0d546f5b9f.zip |
String->int conversion and a few other simplifications to fo.Region* classes.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
13 files changed, 41 insertions, 91 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index 0e6069be9..4ad02daab 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -140,11 +140,12 @@ public class LayoutMasterSet extends FObj { } /** - * 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();) { @@ -153,22 +154,22 @@ public class LayoutMasterSet extends FObj { 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()); } } } diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index ce6842945..bccd5402f 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -32,17 +32,6 @@ import org.xml.sax.Attributes; */ 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; @@ -56,6 +45,7 @@ public abstract class Region extends FObj { public static final int AFTER_CODE = 4; private SimplePageMaster layoutMaster; + private int regionId = -1; private String regionName; /** Holds the overflow attribute */ @@ -66,8 +56,9 @@ public abstract class Region extends FObj { /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ - protected Region(FONode parent) { + protected Region(FONode parent, int id) { super(parent); + regionId = id; } /** @@ -115,13 +106,6 @@ public abstract class Region extends FObj { */ 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 @@ -179,9 +163,9 @@ public abstract class Region extends FObj { * @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); } /** diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java index c857da826..38049c3e6 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java @@ -35,7 +35,7 @@ public class RegionAfter extends RegionBA { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionAfter(FONode parent) { - super(parent); + super(parent, Region.AFTER_CODE); } /** @@ -63,13 +63,6 @@ public class RegionAfter extends RegionBA { } /** - * @see org.apache.fop.fo.pagination.Region#getRegionClass() - */ - public String getRegionClass() { - return Region.AFTER; - } - - /** * @see org.apache.fop.fo.pagination.Region#getRegionClassCode() */ public int getRegionClassCode() { diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java index ebd91d308..ca9622af3 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBA.java @@ -35,8 +35,8 @@ public abstract class RegionBA extends RegionBASE { /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ - protected RegionBA(FONode parent) { - super(parent); + protected RegionBA(FONode parent, int regionId) { + super(parent, regionId); } /** diff --git a/src/java/org/apache/fop/fo/pagination/RegionBASE.java b/src/java/org/apache/fop/fo/pagination/RegionBASE.java index 694949643..a411d1098 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBASE.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBASE.java @@ -32,8 +32,8 @@ public abstract class RegionBASE extends Region { /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ - protected RegionBASE(FONode parent) { - super(parent); + protected RegionBASE(FONode parent, int regionId) { + super(parent, regionId); } /** diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index a0d1d3786..f9d3ec66f 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java @@ -35,7 +35,7 @@ public class RegionBefore extends RegionBA { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionBefore(FONode parent) { - super(parent); + super(parent, Region.BEFORE_CODE); } /** @@ -46,13 +46,6 @@ public class RegionBefore extends RegionBA { } /** - * @see org.apache.fop.fo.pagination.Region#getRegionClass() - */ - public String getRegionClass() { - return Region.BEFORE; - } - - /** * @see org.apache.fop.fo.pagination.Region#getRegionClassCode() */ public int getRegionClassCode() { diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index 0f7e840ad..6de00eb60 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -41,7 +41,7 @@ public class RegionBody extends Region { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionBody(FONode parent) { - super(parent); + super(parent, Region.BODY_CODE); } /** @@ -96,13 +96,6 @@ public class RegionBody extends Region { } /** - * @see org.apache.fop.fo.pagination.Region#getRegionClass() - */ - public String getRegionClass() { - return Region.BODY; - } - - /** * @see org.apache.fop.fo.pagination.Region#getRegionClassCode() */ public int getRegionClassCode() { diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java index d29e55870..597517c5d 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java @@ -36,7 +36,7 @@ public class RegionEnd extends RegionSE { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionEnd(FONode parent) { - super(parent); + super(parent, Region.END_CODE); } /** @@ -64,13 +64,6 @@ public class RegionEnd extends RegionSE { } /** - * @see org.apache.fop.fo.pagination.Region#getRegionClass() - */ - public String getRegionClass() { - return Region.END; - } - - /** * @see org.apache.fop.fo.pagination.Region#getRegionClassCode() */ public int getRegionClassCode() { diff --git a/src/java/org/apache/fop/fo/pagination/RegionSE.java b/src/java/org/apache/fop/fo/pagination/RegionSE.java index e2c9d34e9..98040d541 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionSE.java +++ b/src/java/org/apache/fop/fo/pagination/RegionSE.java @@ -33,8 +33,8 @@ public abstract class RegionSE extends RegionBASE { /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ - protected RegionSE(FONode parent) { - super(parent); + protected RegionSE(FONode parent, int regionId) { + super(parent, regionId); } /** diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java index fbdb76533..9fb29b1b5 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java @@ -35,7 +35,7 @@ public class RegionStart extends RegionSE { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionStart(FONode parent) { - super(parent); + super(parent, Region.START_CODE); } /** @@ -63,13 +63,6 @@ public class RegionStart extends RegionSE { } /** - * @see org.apache.fop.fo.pagination.Region#getRegionClass() - */ - public String getRegionClass() { - return Region.START; - } - - /** * @see org.apache.fop.fo.pagination.Region#getRegionClassCode() */ public int getRegionClassCode() { diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java index a9100e557..542a91261 100644 --- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -108,9 +108,9 @@ public class SimplePageMaster extends FObj { * @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 { @@ -123,8 +123,8 @@ public class SimplePageMaster extends FObj { * @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)); } /** diff --git a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java index 84f0fe121..958834654 100644 --- a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java @@ -489,13 +489,13 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable } // 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); @@ -706,7 +706,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable 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 '" diff --git a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java index fb34f9413..5220bb1bc 100644 --- a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java @@ -55,9 +55,9 @@ class PageAttributesConverter { 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; |