From 92df5d3b4839a699d036940d3b9b3c0e797deb8b Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Tue, 22 Jun 2004 00:44:46 +0000 Subject: [PATCH] 1. Moved renderer options to within FOUserAgent 2. Validity checking on fo:conditional-page-master-reference added. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197741 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/apps/CommandLineOptions.java | 18 ++++++++++-------- src/java/org/apache/fop/apps/FOUserAgent.java | 10 ++++++++++ src/java/org/apache/fop/apps/Fop.java | 4 +--- .../ConditionalPageMasterReference.java | 9 +++++++++ .../apache/fop/render/AbstractRenderer.java | 10 ---------- src/java/org/apache/fop/render/Renderer.java | 7 ------- .../org/apache/fop/render/xml/XMLRenderer.java | 3 ++- .../org/apache/fop/tools/TestConverter.java | 6 ++---- 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/java/org/apache/fop/apps/CommandLineOptions.java b/src/java/org/apache/fop/apps/CommandLineOptions.java index b6116c7bc..14b7f610c 100644 --- a/src/java/org/apache/fop/apps/CommandLineOptions.java +++ b/src/java/org/apache/fop/apps/CommandLineOptions.java @@ -78,8 +78,8 @@ public class CommandLineOptions { /* output mode */ private int outputmode = NOT_SET; - private java.util.HashMap rendererOptions; - + private FOUserAgent foUserAgent; + private Log log; private Vector xsltParams = null; @@ -96,7 +96,9 @@ public class CommandLineOptions { log = LogFactory.getLog("FOP"); boolean optionsParsed = true; - rendererOptions = new java.util.HashMap(); + + foUserAgent = new FOUserAgent(); + try { optionsParsed = parseOptions(args); if (optionsParsed) { @@ -454,7 +456,7 @@ public class CommandLineOptions { case SVG_OUTPUT: return Driver.RENDER_SVG; case AREA_OUTPUT: - rendererOptions.put("fineDetail", isCoarseAreaXml()); + foUserAgent.getRendererOptions().put("fineDetail", isCoarseAreaXml()); return Driver.RENDER_XML; case RTF_OUTPUT: return Driver.RENDER_RTF; @@ -480,11 +482,11 @@ public class CommandLineOptions { } /** - * Get the renderer specific options. - * @return hash map with option/value pairs. + * Get the FOUserAgent for this Command-Line run + * @return FOUserAgent instance */ - public java.util.HashMap getRendererOptions() { - return rendererOptions; + protected FOUserAgent getFOUserAgent() { + return foUserAgent; } /** diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index cd862c7cd..56854e0e9 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -19,6 +19,7 @@ package org.apache.fop.apps; // Java +import java.util.HashMap; import java.util.Map; import java.io.IOException; import java.io.InputStream; @@ -55,6 +56,15 @@ public class FOUserAgent { private String baseURL; private PDFEncryptionParams pdfEncryptionParams; private float px2mm = 0.35277777777777777778f; //72dpi (=25.4/dpi) + private HashMap rendererOptions = new java.util.HashMap(); + + /** + * Returns the renderer options + * @return renderer options + */ + public HashMap getRendererOptions() { + return rendererOptions; + } /** * Sets the base URL. diff --git a/src/java/org/apache/fop/apps/Fop.java b/src/java/org/apache/fop/apps/Fop.java index 362739c22..7e75f4ab7 100644 --- a/src/java/org/apache/fop/apps/Fop.java +++ b/src/java/org/apache/fop/apps/Fop.java @@ -45,6 +45,7 @@ public class Fop { Driver driver = new Driver(); options = new CommandLineOptions(args); + driver.setUserAgent(options.getFOUserAgent()); inputHandler = options.getInputHandler(); try { @@ -60,9 +61,6 @@ public class Fop { } } - if (driver.getRenderer() != null) { - driver.getRenderer().setOptions(options.getRendererOptions()); - } driver.render(inputHandler); } finally { if (bos != null) { diff --git a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java index a2a931a91..71180dc45 100644 --- a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java @@ -20,6 +20,7 @@ package org.apache.fop.fo.pagination; // XML import org.xml.sax.Attributes; +import org.xml.sax.Locator; // FOP import org.apache.fop.fo.FONode; @@ -52,6 +53,14 @@ public class ConditionalPageMasterReference extends FObj { super(parent); } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL/FOP Content Model: empty + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) { + invalidChildError(loc, nsURI, localName); + } + /** * @see org.apache.fop.fo.FObj#addProperties */ diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 96c10d0ac..f3fd05848 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -104,11 +104,6 @@ public abstract class AbstractRenderer */ protected Date creationDate = null; - /** - * renderer configuration - */ - protected Map options; - /** * block progression position */ @@ -179,11 +174,6 @@ public abstract class AbstractRenderer creationDate = date; } - /** @see org.apache.fop.render.Renderer */ - public void setOptions(Map opt) { - options = opt; - } - /** @see org.apache.fop.render.Renderer */ public void startRenderer(OutputStream outputStream) throws IOException { } diff --git a/src/java/org/apache/fop/render/Renderer.java b/src/java/org/apache/fop/render/Renderer.java index 6ca5ad708..dda6788e4 100644 --- a/src/java/org/apache/fop/render/Renderer.java +++ b/src/java/org/apache/fop/render/Renderer.java @@ -96,13 +96,6 @@ public interface Renderer { */ void setupFontInfo(FontInfo fontInfo); - /** - * Set up renderer options. - * - * @param options The Configuration for the renderer - */ - void setOptions(Map options); - /** * Set the producer of the rendering. If this method isn't called the * renderer uses a default. Note: Not all renderers support this feature. diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 9e415bb72..d73e32556 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -180,7 +180,8 @@ public class XMLRenderer extends AbstractRenderer { } private boolean isCoarseXml() { - return ((Boolean) options.get("fineDetail")).booleanValue(); + return ((Boolean) + userAgent.getRendererOptions().get("fineDetail")).booleanValue(); } /** diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java index 71b6e764a..8b4ce8cc4 100644 --- a/src/java/org/apache/fop/tools/TestConverter.java +++ b/src/java/org/apache/fop/tools/TestConverter.java @@ -315,10 +315,8 @@ public class TestConverter { driver.setRenderer(Driver.RENDER_XML); } - Map rendererOptions = new java.util.HashMap(); - rendererOptions.put("fineDetail", new Boolean(false)); - rendererOptions.put("consistentOutput", new Boolean(true)); - driver.getRenderer().setOptions(rendererOptions); + userAgent.getRendererOptions().put("fineDetail", new Boolean(false)); + userAgent.getRendererOptions().put("consistentOutput", new Boolean(true)); driver.getRenderer().setProducer("Testsuite Converter"); String outname = res; -- 2.39.5