aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-09-13 03:46:04 +0000
committerGlen Mazza <gmazza@apache.org>2004-09-13 03:46:04 +0000
commit5fee7bd957ac85640ed4851bece1216eb6c6d5a5 (patch)
tree229862201f1bd0d4698a5c82178c3b68ce81f826 /src
parentf7d5393a79bc58683b3d63632bd235932b37d9d6 (diff)
downloadxmlgraphics-fop-5fee7bd957ac85640ed4851bece1216eb6c6d5a5.tar.gz
xmlgraphics-fop-5fee7bd957ac85640ed4851bece1216eb6c6d5a5.zip
1.) Returned to recursion for FOEventHandler.
2.) InstreamForeignObject validation changed to accomodate Finn's validation changes. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197945 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/FONode.java16
-rw-r--r--src/java/org/apache/fop/fo/FOTreeBuilder.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/InstreamForeignObject.java8
-rw-r--r--src/java/org/apache/fop/fo/pagination/Root.java25
4 files changed, 29 insertions, 22 deletions
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index 0b422bc8b..24e345a00 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -41,12 +41,6 @@ public abstract class FONode {
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 @@ public abstract class FONode {
}
/**
- * 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();
}
/**
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index 38bd0ef18..cda21f8e0 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -218,7 +218,6 @@ public class FOTreeBuilder extends DefaultHandler {
*/
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 @@ public class FOTreeBuilder extends DefaultHandler {
if (rootFObj == null) {
rootFObj = (Root) foNode;
+ rootFObj.setFOEventHandler(foEventHandler);
} else {
currentFObj.addChildNode(foNode);
}
diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
index bbb92af80..6505db5f7 100644
--- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
+++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
@@ -37,8 +37,6 @@ import org.apache.fop.fo.FObj;
*/
public class InstreamForeignObject extends FObj {
- boolean hasNonXSLNamespaceElement = false;
-
/**
* constructs an instream-foreign-object object (called by Maker).
*
@@ -56,10 +54,8 @@ public class InstreamForeignObject extends FObj {
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 @@ public class InstreamForeignObject extends FObj {
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
- if (!hasNonXSLNamespaceElement) {
+ if (childNodes == null) {
missingChildElementError("one (1) non-XSL namespace child");
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java
index 4ef17ddec..da3f642bf 100644
--- a/src/java/org/apache/fop/fo/pagination/Root.java
+++ b/src/java/org/apache/fop/fo/pagination/Root.java
@@ -28,6 +28,7 @@ import org.xml.sax.SAXParseException;
// 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 @@ public class Root extends FObj {
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 @@ public class Root extends FObj {
}
/**
+ * 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
*/