From 42dc46911b6f085878be224ab0787e69a524fcb0 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Mon, 6 Sep 2004 18:28:17 +0000 Subject: [PATCH] PR: Obtained from: Submitted by: Reviewed by: Switched to a static FOInputHandler object for the FOTree instead of relying on recursion to get to the FOInputHandler object stored at pagination.Root. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197910 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FONode.java | 16 +++++++++++- src/java/org/apache/fop/fo/FOTreeBuilder.java | 2 +- .../org/apache/fop/fo/pagination/Root.java | 25 ------------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 193b92e57..c42577f7c 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -41,6 +41,12 @@ public abstract class FONode { protected static String FO_URI = FOElementMapping.URI; + /** + * FOInputHandler that handles FO events occurring + * during FO Tree processing. + */ + protected static FOInputHandler foInputHandler = null; + /** Parent FO node */ protected FONode parent; @@ -72,13 +78,21 @@ public abstract class FONode { } } + /** + * Sets the FOInputHandler that the FOTree processing fires events to + * @param inputHandler the FOInputHandler subclass to send FO events to + */ + public static void setFOInputHandler(FOInputHandler inputHandler) { + FONode.foInputHandler = inputHandler; + } + /** * 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 FOInputHandler getFOInputHandler() { - return parent.getFOInputHandler(); + return FONode.foInputHandler; } /** diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index da0f6f6c9..a5b94d978 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -217,6 +217,7 @@ public class FOTreeBuilder extends DefaultHandler { */ public void startDocument() throws SAXException { rootFObj = null; // allows FOTreeBuilder to be reused + FONode.setFOInputHandler(foInputHandler); if (log.isDebugEnabled()) { log.debug("Building formatting object tree"); } @@ -273,7 +274,6 @@ public class FOTreeBuilder extends DefaultHandler { if (rootFObj == null) { rootFObj = (Root) foNode; - rootFObj.setFOInputHandler(foInputHandler); } else { currentFObj.addChildNode(foNode); } diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index a879f9469..71e0c5ffe 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -49,11 +49,6 @@ public class Root extends FObj { */ private int runningPageNumberCounter = 0; - /** - * Controlling FOTreeHandler object for this FO Tree - */ - private FOInputHandler foInputHandler = null; - /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ @@ -202,26 +197,6 @@ public class Root extends FObj { return bookmarks; } - /** - * Sets the Document that this Root is attached to - * @param document the apps.Document implementation to which this Root - * is attached - */ - 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 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 FOInputHandler getFOInputHandler() { - return foInputHandler; - } - /** * @see org.apache.fop.fo.FObj#getName() */ -- 2.39.5