diff options
author | William Victor Mote <vmote@apache.org> | 2003-08-26 22:11:17 +0000 |
---|---|---|
committer | William Victor Mote <vmote@apache.org> | 2003-08-26 22:11:17 +0000 |
commit | 2bcc2b69e50c8bdf4f79ae0295ec65f3cb3b443e (patch) | |
tree | 4b5f626a17d495dc4c985eeaa14ee27d85d7be78 /src | |
parent | db67b47747979aebc1903f673bc3646a4116fc9d (diff) | |
download | xmlgraphics-fop-2bcc2b69e50c8bdf4f79ae0295ec65f3cb3b443e.tar.gz xmlgraphics-fop-2bcc2b69e50c8bdf4f79ae0295ec65f3cb3b443e.zip |
move logic from fo/pagination/SimplePageMaster.end() to layoutmgr/PageLayoutManager.createSimplePageMasterAreas()
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196853 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
3 files changed, 77 insertions, 71 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index c3c5bee2b..8c7043875 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -204,7 +204,7 @@ public abstract class Region extends FObj { * Area tree. * @return the region area class */ - protected abstract int getRegionAreaClass(); + public abstract int getRegionAreaClass(); /** * Returns the default region name (xsl-region-before, xsl-region-start, diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java index bc58b0d5a..d45e98aea 100644 --- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -51,7 +51,6 @@ package org.apache.fop.fo.pagination; // Java -import java.awt.Rectangle; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -60,16 +59,12 @@ import java.util.Map; import org.xml.sax.Attributes; // FOP -import org.apache.fop.area.CTM; -import org.apache.fop.datatypes.FODimension; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.area.PageViewport; import org.apache.fop.area.Page; -import org.apache.fop.area.RegionViewport; import org.apache.fop.area.RegionReference; -import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.layout.PageMaster; import org.apache.fop.apps.FOPException; @@ -119,67 +114,6 @@ public class SimplePageMaster extends FObj { } /** - * At the end of this element read all the information and create - * the page master. - */ - protected void end() { - int pageWidth = - this.properties.get("page-width").getLength().getValue(); - int pageHeight = - this.properties.get("page-height").getLength().getValue(); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - // Get absolute margin properties (top, left, bottom, right) - CommonMarginBlock mProps = propMgr.getMarginProps(); - - /* Create the page reference area rectangle (0,0 is at top left - * of the "page media" and y increases - * when moving towards the bottom of the page. - * The media rectangle itself is (0,0,pageWidth,pageHeight). - */ - Rectangle pageRefRect = - new Rectangle(mProps.marginLeft, mProps.marginTop, - pageWidth - mProps.marginLeft - mProps.marginRight, - pageHeight - mProps.marginTop - mProps.marginBottom); - - // ??? KL shouldn't this take the viewport too??? - Page page = new Page(); // page reference area - - // Set up the CTM on the page reference area based on writing-mode - // and reference-orientation - FODimension reldims = new FODimension(0, 0); - CTM pageCTM = CTM.getCTMandRelDims(propMgr.getAbsRefOrient(), - propMgr.getWritingMode(), pageRefRect, reldims); - - // Create a RegionViewport/ reference area pair for each page region - - boolean bHasBody = false; - - for (Iterator regenum = regions.values().iterator(); - regenum.hasNext();) { - Region r = (Region)regenum.next(); - RegionViewport rvp = r.makeRegionViewport(reldims, pageCTM); - rvp.setRegion(r.makeRegionReferenceArea(rvp.getViewArea())); - page.setRegion(r.getRegionAreaClass(), rvp); - if (r.getRegionAreaClass() == RegionReference.BODY) { - bHasBody = true; - } - } - - if (!bHasBody) { - getLogger().error("simple-page-master has no region-body"); - } - - this.pageMaster = new PageMaster(new PageViewport(page, - new Rectangle(0, 0, pageWidth, pageHeight))); - - // regions = null; // PageSequence access SimplePageMaster.... - children = null; - properties = null; - } - - /** * @see org.apache.fop.fo.FObj#generatesReferenceAreas() */ public boolean generatesReferenceAreas() { @@ -194,6 +128,10 @@ public class SimplePageMaster extends FObj { return this.pageMaster; } + public void setPageMaster(PageMaster pageMaster) { + this.pageMaster = pageMaster; + } + /** * Returns the next page master. For simple-page-master this is always the * same as the previous. @@ -251,7 +189,7 @@ public class SimplePageMaster extends FObj { * Returns a Map of regions associated with this simple-page-master * @return the regions */ - protected Map getRegions() { + public Map getRegions() { return regions; } diff --git a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java index ee422c051..bd427b3fa 100644 --- a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java @@ -51,11 +51,14 @@ package org.apache.fop.layoutmgr; import org.apache.fop.apps.FOPException; + +import org.apache.fop.area.CTM; import org.apache.fop.area.AreaTree; import org.apache.fop.area.AreaTreeModel; import org.apache.fop.area.Area; import org.apache.fop.area.PageViewport; import org.apache.fop.area.Flow; +import org.apache.fop.area.Page; import org.apache.fop.area.RegionViewport; import org.apache.fop.area.RegionReference; import org.apache.fop.area.BodyRegion; @@ -64,20 +67,28 @@ import org.apache.fop.area.Span; import org.apache.fop.area.BeforeFloat; import org.apache.fop.area.Footnote; import org.apache.fop.area.Resolveable; + +import org.apache.fop.datatypes.FODimension; + import org.apache.fop.fo.flow.Marker; -import org.apache.fop.fo.properties.Constants; + import org.apache.fop.fo.pagination.PageNumberGenerator; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fo.pagination.Region; import org.apache.fop.fo.properties.RetrieveBoundary; import org.apache.fop.fo.pagination.SimplePageMaster; import org.apache.fop.fo.pagination.StaticContent; + +import org.apache.fop.fo.properties.CommonMarginBlock; +import org.apache.fop.fo.properties.Constants; + import org.apache.fop.layout.PageMaster; import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.apache.fop.apps.*; +import java.awt.Rectangle; +import java.util.Iterator; /** * LayoutManager for a PageSequence and its flow. @@ -715,7 +726,12 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable + "' does not map to the region-body in page-master '" + pageSequence.getCurrentSimplePageMaster().getMasterName() + "'"); } - PageMaster pageMaster = pageSequence.getCurrentSimplePageMaster().getPageMaster(); + SimplePageMaster currentSimplePageMaster = pageSequence.getCurrentSimplePageMaster(); + PageMaster pageMaster = currentSimplePageMaster.getPageMaster(); + if (pageMaster == null) { + createSimplePageMasterAreas(currentSimplePageMaster); + } + pageMaster = pageSequence.getCurrentSimplePageMaster().getPageMaster(); PageViewport p = pageMaster.makePage(); return p; // The page will have a viewport/reference area pair defined @@ -730,5 +746,57 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable //forcePage(areaTree, firstAvailPageNumber); } + public void createSimplePageMasterAreas(SimplePageMaster node) { + int pageWidth = + node.properties.get("page-width").getLength().getValue(); + int pageHeight = + node.properties.get("page-height").getLength().getValue(); + // Get absolute margin properties (top, left, bottom, right) + CommonMarginBlock mProps = node.getPropertyManager().getMarginProps(); + + /* Create the page reference area rectangle (0,0 is at top left + * of the "page media" and y increases + * when moving towards the bottom of the page. + * The media rectangle itself is (0,0,pageWidth,pageHeight). + */ + Rectangle pageRefRect = + new Rectangle(mProps.marginLeft, mProps.marginTop, + pageWidth - mProps.marginLeft - mProps.marginRight, + pageHeight - mProps.marginTop - mProps.marginBottom); + + // ??? KL shouldn't this take the viewport too??? + Page page = new Page(); // page reference area + + // Set up the CTM on the page reference area based on writing-mode + // and reference-orientation + FODimension reldims = new FODimension(0, 0); + CTM pageCTM = CTM.getCTMandRelDims(node.getPropertyManager().getAbsRefOrient(), + node.getPropertyManager().getWritingMode(), pageRefRect, reldims); + + // Create a RegionViewport/ reference area pair for each page region + + boolean bHasBody = false; + + for (Iterator regenum = node.getRegions().values().iterator(); + regenum.hasNext();) { + Region r = (Region)regenum.next(); + RegionViewport rvp = r.makeRegionViewport(reldims, pageCTM); + rvp.setRegion(r.makeRegionReferenceArea(rvp.getViewArea())); + page.setRegion(r.getRegionAreaClass(), rvp); + if (r.getRegionAreaClass() == RegionReference.BODY) { + bHasBody = true; + } + } + + if (!bHasBody) { + node.getLogger().error("simple-page-master has no region-body"); + } + + node.setPageMaster(new PageMaster(new PageViewport(page, + new Rectangle(0, 0, pageWidth, pageHeight)))); + + + } + } |