diff options
author | Glen Mazza <gmazza@apache.org> | 2004-06-13 19:58:58 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-06-13 19:58:58 +0000 |
commit | 239320b99c8ba834d186fd4fa0c59ada5e66a633 (patch) | |
tree | bffa984fe2471afe23782c5ad9f73703fdaa4c7c /src/java/org/apache/fop/fo/pagination | |
parent | b56039a254c45b778bbb916b7cae796dc5ab16ea (diff) | |
download | xmlgraphics-fop-239320b99c8ba834d186fd4fa0c59ada5e66a633.tar.gz xmlgraphics-fop-239320b99c8ba834d186fd4fa0c59ada5e66a633.zip |
1.) App now returns an error if no page-sequence declared within fo:root.
2.) Standardized node names via a new static FONode.getNodeName() method
3.) Declarations object now tied to Root object, will no longer return NPE
if empty (bug fixed).
4.) AreaTreeControl removed in favor of direct connection between Document
and the Area Tree.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197708 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/pagination')
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/Declarations.java | 45 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/Root.java | 26 |
2 files changed, 47 insertions, 24 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index d48af48a8..21cca9935 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.java @@ -47,37 +47,40 @@ public class Declarations extends FObj { */ public Declarations(FONode parent) { super(parent); + ((Root) parent).setDeclarations(this); } /** - * At then end of this element sort out the child into + * At the end of this element sort out the child into * a hashmap of color profiles and a list of external xml. */ public void end() { - for (Iterator iter = children.iterator(); iter.hasNext();) { - FONode node = (FONode)iter.next(); - if (node.getName().equals("fo:color-profile")) { - ColorProfile cp = (ColorProfile)node; - if (!"".equals(cp.getProfileName())) { - if (colorProfiles == null) { - colorProfiles = new java.util.HashMap(); + if (children != null) { + for (Iterator iter = children.iterator(); iter.hasNext();) { + FONode node = (FONode)iter.next(); + if (node.getName().equals("fo:color-profile")) { + ColorProfile cp = (ColorProfile)node; + if (!"".equals(cp.getProfileName())) { + if (colorProfiles == null) { + colorProfiles = new java.util.HashMap(); + } + if (colorProfiles.get(cp.getProfileName()) != null) { + // duplicate names + getLogger().warn("Duplicate fo:color-profile profile name : " + + cp.getProfileName()); + } + colorProfiles.put(cp.getProfileName(), cp); + } else { + getLogger().warn("color-profile-name required for color profile"); } - if (colorProfiles.get(cp.getProfileName()) != null) { - // duplicate names - getLogger().warn("Duplicate fo:color-profile profile name : " - + cp.getProfileName()); + } else if (node instanceof XMLObj) { + if (external == null) { + external = new java.util.ArrayList(); } - colorProfiles.put(cp.getProfileName(), cp); + external.add(node); } else { - getLogger().warn("color-profile-name required for color profile"); + getLogger().warn("invalid element " + node.getName() + "inside declarations"); } - } else if (node instanceof XMLObj) { - if (external == null) { - external = new java.util.ArrayList(); - } - external.add(node); - } else { - getLogger().warn("invalid element " + node.getName() + "inside declarations"); } } children = null; diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index db4da1247..8fc8648eb 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -34,6 +34,8 @@ public class Root extends FObj { private LayoutMasterSet layoutMasterSet; private Declarations declarations; private List pageSequences; + // temporary until above list populated + private boolean pageSequenceFound = false; /** * Keeps count of page number from over PageSequence instances @@ -72,7 +74,7 @@ public class Root extends FObj { } else if (declarations != null) { // only one fo:declarations throw new IllegalArgumentException("Error: Only one" + " fo:declarations may be defined per fo:root"); - } else if (!pageSequences.isEmpty()) { // no page-seqs yet + } else if (pageSequenceFound) { // no page-seqs yet throw new IllegalArgumentException("Error: fo:declarations" + " must be defined before fo:page-sequence declarations"); } @@ -80,13 +82,15 @@ public class Root extends FObj { if (layoutMasterSet == null) { // must already have a l-m-s throw new IllegalArgumentException("Error:" + " fo:layout-master-set must be first child of fo:root"); + } else { + pageSequenceFound = true; } } else throw new IllegalArgumentException("Error: Invalid child" + " node \"fo:" + localName + "\" of fo:root"); } else { - throw new IllegalArgumentException("Error: Invalid child node (" - + namespaceURI + ") \"" + localName + "\" of fo:root"); + throw new IllegalArgumentException("Error: Invalid child node " + + FONode.getNodeString(namespaceURI, localName) + " of fo:root"); } } @@ -149,6 +153,22 @@ public class Root extends FObj { } /** + * Returns the associated Declarations. + * @return the Declarations instance + */ + public Declarations getDeclarations() { + return this.declarations; + } + + /** + * Sets the associated Declarations. + * @param Declarations the Declarations to use + */ + public void setDeclarations(Declarations declarations) { + this.declarations = declarations; + } + + /** * Sets the FOTreeControl that this Root is attached to * @param foTreeControl the FOTreeControl implementation to which this Root * is attached |