From: Glen Mazza Date: Sat, 4 Sep 2004 20:55:21 +0000 (+0000) Subject: 1.) Validation for fo:multi-toggle added. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~589 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fe2d99426ed26953441a63e27aa87935e0877d6d;p=xmlgraphics-fop.git 1.) Validation for fo:multi-toggle added. 2.) Switch to faster int's for findAncestor(). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197902 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 64c1f199d..e1bfe272e 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -110,23 +110,6 @@ public abstract class FONode { System.out.println("name = " + elementName); } - /** - * Returns the name of the node - * @return the name of this node - */ - public String getName() { - return null; - } - - /** - * Returns the Constants class integer value of this node - * @return the integer enumeration of this FO (e.g., FO_ROOT) - * if a formatting object, FO_UNKNOWN_NODE otherwise - */ - public int getNameId() { - return Constants.FO_UNKNOWN_NODE; - } - /** * Checks to make sure, during SAX processing of input document, that the * incoming node is valid for the this (parent) node (e.g., checking to @@ -344,5 +327,22 @@ public abstract class FONode { return "Error(" + loc.getLineNumber() + "/" + loc.getColumnNumber() + "): "; } } + + /** + * Returns the name of the node + * @return the name of this node + */ + public String getName() { + return null; + } + + /** + * Returns the Constants class integer value of this node + * @return the integer enumeration of this FO (e.g., FO_ROOT) + * if a formatting object, FO_UNKNOWN_NODE otherwise + */ + public int getNameId() { + return Constants.FO_UNKNOWN_NODE; + } } diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index a1a25e8b7..cebe2e164 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -514,8 +514,9 @@ public class FObj extends FONode implements Constants { || lName.equals("page-number") || lName.equals("page-number-citation") || lName.equals("basic-link") - || lName.equals("multi-toggle") - || (!isOutOfLineFODescendant && lName.equals("footnote")) + || (lName.equals("multi-toggle") + && (getNameId() == FO_MULTI_CASE || findAncestor(FO_MULTI_CASE) > 0)) + || (lName.equals("footnote") && !isOutOfLineFODescendant) || isNeutralItem(nsURI, lName))); } @@ -551,15 +552,15 @@ public class FObj extends FONode implements Constants { /** * Convenience method for validity checking. Checks if the * current node has an ancestor of a given name. - * @param ancestorName -- node name to check for (e.g., "fo:root") + * @param ancestorID -- Constants ID of node name to check for (e.g., FO_ROOT) * @return number of levels above FO where ancestor exists, * -1 if not found */ - protected int findAncestor(String ancestorName) { + protected int findAncestor(int ancestorID) { int found = 1; FONode temp = getParent(); while (temp != null) { - if (temp.getName().equals(ancestorName)) { + if (temp.getNameId() == ancestorID) { return found; } found += 1; diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 0e97b6d83..48874bf1c 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java @@ -52,10 +52,10 @@ public class BidiOverride extends FObjMixed { /* Check to see if this node can have block-level children. * See validateChildNode() below. */ - int lvlLeader = findAncestor("fo:leader"); - int lvlInCntr = findAncestor("fo:inline-container"); - int lvlInline = findAncestor("fo:inline"); - int lvlFootnote = findAncestor("fo:footnote"); + int lvlLeader = findAncestor(FO_LEADER); + int lvlInCntr = findAncestor(FO_INLINE_CONTAINER); + int lvlInline = findAncestor(FO_INLINE); + int lvlFootnote = findAncestor(FO_FOOTNOTE); if (lvlLeader > 0) { if (lvlInCntr < 0 || diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index 5df8b7573..33605498f 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.java @@ -54,9 +54,9 @@ public class Inline extends FObjMixed { /* Check to see if this node can have block-level children. * See validateChildNode() below. */ - int lvlLeader = findAncestor("fo:leader"); - int lvlFootnote = findAncestor("fo:footnote"); - int lvlInCntr = findAncestor("fo:inline-container"); + int lvlLeader = findAncestor(FO_LEADER); + int lvlFootnote = findAncestor(FO_FOOTNOTE); + int lvlInCntr = findAncestor(FO_INLINE_CONTAINER); if (lvlLeader > 0) { if (lvlInCntr < 0 ||