]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Reverted changes made in r1234877, see bugzilla#52513
authorMehdi Houshmand <mehdi@apache.org>
Tue, 24 Jan 2012 09:53:32 +0000 (09:53 +0000)
committerMehdi Houshmand <mehdi@apache.org>
Tue, 24 Jan 2012 09:53:32 +0000 (09:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1235189 13f79535-47bb-0310-9956-ffa450edef68

30 files changed:
examples/embedding/java/embedding/ExampleFO2JPSPrint.java
examples/embedding/java/embedding/atxml/ExampleConcat.java
src/java/org/apache/fop/cli/CommandLineOptions.java
src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
src/java/org/apache/fop/render/AbstractRenderer.java
src/java/org/apache/fop/render/PrintRenderer.java
src/java/org/apache/fop/render/Renderer.java
src/java/org/apache/fop/render/RendererFactory.java
src/java/org/apache/fop/render/awt/AWTRenderer.java
src/java/org/apache/fop/render/awt/AWTRendererMaker.java
src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
src/java/org/apache/fop/render/bitmap/PNGRenderer.java
src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
src/java/org/apache/fop/render/intermediate/IFRenderer.java
src/java/org/apache/fop/render/java2d/Java2DRenderer.java
src/java/org/apache/fop/render/print/PageableRenderer.java
src/java/org/apache/fop/render/print/PrintRenderer.java
src/java/org/apache/fop/render/print/PrintRendererMaker.java
src/java/org/apache/fop/render/txt/TXTRenderer.java
src/java/org/apache/fop/render/txt/TXTRendererMaker.java
src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
src/java/org/apache/fop/render/xml/XMLRenderer.java
src/java/org/apache/fop/render/xml/XMLRendererMaker.java
src/sandbox/org/apache/fop/render/svg/SVGRenderer.java
src/sandbox/org/apache/fop/render/svg/SVGRendererMaker.java
test/java/org/apache/fop/URIResolutionTestCase.java
test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java
test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java

index 1e0ec485333e6e03b8c03a3bdcc74dd3af5d7fbb..4f18b71abd6797fc8ca0c0b673e5f6e413bbb213 100644 (file)
@@ -85,7 +85,8 @@ public class ExampleFO2JPSPrint {
         //Set up a custom user agent so we can supply our own renderer instance
         FOUserAgent userAgent = fopFactory.newFOUserAgent();
 
-        PageableRenderer renderer = new PageableRenderer(userAgent);
+        PageableRenderer renderer = new PageableRenderer();
+        renderer.setUserAgent(userAgent);
         userAgent.setRendererOverride(renderer);
 
         // Construct FOP with desired output format
index 289f7d0747ff23c039cc52b3d944c724e4e45142..adec1b08cb7dbd9ae0562afb0ff22a6f80df373c 100644 (file)
@@ -93,7 +93,8 @@ public class ExampleConcat {
                 userAgent, MimeConstants.MIME_PDF);
 
         //Create the XMLRenderer to create the area tree XML
-        XMLRenderer xmlRenderer = new XMLRenderer(userAgent);
+        XMLRenderer xmlRenderer = new XMLRenderer();
+        xmlRenderer.setUserAgent(userAgent);
 
         //Tell the XMLRenderer to mimic the target renderer
         xmlRenderer.mimicRenderer(targetRenderer);
index 845c11a0d78ab381572a650d0769401fb26e33b4..0d4c3790c764a01bfa8290f39c56f60eef28ef22 100644 (file)
@@ -203,14 +203,17 @@ public class CommandLineOptions {
                 System.err.println("Couldn't set system look & feel!");
             }
 
-            AWTRenderer renderer = new AWTRenderer(foUserAgent, inputHandler, true, true);
+            AWTRenderer renderer = new AWTRenderer(true);
+            renderer.setRenderable(inputHandler); //set before user agent!
+            renderer.setUserAgent(foUserAgent);
             foUserAgent.setRendererOverride(renderer);
         } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode)
                && mimicRenderer != null) {
             // render from FO to Intermediate Format
             Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer(
                    foUserAgent, mimicRenderer);
-            XMLRenderer xmlRenderer = new XMLRenderer(foUserAgent);
+            XMLRenderer xmlRenderer = new XMLRenderer();
+            xmlRenderer.setUserAgent(foUserAgent);
 
             //Tell the XMLRenderer to mimic the target renderer
             xmlRenderer.mimicRenderer(targetRenderer);
index 83d3d84a2554d86174d3a377aead15cd9e1d1c1c..45a02a9772eaad4fa1a881e36c2af60d5184847f 100644 (file)
@@ -34,7 +34,6 @@ import org.apache.xmlgraphics.image.loader.ImageSize;
 import org.apache.xmlgraphics.util.QName;
 import org.apache.xmlgraphics.util.UnitConv;
 
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
@@ -57,10 +56,6 @@ import org.apache.fop.traits.BorderProps;
  */
 public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
 
-    public AbstractPathOrientedRenderer(FOUserAgent userAgent) {
-        super(userAgent);
-    }
-
     /**
      * Handle block traits.
      * The block could be any sort of block with any positioning
index 659748df9ea67e96b833119d6c3f0ed25ba005d4..7ff236d160867eefd8491a1919645e9de5b60715 100644 (file)
@@ -61,11 +61,11 @@ import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.InlineBlockParent;
 import org.apache.fop.area.inline.InlineParent;
-import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.Space;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.FontInfo;
@@ -116,16 +116,16 @@ public abstract class AbstractRenderer
     /** {@inheritDoc} */
     public abstract void setupFontInfo(FontInfo fontInfo) throws FOPException;
 
-    /**
-     *
-     * @param userAgent the user agent that contains configuration details. This cannot be null.
-     */
-    public AbstractRenderer(FOUserAgent userAgent) {
-        this.userAgent = userAgent;
+    /** {@inheritDoc} */
+    public void setUserAgent(FOUserAgent agent) {
+        userAgent = agent;
     }
 
     /** {@inheritDoc} */
     public FOUserAgent getUserAgent() {
+        if (userAgent == null) {
+            throw new IllegalStateException("FOUserAgent has not been set on Renderer");
+        }
         return userAgent;
     }
 
index 05e9cb7af6ab17a5aec35bf6e69390dd04f85769..be3ace0169f9bafb955dea2abeed008d274e6e4c 100644 (file)
@@ -27,7 +27,6 @@ import java.util.Map;
 import org.w3c.dom.Document;
 
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Trait;
 import org.apache.fop.fonts.CustomFontCollection;
@@ -43,10 +42,6 @@ import org.apache.fop.fonts.base14.Base14FontCollection;
 /** Abstract base class of "Print" type renderers.  */
 public abstract class PrintRenderer extends AbstractRenderer {
 
-    public PrintRenderer(FOUserAgent userAgent) {
-        super(userAgent);
-    }
-
     /** Font configuration */
     protected FontInfo fontInfo;
 
index 5f5596dfb2722aa62f3524eb80c91037186b5441..76f245251938dd8076518aeb7e63c56b1d71d3b2 100644 (file)
@@ -81,6 +81,13 @@ public interface Renderer {
     void stopRenderer()
         throws IOException;
 
+    /**
+     * Set the User Agent.
+     *
+     * @param agent  The User Agent
+     */
+    void setUserAgent(FOUserAgent agent);
+
     /**
      * Returns the associated user agent.
      * @return the user agent
index 3ceb27a8e4ed817329e6eebff80892bf20028502..bc598450f40625862932c6586107d94e0b6ddd0b 100644 (file)
@@ -299,6 +299,7 @@ public class RendererFactory {
         AbstractRendererMaker maker = getRendererMaker(outputFormat);
         if (maker != null) {
             Renderer rend = maker.makeRenderer(userAgent);
+            rend.setUserAgent(userAgent);
             RendererConfigurator configurator = maker.getConfigurator(userAgent);
             if (configurator != null) {
                 configurator.configure(rend);
@@ -310,7 +311,8 @@ public class RendererFactory {
     }
 
     private Renderer createRendererForDocumentHandler(IFDocumentHandler documentHandler) {
-        IFRenderer rend = new IFRenderer(documentHandler.getContext().getUserAgent());
+        IFRenderer rend = new IFRenderer();
+        rend.setUserAgent(documentHandler.getContext().getUserAgent());
         rend.setDocumentHandler(documentHandler);
         return rend;
     }
index c366552042f0cea985ed6d605c4e9b2dbce734d5..99dece24a271d71cb5e71410551e6544679bffa1 100644 (file)
@@ -64,6 +64,18 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
     /** flag for debugging */
     public boolean debug;                                       // CSOK: VisibilityModifier
 
+    /** If true, preview dialog is shown. */
+    public boolean dialogDisplay = true;                        // CSOK: VisibilityModifier
+
+    /** true if the preview dialog should be the main window of the application */
+    private boolean previewAsMainWindow;
+
+    /**
+     * Renderable instance that can be used to reload and re-render a document after
+     * modifications.
+     */
+    protected Renderable renderable;
+
     /**
      * Will be notified when rendering progresses
      */
@@ -72,35 +84,47 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
 
     /**
      * Creates a new AWTRenderer instance.
-     *
-     * @param userAgent the user agent that contains configuration data
      */
-    public AWTRenderer(FOUserAgent userAgent) {
-        this(userAgent, null, false, false);
+    public AWTRenderer() {
+        this(false);
     }
 
     /**
      * Creates a new AWTRenderer instance.
-     *
-     * @param userAgent the user agent that contains configuration data
-     * @param renderable a Renderable instance can be set so the Preview Dialog can enable the
-     * "Reload" button which causes the current document to be reprocessed and redisplayed.
      * @param previewAsMainWindow true if the preview dialog created by the renderer should be
-     * the main window of the application.
-     * @param show sets whether the preview dialog should be created and displayed when the
-     * rendering has finished.
+     *                            the main window of the application.
      */
-    public AWTRenderer(FOUserAgent userAgent, Renderable renderable, boolean previewAsMainWindow,
-            boolean show) {
-        super(userAgent);
-        if (show) {
-            // MH: Not sure about this??? If show is false, there's no way for this class
-            // to create a preview dialog... Previously a "setUserAgent" could be called.
-            setStatusListener(PreviewDialog.createPreviewDialog(userAgent, renderable,
-                    previewAsMainWindow));
+    public AWTRenderer(boolean previewAsMainWindow) {
+        this.previewAsMainWindow = previewAsMainWindow;
+    }
+
+    /** {@inheritDoc} */
+    public void setUserAgent(FOUserAgent foUserAgent) {
+        super.setUserAgent(foUserAgent);
+        if (dialogDisplay) {
+            setStatusListener(PreviewDialog.createPreviewDialog(userAgent, this.renderable,
+                    this.previewAsMainWindow));
         }
     }
 
+    /**
+     * A Renderable instance can be set so the Preview Dialog can enable the "Reload" button
+     * which causes the current document to be reprocessed and redisplayed.
+     * @param renderable the Renderable instance.
+     */
+    public void setRenderable(Renderable renderable) {
+        this.renderable = renderable;
+    }
+
+    /**
+     * Sets whether the preview dialog should be created and displayed when
+     * the rendering is finished.
+     * @param show If false, preview dialog is not shown. True by default
+     */
+    public void setPreviewDialogDisplayed(boolean show) {
+        dialogDisplay = show;
+    }
+
     /**
      * {@inheritDoc}
      */
index d65a550d43f613a928153fa96eb8ce64fa605626..983b42e0c8e4496fdcc6f2f6e96e691efdfc63e3 100644 (file)
@@ -34,7 +34,7 @@ public class AWTRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent ua) {
-        return new AWTRenderer(ua);
+        return new AWTRenderer();
     }
 
     /** {@inheritDoc} */
index c850c35e7eef5d0870e2639e6b88ff6ff6be3d83..2303c0e8ee5dcb4b5f4949a6fbc72b687e0504f1 100644 (file)
@@ -67,9 +67,12 @@ import org.apache.fop.render.awt.AWTRenderer;
  * </p>
  * <pre>
  * FopFactory fopFactory = FopFactory.newInstance();
+ * AWTRenderer renderer = new AWTRenderer();
  * FOUserAgent agent = fopFactory.newFOUserAgent();
- * AWTRenderer renderer = new AWTRenderer(agent);
  * agent.setRendererOverride(renderer);
+ * renderer.setPreviewDialogDisplayed(false);
+ * renderer.setUserAgent(agent);
+ * renderer.setUserAgent(agent);
  * previewPanel = new PreviewPanel(agent, null, renderer);
  * previewPanel = new PreviewPanel(ua);
  * myGui.add(previewPanel);
index 1c6f2e33df6ad0c3e81bd6cca4454142817daef0..3733bf2f27462e7f168606053cdd1a765dc8887e 100644 (file)
@@ -29,7 +29,6 @@ import org.apache.xmlgraphics.image.writer.ImageWriter;
 import org.apache.xmlgraphics.image.writer.ImageWriterParams;
 import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
 
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.render.java2d.Java2DRenderer;
@@ -41,10 +40,6 @@ import org.apache.fop.render.java2d.Java2DRenderer;
  */
 public class PNGRenderer extends Java2DRenderer {
 
-    public PNGRenderer(FOUserAgent userAgent) {
-        super(userAgent);
-    }
-
     /** The MIME type for png-Rendering */
     public static final String MIME_TYPE = MimeConstants.MIME_PNG;
 
index da19b29869f249a7da59395a37757f4f933994a9..7d321791af5567fc39da7a72edc990e35efd4ed3 100644 (file)
@@ -36,7 +36,7 @@ public class PNGRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent ua) {
-        return new PNGRenderer(ua);
+        return new PNGRenderer();
     }
 
     /** {@inheritDoc} */
index 0e2364d35d36d46306ca68136a8550aa02a18ab7..5a9cfa21b2cf126cf5c10ed8dd09ed13108f61e2 100644 (file)
@@ -83,11 +83,19 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
     }
 
     /** Creates TIFF renderer. */
-    public TIFFRenderer(FOUserAgent userAgent) {
-        super(userAgent);
+    public TIFFRenderer() {
         writerParams = new ImageWriterParams();
         writerParams.setCompressionMethod(COMPRESSION_PACKBITS);
+    }
+
+    /**
+     * {@inheritDoc}
+     *          org.apache.fop.apps.FOUserAgent)
+     */
+    public void setUserAgent(FOUserAgent foUserAgent) {
+        super.setUserAgent(foUserAgent);
 
+        //Set target resolution
         int dpi = Math.round(userAgent.getTargetResolution());
         writerParams.setResolution(dpi);
     }
index 852e6ba04565f7685a449986d896d5be546781bf..e3c567995228af973166441a2eaa9066d2cbd322 100644 (file)
@@ -34,7 +34,7 @@ public class TIFFRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new TIFFRenderer(userAgent);
+        return new TIFFRenderer();
     }
 
     /** {@inheritDoc} */
index d5d5a154a99547cac2b0643f1344b54699912ea7..24a2e8a75809b11ec0888e0bd1579911160aa695 100644 (file)
@@ -51,7 +51,6 @@ import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
 
 import org.apache.fop.Version;
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.AreaTreeObject;
@@ -71,10 +70,10 @@ import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.InlineParent;
-import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.datatypes.URISpecification;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
@@ -159,8 +158,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
     /**
      * Main constructor
      */
-    public IFRenderer(FOUserAgent userAgent) {
-        super(userAgent);
+    public IFRenderer() {
     }
 
     /** {@inheritDoc} */
index 3c7006588cadf822104805e77b23acdf22999a98..766aa081f8d273eafe0fd5012482549b901d5214 100644 (file)
@@ -147,13 +147,15 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
     private GeneralPath currentPath = null;
 
     /** Default constructor */
-    public Java2DRenderer(FOUserAgent userAgent) {
-        super(userAgent);
+    public Java2DRenderer() {
+    }
 
-        // MH: necessary? the caller has access to FOUserAgent
+    /** {@inheritDoc} */
+    public void setUserAgent(FOUserAgent foUserAgent) {
+        super.setUserAgent(foUserAgent);
         userAgent.setRendererOverride(this); // for document regeneration
 
-        String s = (String) userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND);
+        String s = (String)userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND);
         if (s != null) {
             this.transparentPageBackground = "true".equalsIgnoreCase(s);
         }
index 08d5b0f041805bef23110a9b3d2f7deb93bfc43d..89ab980710969da3f47cdb61c9cc38cc14cfa445 100644 (file)
@@ -73,11 +73,7 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
     /**
      * Creates a new PageableRenderer.
      */
-    public PageableRenderer(FOUserAgent userAgent) {
-        super(userAgent);
-        Map rendererOptions = getUserAgent().getRendererOptions();
-        processOptions(rendererOptions);
-        this.pageFilter = new DefaultPageFilter();
+    public PageableRenderer() {
     }
 
     /** {@inheritDoc} */
@@ -85,6 +81,15 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
         return MimeConstants.MIME_FOP_PRINT;
     }
 
+    /** {@inheritDoc} */
+    public void setUserAgent(FOUserAgent agent) {
+        super.setUserAgent(agent);
+
+        Map rendererOptions = agent.getRendererOptions();
+        processOptions(rendererOptions);
+        this.pageFilter = new DefaultPageFilter();
+    }
+
     private void processOptions(Map rendererOptions) {
         Object o = rendererOptions.get(PageableRenderer.PAGES_MODE);
         if (o != null) {
index ea68bc9b2aa939cbbdece771439911418443e7e4..2eb2b07a2565d9d639d0514ac65134ca8655868a 100644 (file)
@@ -55,9 +55,19 @@ public class PrintRenderer extends PageableRenderer {
      * Creates a new PrintRenderer with the options set through the renderer options if a custom
      * PrinterJob is not given in FOUserAgent's renderer options.
      */
-    public PrintRenderer(FOUserAgent userAgent) {
-        super(userAgent);
-        setRendererOptions();
+    public PrintRenderer() {
+    }
+
+    /**
+     * Creates a new PrintRenderer and allows you to pass in a specific PrinterJob instance
+     * that this renderer should work with.
+     * @param printerJob the PrinterJob instance
+     * @deprecated Please use the rendering options on the user agent to pass in the PrinterJob!
+     */
+    public PrintRenderer(PrinterJob printerJob) {
+        this();
+        this.printerJob = printerJob;
+        printerJob.setPageable(this);
     }
 
     private void initializePrinterJob() {
@@ -75,8 +85,11 @@ public class PrintRenderer extends PageableRenderer {
         }
     }
 
-    private void setRendererOptions() {
-        Map rendererOptions = getUserAgent().getRendererOptions();
+    /** {@inheritDoc} */
+    public void setUserAgent(FOUserAgent agent) {
+        super.setUserAgent(agent);
+
+        Map rendererOptions = agent.getRendererOptions();
 
         Object printerJobO = rendererOptions.get(PrintRenderer.PRINTER_JOB);
         if (printerJobO != null) {
index 63444a628447c608984f599e9a79ffcfdc221b63..21eb4717a5548f73df933552cecc972f58953c01 100644 (file)
@@ -35,7 +35,7 @@ public class PrintRendererMaker extends AbstractRendererMaker {
 
     /**{@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new PrintRenderer(userAgent);
+        return new PrintRenderer();
     }
 
     /** {@inheritDoc} */
index 74c5b84a8b4547f00009c065a3a265aa19e70ce1..386f95838c56c8cd40edffc69d9274a11aa4f277 100644 (file)
@@ -32,7 +32,6 @@ import java.util.Map;
 import org.apache.xmlgraphics.util.UnitConv;
 
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.CTM;
 import org.apache.fop.area.PageViewport;
@@ -111,8 +110,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
     /**
      * Constructs a newly allocated <code>TXTRenderer</code> object.
      */
-    public TXTRenderer(FOUserAgent userAgent) {
-        super(userAgent);
+    public TXTRenderer() {
     }
 
     /** {@inheritDoc} */
index 740866e0cbb889939fc35bc0e3051d5871121162..0db369ef2102c703c070a2de646b0c78077a60d8 100644 (file)
@@ -34,7 +34,7 @@ public class TXTRendererMaker extends AbstractRendererMaker {
 
     /**{@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new TXTRenderer(userAgent);
+        return new TXTRenderer();
     }
 
     /**{@inheritDoc} */
index 9c938199f9819602aa439d8336269953af969e1f..497e3c04786330d5cfbc4d35e6e16333a68b0b86 100644 (file)
@@ -29,15 +29,6 @@ import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
-
-import org.apache.xmlgraphics.util.QName;
-
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.BookmarkData;
 import org.apache.fop.area.OffDocumentExtensionAttachment;
 import org.apache.fop.area.OffDocumentItem;
@@ -45,14 +36,16 @@ import org.apache.fop.area.PageViewport;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.render.PrintRenderer;
 import org.apache.fop.render.RendererContext;
+import org.apache.xmlgraphics.util.QName;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
 
 /** Abstract xml renderer base class. */
 public abstract class AbstractXMLRenderer extends PrintRenderer {
 
-    public AbstractXMLRenderer(FOUserAgent userAgent) {
-        super(userAgent);
-    }
-
     /** Main namespace in use. */
     public static final String NS = "";
 
index 3ae49b1214cdf2d9261e72c0bc71292da52e92ed..21d28042dfce20708331bdbc4876b25a9ff7d2ca 100644 (file)
@@ -37,6 +37,7 @@ import javax.xml.transform.stream.StreamResult;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
+
 import org.xml.sax.SAXException;
 
 import org.apache.xmlgraphics.util.QName;
@@ -74,11 +75,11 @@ import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.InlineBlockParent;
 import org.apache.fop.area.inline.InlineParent;
-import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.Space;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
@@ -112,9 +113,20 @@ public class XMLRenderer extends AbstractXMLRenderer {
 
     private int pageSequenceIndex;
 
-    public XMLRenderer(FOUserAgent userAgent) {
-        super(userAgent);
+    /**
+     * Creates a new XML renderer.
+     */
+    public XMLRenderer() {
         context = new RendererContext(this, XML_MIME_TYPE);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setUserAgent(FOUserAgent agent) {
+        super.setUserAgent(agent);
+
         XMLHandler xmlHandler = new XMLXMLHandler();
         userAgent.getXMLHandlerRegistry().addXMLHandler(xmlHandler);
         Boolean b = (Boolean)userAgent.getRendererOptions().get("compact-format");
index f54c74b3243bdfa5f51d9b88d95cdae22209f47e..8526daa2ab742c42c80856cf88783e71f0c16aca 100644 (file)
@@ -35,7 +35,7 @@ public class XMLRendererMaker extends AbstractRendererMaker {
 
     /**{@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new XMLRenderer(userAgent);
+        return new XMLRenderer();
     }
 
     /**{@inheritDoc} */
index 246062a3285ccbab7f2f65fc2d4bfd06256b8745..63f486c07df2ceddf8db05aa1d62fee6e8239692 100644 (file)
@@ -26,22 +26,19 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
 
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-
 import org.apache.batik.dom.GenericDOMImplementation;
 import org.apache.batik.svggen.SVGGeneratorContext;
 import org.apache.batik.svggen.SVGGraphics2D;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.render.bitmap.MultiFileRenderingUtil;
 import org.apache.fop.render.java2d.Java2DGraphicsState;
 import org.apache.fop.render.java2d.Java2DRenderer;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
 
 /**
  * <p>
@@ -70,8 +67,8 @@ public class SVGRenderer extends Java2DRenderer {
     /** Helper class for generating multiple files */
     private MultiFileRenderingUtil multiFileUtil;
 
-    public SVGRenderer(FOUserAgent userAgent) {
-        super(userAgent);
+    /** Default constructor. */
+    public SVGRenderer() {
     }
 
     /** {@inheritDoc} */
index 892d017118190e9e9b645587d2b27d7cd3422833..f0da974e6634ab45d7f11a2f14e9c809df8b03d3 100644 (file)
@@ -34,7 +34,7 @@ public class SVGRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent ua) {
-        return new SVGRenderer(ua);
+        return new SVGRenderer();
     }
 
     /** {@inheritDoc} */
index 490486158bb8413bd2d7f31f2d1a2d471b5f1b6b..97d1c9c25afa521ed298c1c8b09ec101eca94b49 100644 (file)
@@ -39,21 +39,19 @@ import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.w3c.dom.Document;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.xpath.XPathAPI;
-import org.apache.xpath.objects.XObject;
-
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.xml.XMLRenderer;
+import org.apache.xpath.XPathAPI;
+import org.apache.xpath.objects.XObject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
 
 /**
  * Tests URI resolution facilities.
@@ -162,7 +160,8 @@ public class URIResolutionTestCase extends AbstractFOPTest {
         TransformerHandler athandler = tfactory.newTransformerHandler();
         athandler.setResult(domres);
 
-        XMLRenderer atrenderer = new XMLRenderer(ua);
+        XMLRenderer atrenderer = new XMLRenderer();
+        atrenderer.setUserAgent(ua);
         atrenderer.setContentHandler(athandler);
         ua.setRendererOverride(atrenderer);
 
index 1f8abb9befa2d5200729f50f749e61e168f51ad5..a0de2e8abeb5681fd28fe6a4913ce71955cd9d34 100644 (file)
@@ -97,9 +97,10 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTest {
         Renderer targetRenderer = userAgent.getRendererFactory().createRenderer(
                 userAgent, getTargetMIME());
 
-        XMLRenderer renderer = new XMLRenderer(userAgent);
+        XMLRenderer renderer = new XMLRenderer();
         renderer.mimicRenderer(targetRenderer);
         renderer.setContentHandler(handler);
+        renderer.setUserAgent(userAgent);
 
         userAgent.setRendererOverride(renderer);
 
@@ -130,10 +131,12 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTest {
         TransformerHandler handler = testAssistant.getTransformerFactory().newTransformerHandler();
         DOMResult domResult = new DOMResult();
         handler.setResult(domResult);
+        XMLRenderer renderer = new XMLRenderer();
+        renderer.setContentHandler(handler);
+
         FOUserAgent userAgent = createUserAgent();
-        XMLRenderer renderer = new XMLRenderer(userAgent);
         userAgent.setRendererOverride(renderer);
-        renderer.setContentHandler(handler);
+        renderer.setUserAgent(userAgent);
 
         FontInfo fontInfo = new FontInfo();
         AreaTreeModel treeModel = new RenderPagesModel(userAgent,
index 6a0d424e9a7b5d9e4f34f8c5818d4ca339f18ebf..46908a4480bbe6b447b1b95d4d64eed3d743ce72 100644 (file)
@@ -150,7 +150,8 @@ public class LayoutEngineTestCase {
             ua.getEventBroadcaster().addEventListener(
                     new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN));
 
-            XMLRenderer atrenderer = new XMLRenderer(ua);
+            XMLRenderer atrenderer = new XMLRenderer();
+            atrenderer.setUserAgent(ua);
             atrenderer.setContentHandler(athandler);
             ua.setRendererOverride(atrenderer);
             fop = effFactory.newFop(ua);
@@ -207,7 +208,8 @@ public class LayoutEngineTestCase {
             ua.getEventBroadcaster().addEventListener(
                     new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN));
 
-            IFRenderer ifRenderer = new IFRenderer(ua);
+            IFRenderer ifRenderer = new IFRenderer();
+            ifRenderer.setUserAgent(ua);
 
             IFSerializer serializer = new IFSerializer();
             serializer.setContext(new IFContext(ua));