diff options
author | Glen Mazza <gmazza@apache.org> | 2004-09-05 04:00:52 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-09-05 04:00:52 +0000 |
commit | efb1d8b52a886e9fe36f82abcb0064a89b2e022f (patch) | |
tree | edc05717405d4227252323e2cdf80b89fc94dc84 /src/java/org | |
parent | fe2d99426ed26953441a63e27aa87935e0877d6d (diff) | |
download | xmlgraphics-fop-efb1d8b52a886e9fe36f82abcb0064a89b2e022f.tar.gz xmlgraphics-fop-efb1d8b52a886e9fe36f82abcb0064a89b2e022f.zip |
PR:
Obtained from:
Submitted by:
Reviewed by:
1.) AddChildNode(), characters() modified to throw SAXParseException to
allow AddChildNode() to do validation of its own.
2.) Better child validation added to PageSequence.java.
3.) Various other code cleanups.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197903 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
18 files changed, 174 insertions, 236 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index cb6d26e9a..e33423fb0 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -351,8 +351,7 @@ public class AreaTreeHandler extends FOInputHandler { * @param pageSequence the page sequence ending * @throws FOPException if there is an error formatting the pages */ - public void endPageSequence(PageSequence pageSequence) - throws FOPException { + public void endPageSequence(PageSequence pageSequence) { //areaTree.setFontInfo(fontInfo); if (collectStatistics) { @@ -377,8 +376,7 @@ public class AreaTreeHandler extends FOInputHandler { * @param areaTree the area tree to format this page sequence into * @throws FOPException if there is an error formatting the contents */ - private void formatPageSequence(PageSequence pageSeq) - throws FOPException { + private void formatPageSequence(PageSequence pageSeq) { Title title = null; if (pageSeq.getTitleFO() != null) { title = getTitleArea(pageSeq.getTitleFO()); diff --git a/src/java/org/apache/fop/fo/FOInputHandler.java b/src/java/org/apache/fop/fo/FOInputHandler.java index 629eaea06..0cffe83c3 100644 --- a/src/java/org/apache/fop/fo/FOInputHandler.java +++ b/src/java/org/apache/fop/fo/FOInputHandler.java @@ -144,11 +144,9 @@ public abstract class FOInputHandler { } /** - * * @param pageSeq PageSequence that is ending. - * @throws FOPException For errors encountered. */ - public void endPageSequence(PageSequence pageSeq) throws FOPException { + public void endPageSequence(PageSequence pageSeq) { } /** diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index e1bfe272e..193b92e57 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -66,7 +66,7 @@ public abstract class FONode { * Set the location information for this element * @param locator the org.xml.sax.Locator object */ - public void setLocation(Locator locator) { + public void setLocator(Locator locator) { if (locator != null) { this.locator = locator; } @@ -130,7 +130,7 @@ public abstract class FONode { * @param locator location in fo source file. */ protected void addCharacters(char data[], int start, int length, - Locator locator) { + Locator locator) throws SAXParseException { // ignore } @@ -151,7 +151,7 @@ public abstract class FONode { /** * @param child child node to be added to the childNodes of this node */ - protected void addChildNode(FONode child) { + protected void addChildNode(FONode child) throws SAXParseException { } /** diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 97cbe637e..da0f6f6c9 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -204,10 +204,11 @@ public class FOTreeBuilder extends DefaultHandler { * SAX Handler for characters * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ - public void characters(char[] data, int start, int length) { - if (currentFObj != null) { - currentFObj.addCharacters(data, start, start + length, locator); - } + public void characters(char[] data, int start, int length) + throws SAXParseException { + if (currentFObj != null) { + currentFObj.addCharacters(data, start, start + length, locator); + } } /** diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index cebe2e164..bcaf8906b 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -102,7 +102,7 @@ public class FObj extends FONode implements Constants { */ public void processNode(String elementName, Locator locator, Attributes attlist) throws SAXParseException { - setLocation(locator); + setLocator(locator); addProperties(attlist); } @@ -225,7 +225,7 @@ public class FObj extends FONode implements Constants { /** * @see org.apache.fop.fo.FONode#addChildNode(FONode) */ - protected void addChildNode(FONode child) { + protected void addChildNode(FONode child) throws SAXParseException { if (PropertySets.canHaveMarkers(getNameId()) && child.getNameId() == FO_MARKER) { addMarker((Marker) child); diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 8d3cc9ef1..8e82b3e0c 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -20,6 +20,7 @@ package org.apache.fop.fo; import java.util.List; import org.xml.sax.Locator; +import org.xml.sax.SAXParseException; import org.apache.fop.layoutmgr.LMiter; import org.apache.fop.layoutmgr.InlineStackingLayoutManager; @@ -46,7 +47,7 @@ public class FObjMixed extends FObj { * @param locator location in fo source file. */ protected void addCharacters(char data[], int start, int length, - Locator locator) { + Locator locator) throws SAXParseException { if (textInfo == null) { // Really only need one of these, but need to get fontInfo // stored in propMgr for later use. @@ -55,7 +56,7 @@ public class FObjMixed extends FObj { } FOText ft = new FOText(data, start, length, textInfo, this); - ft.setLocation(locator); + ft.setLocator(locator); getFOInputHandler().characters(ft.ca, ft.startIndex, ft.endIndex); addChildNode(ft); diff --git a/src/java/org/apache/fop/fo/XMLObj.java b/src/java/org/apache/fop/fo/XMLObj.java index b12bbeffb..24e260f4e 100644 --- a/src/java/org/apache/fop/fo/XMLObj.java +++ b/src/java/org/apache/fop/fo/XMLObj.java @@ -70,7 +70,7 @@ public abstract class XMLObj extends FONode { */ public void processNode(String elementName, Locator locator, Attributes attlist) throws SAXParseException { - setLocation(locator); + setLocator(locator); name = elementName; attr = attlist; } diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 1040d2538..bcecb48fa 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -166,7 +166,7 @@ public class Block extends FObjMixed { /** * @see org.apache.fop.fo.FONode#addChildNode(FONode) */ - public void addChildNode(FONode child) { + public void addChildNode(FONode child) throws SAXParseException { // Handle whitespace based on values of properties // Handle a sequence of inline-producing child nodes in // one pass diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index c5df32f8b..8373727bb 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -109,7 +109,7 @@ public class Table extends FObj { /** * @see org.apache.fop.fo.FONode#addChildNode(FONode) */ - protected void addChildNode(FONode child) { + protected void addChildNode(FONode child) throws SAXParseException { if (child.getName().equals("fo:table-column")) { if (columns == null) { columns = new ArrayList(); diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index 723911c42..fb1b50802 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -34,26 +34,16 @@ import org.apache.fop.layoutmgr.FlowLayoutManager; /** * Class modelling the fo:flow object. + * @todo check need for markerSnapshot, contentWidth */ public class Flow extends FObj { /** - * PageSequence container - */ - private PageSequence pageSequence; - - /** * ArrayList to store snapshot */ private ArrayList markerSnapshot; /** - * flow-name attribute: indicates the region the content of this - * flow should go to. - */ - protected String flowName; - - /** * Content-width of current column area during layout */ private int contentWidth; @@ -74,16 +64,13 @@ public class Flow extends FObj { protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); - this.pageSequence = (PageSequence) parent; - - flowName = getPropString(PR_FLOW_NAME); + // check flow_name property + String flowName = getPropString(PR_FLOW_NAME); if (flowName == null || flowName.equals("")) { missingPropertyError("flow-name"); } - - // Now done in addChild of page-sequence - //pageSequence.addFlow(this); + getFOInputHandler().startFlow(this); } diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index a0ad061c3..bb8533706 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -93,6 +93,42 @@ public class LayoutMasterSet extends FObj { if (childNodes == null) { missingChildElementError("(simple-page-master|page-sequence-master)+"); } + checkRegionNames(); + } + + /** + * 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 SAXParseException if there's a name duplication + */ + private void checkRegionNames() throws SAXParseException { + // (user-entered) region-name to default region map. + Map allRegions = new java.util.HashMap(); + for (Iterator spm = simplePageMasters.values().iterator(); + spm.hasNext();) { + SimplePageMaster simplePageMaster = + (SimplePageMaster)spm.next(); + Map spmRegions = simplePageMaster.getRegions(); + for (Iterator e = spmRegions.values().iterator(); + e.hasNext();) { + Region region = (Region) e.next(); + if (allRegions.containsKey(region.getRegionName())) { + String defaultRegionName = + (String) allRegions.get(region.getRegionName()); + if (!defaultRegionName.equals(region.getDefaultRegionName())) { + throw new SAXParseException("Region-name (" + + region.getRegionName() + + ") is being mapped to multiple " + + "region-classes (" + + defaultRegionName + " and " + + region.getDefaultRegionName() + + ")", locator); + } + } + allRegions.put(region.getRegionName(), + region.getDefaultRegionName()); + } + } } /** @@ -167,41 +203,6 @@ public class LayoutMasterSet extends FObj { } /** - * 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 SAXParseException if there's a name duplication - */ - public void checkRegionNames() throws SAXParseException { - // (user-entered) region-name to default region map. - Map allRegions = new java.util.HashMap(); - for (Iterator spm = simplePageMasters.values().iterator(); - spm.hasNext();) { - SimplePageMaster simplePageMaster = - (SimplePageMaster)spm.next(); - Map spmRegions = simplePageMaster.getRegions(); - for (Iterator e = spmRegions.values().iterator(); - e.hasNext();) { - Region region = (Region) e.next(); - if (allRegions.containsKey(region.getRegionName())) { - String defaultRegionName = - (String) allRegions.get(region.getRegionName()); - if (!defaultRegionName.equals(region.getDefaultRegionName())) { - throw new SAXParseException("Region-name (" - + region.getRegionName() - + ") is being mapped to multiple " - + "region-classes (" - + defaultRegionName + " and " - + region.getDefaultRegionName() - + ")", locator); - } - } - allRegions.put(region.getRegionName(), - region.getDefaultRegionName()); - } - } - } - - /** * Checks whether or not a region name exists in this master set. * @param regionName name of the region * @return true when the region name specified has a region in this LayoutMasterSet diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 7a025097f..9e9f54f47 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -27,7 +27,6 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; @@ -38,16 +37,13 @@ import org.apache.fop.fo.FObj; */ public class PageSequence extends FObj { // - // intial-page-number types + // initial-page-number types // public static final int EXPLICIT = 0; public static final int AUTO = 1; public static final int AUTO_EVEN = 2; public static final int AUTO_ODD = 3; - // - // associations - // /** * The parent root object */ @@ -68,11 +64,7 @@ public class PageSequence extends FObj { */ public HashMap flowMap; - // according to communication from Paul Grosso (XSL-List, - // 001228, Number 406), confusion in spec section 6.4.5 about - // multiplicity of fo:flow in XSL 1.0 is cleared up - one (1) - // fo:flow per fo:page-sequence only. -// private boolean isFlowSet = false; +// private boolean isFlowSet = false; // for structure handler private boolean sequenceStarted = false; @@ -113,14 +105,14 @@ public class PageSequence extends FObj { public PageSequenceMaster pageSequenceMaster; /** - * The main content flow for this page-sequence. + * The fo:title object for this page-sequence. */ - private Flow mainFlow = null; + private Title titleFO; /** - * The fo:title object for this page-sequence. + * The fo:flow object for this page-sequence. */ - private Title titleFO; + private Flow mainFlow = null; /** * Create a page sequence FO node. @@ -132,112 +124,12 @@ public class PageSequence extends FObj { } /** - * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) - XSL Content Model: (title?,static-content*,flow) - */ - protected void validateChildNode(Locator loc, String nsURI, String localName) - throws SAXParseException { - if (nsURI == FO_URI) { - if (localName.equals("title")) { - if (titleFO != null) { - tooManyNodesError(loc, "fo:title"); - } else if (flowMap.size() > 0) { - nodesOutOfOrderError(loc, "fo:title", "fo:static-content"); - } else if (mainFlow != null) { - nodesOutOfOrderError(loc, "fo:title", "fo:flow"); - } - } else if (localName.equals("static-content")) { - if (mainFlow != null) { - nodesOutOfOrderError(loc, "fo:static-content", "fo:flow"); - } - } else if (localName.equals("flow")) { - if (mainFlow != null) { - tooManyNodesError(loc, "fo:flow"); - } - } else { - invalidChildError(loc, nsURI, localName); - } - } else { - invalidChildError(loc, nsURI, localName); - } - } - - /** - * Signal end of this xml element. - * This passes the end page sequence to the structure handler - * so it can act upon that. - */ - protected void endOfNode() throws SAXParseException { - if (mainFlow == null) { - missingChildElementError("(title?,static-content*,flow)"); - } - try { - getFOInputHandler().endPageSequence(this); - } catch (FOPException fopex) { - getLogger().error("Error in PageSequence.endOfNode(): " - + fopex.getMessage(), fopex); - } - } - - /** - * @see org.apache.fop.fo.FONode#addChildNode(FONode) - */ - public void addChildNode(FONode child) { - try { - String childName = child.getName(); - if (childName.equals("fo:title")) { - this.titleFO = (Title)child; - } else if (childName.equals("fo:flow")) { - this.mainFlow = (Flow)child; - String flowName = this.mainFlow.getPropString(PR_FLOW_NAME); - if (flowMap.containsKey(flowName)) { - throw new FOPException("flow-name " - + flowName - + " is not unique within an fo:page-sequence"); - } - if (!this.layoutMasterSet.regionNameExists(flowName)) { - getLogger().error("region-name '" - + flowName - + "' doesn't exist in the layout-master-set."); - } - // Don't add main flow to the flow map -// addFlow(mainFlow); - startStructuredPageSequence(); - super.addChildNode(child); // For getChildren - } else if (childName.equals("fo:static-content")) { - String flowName = ((StaticContent)child).getPropString(PR_FLOW_NAME); - if (flowMap.containsKey(flowName)) { - throw new FOPException("flow-name " + flowName - + " is not unique within an fo:page-sequence"); - } - if (!this.layoutMasterSet.regionNameExists(flowName)) { - throw new FOPException("region-name '" + flowName - + "' doesn't exist in the layout-master-set."); - } - flowMap.put(flowName, child); -// addFlow((Flow)child); - startStructuredPageSequence(); - } - } catch (FOPException fopex) { - getLogger().error("Error in PageSequence.addChildNode(): " - + fopex.getMessage(), fopex); - } - } - - - /** * @see org.apache.fop.fo.FObj#addProperties */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); - this.root = (Root) parent; -// this.root.addPageSequence(this); layoutMasterSet = root.getLayoutMasterSet(); - - // best time to run some checks on LayoutMasterSet - layoutMasterSet.checkRegionNames(); - flowMap = new HashMap(); // we are now on the first page of the page sequence @@ -257,7 +149,7 @@ public class PageSequence extends FObj { this.explicitFirstNumber = (pageStart > 0) ? pageStart : 1; } catch (NumberFormatException nfe) { throw new SAXParseException("\"" + ipnValue - + "\" is not a valid value for initial-page-number", locator); + + "\" is not a valid value for initial-page-number", locator); } } @@ -269,17 +161,17 @@ public class PageSequence extends FObj { this.layoutMasterSet.getPageSequenceMaster(masterName); if (this.pageSequenceMaster == null) { throw new SAXParseException("master-reference '" + masterName - + "' for fo:page-sequence matches no" - + " simple-page-master or page-sequence-master", locator); + + "' for fo:page-sequence matches no" + + " simple-page-master or page-sequence-master", locator); } } // get the 'format' properties this.pageNumberGenerator = new PageNumberGenerator(getPropString(PR_FORMAT), - this.propertyList.get(PR_GROUPING_SEPARATOR).getCharacter(), - this.propertyList.get(PR_GROUPING_SIZE).getNumber().intValue(), - getPropEnum(PR_LETTER_VALUE)); + this.propertyList.get(PR_GROUPING_SEPARATOR).getCharacter(), + this.propertyList.get(PR_GROUPING_SIZE).getNumber().intValue(), + getPropEnum(PR_LETTER_VALUE)); this.forcePageCount = getPropEnum(PR_FORCE_PAGE_COUNT); @@ -291,26 +183,95 @@ public class PageSequence extends FObj { startStructuredPageSequence(); } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + XSL Content Model: (title?,static-content*,flow) + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws SAXParseException { + if (nsURI == FO_URI) { + if (localName.equals("title")) { + if (titleFO != null) { + tooManyNodesError(loc, "fo:title"); + } else if (flowMap.size() > 0) { + nodesOutOfOrderError(loc, "fo:title", "fo:static-content"); + } else if (mainFlow != null) { + nodesOutOfOrderError(loc, "fo:title", "fo:flow"); + } + } else if (localName.equals("static-content")) { + if (mainFlow != null) { + nodesOutOfOrderError(loc, "fo:static-content", "fo:flow"); + } + } else if (localName.equals("flow")) { + if (mainFlow != null) { + tooManyNodesError(loc, "fo:flow"); + } + } else { + invalidChildError(loc, nsURI, localName); + } + } else { + invalidChildError(loc, nsURI, localName); + } + } + + /** + * @see org.apache.fop.fo.FONode#addChildNode(FONode) + * @todo see if addChildNode() should also be called for fo's other than + * fo:flow. + */ + public void addChildNode(FONode child) throws SAXParseException { + int childId = child.getNameId(); + + if (childId == FO_TITLE) { + this.titleFO = (Title) child; + } else if (childId == FO_FLOW) { + this.mainFlow = (Flow) child; + addFlow(mainFlow); + startStructuredPageSequence(); + super.addChildNode(child); // For getChildren + } else if (childId == FO_STATIC_CONTENT) { + addFlow((StaticContent) child); + startStructuredPageSequence(); + } + } + + /** + * Signal end of this xml element. + * This passes the end page sequence to the structure handler + * so it can act upon that. + */ + protected void endOfNode() throws SAXParseException { + if (mainFlow == null) { + missingChildElementError("(title?,static-content*,flow)"); + } + + getFOInputHandler().endPageSequence(this); + } /** * Add a flow or static content, mapped by its flow-name. * The flow-name is used to associate the flow with a region on a page, - * based on the names given to the regions in the page-master used to - * generate that page. + * based on the region-names given to the regions in the page-master + * used to generate that page. */ -// private void addFlow(Flow flow) throws FOPException { -// if (flowMap.containsKey(flow.getFlowName())) { -// throw new FOPException("flow-names must be unique within an fo:page-sequence"); -// } -// if (!this.layoutMasterSet.regionNameExists(flow.getFlowName())) { -// getLogger().error("region-name '" -// + flow.getFlowName() -// + "' doesn't exist in the layout-master-set."); -// } -// flowMap.put(flow.getFlowName(), flow); -// //setIsFlowSet(true); -// } + private void addFlow(Flow flow) throws SAXParseException { + String flowName = flow.getPropString(PR_FLOW_NAME); + + if (hasFlowName(flowName)) { + throw new SAXParseException ("duplicate flow-name \"" + + flowName + + "\" found within fo:page-sequence", flow.locator); + } + if (!layoutMasterSet.regionNameExists(flowName) + && !flowName.equals("xsl-before-float-separator") + && !flowName.equals("xsl-footnote-separator")) { + throw new SAXParseException ("flow-name \"" + + flowName + + "\" could not be mapped to a region-name in the" + + " layout-master-set", flow.locator); + } + } /** * Start the page-sequence logic in the Structured Handler @@ -322,7 +283,6 @@ public class PageSequence extends FObj { } } - /** * Initialize the current page number for the start of the page sequence. */ @@ -667,15 +627,7 @@ public class PageSequence extends FObj { * @return the static content FO node */ public StaticContent getStaticContent(String name) { - return (StaticContent)flowMap.get(name); - } - - /** - * Accessor method for layoutMasterSet - * @return layoutMasterSet for this object - */ - public LayoutMasterSet getLayoutMasterSet() { - return layoutMasterSet; + return (StaticContent) flowMap.get(name); } /** @@ -696,6 +648,17 @@ public class PageSequence extends FObj { } /** + * Determine if this PageSequence already has a flow with the given flow-name + * Used for validation of incoming fo:flow or fo:static-content objects + * @param flowName The flow-name to search for + * @return true if flow-name already defined within this page sequence, + * false otherwise + */ + public boolean hasFlowName(String flowName) { + return flowMap.containsKey(flowName); + } + + /** * Public accessor for getting the PageSequenceMaster (if any) to which this * PageSequence is attached. * @return the PageSequenceMaster to which this PageSequence is attached, or diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java index 57273828f..9f61cf93a 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBA.java @@ -61,7 +61,7 @@ public abstract class RegionBA extends Region { Region start = getSiblingRegion(FO_REGION_START); if (start != null) { offset = start.getPropLength(PR_EXTENT); - vpRefRect.translate(offset, 0); + vpRefRect.translate(offset, 0); // move (x, y) units } Region end = getSiblingRegion(FO_REGION_END); if (end != null) { diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java index 3636dfc7a..bfadeb48b 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java @@ -58,9 +58,11 @@ public class RegionEnd extends RegionSE { // Depends on extent, precedence and writing mode Rectangle vpRect; if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) { + // Rectangle: x , y (of top left point), width, height vpRect = new Rectangle(reldims.ipd - extent, 0, extent, reldims.bpd); } else { + // Rectangle: x , y (of top left point), width, height vpRect = new Rectangle(reldims.ipd - extent, 0, reldims.bpd, extent); } diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java index 3435f1148..32c8a14b0 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java @@ -50,7 +50,6 @@ public class RepeatablePageMasterReference extends FObj /** * @see org.apache.fop.fo.FObj#addProperties - * @todo need to */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); diff --git a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java index 6d701958e..d00dedeef 100644 --- a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java @@ -768,9 +768,6 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable spm.getPropertyManager().getWritingMode(), pageRefRect, reldims); // Create a RegionViewport/ reference area pair for each page region - - boolean bHasBody = false; - for (Iterator regenum = spm.getRegions().values().iterator(); regenum.hasNext();) { Region r = (Region)regenum.next(); @@ -783,17 +780,9 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable rvp.setRegion(makeRegionReferenceArea(r, rvp.getViewArea())); } page.setRegionViewport(r.getNameId(), rvp); - if (r.getNameId() == FO_REGION_BODY) { - bHasBody = true; - } - } - - if (!bHasBody) { - spm.getLogger().error("simple-page-master has no region-body"); } return new PageViewport(page, new Rectangle(0, 0, pageWidth, pageHeight)); - } /** diff --git a/src/java/org/apache/fop/render/mif/MIFHandler.java b/src/java/org/apache/fop/render/mif/MIFHandler.java index 16b0ba357..2a50c3536 100644 --- a/src/java/org/apache/fop/render/mif/MIFHandler.java +++ b/src/java/org/apache/fop/render/mif/MIFHandler.java @@ -116,9 +116,9 @@ public class MIFHandler extends FOInputHandler { // get the layout master set // setup the pages for this sequence String name = pageSeq.getPropString(Constants.PR_MASTER_REFERENCE); - SimplePageMaster spm = pageSeq.getLayoutMasterSet().getSimplePageMaster(name); + SimplePageMaster spm = pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(name); if (spm == null) { - PageSequenceMaster psm = pageSeq.getLayoutMasterSet().getPageSequenceMaster(name); + PageSequenceMaster psm = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(name); } else { // create simple master with regions MIFElement prop = new MIFElement("PageType"); @@ -159,8 +159,7 @@ public class MIFHandler extends FOInputHandler { /** * @see org.apache.fop.fo.FOInputHandler#endPageSequence(PageSequence) */ - public void endPageSequence(PageSequence pageSeq) throws FOPException { - + public void endPageSequence(PageSequence pageSeq) { } /** diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index fe8a26b9a..8ac6f46b9 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -178,7 +178,7 @@ public class RTFHandler extends FOInputHandler { String reference = prop.getString(); SimplePageMaster pagemaster - = pageSeq.getLayoutMasterSet().getSimplePageMaster(reference); + = pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference); //only simple-page-master supported, so pagemaster may be null if (pagemaster != null) { @@ -202,7 +202,7 @@ public class RTFHandler extends FOInputHandler { /** * @see org.apache.fop.fo.FOInputHandler#endPageSequence(PageSequence) */ - public void endPageSequence(PageSequence pageSeq) throws FOPException { + public void endPageSequence(PageSequence pageSeq) { if (bDefer) { return; } |