From cc795e0d956d96026150531687ccbf8e147d5819 Mon Sep 17 00:00:00 2001 From: Karen Lease Date: Fri, 9 Nov 2001 22:31:50 +0000 Subject: [PATCH] Rework the page creation process and prepare to use layout managers git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194550 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/pagination/Region.java | 91 +++++++++--- .../apache/fop/fo/pagination/RegionAfter.java | 57 +++----- .../fop/fo/pagination/RegionBefore.java | 54 +++----- .../apache/fop/fo/pagination/RegionBody.java | 83 +++++------ .../apache/fop/fo/pagination/RegionEnd.java | 72 +++------- .../apache/fop/fo/pagination/RegionStart.java | 68 +++------ .../fop/fo/pagination/SimplePageMaster.java | 130 ++++++++---------- 7 files changed, 236 insertions(+), 319 deletions(-) diff --git a/src/org/apache/fop/fo/pagination/Region.java b/src/org/apache/fop/fo/pagination/Region.java index c46745f84..9afbbaa81 100644 --- a/src/org/apache/fop/fo/pagination/Region.java +++ b/src/org/apache/fop/fo/pagination/Region.java @@ -7,12 +7,18 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + // FOP import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; +import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; -import org.apache.fop.layout.RegionArea; +import org.apache.fop.area.RegionViewport; +import org.apache.fop.area.RegionReference; + import org.xml.sax.Attributes; @@ -22,12 +28,20 @@ import org.xml.sax.Attributes; public abstract class Region extends FObj { public static final String PROP_REGION_NAME = "region-name"; + final static String BEFORE = "before"; + final static String START = "start"; + final static String END = "end"; + final static String AFTER = "after"; + final static String BODY = "body"; + private SimplePageMaster _layoutMaster; private String _regionName; + protected int overflow; + + protected Region(FONode parent) { super(parent); - this.name = getElementName(); } public void handleAttrs(Attributes attlist) throws FOPException { @@ -49,23 +63,58 @@ public abstract class Region extends FObj { } } - if (parent.getName().equals("fo:simple-page-master")) { - _layoutMaster = (SimplePageMaster)parent; - getPageMaster().addRegion(this); - } else { - throw new FOPException(getElementName() + " must be child " + if (parent instanceof SimplePageMaster) { + _layoutMaster = (SimplePageMaster)parent; + } + else { + throw new FOPException(this.name + " must be child " + "of simple-page-master, not " + parent.getName()); } + + } + + + /** + * Creates a RegionViewport Area object for this pagination Region. + */ + public RegionViewport makeRegionViewport(Rectangle pageRefRect) { + return new RegionViewport(getViewportRectangle(pageRefRect)); + } + + + abstract protected Rectangle getViewportRectangle(Rectangle pageRefRect); + + + public RegionReference makeRegionReferenceArea() { + RegionReference r = new RegionReference(getRegionAreaClass()); + setRegionTraits(r); + return r; + } + + protected void setRegionTraits(RegionReference r) { + // Common Border, Padding, and Background Properties + BorderAndPadding bap = propMgr.getBorderAndPadding(); + BackgroundProps bProps = propMgr.getBackgroundProps(); + /* this.backgroundColor = + this.properties.get("background-color").getColorType();*/ + + // this.properties.get("clip"); + // this.properties.get("display-align"); + // this.properties.get("overflow"); + this.overflow = this.properties.get("overflow").getEnum(); + // this.properties.get("region-name"); + // this.properties.get("reference-orientation"); + // this.properties.get("writing-mode"); + + //r.setBackground(bProps); } /** - * Creates a Region layout object for this pagination Region. + * Return the enumerated value designating this type of region in the + * Area tree. */ - abstract RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight); + abstract protected int getRegionAreaClass(); /** * Returns the default region name (xsl-region-before, xsl-region-start, @@ -73,11 +122,6 @@ public abstract class Region extends FObj { */ protected abstract String getDefaultRegionName(); - /** - * Returns the element name ("fo:region-body", "fo:region-start", - * etc.) - */ - protected abstract String getElementName(); public abstract String getRegionClass(); @@ -116,4 +160,17 @@ public abstract class Region extends FObj { return true; } + protected Region getSiblingRegion(String regionClass) { + // Ask parent for region + return _layoutMaster.getRegion(regionClass); + } + + boolean getPrecedence() { + return false; + } + + int getExtent() { + return 0; + } + } diff --git a/src/org/apache/fop/fo/pagination/RegionAfter.java b/src/org/apache/fop/fo/pagination/RegionAfter.java index a1eb587d8..c1466001c 100644 --- a/src/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/org/apache/fop/fo/pagination/RegionAfter.java @@ -9,51 +9,31 @@ package org.apache.fop.fo.pagination; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; import org.apache.fop.apps.FOPException; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; +import org.apache.fop.area.RegionReference; +import java.awt.Rectangle; import org.xml.sax.Attributes; -public class RegionAfter extends Region { +public class RegionAfter extends RegionBA { - public static final String REGION_CLASS = "after"; - - private int precedence; public RegionAfter(FONode parent) { super(parent); } - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - precedence = this.properties.get("precedence").getEnum(); - } - - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("precedence"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return new RegionArea(allocationRectangleXPosition, - allocationRectangleYPosition - - allocationRectangleHeight + extent, - allocationRectangleWidth, extent); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = + new Rectangle((int)pageRefRect.getX(), + (int)pageRefRect.getY() - (int)pageRefRect.getHeight() + + getExtent(), + (int)pageRefRect.getWidth(), getExtent()); + if (getPrecedence() == false) { + adjustIPD(vpRect); + } + return vpRect; } @@ -61,16 +41,13 @@ public class RegionAfter extends Region { return "xsl-region-after"; } - protected String getElementName() { - return "fo:region-after"; + public int getRegionAreaClass() { + return RegionReference.AFTER; } public String getRegionClass() { - return REGION_CLASS; + return Region.AFTER; } - public boolean getPrecedence() { - return (precedence == Precedence.TRUE ? true : false); - } } diff --git a/src/org/apache/fop/fo/pagination/RegionBefore.java b/src/org/apache/fop/fo/pagination/RegionBefore.java index ab275d3f0..0b33ccec1 100644 --- a/src/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/org/apache/fop/fo/pagination/RegionBefore.java @@ -9,19 +9,14 @@ package org.apache.fop.fo.pagination; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; +import org.apache.fop.area.RegionReference; +import java.awt.Rectangle; import org.xml.sax.Attributes; -public class RegionBefore extends Region { +public class RegionBefore extends RegionBA { - public static final String REGION_CLASS = "before"; - - private int precedence; public RegionBefore(FONode parent) { super(parent); @@ -29,30 +24,6 @@ public class RegionBefore extends Region { public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); - precedence = this.properties.get("precedence").getEnum(); - } - - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("precedence"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return new RegionArea(allocationRectangleXPosition, - allocationRectangleYPosition, - allocationRectangleWidth, extent); } @@ -60,16 +31,23 @@ public class RegionBefore extends Region { return "xsl-region-before"; } - protected String getElementName() { - return "fo:region-before"; + public String getRegionClass() { + return Region.BEFORE; } - public String getRegionClass() { - return REGION_CLASS; + public int getRegionAreaClass() { + return RegionReference.BEFORE; } - public boolean getPrecedence() { - return (precedence == Precedence.TRUE ? true : false); + + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = new Rectangle(pageRefRect); + vpRect.height = getExtent(); + if (getPrecedence() == false) { + adjustIPD(vpRect); + } + return vpRect; } } diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java index 5cf97352c..e99561772 100644 --- a/src/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/org/apache/fop/fo/pagination/RegionBody.java @@ -7,62 +7,42 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + // FOP -import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.properties.Overflow; import org.apache.fop.datatypes.ColorType; import org.apache.fop.apps.FOPException; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BodyRegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; +import org.apache.fop.area.RegionReference; +import org.apache.fop.area.BodyRegion; import org.apache.fop.layout.MarginProps; public class RegionBody extends Region { - public static final String REGION_CLASS = "body"; - ColorType backgroundColor; public RegionBody(FONode parent) { super(parent); } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - + protected Rectangle getViewportRectangle (Rectangle pageRefRect) + { // Common Margin Properties-Block MarginProps mProps = propMgr.getMarginProps(); + return + new Rectangle((int)pageRefRect.getX() + mProps.marginLeft, + (int)pageRefRect.getY() - mProps.marginTop, + (int)pageRefRect.getWidth() - mProps.marginLeft - + mProps.marginRight, + (int)pageRefRect.getHeight() - mProps.marginTop - + mProps.marginBottom); + } + + protected void setRegionTraits(RegionReference r) { + super.setRegionTraits(r); - // this.properties.get("clip"); - // this.properties.get("display-align"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - BodyRegionArea body = new BodyRegionArea(allocationRectangleXPosition - + mProps.marginLeft, - allocationRectangleYPosition - - mProps.marginTop, - allocationRectangleWidth - - mProps.marginLeft - - mProps.marginRight, - allocationRectangleHeight - - mProps.marginTop - - mProps.marginBottom); - - int overflow = this.properties.get("overflow").getEnum(); String columnCountAsString = this.properties.get("column-count").getString(); int columnCount = 1; @@ -79,27 +59,34 @@ public class RegionBody extends Region { + "'overflow' is set to 'scroll'"); columnCount = 1; } - body.setColumnCount(columnCount); +// r.setColumnCount(columnCount); - int columnGap = - this.properties.get("column-gap").getLength().mvalue(); - body.setColumnGap(columnGap); +// int columnGap = +// this.properties.get("column-gap").getLength().mvalue(); +// r.setColumnGap(columnGap); - body.setBackgroundColor(backgroundColor); - - return body; +// r.setBackgroundColor(backgroundColor); } protected String getDefaultRegionName() { return "xsl-region-body"; } - protected String getElementName() { - return "fo:region-body"; - } public String getRegionClass() { - return REGION_CLASS; + return Region.BODY; + } + + public int getRegionAreaClass() { + return RegionReference.BODY; + } + + /** + * Override the inherited method. + */ + public RegionReference makeRegionReferenceArea() { + // Should set some column stuff here I think, or put it elsewhere + return new BodyRegion(); } } diff --git a/src/org/apache/fop/fo/pagination/RegionEnd.java b/src/org/apache/fop/fo/pagination/RegionEnd.java index 5a077a86b..68f4cabd2 100644 --- a/src/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/org/apache/fop/fo/pagination/RegionEnd.java @@ -7,78 +7,46 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; +import org.apache.fop.area.RegionReference; + -public class RegionEnd extends Region { +public class RegionEnd extends RegionSE { - public static final String REGION_CLASS = "end"; public RegionEnd(FONode parent) { super(parent); } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight, - boolean beforePrecedence, - boolean afterPrecedence, int beforeHeight, - int afterHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); - - int startY = allocationRectangleYPosition; - int startH = allocationRectangleHeight; - if (beforePrecedence) { - startY -= beforeHeight; - startH -= beforeHeight; - } - if (afterPrecedence) - startH -= afterHeight; - return new RegionArea(allocationRectangleXPosition - + allocationRectangleWidth - extent, startY, - extent, startH); - } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return makeRegionArea(allocationRectangleXPosition, - allocationRectangleYPosition, - allocationRectangleWidth, extent, false, false, - 0, 0); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = + new Rectangle((int)pageRefRect.getX() + (int)pageRefRect.getWidth() - + getExtent(), + (int)pageRefRect.getY(), + getExtent(), (int)pageRefRect.getHeight()); + adjustIPD(vpRect); + return vpRect; } + protected String getDefaultRegionName() { return "xsl-region-end"; } - protected String getElementName() { - return "fo:region-end"; - } public String getRegionClass() { - return REGION_CLASS; + return Region.END; + } + + public int getRegionAreaClass() { + return RegionReference.END; } } diff --git a/src/org/apache/fop/fo/pagination/RegionStart.java b/src/org/apache/fop/fo/pagination/RegionStart.java index a4ef1df5a..bd61b2c8c 100644 --- a/src/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/org/apache/fop/fo/pagination/RegionStart.java @@ -7,77 +7,43 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + + // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; +import org.apache.fop.area.RegionReference; -public class RegionStart extends Region { +public class RegionStart extends RegionSE { - public static final String REGION_CLASS = "start"; public RegionStart(FONode parent) { super(parent); } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight, - boolean beforePrecedence, - boolean afterPrecedence, int beforeHeight, - int afterHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); - int startY = allocationRectangleYPosition; - int startH = allocationRectangleHeight; - if (beforePrecedence) { - startY -= beforeHeight; - startH -= beforeHeight; - } - if (afterPrecedence) - startH -= afterHeight; - return new RegionArea(allocationRectangleXPosition, startY, extent, - startH); - } - - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return makeRegionArea(allocationRectangleXPosition, - allocationRectangleYPosition, - allocationRectangleWidth, extent, false, false, - 0, 0); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = + new Rectangle((int)pageRefRect.getX(), + (int)pageRefRect.getY(), + getExtent(), (int)pageRefRect.getHeight()); + adjustIPD(vpRect); + return vpRect; } protected String getDefaultRegionName() { return "xsl-region-start"; } - protected String getElementName() { - return "fo:region-start"; + public String getRegionClass() { + return Region.START; } - public String getRegionClass() { - return REGION_CLASS; + public int getRegionAreaClass() { + return RegionReference.START; } } diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index 853aaada9..3c3931cf9 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -10,16 +10,20 @@ package org.apache.fop.fo.pagination; // FOP import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.PageMaster; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BodyRegionArea; +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.layout.MarginProps; +import org.apache.fop.layout.PageMaster; import org.apache.fop.apps.FOPException; -import java.util.*; - +import java.awt.Rectangle; +import java.util.Hashtable; +import java.util.Enumeration; import org.xml.sax.Attributes; + public class SimplePageMaster extends FObj { /** @@ -31,12 +35,6 @@ public class SimplePageMaster extends FObj { PageMaster pageMaster; String masterName; - // before and after data as required by start and end - boolean beforePrecedence; - int beforeHeight; - boolean afterPrecedence; - int afterHeight; - public SimplePageMaster(FONode parent) { super(parent); } @@ -73,69 +71,41 @@ public class SimplePageMaster extends FObj { // Common Margin Properties-Block MarginProps mProps = propMgr.getMarginProps(); - int contentRectangleXPosition = mProps.marginLeft; - int contentRectangleYPosition = pageHeight - mProps.marginTop; - int contentRectangleWidth = pageWidth - mProps.marginLeft - - mProps.marginRight; - int contentRectangleHeight = pageHeight - mProps.marginTop - - mProps.marginBottom; - - this.pageMaster = new PageMaster(pageWidth, pageHeight); - if (getRegion(RegionBody.REGION_CLASS) != null) { - BodyRegionArea body = - (BodyRegionArea)getRegion(RegionBody.REGION_CLASS).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, - contentRectangleWidth, - contentRectangleHeight); - this.pageMaster.addBody(body); - } else { - log.error("simple-page-master must have a region of class " - + RegionBody.REGION_CLASS); - } + /* Create the page reference area rectangle in first quadrant coordinates + * (ie, 0,0 is at bottom,left of the "page meida" and y increases + * when moving towards the top of the page. + * The media rectangle itself is (0,0,pageWidth,pageHeight). + */ + Rectangle pageRefRect = + new Rectangle(mProps.marginLeft, pageHeight - mProps.marginTop, + pageWidth - mProps.marginLeft - mProps.marginRight, + pageHeight - mProps.marginTop - mProps.marginBottom); - if (getRegion(RegionBefore.REGION_CLASS) != null) { - RegionArea before = - getRegion(RegionBefore.REGION_CLASS).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight); - this.pageMaster.addBefore(before); - beforePrecedence = - ((RegionBefore)getRegion(RegionBefore.REGION_CLASS)).getPrecedence(); - beforeHeight = before.getHeight(); - } else { - beforePrecedence = false; - } + // ??? KL shouldn't this take the viewport too??? + Page page = new Page(); // page reference area - if (getRegion(RegionAfter.REGION_CLASS) != null) { - RegionArea after = - getRegion(RegionAfter.REGION_CLASS).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight); - this.pageMaster.addAfter(after); - afterPrecedence = - ((RegionAfter)getRegion(RegionAfter.REGION_CLASS)).getPrecedence(); - afterHeight = after.getHeight(); - } else { - afterPrecedence = false; - } + // Create a RegionViewport/ reference area pair for each page region + + boolean bHasBody=false; - if (getRegion(RegionStart.REGION_CLASS) != null) { - RegionArea start = - ((RegionStart)getRegion(RegionStart.REGION_CLASS)).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight, beforePrecedence, - afterPrecedence, beforeHeight, afterHeight); - this.pageMaster.addStart(start); + for (Enumeration regenum = _regions.elements(); + regenum.hasMoreElements(); ) { + Region r = (Region)regenum.nextElement(); + RegionViewport rvp = r.makeRegionViewport(pageRefRect); + rvp.setRegion(r.makeRegionReferenceArea()); + page.setRegion(r.getRegionAreaClass(), rvp); + if (r.getRegionAreaClass() == RegionReference.BODY) { + bHasBody = true; + } } - if (getRegion(RegionEnd.REGION_CLASS) != null) { - RegionArea end = - ((RegionEnd)getRegion(RegionEnd.REGION_CLASS)).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight, beforePrecedence, - afterPrecedence, beforeHeight, afterHeight); - this.pageMaster.addEnd(end); + if (!bHasBody) { + log.error("simple-page-master has no region-body"); } + + this.pageMaster = new PageMaster(new PageViewport(page, + new Rectangle(0,0, + pageWidth,pageHeight))); } public PageMaster getPageMaster() { @@ -151,13 +121,27 @@ public class SimplePageMaster extends FObj { } - protected void addRegion(Region region) throws FOPException { - if (_regions.containsKey(region.getRegionClass())) { - throw new FOPException("Only one region of class " - + region.getRegionClass() + protected void addChild(FONode child) { + if (child instanceof Region) { + addRegion((Region)child); + } + else { + log.error("SimplePageMaster cannot have child of type " + + child.getName()); + } + } + + protected void addRegion(Region region) { + String key = region.getRegionClass(); + if (_regions.containsKey(key)) { + log.error("Only one region of class " + + key + " allowed within a simple-page-master."); + // throw new FOPException("Only one region of class " +// + key +// + " allowed within a simple-page-master."); } else { - _regions.put(region.getRegionClass(), region); + _regions.put(key, region); } } -- 2.39.5