diff options
author | Jeremias Maerki <jeremias@apache.org> | 2009-02-23 13:25:08 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2009-02-23 13:25:08 +0000 |
commit | 96d9ae1c7cf3b0831dda48869f1414328ed6d875 (patch) | |
tree | 565afa6e81cec129286e1866acc2c268f7e52ac7 /src/java | |
parent | 9120a58556709f8822c5b3192b0d82d10e88919a (diff) | |
download | xmlgraphics-fop-96d9ae1c7cf3b0831dda48869f1414328ed6d875.tar.gz xmlgraphics-fop-96d9ae1c7cf3b0831dda48869f1414328ed6d875.zip |
";mode=painter" MIME suffix removed from all new IFDocumentHandler implementations.
Changed RendererFactory to prefer IFDocumentHandler over Renderer if available.
A setting on RendererFactory allows to to prefer Renderer over IFDocumentHandler if necessary for compatibility. (not yet tied into CLI or configuration)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@747010 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
6 files changed, 74 insertions, 27 deletions
diff --git a/src/java/org/apache/fop/render/RendererFactory.java b/src/java/org/apache/fop/render/RendererFactory.java index b12664818..3832a0714 100644 --- a/src/java/org/apache/fop/render/RendererFactory.java +++ b/src/java/org/apache/fop/render/RendererFactory.java @@ -51,6 +51,8 @@ public class RendererFactory { private Map eventHandlerMakerMapping = new java.util.HashMap(); private Map documentHandlerMakerMapping = new java.util.HashMap(); + private boolean rendererPreferred = false; + /** * Main constructor. */ @@ -61,6 +63,26 @@ public class RendererFactory { } /** + * Controls whether a {@link Renderer} is preferred over a {@link IFDocumentHandler} if + * both are available for the same MIME type. + * @param value true to prefer the {@link Renderer}, + * false to prefer the {@link IFDocumentHandler}. + */ + public void setRendererPreferred(boolean value) { + this.rendererPreferred = value; + } + + /** + * Indicates whether a {@link Renderer} is preferred over a {@link IFDocumentHandler} if + * both are available for the same MIME type. + * @return true if the {@link Renderer} is preferred, + * false if the {@link IFDocumentHandler} is preferred. + */ + public boolean isRendererPreferred() { + return this.rendererPreferred; + } + + /** * Add a new RendererMaker. If another maker has already been registered for a * particular MIME type, this call overwrites the existing one. * @param maker the RendererMaker @@ -236,27 +258,54 @@ public class RendererFactory { } else if (userAgent.getRendererOverride() != null) { return userAgent.getRendererOverride(); } else { - 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); + Renderer renderer; + if (isRendererPreferred()) { + //Try renderer first + renderer = tryRendererMaker(userAgent, outputFormat); + if (renderer == null) { + renderer = tryIFDocumentHandlerMaker(userAgent, outputFormat); } - return rend; } else { - AbstractIFDocumentHandlerMaker documentHandlerMaker - = getDocumentHandlerMaker(outputFormat); - if (documentHandlerMaker != null) { - IFDocumentHandler documentHandler = createDocumentHandler( - userAgent, outputFormat); - return createRendererForDocumentHandler(documentHandler); - } else { - throw new UnsupportedOperationException( - "No renderer for the requested format available: " + outputFormat); + //Try document handler first + renderer = tryIFDocumentHandlerMaker(userAgent, outputFormat); + if (renderer == null) { + renderer = tryRendererMaker(userAgent, outputFormat); } } + if (renderer == null) { + throw new UnsupportedOperationException( + "No renderer for the requested format available: " + outputFormat); + } + return renderer; + } + } + + private Renderer tryIFDocumentHandlerMaker(FOUserAgent userAgent, String outputFormat) + throws FOPException { + AbstractIFDocumentHandlerMaker documentHandlerMaker + = getDocumentHandlerMaker(outputFormat); + if (documentHandlerMaker != null) { + IFDocumentHandler documentHandler = createDocumentHandler( + userAgent, outputFormat); + return createRendererForDocumentHandler(documentHandler); + } else { + return null; + } + } + + private Renderer tryRendererMaker(FOUserAgent userAgent, String outputFormat) + throws FOPException { + 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); + } + return rend; + } else { + return null; } } @@ -327,6 +376,9 @@ public class RendererFactory { */ public IFDocumentHandler createDocumentHandler(FOUserAgent userAgent, String outputFormat) throws FOPException { + if (userAgent.getDocumentHandlerOverride() != null) { + return userAgent.getDocumentHandlerOverride(); + } AbstractIFDocumentHandlerMaker maker = getDocumentHandlerMaker(outputFormat); if (maker == null) { throw new UnsupportedOperationException( diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java index e0b13d979..440db3eda 100644 --- a/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java +++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java @@ -30,9 +30,8 @@ import org.apache.fop.render.intermediate.IFDocumentHandler; */ public class AFPDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker { - //TODO Revert to normal MIME after stabilization! private static final String[] MIMES = new String[] - {MimeConstants.MIME_AFP + ";mode=painter"}; + {MimeConstants.MIME_AFP}; /** {@inheritDoc} */ public IFDocumentHandler makeIFDocumentHandler(FOUserAgent ua) { diff --git a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandlerMaker.java b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandlerMaker.java index 4a6c9cbb7..b14ba3c18 100644 --- a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandlerMaker.java +++ b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandlerMaker.java @@ -30,8 +30,7 @@ import org.apache.fop.render.intermediate.IFDocumentHandler; */ public class TIFFDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker { - //TODO Revert to normal MIME after stabilization! - private static final String[] MIMES = new String[] {MimeConstants.MIME_TIFF + ";mode=painter"}; + private static final String[] MIMES = new String[] {MimeConstants.MIME_TIFF}; /** {@inheritDoc} */ public IFDocumentHandler makeIFDocumentHandler(FOUserAgent ua) { diff --git a/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java b/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java index db47c9712..797daa3a1 100644 --- a/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java +++ b/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java @@ -30,8 +30,7 @@ import org.apache.fop.render.intermediate.IFDocumentHandler; */ public class PCLDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker { - //TODO Revert to normal MIME after stabilization! - private static final String[] MIMES = new String[] {MimeConstants.MIME_PCL + ";mode=painter"}; + private static final String[] MIMES = new String[] {MimeConstants.MIME_PCL}; /** {@inheritDoc} */ public IFDocumentHandler makeIFDocumentHandler(FOUserAgent ua) { diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentHandlerMaker.java b/src/java/org/apache/fop/render/pdf/PDFDocumentHandlerMaker.java index 532b50f80..f4ba03d5b 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentHandlerMaker.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentHandlerMaker.java @@ -30,8 +30,7 @@ import org.apache.fop.render.intermediate.IFDocumentHandler; */ public class PDFDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker { - //TODO Revert to normal MIME after stabilization! - private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF + ";mode=painter"}; + private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF}; /** {@inheritDoc} */ public IFDocumentHandler makeIFDocumentHandler(FOUserAgent ua) { diff --git a/src/java/org/apache/fop/render/ps/PSDocumentHandlerMaker.java b/src/java/org/apache/fop/render/ps/PSDocumentHandlerMaker.java index eb085c0a4..c581f9e02 100644 --- a/src/java/org/apache/fop/render/ps/PSDocumentHandlerMaker.java +++ b/src/java/org/apache/fop/render/ps/PSDocumentHandlerMaker.java @@ -30,9 +30,8 @@ import org.apache.fop.render.intermediate.IFDocumentHandler; */ public class PSDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker { - //TODO Revert to normal MIME after stabilization! private static final String[] MIMES = new String[] - {MimeConstants.MIME_POSTSCRIPT + ";mode=painter"}; + {MimeConstants.MIME_POSTSCRIPT}; /** {@inheritDoc} */ public IFDocumentHandler makeIFDocumentHandler(FOUserAgent ua) { |