From 671f7a301437b0dd5d10e49ea9c3e22bc3321748 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Mon, 5 Jul 2004 23:47:56 +0000 Subject: [PATCH] 1.) Moved DocumentInputSource & DocumentReader to apps package, made private to package. 2.) Added validity checking to fo:static-content. 3.) Bug with uninitialized FOUserAgent in Driver fixed (this will probably need more analysis later.) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197753 13f79535-47bb-0310-9956-ffa450edef68 --- .../{tools => apps}/DocumentInputSource.java | 4 +-- .../fop/{tools => apps}/DocumentReader.java | 4 +-- src/java/org/apache/fop/apps/Driver.java | 5 ++-- .../org/apache/fop/fo/pagination/Flow.java | 2 +- .../fop/fo/pagination/StaticContent.java | 28 ++++++++++++++++++- 5 files changed, 35 insertions(+), 8 deletions(-) rename src/java/org/apache/fop/{tools => apps}/DocumentInputSource.java (94%) rename src/java/org/apache/fop/{tools => apps}/DocumentReader.java (99%) diff --git a/src/java/org/apache/fop/tools/DocumentInputSource.java b/src/java/org/apache/fop/apps/DocumentInputSource.java similarity index 94% rename from src/java/org/apache/fop/tools/DocumentInputSource.java rename to src/java/org/apache/fop/apps/DocumentInputSource.java index 92fc6ed9d..cff13693d 100644 --- a/src/java/org/apache/fop/tools/DocumentInputSource.java +++ b/src/java/org/apache/fop/apps/DocumentInputSource.java @@ -16,7 +16,7 @@ /* $Id$ */ -package org.apache.fop.tools; +package org.apache.fop.apps; import org.w3c.dom.Document; import org.xml.sax.InputSource; @@ -26,7 +26,7 @@ import org.xml.sax.InputSource; * * @author Kelly A Campbell */ -public class DocumentInputSource extends InputSource { +class DocumentInputSource extends InputSource { private Document document; diff --git a/src/java/org/apache/fop/tools/DocumentReader.java b/src/java/org/apache/fop/apps/DocumentReader.java similarity index 99% rename from src/java/org/apache/fop/tools/DocumentReader.java rename to src/java/org/apache/fop/apps/DocumentReader.java index db2fe6c64..624676192 100644 --- a/src/java/org/apache/fop/tools/DocumentReader.java +++ b/src/java/org/apache/fop/apps/DocumentReader.java @@ -16,7 +16,7 @@ /* $Id$ */ -package org.apache.fop.tools; +package org.apache.fop.apps; import java.io.IOException; @@ -46,7 +46,7 @@ import org.xml.sax.helpers.AttributesImpl; * */ -public class DocumentReader implements XMLReader { +class DocumentReader implements XMLReader { // ////////////////////////////////////////////////////////////////// // Configuration. diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index ed4f3b50e..e5ffada6e 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -38,8 +38,6 @@ import org.apache.fop.fo.FOTreeHandler; import org.apache.fop.render.awt.AWTRenderer; import org.apache.fop.render.mif.MIFHandler; import org.apache.fop.render.rtf.RTFHandler; -import org.apache.fop.tools.DocumentInputSource; -import org.apache.fop.tools.DocumentReader; /** * Primary class that drives overall FOP process. @@ -163,6 +161,9 @@ public class Driver implements Constants { throw new IllegalStateException("Driver already initialized"); } treeBuilder = new FOTreeBuilder(); + if (foUserAgent == null) { + foUserAgent = new FOUserAgent(); + } } /** diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index 6d8b7966d..d4aa1f1f5 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -73,7 +73,7 @@ public class Flow extends FObj { * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) * XSL/FOP Content Model: marker* (%block;)+ */ - protected void validateChildNode(Locator loc, String nsURI, String localName) { + protected void validateChildNode(Locator loc, String nsURI, String localName) { if (nsURI == FOElementMapping.URI && localName.equals("marker")) { if (blockItemFound) { nodesOutOfOrderError(loc, "fo:marker", "(%block;)"); diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index 6fe6a67f1..f33e70371 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java @@ -18,10 +18,15 @@ package org.apache.fop.fo.pagination; +// XML +import org.xml.sax.Attributes; +import org.xml.sax.Locator; + // FOP +import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOTreeVisitor; -import org.apache.fop.apps.FOPException; /** * Class modelling the fo:static-content object. See Sec. 6.4.19 of the XSL-FO @@ -39,6 +44,27 @@ public class StaticContent extends Flow { private void setup() { } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL/FOP Content Model: (%block;)+ + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) { + if (!isBlockItem(nsURI, localName)) { + invalidChildError(loc, nsURI, localName); + } + } + + /** + * Make sure content model satisfied, if so then tell the + * StructureRenderer that we are at the end of the flow. + * @see org.apache.fop.fo.FONode#end + */ + protected void end() { + if (children == null) { + missingChildElementError("(%block;)+"); + } + } + /** * flowname checking is more stringient for static content currently * @param name the flow-name to set -- 2.39.5