gmazza 2004/09/12 20:46:04 Modified: src/java/org/apache/fop/fo FONode.java FOTreeBuilder.java src/java/org/apache/fop/fo/flow InstreamForeignObject.java src/java/org/apache/fop/fo/pagination Root.java Log: 1.) Returned to recursion for FOEventHandler. 2.) InstreamForeignObject validation changed to accomodate Finn's validation changes. Revision Changes Path 1.45 +1 -15 xml-fop/src/java/org/apache/fop/fo/FONode.java Index: FONode.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- FONode.java 6 Sep 2004 18:44:31 -0000 1.44 +++ FONode.java 13 Sep 2004 03:46:04 -0000 1.45 @@ -41,12 +41,6 @@ protected static String FO_URI = FOElementMapping.URI; - /** - * FOEventHandler that handles FO events occurring - * during FO Tree processing. - */ - protected static FOEventHandler foEventHandler = null; - /** Parent FO node */ protected FONode parent; @@ -79,20 +73,12 @@ } /** - * Sets the FOEventHandler that the FOTree processing fires events to - * @param eventHandler the FOEventHandler subclass to send FO events to - */ - public static void setFOEventHandler(FOEventHandler eventHandler) { - FONode.foEventHandler = eventHandler; - } - - /** * Recursively goes up the FOTree hierarchy until the fo:root is found, * which returns the parent FOEventHandler. * @return the FOEventHandler object that is the parent of the FO Tree */ public FOEventHandler getFOEventHandler() { - return FONode.foEventHandler; + return parent.getFOEventHandler(); } /** 1.51 +1 -1 xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java Index: FOTreeBuilder.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- FOTreeBuilder.java 9 Sep 2004 07:19:23 -0000 1.50 +++ FOTreeBuilder.java 13 Sep 2004 03:46:04 -0000 1.51 @@ -218,7 +218,6 @@ */ public void startDocument() throws SAXException { rootFObj = null; // allows FOTreeBuilder to be reused - FONode.setFOEventHandler(foEventHandler); if (log.isDebugEnabled()) { log.debug("Building formatting object tree"); } @@ -278,6 +277,7 @@ if (rootFObj == null) { rootFObj = (Root) foNode; + rootFObj.setFOEventHandler(foEventHandler); } else { currentFObj.addChildNode(foNode); } 1.26 +2 -6 xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java Index: InstreamForeignObject.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- InstreamForeignObject.java 7 Sep 2004 20:47:09 -0000 1.25 +++ InstreamForeignObject.java 13 Sep 2004 03:46:04 -0000 1.26 @@ -37,8 +37,6 @@ */ public class InstreamForeignObject extends FObj { - boolean hasNonXSLNamespaceElement = false; - /** * constructs an instream-foreign-object object (called by Maker). * @@ -56,10 +54,8 @@ throws SAXParseException { if (nsURI == FO_URI) { invalidChildError(loc, nsURI, localName); - } else if (hasNonXSLNamespaceElement) { + } else if (childNodes != null) { tooManyNodesError(loc, "child element"); - } else { - hasNonXSLNamespaceElement = true; } } @@ -69,7 +65,7 @@ * @see org.apache.fop.fo.FONode#end */ protected void endOfNode() throws SAXParseException { - if (!hasNonXSLNamespaceElement) { + if (childNodes == null) { missingChildElementError("one (1) non-XSL namespace child"); } } 1.28 +25 -0 xml-fop/src/java/org/apache/fop/fo/pagination/Root.java Index: Root.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Root.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- Root.java 7 Sep 2004 20:47:10 -0000 1.27 +++ Root.java 13 Sep 2004 03:46:04 -0000 1.28 @@ -28,6 +28,7 @@ // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.Bookmarks; @@ -49,6 +50,11 @@ private int runningPageNumberCounter = 0; /** + * FOEventHandler object for this FO Tree + */ + private FOEventHandler foEventHandler = null; + + /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ public Root(FONode parent) { @@ -107,6 +113,25 @@ } /** + * Sets the FOEventHandler object that this Root is attached to + * @param foEventHandler the FOEventHandler object + */ + public void setFOEventHandler(FOEventHandler foEventHandler) { + this.foEventHandler = foEventHandler; + } + + /** + * 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 FOEventHandler object. Thus, any FONode + * can use this chain to find which FOEventHandler it is being built for. + * @return the FOEventHandler implementation that this Root is attached to + */ + public FOEventHandler getFOEventHandler() { + return foEventHandler; + } + + /** * Returns the number of pages generated (over all PageSequence instances). * @return the number of pages */
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]