From: Glen Mazza Date: Wed, 16 Jun 2004 00:27:27 +0000 (+0000) Subject: 1.) Check for fo:color-profile made to ensure no child elements during processing. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~712 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ff3ccfb8410b3f3646d2fd80b60329208caacbfc;p=xmlgraphics-fop.git 1.) Check for fo:color-profile made to ensure no child elements during processing. 2.) Error messages for bad fo: files now give locator (line/col. #) information. 3.) Parent of the fo:root (FO Tree) "lowered" from apps.Document to fo.FOInputHandler; IDReferences moved from former to latter. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197717 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/apps/Document.java b/src/java/org/apache/fop/apps/Document.java index be8a025c4..ec28fa891 100644 --- a/src/java/org/apache/fop/apps/Document.java +++ b/src/java/org/apache/fop/apps/Document.java @@ -18,20 +18,12 @@ package org.apache.fop.apps; -// Java -import java.util.Map; -import java.util.Set; -import java.util.HashSet; - // FOP import org.apache.fop.area.AreaTree; import org.apache.fop.area.AreaTreeModel; - import org.apache.fop.fo.FOInputHandler; import org.apache.fop.fonts.FontInfo; -import org.apache.commons.logging.Log; - // SAX import org.xml.sax.SAXException; @@ -53,12 +45,6 @@ public class Document { /** The AreaTreeModel for the PageSequence being rendered. */ public AreaTreeModel atModel; - /** - * The current set of id's in the FO tree. - * This is used so we know if the FO tree contains duplicates. - */ - private Set idReferences = new HashSet(); - /** * Structure handler used to notify structure * events such as start end element. @@ -99,14 +85,6 @@ public class Document { return areaTree; } - /** - * Retuns the set of ID references. - * @return the ID references - */ - public Set getIDReferences() { - return idReferences; - } - /** * @return the FOInputHandler for parsing this FO Tree */ diff --git a/src/java/org/apache/fop/fo/FOInputHandler.java b/src/java/org/apache/fop/fo/FOInputHandler.java index 994603505..c44ddf91e 100644 --- a/src/java/org/apache/fop/fo/FOInputHandler.java +++ b/src/java/org/apache/fop/fo/FOInputHandler.java @@ -18,6 +18,10 @@ package org.apache.fop.fo; +// Java +import java.util.HashSet; +import java.util.Set; + // FOP import org.apache.fop.apps.Document; import org.apache.fop.apps.Driver; @@ -68,6 +72,12 @@ public abstract class FOInputHandler { */ protected Log logger = null; + /** + * The current set of id's in the FO tree. + * This is used so we know if the FO tree contains duplicates. + */ + private Set idReferences = new HashSet(); + /** * Main constructor * @param document the apps.Document implementation that is controlling @@ -77,6 +87,14 @@ public abstract class FOInputHandler { doc = document; } + /** + * Retuns the set of ID references. + * @return the ID references + */ + public Set getIDReferences() { + return idReferences; + } + /** * Sets the Commons-Logging instance for this class * @param logger The Commons-Logging instance diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 1092be5c7..90775eacf 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -28,7 +28,6 @@ import org.xml.sax.Locator; import org.apache.commons.logging.Log; // FOP -import org.apache.fop.apps.Document; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.util.CharUtilities; @@ -60,7 +59,7 @@ public abstract class FONode { * @return FOUserAgent */ public FOUserAgent getUserAgent() { - return getDocument().getDriver().getUserAgent(); + return getFOInputHandler().getDriver().getUserAgent(); } /** @@ -68,7 +67,7 @@ public abstract class FONode { * @return the logger */ public Log getLogger() { - return getDocument().getDriver().getLogger(); + return getFOInputHandler().getDriver().getLogger(); } /** @@ -101,7 +100,7 @@ public abstract class FONode { * @param localName (e.g. "table" for "fo:table") * @throws IllegalArgumentException if incoming node not valid for parent */ - protected void validateChildNode(String namespaceURI, String localName) {} + protected void validateChildNode(Locator loc, String namespaceURI, String localName) {} /** * Adds characters (does nothing here) @@ -180,12 +179,12 @@ public abstract class FONode { } /** - * Recursively goes up the FOTree hierarchy until the FONode is found, - * which returns the parent Document. - * @return the Document object that is the parent of this node. + * Recursively goes up the FOTree hierarchy until the fo:root is found, + * which returns the parent FOInputHandler. + * @return the FOInputHandler object that is the parent of the FO Tree */ - public Document getDocument() { - return parent.getDocument(); + public FOInputHandler getFOInputHandler() { + return parent.getFOInputHandler(); } /** @@ -226,9 +225,9 @@ public abstract class FONode { * (e.g., two fo:declarations within fo:root) * @param offendingNode incoming node that would cause a duplication. */ - protected void tooManyNodesError(String offendingNode) { + protected void tooManyNodesError(Locator loc, String offendingNode) { throw new IllegalArgumentException( - "Error: for " + getName() + ", only one " + errorText(loc) + getName() + ", only one " + offendingNode + " may be declared."); } @@ -238,9 +237,10 @@ public abstract class FONode { * @param tooLateNode string name of node that should be earlier in document * @param tooEarlyNode string name of node that should be later in document */ - protected void nodesOutOfOrderError(String tooLateNode, String tooEarlyNode) { + protected void nodesOutOfOrderError(Locator loc, String tooLateNode, + String tooEarlyNode) { throw new IllegalArgumentException( - "Error: for " + getName() + ", " + tooLateNode + errorText(loc) + getName() + ", " + tooLateNode + " must be declared before " + tooEarlyNode + "."); } @@ -250,11 +250,19 @@ public abstract class FONode { * @param nsURI namespace URI of incoming invalid node * @param lName local name (i.e., no prefix) of incoming node */ - protected void invalidChildError(String nsURI, String lName) { + protected void invalidChildError(Locator loc, String nsURI, String lName) { throw new IllegalArgumentException( - "Error: " + getNodeString(nsURI, lName) + + errorText(loc) + getNodeString(nsURI, lName) + " is not valid child element of " + getName() + "."); } + /** + * Helper function to return "Error (line#/column#)" string for + * above exception messages + * @param loc org.xml.sax.Locator object + */ + protected static String errorText(Locator loc) { + return "Error(" + loc.getLineNumber() + "/" + loc.getColumnNumber() + "): "; + } } diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 519d05b88..95bb1402c 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -234,7 +234,7 @@ public class FOTreeBuilder extends DefaultHandler { } } else { // check that incoming node is valid for currentFObj try { - currentFObj.validateChildNode(namespaceURI, localName); + currentFObj.validateChildNode(locator, namespaceURI, localName); } catch (IllegalArgumentException e) { throw new SAXException(e); } @@ -254,7 +254,7 @@ public class FOTreeBuilder extends DefaultHandler { if (rootFObj == null) { rootFObj = (Root) foNode; - rootFObj.setDocument(document); + rootFObj.setFOInputHandler(document.getFOInputHandler()); } else { currentFObj.addChild(foNode); } diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 4afe44319..38a8738a4 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -298,7 +298,7 @@ public class FObj extends FONode implements Constants { if (prop != null) { String str = prop.getString(); if (str != null && !str.equals("")) { - Set idrefs = getDocument().getIDReferences(); + Set idrefs = getFOInputHandler().getIDReferences(); if (!idrefs.contains(str)) { id = str; idrefs.add(id); diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 78831cade..343787701 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -46,8 +46,8 @@ public class FObjMixed extends FObj { if (textInfo == null) { // Really only need one of these, but need to get fontInfo // stored in propMgr for later use. - propMgr.setFontInfo(getDocument()); - textInfo = propMgr.getTextLayoutProps(getDocument()); + propMgr.setFontInfo(getFOInputHandler().getDocument()); + textInfo = propMgr.getTextLayoutProps(getFOInputHandler().getDocument()); } FOText ft = new FOText(data, start, length, textInfo, this); @@ -55,7 +55,7 @@ public class FObjMixed extends FObj { ft.setName("text"); /* characters() processing empty for FOTreeHandler, not empty for RTF & MIFHandlers */ - getDocument().getFOInputHandler().characters(ft.ca, ft.startIndex, ft.endIndex); + getFOInputHandler().characters(ft.ca, ft.startIndex, ft.endIndex); addChild(ft); } diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index 88a656547..728c12ae9 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.java @@ -54,7 +54,7 @@ public class BasicLink extends Inline { */ protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); - getDocument().getFOInputHandler().startLink(this); + getFOInputHandler().startLink(this); } public void setup() { @@ -142,8 +142,7 @@ public class BasicLink extends Inline { */ public void end() { super.end(); - - getDocument().getFOInputHandler().endLink(); + getFOInputHandler().endLink(); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 0a0365ede..ade2ce9b1 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -111,7 +111,7 @@ public class Block extends FObjMixed { setupID(); - getDocument().getFOInputHandler().startBlock(this); + getFOInputHandler().startBlock(this); } private void setup() { @@ -238,7 +238,7 @@ public class Block extends FObjMixed { */ public void end() { handleWhiteSpace(); - getDocument().getFOInputHandler().endBlock(this); + getFOInputHandler().endBlock(this); } private void handleWhiteSpace() { diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index 4b7ff9035..f617d5620 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -63,7 +63,7 @@ public class ExternalGraphic extends FObj { */ protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); - getDocument().getFOInputHandler().image(this); + getFOInputHandler().image(this); } /** diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java index 536c8b06d..d2b5e9361 100644 --- a/src/java/org/apache/fop/fo/flow/Footnote.java +++ b/src/java/org/apache/fop/fo/flow/Footnote.java @@ -48,7 +48,7 @@ public class Footnote extends FObj { */ protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); - getDocument().getFOInputHandler().startFootnote(this); + getFOInputHandler().startFootnote(this); } /** @@ -79,7 +79,7 @@ public class Footnote extends FObj { protected void end() { super.end(); - getDocument().getFOInputHandler().endFootnote(this); + getFOInputHandler().endFootnote(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java index 8461b44d8..94fd38848 100644 --- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.java @@ -52,7 +52,7 @@ public class FootnoteBody extends FObj { */ protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); - getDocument().getFOInputHandler().startFootnoteBody(this); + getFOInputHandler().startFootnoteBody(this); } public void acceptVisitor(FOTreeVisitor fotv) { @@ -61,8 +61,7 @@ public class FootnoteBody extends FObj { protected void end() { super.end(); - - getDocument().getFOInputHandler().endFootnoteBody(this); + getFOInputHandler().endFootnoteBody(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index 8d940ddab..076cb00ee 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.java @@ -114,7 +114,7 @@ public class Inline extends FObjMixed { this.lineThrough = true; } - getDocument().getFOInputHandler().startInline(this); + getFOInputHandler().startInline(this); } /** @@ -139,7 +139,7 @@ public class Inline extends FObjMixed { * @see org.apache.fop.fo.FONode#end */ public void end() { - getDocument().getFOInputHandler().endInline(this); + getFOInputHandler().endInline(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index f5387a62c..3ba0eade2 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -66,7 +66,7 @@ public class Leader extends FObjMixed { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - this.fontState = propMgr.getFontState(getDocument()); + this.fontState = propMgr.getFontState(getFOInputHandler().getDocument()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index 84b85ed93..550262498 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -64,7 +64,7 @@ public class ListBlock extends FObj { */ protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); - getDocument().getFOInputHandler().startList(this); + getFOInputHandler().startList(this); } private void setup() throws FOPException { @@ -138,8 +138,7 @@ public class ListBlock extends FObj { protected void end() { super.end(); - - getDocument().getFOInputHandler().endList(this); + getFOInputHandler().endList(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index b403c44cb..5298fa99d 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -64,7 +64,7 @@ public class ListItem extends FObj { */ protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); - getDocument().getFOInputHandler().startListItem(this); + getFOInputHandler().startListItem(this); } private void setup() { @@ -148,7 +148,7 @@ public class ListItem extends FObj { protected void end() { super.end(); - getDocument().getFOInputHandler().endListItem(this); + getFOInputHandler().endListItem(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java index 51b8da235..fd6c3becb 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.java @@ -46,7 +46,7 @@ public class ListItemLabel extends FObj { */ protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); - getDocument().getFOInputHandler().startListLabel(); + getFOInputHandler().startListLabel(); } private void setup() { @@ -85,8 +85,7 @@ public class ListItemLabel extends FObj { protected void end() { super.end(); - - getDocument().getFOInputHandler().endListLabel(); + getFOInputHandler().endListLabel(); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index 0c4e558bf..593c10df4 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.java @@ -61,7 +61,7 @@ public class PageNumber extends FObj { protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); setup(); - getDocument().getFOInputHandler().startPageNumber(this); + getFOInputHandler().startPageNumber(this); } public void setup() { @@ -77,7 +77,7 @@ public class PageNumber extends FObj { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - this.fontState = propMgr.getFontState(getDocument()); + this.fontState = propMgr.getFontState(getFOInputHandler().getDocument()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); @@ -129,7 +129,7 @@ public class PageNumber extends FObj { } protected void end() { - getDocument().getFOInputHandler().endPageNumber(this); + getFOInputHandler().endPageNumber(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index 6ea66fe3a..7b343d66c 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java @@ -82,7 +82,7 @@ public class PageNumberCitation extends FObj { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - this.fontState = propMgr.getFontState(getDocument()); + this.fontState = propMgr.getFontState(getFOInputHandler().getDocument()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index 82202e65c..aa98f304b 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -81,7 +81,7 @@ public class Table extends FObj { protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); setupID(); - getDocument().getFOInputHandler().startTable(this); + getFOInputHandler().startTable(this); } /** @@ -203,7 +203,7 @@ public class Table extends FObj { } protected void end() { - getDocument().getFOInputHandler().endTable(this); + getFOInputHandler().endTable(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java index a75142b1c..ab8424d8b 100644 --- a/src/java/org/apache/fop/fo/flow/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/TableBody.java @@ -57,7 +57,7 @@ public class TableBody extends FObj { protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); setupID(); - getDocument().getFOInputHandler().startBody(this); + getFOInputHandler().startBody(this); } private void setup() throws FOPException { @@ -104,7 +104,7 @@ public class TableBody extends FObj { } protected void end() { - getDocument().getFOInputHandler().endBody(this); + getFOInputHandler().endBody(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java index 88c089963..7a2a09b02 100644 --- a/src/java/org/apache/fop/fo/flow/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/TableCell.java @@ -123,7 +123,7 @@ public class TableCell extends FObj { protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); doSetup(); // init some basic property values - getDocument().getFOInputHandler().startCell(this); + getFOInputHandler().startCell(this); } /** @@ -348,7 +348,7 @@ public class TableCell extends FObj { } protected void end() { - getDocument().getFOInputHandler().endCell(this); + getFOInputHandler().endCell(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java index 69e18b8fa..30fc4d4fc 100644 --- a/src/java/org/apache/fop/fo/flow/TableColumn.java +++ b/src/java/org/apache/fop/fo/flow/TableColumn.java @@ -60,7 +60,7 @@ public class TableColumn extends FObj { protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); initialize(); // init some basic property values - getDocument().getFOInputHandler().startColumn(this); + getFOInputHandler().startColumn(this); } /** @@ -124,7 +124,7 @@ public class TableColumn extends FObj { } protected void end() { - getDocument().getFOInputHandler().endColumn(this); + getFOInputHandler().endColumn(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java index 467fe02b2..7bb3eda5d 100644 --- a/src/java/org/apache/fop/fo/flow/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/TableRow.java @@ -68,7 +68,7 @@ public class TableRow extends FObj { protected void addProperties(Attributes attlist) throws FOPException { super.addProperties(attlist); setupID(); - getDocument().getFOInputHandler().startRow(this); + getFOInputHandler().startRow(this); } /** @@ -145,7 +145,7 @@ public class TableRow extends FObj { } protected void end() { - getDocument().getFOInputHandler().endRow(this); + getFOInputHandler().endRow(this); } public String getName() { diff --git a/src/java/org/apache/fop/fo/pagination/ColorProfile.java b/src/java/org/apache/fop/fo/pagination/ColorProfile.java index a35ac9311..56a415c1b 100644 --- a/src/java/org/apache/fop/fo/pagination/ColorProfile.java +++ b/src/java/org/apache/fop/fo/pagination/ColorProfile.java @@ -24,6 +24,7 @@ import java.awt.color.ICC_ColorSpace; import java.net.URL; import java.io.IOException; import java.io.InputStream; +import org.xml.sax.Locator; // FOP import org.apache.fop.datatypes.ColorType; @@ -48,6 +49,14 @@ public class ColorProfile extends FObj { super(parent); } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(String, String) + XSL 1.0/FOP: EMPTY (no child nodes permitted) + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) { + invalidChildError(loc, nsURI, localName); + } + /** * Special processing for the end of parsing an ColorProfile object. * Extract instance variables from the collection of properties for this diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index e54a6f714..3e0d3aa36 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.java @@ -29,6 +29,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.fo.XMLObj; +import org.xml.sax.Locator; /** @@ -54,12 +55,12 @@ public class Declarations extends FObj { /** * @see org.apache.fop.fo.FONode#validateChildNode(String, String) XSL 1.0: (color-profile)+ (and non-XSL NS nodes) - FOP (currently): (color-profile)* (and non-XSL NS nodes) + FOP/XSL 1.1: (color-profile)* (and non-XSL NS nodes) */ - protected void validateChildNode(String nsURI, String localName) { + protected void validateChildNode(Locator loc, String nsURI, String localName) { if (nsURI == FOElementMapping.URI) { if (!localName.equals("color-profile")) { - invalidChildError(nsURI, localName); + invalidChildError(loc, nsURI, localName); } } // anything outside of XSL namespace is OK. } diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index 115e18173..64037dfc2 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -92,14 +92,14 @@ public class Flow extends FObj { // Now done in addChild of page-sequence //pageSequence.addFlow(this); - getDocument().getFOInputHandler().startFlow(this); + getFOInputHandler().startFlow(this); } /** * Tell the StructureRenderer that we are at the end of the flow. */ public void end() { - getDocument().getFOInputHandler().endFlow(this); + getFOInputHandler().endFlow(this); } /** diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index d9c32092a..cc04488e1 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -291,7 +291,7 @@ public class PageSequence extends FObj { */ private void startStructuredPageSequence() { if (!sequenceStarted) { - getDocument().getFOInputHandler().startPageSequence(this); + getFOInputHandler().startPageSequence(this); sequenceStarted = true; } } @@ -303,7 +303,7 @@ public class PageSequence extends FObj { */ public void end() { try { - this.getDocument().getFOInputHandler().endPageSequence(this); + getFOInputHandler().endPageSequence(this); } catch (FOPException fopex) { getLogger().error("Error in PageSequence.end(): " + fopex.getMessage(), fopex); diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index 71e3c6feb..46a9bf36c 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -22,13 +22,14 @@ package org.apache.fop.fo.pagination; import java.util.List; // FOP -import org.apache.fop.apps.Document; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.Bookmarks; +import org.apache.fop.fo.FOInputHandler; import org.apache.fop.fo.FOTreeVisitor; +import org.xml.sax.Locator; /** * The fo:root formatting object. Contains page masters, page-sequences. @@ -47,7 +48,10 @@ public class Root extends FObj { */ private int runningPageNumberCounter = 0; - private Document document = null; + /** + * Controlling FOTreeHandler object for this FO Tree + */ + private FOInputHandler foInputHandler = null; /** * @see org.apache.fop.fo.FONode#FONode(FONode) @@ -66,43 +70,43 @@ public class Root extends FObj { XSL 1.0 Spec: (layout-master-set,declarations?,page-sequence+) FOP: (layout-master-set, declarations?, fox:bookmarks?, page-sequence+) */ - protected void validateChildNode(String nsURI, String localName) { + protected void validateChildNode(Locator loc, String nsURI, String localName) { if (nsURI == FOElementMapping.URI) { if (localName.equals("layout-master-set")) { if (layoutMasterSet != null) { - tooManyNodesError("fo:layout-master-set"); + tooManyNodesError(loc, "fo:layout-master-set"); } } else if (localName.equals("declarations")) { if (layoutMasterSet == null) { - nodesOutOfOrderError("fo:layout-master-set", "fo:declarations"); + nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:declarations"); } else if (declarations != null) { - tooManyNodesError("fo:declarations"); + tooManyNodesError(loc, "fo:declarations"); } else if (bookmarks != null) { - nodesOutOfOrderError("fo:declarations", "fox:bookmarks"); + nodesOutOfOrderError(loc, "fo:declarations", "fox:bookmarks"); } else if (pageSequenceFound) { - nodesOutOfOrderError("fo:declarations", "fo:page-sequence"); + nodesOutOfOrderError(loc, "fo:declarations", "fo:page-sequence"); } } else if (localName.equals("page-sequence")) { if (layoutMasterSet == null) { - nodesOutOfOrderError("fo:layout-master-set", "fo:page-sequence"); + nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:page-sequence"); } else { pageSequenceFound = true; } } else { - invalidChildError(nsURI, localName); + invalidChildError(loc, nsURI, localName); } } else if (nsURI.equals(ExtensionElementMapping.URI)) { if (!localName.equals("bookmarks")) { - invalidChildError(nsURI, localName); + invalidChildError(loc, nsURI, localName); } else if (layoutMasterSet == null) { - nodesOutOfOrderError("fo:layout-master-set", "fox:bookmarks"); + nodesOutOfOrderError(loc, "fo:layout-master-set", "fox:bookmarks"); } else if (bookmarks != null) { - tooManyNodesError("fox:bookmarks"); + tooManyNodesError(loc, "fox:bookmarks"); } else if (pageSequenceFound) { - nodesOutOfOrderError("fox:bookmarks", "fo:page-sequence"); + nodesOutOfOrderError(loc, "fox:bookmarks", "fo:page-sequence"); } } else { - invalidChildError(nsURI, localName); + invalidChildError(loc, nsURI, localName); } } @@ -201,19 +205,19 @@ public class Root extends FObj { * @param document the apps.Document implementation to which this Root * is attached */ - public void setDocument(Document document) { - this.document = document; + public void setFOInputHandler(FOInputHandler foInputHandler) { + this.foInputHandler = foInputHandler; } /** * This method overrides the FONode version. The FONode version calls the * method by the same name for the parent object. Since Root is at the top - * of the tree, it returns the actual apps.Document object. Thus, any FONode - * can use this chain to find which apps.Document it is being built for. - * @return the Document implementation that this Root is attached to + * of the tree, it returns the actual FOInputHandler object. Thus, any FONode + * can use this chain to find which FOInputHandler it is being built for. + * @return the FOInputHandler implementation that this Root is attached to */ - public Document getDocument() { - return document; + public FOInputHandler getFOInputHandler() { + return foInputHandler; } /** diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java index c0599cd18..a3b45b74b 100644 --- a/src/java/org/apache/fop/fo/pagination/Title.java +++ b/src/java/org/apache/fop/fo/pagination/Title.java @@ -59,7 +59,7 @@ public class Title extends FObjMixed { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - Font fontState = propMgr.getFontState(getDocument()); + Font fontState = propMgr.getFontState(getFOInputHandler().getDocument()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 8e3fc034b..35d640c4d 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -74,7 +74,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { childLMiter = new BlockLMiter(this, childLMiter); userAgent = inBlock.getUserAgent(); setBlockTextInfo(inBlock.getPropertyManager().getTextLayoutProps( - inBlock.getDocument())); + inBlock.getFOInputHandler().getDocument())); } private void setBlockTextInfo(TextInfo ti) {