diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-10-21 08:58:08 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-10-21 08:58:08 +0000 |
commit | 8b65aafce052c7048b2366cd2ac73cbfbcb9c154 (patch) | |
tree | 67b41c84b03fbd83300bcd7aa103606374f67f28 /src/java/org/apache/fop | |
parent | d6d3411ca856d605080c25624da32cd9ad1df9bb (diff) | |
parent | e157058f724241cee23ad406fb2fd3707a4efac3 (diff) | |
download | xmlgraphics-fop-8b65aafce052c7048b2366cd2ac73cbfbcb9c154.tar.gz xmlgraphics-fop-8b65aafce052c7048b2366cd2ac73cbfbcb9c154.zip |
Merge from Trunk revisions 699793 to 706550.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@706553 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
11 files changed, 179 insertions, 67 deletions
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index 916745e4c..c0bcc96f4 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -23,17 +23,15 @@ package org.apache.fop.cli; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.PrintStream; import java.util.Locale; import java.util.Map; import java.util.Vector; import javax.swing.UIManager; -import org.xml.sax.SAXException; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.fop.Version; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; @@ -51,6 +49,7 @@ import org.apache.fop.render.print.PagesMode; import org.apache.fop.render.print.PrintRenderer; import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.util.CommandLineLogger; +import org.xml.sax.SAXException; /** * Options parses the commandline arguments @@ -135,7 +134,8 @@ public class CommandLineOptions { } /** - * Parse the command line arguments. + * Parses the command line arguments. + * * @param args the command line arguments. * @throws FOPException for general errors * @throws IOException if the the configuration file could not be loaded @@ -166,10 +166,10 @@ public class CommandLineOptions { return false; } } catch (FOPException e) { - printUsage(); + printUsage(System.err); throw e; } catch (java.io.FileNotFoundException e) { - printUsage(); + printUsage(System.err); throw e; } @@ -236,12 +236,18 @@ public class CommandLineOptions { } /** - * parses the commandline arguments - * @return true if parse was successful and processing can continue, false - * if processing should stop + * Parses the command line arguments. + * + * @return true if processing can continue, false if it should stop (nothing to do) * @exception FOPException if there was an error in the format of the options */ private boolean parseOptions(String[] args) throws FOPException { + // do not throw an exception for no args + if (args.length == 0) { + printVersion(); + printUsage(System.out); + return false; + } for (int i = 0; i < args.length; i++) { if (args[i].equals("-x") || args[i].equals("--dump-config")) { @@ -314,7 +320,8 @@ public class CommandLineOptions { } else if (args[i].equals("-if")) { i = i + parseIntermediateFormatOption(args, i); } else if (args[i].equals("-v")) { - System.out.println("FOP Version " + Version.getVersion()); + printVersion(); + return false; } else if (args[i].equals("-param")) { if (i + 2 < args.length) { String name = args[++i]; @@ -340,8 +347,8 @@ public class CommandLineOptions { } else if (!isOption(args[i])) { i = i + parseUnknownOption(args, i); } else { - printUsage(); - return false; + printUsage(System.err); + System.exit(1); } } return true; @@ -1056,12 +1063,19 @@ public class CommandLineOptions { } } + private static void printVersion() { + System.out.println("FOP Version " + Version.getVersion()); + } + /** - * shows the commandline syntax including a summary of all available options and some examples + * Shows the command line syntax including a summary of all available options and some + * examples. + * + * @param out the stream to which the message must be printed */ - public static void printUsage() { - System.err.println( - "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] " + public static void printUsage(PrintStream out) { + out.println( + "\nUSAGE\nfop [options] [-fo|-xml] infile [-xsl file] " + "[-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>\n" + " [OPTIONS] \n" + " -d debug mode \n" @@ -1123,15 +1137,15 @@ public class CommandLineOptions { + " XSL-FO file is saved and no rendering is performed. \n" + " (Only available if you use -xml and -xsl parameters)\n\n" + "\n" - + " [Examples]\n" + " Fop foo.fo foo.pdf \n" - + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n" - + " Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n" - + " Fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n" - + " Fop -xml - -xsl foo.xsl -pdf -\n" - + " Fop foo.fo -mif foo.mif\n" - + " Fop foo.fo -rtf foo.rtf\n" - + " Fop foo.fo -print\n" - + " Fop foo.fo -awt\n"); + + " [Examples]\n" + " fop foo.fo foo.pdf \n" + + " fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n" + + " fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n" + + " fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n" + + " fop -xml - -xsl foo.xsl -pdf -\n" + + " fop foo.fo -mif foo.mif\n" + + " fop foo.fo -rtf foo.rtf\n" + + " fop foo.fo -print\n" + + " fop foo.fo -awt\n"); } /** @@ -1140,11 +1154,11 @@ public class CommandLineOptions { private void printUsagePrintOutput() { System.err.println("USAGE: -print [from[-to][,even|odd]] [-copies numCopies]\n\n" + "Example:\n" - + "all pages: Fop infile.fo -print\n" - + "all pages with two copies: Fop infile.fo -print -copies 2\n" - + "all pages starting with page 7: Fop infile.fo -print 7\n" - + "pages 2 to 3: Fop infile.fo -print 2-3\n" - + "only even page between 10 and 20: Fop infile.fo -print 10-20,even\n"); + + "all pages: fop infile.fo -print\n" + + "all pages with two copies: fop infile.fo -print -copies 2\n" + + "all pages starting with page 7: fop infile.fo -print 7\n" + + "pages 2 to 3: fop infile.fo -print 2-3\n" + + "only even page between 10 and 20: fop infile.fo -print 10-20,even\n"); } /** diff --git a/src/java/org/apache/fop/cli/Main.java b/src/java/org/apache/fop/cli/Main.java index f1a23ea46..c4393bb03 100644 --- a/src/java/org/apache/fop/cli/Main.java +++ b/src/java/org/apache/fop/cli/Main.java @@ -139,7 +139,10 @@ public class Main { } /** - * Executes FOP with the given ClassLoader setup. + * Executes FOP with the given arguments. If no argument is provided, returns its + * version number as well as a short usage statement; if '-v' is provided, returns its + * version number alone; if '-h' is provided, returns its short help message. + * * @param args command-line arguments */ public static void startFOP(String[] args) { @@ -153,7 +156,7 @@ public class Main { try { options = new CommandLineOptions(); if (!options.parse(args)) { - System.exit(1); + System.exit(0); } foUserAgent = options.getFOUserAgent(); diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java index c5c113b04..bb9c7d395 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Map; import org.apache.batik.dom.svg.SVGDOMImplementation; + import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; @@ -45,8 +46,8 @@ public class ImageLoaderSVG extends AbstractImageLoader { * @param targetFlavor the target flavor */ public ImageLoaderSVG(ImageFlavor targetFlavor) { - if (!(XMLNamespaceEnabledImageFlavor.SVG_DOM.equals(targetFlavor))) { - throw new IllegalArgumentException("Unsupported target ImageFlavor: " + targetFlavor); + if (!(XMLNamespaceEnabledImageFlavor.SVG_DOM.isCompatible(targetFlavor))) { + throw new IllegalArgumentException("Incompatible target ImageFlavor: " + targetFlavor); } this.targetFlavor = targetFlavor; } diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index 9366c6dc7..154d32e96 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -393,12 +393,15 @@ public class TraitSetter { int width = area.getIPD(); width += backProps.getPaddingStart(false, context); width += backProps.getPaddingEnd(false, context); - back.setHoriz(backProps.backgroundPositionHorizontal.getValue( - new SimplePercentBaseContext(context, - LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, - (width - back.getImageInfo().getSize().getWidthMpt()) - ) - )); + int imageWidthMpt = back.getImageInfo().getSize().getWidthMpt(); + int lengthBaseValue = width - imageWidthMpt; + SimplePercentBaseContext simplePercentBaseContext + = new SimplePercentBaseContext(context, + LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, + lengthBaseValue); + int horizontal = backProps.backgroundPositionHorizontal.getValue( + simplePercentBaseContext); + back.setHoriz(horizontal); } else { //TODO Area IPD has to be set for this to work log.warn("Horizontal background image positioning ignored" @@ -414,12 +417,15 @@ public class TraitSetter { int height = area.getBPD(); height += backProps.getPaddingBefore(false, context); height += backProps.getPaddingAfter(false, context); - back.setVertical(backProps.backgroundPositionVertical.getValue( - new SimplePercentBaseContext(context, - LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL, - (height - back.getImageInfo().getSize().getHeightMpt()) - ) - )); + int imageHeightMpt = back.getImageInfo().getSize().getHeightMpt(); + int lengthBaseValue = height - imageHeightMpt; + SimplePercentBaseContext simplePercentBaseContext + = new SimplePercentBaseContext(context, + LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL, + lengthBaseValue); + int vertical = backProps.backgroundPositionVertical.getValue( + simplePercentBaseContext); + back.setVertical(vertical); } else { //TODO Area BPD has to be set for this to work log.warn("Vertical background image positioning ignored" diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index 2d4b20e6a..fb62e653d 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -35,7 +35,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.fo.extensions.ExtensionElementMapping; import org.apache.fop.render.RendererContext.RendererContextWrapper; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; @@ -48,6 +50,10 @@ 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"); + /** {@inheritDoc} */ public void handleXML(RendererContext context, Document doc, String ns) throws Exception { diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java index 711b1a8bd..44631af4f 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java @@ -59,6 +59,7 @@ import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.xmlgraphics.java2d.GraphicContext; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; import org.apache.xmlgraphics.util.QName; +import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.MimeConstants; @@ -74,6 +75,7 @@ import org.apache.fop.area.inline.AbstractTextArea; 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.Leader; import org.apache.fop.area.inline.SpaceArea; import org.apache.fop.area.inline.TextArea; import org.apache.fop.area.inline.Viewport; @@ -96,7 +98,6 @@ import org.apache.fop.render.java2d.InstalledFontCollection; import org.apache.fop.render.java2d.Java2DRenderer; import org.apache.fop.render.pcl.extensions.PCLElementMapping; import org.apache.fop.traits.BorderProps; -import org.apache.xmlgraphics.util.UnitConv; /* Note: * There are some commonalities with AbstractPathOrientedRenderer but it's not possible @@ -1641,6 +1642,37 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants { } } + /** {@inheritDoc} */ + public void renderLeader(Leader area) { + renderInlineAreaBackAndBorders(area); + + saveGraphicsState(); + int style = area.getRuleStyle(); + float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f; + float starty = (currentBPPosition + area.getOffset()) / 1000f; + float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + + area.getIPD()) / 1000f; + float ruleThickness = area.getRuleThickness() / 1000f; + Color col = (Color)area.getTrait(Trait.COLOR); + + switch (style) { + case EN_SOLID: + case EN_DASHED: //TODO Improve me and following (this is just a quick-fix ATM) + case EN_DOUBLE: + case EN_DOTTED: + case EN_GROOVE: + case EN_RIDGE: + updateFillColor(col); + fillRect(startx, starty, endx - startx, ruleThickness); + break; + default: + throw new UnsupportedOperationException("rule style not supported"); + } + + restoreGraphicsState(); + super.renderLeader(area); + } + /** * Controls whether all text should be generated as bitmaps or only text for which there's * no native font. diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java index f69937888..4da7f13cb 100644 --- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java @@ -67,8 +67,8 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { float imw = (float)dim.getWidth() / 1000f; float imh = (float)dim.getHeight() / 1000f; - float sx = fwidth / (float)imw; - float sy = fheight / (float)imh; + float sx = pdfInfo.paintAsBitmap ? 1.0f : (fwidth / (float)imw); + float sy = pdfInfo.paintAsBitmap ? 1.0f : (fheight / (float)imh); generator.comment("G2D start"); generator.saveGraphicsState(); diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java index 5f204ad70..e5d8200b7 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java @@ -22,20 +22,31 @@ package org.apache.fop.render.ps; import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; import java.io.IOException; +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.RendererContext; +import org.apache.fop.render.RendererContextConstants; +import org.apache.fop.render.RendererContext.RendererContextWrapper; +import org.apache.fop.render.pdf.PDFRenderer; /** * Graphics2DAdapter implementation for PostScript. */ 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; @@ -71,8 +82,15 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { float imw = (float)dim.getWidth() / 1000f; float imh = (float)dim.getHeight() / 1000f; - float sx = fwidth / (float)imw; - float sy = fheight / (float)imh; + boolean paintAsBitmap = false; + if (context != null) { + Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + paintAsBitmap = (foreign != null + && "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))); + } + + float sx = paintAsBitmap ? 1.0f : (fwidth / (float)imw); + float sy = paintAsBitmap ? 1.0f : (fheight / (float)imh); gen.commentln("%FOPBeginGraphics2D"); gen.saveGraphicsState(); @@ -95,8 +113,19 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { // scale to viewbox transform.translate(fx, fy); gen.getCurrentState().concatMatrix(transform); - Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh); - painter.paint(graphics, area); + if (paintAsBitmap) { + //Fallback solution: Paint to a BufferedImage + int resolution = (int)Math.round(context.getUserAgent().getTargetResolution()); + RendererContextWrapper ctx = RendererContext.wrapRendererContext(context); + BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false); + + float scale = PDFRenderer.NORMAL_PDF_RESOLUTION + / context.getUserAgent().getTargetResolution(); + graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null); + } else { + Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh); + painter.paint(graphics, area); + } gen.restoreGraphicsState(); gen.commentln("%FOPEndGraphics2D"); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index 4785ea14f..4ccb0bd52 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -58,10 +58,10 @@ import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.xmlgraphics.ps.DSCConstants; import org.apache.xmlgraphics.ps.ImageEncoder; import org.apache.xmlgraphics.ps.PSDictionary; -import org.apache.xmlgraphics.ps.PSPageDeviceDictionary; import org.apache.xmlgraphics.ps.PSDictionaryFormatException; import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.xmlgraphics.ps.PSImageUtils; +import org.apache.xmlgraphics.ps.PSPageDeviceDictionary; import org.apache.xmlgraphics.ps.PSProcSets; import org.apache.xmlgraphics.ps.PSResource; import org.apache.xmlgraphics.ps.PSState; @@ -143,7 +143,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer /** The application producing the PostScript */ private int currentPageNumber = 0; - private boolean enableComments = true; + private final boolean enableComments = true; private boolean autoRotateLandscape = false; private int languageLevel = PSGenerator.DEFAULT_LANGUAGE_LEVEL; @@ -589,12 +589,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer /** {@inheritDoc} */ public void paintImage(RenderedImage image, RendererContext context, int x, int y, int width, int height) throws IOException { - float fx = (float)x / 1000f; + float fx = x / 1000f; x += currentIPPosition / 1000f; - float fy = (float)y / 1000f; + float fy = y / 1000f; y += currentBPPosition / 1000f; - float fw = (float)width / 1000f; - float fh = (float)height / 1000f; + float fw = width / 1000f; + float fh = height / 1000f; PSImageUtils.renderBitmapImage(image, fx, fy, fw, fh, gen); } @@ -1235,6 +1235,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer PSExtensionAttachment attachment = (PSExtensionAttachment)attObj; if (attachment instanceof PSCommentBefore) { gen.commentln("%" + attachment.getContent()); + } else if (attachment instanceof PSSetupCode) { + gen.writeln(attachment.getContent()); } } } @@ -1610,7 +1612,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer * {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { - drawImage(image.getURL(), pos); + drawImage(image.getURL(), pos, image.getForeignAttributes()); } /** diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index 1d293fa71..d4a478fa4 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -22,6 +22,7 @@ package org.apache.fop.render.ps; // Java import java.awt.geom.AffineTransform; import java.io.IOException; +import java.util.Map; import org.w3c.dom.Document; @@ -39,6 +40,7 @@ import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; +import org.apache.fop.render.RendererContextConstants; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; @@ -226,6 +228,23 @@ public class PSSVGHandler extends AbstractGenericSVGHandler int yOffset = psInfo.currentYPosition; PSGenerator gen = psInfo.psGenerator; + boolean paintAsBitmap = false; + if (context != null) { + Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + paintAsBitmap = (foreign != null + && "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))); + } + if (paintAsBitmap) { + try { + super.renderSVGDocument(context, doc); + } catch (IOException ioe) { + SVGEventProducer eventProducer = SVGEventProducer.Provider.get( + context.getUserAgent().getEventBroadcaster()); + eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc)); + } + return; + } + //Controls whether text painted by Batik is generated using text or path operations boolean strokeText = false; Configuration cfg = psInfo.getHandlerConfiguration(); diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java index ec90a3afd..d5aea37df 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java @@ -20,21 +20,20 @@ package org.apache.fop.render.ps.extensions; // FOP -import org.xml.sax.Attributes; -import org.xml.sax.Locator; - import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; import org.apache.fop.fo.extensions.ExtensionAttachment; +import org.xml.sax.Attributes; +import org.xml.sax.Locator; /** * Base class for the PostScript-specific extension elements. */ public abstract class AbstractPSExtensionObject extends FONode { - private PSSetupCode setupCode = new PSSetupCode(); + private final PSSetupCode setupCode = new PSSetupCode(); /** * Main constructor. @@ -56,9 +55,10 @@ public abstract class AbstractPSExtensionObject extends FONode { /** {@inheritDoc} */ protected void characters(char[] data, int start, int length, PropertyList pList, Locator locator) { - if (setupCode.getContent() != null) { - StringBuffer sb = new StringBuffer(setupCode.getContent()); - sb.append(data, start, length - start); + String content = setupCode.getContent(); + if (content != null) { + StringBuffer sb = new StringBuffer(content); + sb.append(data, start, length); setupCode.setContent(sb.toString()); } else { setupCode.setContent(new String(data, start, length)); |