diff options
author | Jeremias Maerki <jeremias@apache.org> | 2009-01-11 11:27:03 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2009-01-11 11:27:03 +0000 |
commit | 04bb06d6912f18601d1623935ac0d202da372e67 (patch) | |
tree | 1fbba230b16501945e223b4c0bfe5b8019ce669b /src | |
parent | e381d274f38598752ecc04a82085eea2962d5d4d (diff) | |
download | xmlgraphics-fop-04bb06d6912f18601d1623935ac0d202da372e67.tar.gz xmlgraphics-fop-04bb06d6912f18601d1623935ac0d202da372e67.zip |
Added general support for the fox:conversion-mode inside the new IF.
Cleaned up usage of fox:conversion-mode foreign attribute.
Plus additional cleanup.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@733455 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
15 files changed, 116 insertions, 67 deletions
diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index 731f0bae2..392eb875e 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -33,11 +33,9 @@ import org.apache.batik.dom.svg.SVGDOMImplementation; import org.apache.batik.gvt.GraphicsNode; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; -import org.apache.xmlgraphics.util.QName; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.events.EventBroadcaster; -import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl; import org.apache.fop.render.RendererContext.RendererContextWrapper; @@ -52,13 +50,6 @@ import org.apache.fop.svg.SVGUserAgent; */ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererContextConstants { - /** Qualified name for the "conversion-mode" extension attribute. */ - protected static final QName CONVERSION_MODE = new QName( - ExtensionElementMapping.URI, null, "conversion-mode"); - - /** "bitmap" value for the "conversion-mode" extension attribute. */ - protected static final String BITMAP = "bitmap"; - /** {@inheritDoc} */ public void handleXML(RendererContext context, Document doc, String ns) throws Exception { @@ -82,9 +73,9 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC } /** - * Builds the GVT root + * Builds the GVT root. * - * @param rendererContext the renderer context + * @param userAgent the user agent * @param ctx the batik bridge context * @param doc the document * @return a built GVT root tree diff --git a/src/java/org/apache/fop/render/ImageHandlerUtil.java b/src/java/org/apache/fop/render/ImageHandlerUtil.java new file mode 100644 index 000000000..41e0e1d45 --- /dev/null +++ b/src/java/org/apache/fop/render/ImageHandlerUtil.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.render; + +import java.util.Map; + +import org.apache.xmlgraphics.util.QName; + +import org.apache.fop.fo.extensions.ExtensionElementMapping; + +/** + * Utility methods for image handling. + */ +public class ImageHandlerUtil { + + /** conversion-mode extension attribute */ + public static final QName CONVERSION_MODE = new QName( + ExtensionElementMapping.URI, null, "conversion-mode"); + + /** Conversion mode: indicates that the image shall be converted to a bitmap. */ + public static final String CONVERSION_MODE_BITMAP = "bitmap"; + + /** + * Indicates whether the image conversion mode is set to bitmap mode, i.e. the image shall + * be converted to a bitmap. + * @param mode the conversion mode + * @return true if conversion mode is "bitmap" + */ + public static boolean isConversionModeBitmap(String mode) { + return CONVERSION_MODE_BITMAP.equalsIgnoreCase(mode); + } + + /** + * Indicates whether the image conversion mode is set to bitmap mode, i.e. the image shall + * be converted to a bitmap. + * @param foreignAttributes a map of foreign attributes (Map<QName, Object>) + * @return true if conversion mode is "bitmap" + */ + public static boolean isConversionModeBitmap(Map foreignAttributes) { + if (foreignAttributes == null) { + return false; + } + String conversionMode = (String)foreignAttributes.get(CONVERSION_MODE); + return isConversionModeBitmap(conversionMode); + } + +} diff --git a/src/java/org/apache/fop/render/RendererContext.java b/src/java/org/apache/fop/render/RendererContext.java index ac885a44b..8d62be570 100644 --- a/src/java/org/apache/fop/render/RendererContext.java +++ b/src/java/org/apache/fop/render/RendererContext.java @@ -24,8 +24,6 @@ import java.util.Iterator; import java.util.Map; import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.extensions.ExtensionElementMapping; -import org.apache.xmlgraphics.util.QName; /** * The Render Context for external handlers. This provides a rendering context @@ -33,12 +31,6 @@ import org.apache.xmlgraphics.util.QName; * render target. */ public class RendererContext { - /** conversion-mode extension attribute */ - protected static final QName CONVERSION_MODE = new QName( - ExtensionElementMapping.URI, null, "conversion-mode"); - - /** "bitmap" value for the "conversion-mode" extension attribute. */ - protected static final String BITMAP = "bitmap"; private final String mime; private final AbstractRenderer renderer; diff --git a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java index 3fe7395f3..82ea18d00 100644 --- a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java +++ b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java @@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageException; +import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; @@ -47,6 +48,7 @@ import org.apache.fop.apps.FopFactory; import org.apache.fop.events.ResourceEventProducer; import org.apache.fop.render.ImageHandler; import org.apache.fop.render.ImageHandlerRegistry; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RenderingContext; import org.apache.fop.traits.BorderProps; import org.apache.fop.traits.RuleStyle; @@ -136,8 +138,10 @@ public abstract class AbstractIFPainter implements IFPainter { RenderingContext context = createRenderingContext(); Map hints = createDefaultImageProcessingHints(sessionContext); context.putHints(hints); + + ImageFlavor[] flavors = imageHandlerRegistry.getSupportedFlavors(context); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( - info, imageHandlerRegistry.getSupportedFlavors(context), + info, flavors, hints, sessionContext); try { @@ -155,7 +159,15 @@ public abstract class AbstractIFPainter implements IFPainter { * @return the default processing hints */ protected Map createDefaultImageProcessingHints(ImageSessionContext sessionContext) { - return ImageUtil.getDefaultHints(sessionContext); + Map hints = ImageUtil.getDefaultHints(sessionContext); + + //Transfer common foreign attributes to hints + Object conversionMode = getContext().getForeignAttribute(ImageHandlerUtil.CONVERSION_MODE); + if (conversionMode != null) { + hints.put(ImageHandlerUtil.CONVERSION_MODE, conversionMode); + } + + return hints; } /** @@ -212,7 +224,6 @@ public abstract class AbstractIFPainter implements IFPainter { log.trace("Using ImageHandler: " + handler.getClass().getName()); } - //TODO foreign attributes handler.handleImage(context, effImage, rect); } diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java index 99502096c..de987af25 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java +++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java @@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.render.AbstractGenericSVGHandler; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; @@ -71,10 +72,7 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler pdfi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue(); pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); - if (foreign != null - && BITMAP.equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))) { - pdfi.paintAsBitmap = true; - } + pdfi.paintAsBitmap = ImageHandlerUtil.isConversionModeBitmap(foreign); return pdfi; } diff --git a/src/java/org/apache/fop/render/pcl/PCLConstants.java b/src/java/org/apache/fop/render/pcl/PCLConstants.java index 167800cc9..28532053b 100644 --- a/src/java/org/apache/fop/render/pcl/PCLConstants.java +++ b/src/java/org/apache/fop/render/pcl/PCLConstants.java @@ -26,12 +26,15 @@ import org.apache.fop.fo.extensions.ExtensionElementMapping; /** * Constants used for PCL output. */ -public interface PCLConstants { - - /** Image conversion mode */ - QName CONV_MODE = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); +interface PCLConstants { /** Source transparency mode */ QName SRC_TRANSPARENCY = new QName(ExtensionElementMapping.URI, null, "source-transparency"); + /** Disable clipping */ + Object DISABLE_CLIPPING = new QName(ExtensionElementMapping.URI, null, "disable-clipping"); + + /** Enables/Disables a color canvas for bitmap production (required for SVG, for example) */ + Object COLOR_CANVAS = new QName(ExtensionElementMapping.URI, null, "color-canvas"); + } diff --git a/src/java/org/apache/fop/render/pcl/PCLImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/pcl/PCLImageHandlerGraphics2D.java index c24dfd7dc..f7bb33f68 100644 --- a/src/java/org/apache/fop/render/pcl/PCLImageHandlerGraphics2D.java +++ b/src/java/org/apache/fop/render/pcl/PCLImageHandlerGraphics2D.java @@ -41,6 +41,7 @@ import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.render.ImageHandler; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RenderingContext; /** @@ -146,8 +147,9 @@ public class PCLImageHandlerGraphics2D implements ImageHandler { boolean supported = (image == null || image instanceof ImageGraphics2D) && targetContext instanceof PCLRenderingContext; if (supported) { - Object hint = targetContext.getHint(PCLConstants.CONV_MODE); - if ("bitmap".equals(hint)) { + String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE); + if (ImageHandlerUtil.isConversionModeBitmap(mode)) { + //Disabling this image handler automatically causes a bitmap to be generated return false; } } diff --git a/src/java/org/apache/fop/render/pcl/PCLPainter.java b/src/java/org/apache/fop/render/pcl/PCLPainter.java index 28e8224a8..03e40d549 100644 --- a/src/java/org/apache/fop/render/pcl/PCLPainter.java +++ b/src/java/org/apache/fop/render/pcl/PCLPainter.java @@ -47,6 +47,7 @@ import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontTriplet; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RenderingContext; import org.apache.fop.render.intermediate.AbstractIFPainter; import org.apache.fop.render.intermediate.IFContext; @@ -296,7 +297,7 @@ public class PCLPainter extends AbstractIFPainter implements PCLConstants { hints.put(ImageProcessingHints.BITMAP_TYPE_INTENT, ImageProcessingHints.BITMAP_TYPE_INTENT_GRAY); } - hints.put(PCLConstants.CONV_MODE, "bitmap"); + hints.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP); PCLRenderingContext context = (PCLRenderingContext)createRenderingContext(); context.setSourceTransparencyEnabled(true); try { diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java index eaccc523f..0c1373fb8 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java @@ -85,6 +85,7 @@ import org.apache.fop.fonts.FontCollection; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.render.Graphics2DAdapter; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.PrintRenderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; @@ -513,7 +514,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants { RendererContext rc = createRendererContext(paintRect.x, paintRect.y, paintRect.width, paintRect.height, null); Map atts = new java.util.HashMap(); - atts.put(CONV_MODE, "bitmap"); + atts.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP); atts.put(SRC_TRANSPARENCY, "true"); rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts); @@ -1264,7 +1265,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants { RendererContext rc = createRendererContext(paintRect.x, paintRect.y, paintRect.width, paintRect.height, null); Map atts = new java.util.HashMap(); - atts.put(CONV_MODE, "bitmap"); + atts.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP); atts.put(SRC_TRANSPARENCY, "true"); rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts); diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java index aa6271fe5..6c2c592b1 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java +++ b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java @@ -22,6 +22,7 @@ package org.apache.fop.render.pcl; import org.apache.xmlgraphics.util.QName; import org.apache.fop.fo.extensions.ExtensionElementMapping; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RendererContext; /** @@ -51,16 +52,14 @@ public class PCLRendererContext extends RendererContext.RendererContextWrapper { /** @return true if the SVG image should be rendered as a bitmap */ public boolean paintAsBitmap() { - QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); - return getForeignAttributes() != null - && "bitmap".equalsIgnoreCase((String)getForeignAttributes().get(qName)); + return ImageHandlerUtil.isConversionModeBitmap(getForeignAttributes()); } /** @return true if clipping is disabled inside the PCLGraphics2D. */ public boolean isClippingDisabled() { - QName qName = new QName(ExtensionElementMapping.URI, null, "disable-clipping"); return getForeignAttributes() != null - && "true".equalsIgnoreCase((String)getForeignAttributes().get(qName)); + && "true".equalsIgnoreCase((String)getForeignAttributes().get( + PCLConstants.DISABLE_CLIPPING)); } /** @@ -68,9 +67,9 @@ public class PCLRendererContext extends RendererContext.RendererContextWrapper { * @return true if the background shouldn't be erased */ public boolean isSourceTransparency() { - QName qName = new QName(ExtensionElementMapping.URI, null, "source-transparency"); return getForeignAttributes() != null - && "true".equalsIgnoreCase((String)getForeignAttributes().get(qName)); + && "true".equalsIgnoreCase((String)getForeignAttributes().get( + PCLConstants.SRC_TRANSPARENCY)); } /** @@ -80,11 +79,11 @@ public class PCLRendererContext extends RendererContext.RendererContextWrapper { * @return true if an EGB canvas should be used */ public boolean isColorCanvas() { - QName qName = new QName(ExtensionElementMapping.URI, null, "color-canvas"); Boolean prop = (Boolean)context.getProperty(PCLRendererContextConstants.PCL_COLOR_CANVAS); return Boolean.TRUE.equals(prop) || (getForeignAttributes() != null - && "true".equalsIgnoreCase((String)getForeignAttributes().get(qName))); + && "true".equalsIgnoreCase((String)getForeignAttributes().get( + PCLConstants.COLOR_CANVAS))); } }
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java index 8f7aad300..f9fa8bfeb 100644 --- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java @@ -43,6 +43,7 @@ import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFPage; import org.apache.fop.pdf.PDFResourceContext; import org.apache.fop.render.AbstractGenericSVGHandler; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; @@ -87,11 +88,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); - - if (foreign != null - && BITMAP.equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))) { - pdfi.paintAsBitmap = true; - } + pdfi.paintAsBitmap = ImageHandlerUtil.isConversionModeBitmap(foreign); return pdfi; } diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java index 542a69a4a..3858cc716 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java @@ -29,11 +29,9 @@ import java.util.Map; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; import org.apache.xmlgraphics.ps.PSGenerator; -import org.apache.xmlgraphics.util.QName; -import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.render.AbstractGraphics2DAdapter; -import org.apache.fop.render.Graphics2DAdapter; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; import org.apache.fop.render.RendererContext.RendererContextWrapper; @@ -44,10 +42,6 @@ import org.apache.fop.render.pdf.PDFRenderer; */ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { - /** Qualified name for the "conversion-mode" extension attribute. */ - protected static final QName CONVERSION_MODE = new QName( - ExtensionElementMapping.URI, null, "conversion-mode"); - private PSGenerator gen; private boolean clip = true; @@ -87,7 +81,7 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { if (context != null) { Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); paintAsBitmap = (foreign != null - && "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))); + && ImageHandlerUtil.isConversionModeBitmap(foreign)); } float sx = paintAsBitmap ? 1.0f : (fwidth / (float)imw); diff --git a/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java b/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java index 2138e3cf3..f6679e8da 100644 --- a/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java +++ b/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java @@ -65,7 +65,6 @@ public class PSImageHandlerSVG implements ImageHandler { PSGraphics2D graphics = new PSGraphics2D(strokeText, gen); graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - GVTBuilder builder = new GVTBuilder(); NativeTextHandler nativeTextHandler = null; BridgeContext ctx = new BridgeContext(ua); if (!strokeText) { @@ -79,6 +78,7 @@ public class PSImageHandlerSVG implements ImageHandler { GraphicsNode root; try { + GVTBuilder builder = new GVTBuilder(); root = builder.build(ctx, imageSVG.getDocument()); } catch (Exception e) { SVGEventProducer eventProducer = SVGEventProducer.Provider.get( @@ -94,7 +94,6 @@ public class PSImageHandlerSVG implements ImageHandler { float sy = pos.height / h; ctx = null; - builder = null; gen.commentln("%FOPBeginSVG"); gen.saveGraphicsState(); diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index 7171efb4e..75182682d 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -39,6 +39,7 @@ import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.fop.fonts.FontInfo; import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.render.AbstractGenericSVGHandler; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; @@ -232,8 +233,7 @@ public class PSSVGHandler extends AbstractGenericSVGHandler boolean paintAsBitmap = false; if (context != null) { Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); - paintAsBitmap = (foreign != null - && "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))); + paintAsBitmap = ImageHandlerUtil.isConversionModeBitmap(foreign); } if (paintAsBitmap) { try { diff --git a/src/sandbox/org/apache/fop/render/svg/SVGPainter.java b/src/sandbox/org/apache/fop/render/svg/SVGPainter.java index e1626e6f9..d427096be 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGPainter.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGPainter.java @@ -41,12 +41,11 @@ import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; -import org.apache.xmlgraphics.util.QName; import org.apache.xmlgraphics.xmp.Metadata; import org.apache.fop.apps.MimeConstants; import org.apache.fop.events.ResourceEventProducer; -import org.apache.fop.fo.extensions.ExtensionElementMapping; +import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RenderingContext; import org.apache.fop.render.intermediate.AbstractIFPainter; import org.apache.fop.render.intermediate.IFConstants; @@ -193,9 +192,6 @@ public class SVGPainter extends AbstractIFPainter implements SVGConstants { } } - private static final QName CONVERSION_MODE - = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); - /** {@inheritDoc} */ public void drawImage(String uri, Rectangle rect) throws IFException { try { @@ -209,7 +205,8 @@ public class SVGPainter extends AbstractIFPainter implements SVGConstants { String mime = info.getMimeType(); Map foreignAttributes = getContext().getForeignAttributes(); - String conversionMode = (String)foreignAttributes.get(CONVERSION_MODE); + String conversionMode = (String)foreignAttributes.get( + ImageHandlerUtil.CONVERSION_MODE); if ("reference".equals(conversionMode) && (MimeConstants.MIME_GIF.equals(mime) || MimeConstants.MIME_JPEG.equals(mime) |