From 9dc0ea2f7ad8fd77481901e269b6ac2bbb3d0308 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 25 Jun 2010 12:17:58 +0000 Subject: Bugzilla #49403: Initial support for PDF Separation color spaces (aka spot colors). This is still unfinished but produces valid PDF with Separation colors in simple cases. Based on work by: Patrick Jaromin Note: PDFColor is broken right now, as I'm planning to phase that class out. Squeezing separation colors and what else comes later into that class isn't such a good idea IMO. Instead, PDFColorHandler tries to do all that in a better way based on the new color support classes from XGC. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Color@957913 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/render/intermediate/IFState.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/render/intermediate/IFState.java b/src/java/org/apache/fop/render/intermediate/IFState.java index aa073d03c..5d669d3ef 100644 --- a/src/java/org/apache/fop/render/intermediate/IFState.java +++ b/src/java/org/apache/fop/render/intermediate/IFState.java @@ -178,7 +178,8 @@ public class IFState { * @param color the new text color */ public void setTextColor(Color color) { - if (!color.equals(this.textColor)) { + //Check in both directions due to limitations of java.awt.Color + if (!color.equals(this.textColor) || !this.textColor.equals(color)) { this.fontChanged = true; } this.textColor = color; -- cgit v1.2.3 From e7e29079203c8f847be894289e9bc177fba06cd8 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 21 Oct 2010 14:01:59 +0000 Subject: Allow to pass through document-level extensions from the first document passed to the IFConcatenator. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1026003 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/intermediate/util/IFConcatenator.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java b/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java index 4b0a3fe68..71ee7a0b0 100644 --- a/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java +++ b/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java @@ -19,7 +19,6 @@ package org.apache.fop.render.intermediate.util; - import java.awt.Dimension; import javax.xml.transform.Source; @@ -39,12 +38,17 @@ import org.apache.fop.render.intermediate.IFParser; *

* Note: This class will filter/ignore any document navigation events. Support for this may be * added later. + *

+ * Note: document-level extensions will only be transferred from the first document passed in. + * If you need to merge extensions from all the concatenated documents, you may have to merge + * these manually on the XML level, for example using XSLT. */ public class IFConcatenator { private IFDocumentHandler targetHandler; private int nextPageIndex = 0; + private boolean inFirstDocument = true; /** * Creates a new IF concatenator. @@ -163,14 +167,17 @@ public class IFConcatenator { /** {@inheritDoc} */ public void endDocument() throws IFException { //ignore + inFirstDocument = false; } /** {@inheritDoc} */ public void handleExtensionObject(Object extension) throws IFException { - if (inPageSequence) { + if (inPageSequence || inFirstDocument) { //Only pass through when inside page-sequence + //or for the first document (for document-level extensions). super.handleExtensionObject(extension); } + //Note:Extensions from non-first documents are ignored! } /** {@inheritDoc} */ -- cgit v1.2.3 From cfa853d5b2a728fa90c12cd1a44ca1a3eec1a12e Mon Sep 17 00:00:00 2001 From: Simon Pepping Date: Wed, 17 Nov 2010 19:45:27 +0000 Subject: findbugs-reported bug squashing; 959 bugs left (findbugs 1.3.9) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1036179 13f79535-47bb-0310-9956-ffa450edef68 --- checkstyle-5.1.xml | 2 +- .../embedding/java/embedding/ExampleFO2PDF.java | 4 +- .../embedding/java/embedding/MultipleFO2PDF.java | 4 +- .../org/apache/fop/afp/AbstractAFPPainter.java | 2 +- .../apache/fop/afp/modca/AbstractAFPObject.java | 2 +- .../org/apache/fop/apps/PageSequenceResults.java | 2 +- src/java/org/apache/fop/area/Area.java | 5 +- src/java/org/apache/fop/area/AreaTreeModel.java | 2 +- src/java/org/apache/fop/area/AreaTreeParser.java | 2 +- src/java/org/apache/fop/area/BeforeFloat.java | 3 + src/java/org/apache/fop/area/Block.java | 3 + src/java/org/apache/fop/area/BlockParent.java | 5 + src/java/org/apache/fop/area/BlockViewport.java | 3 + src/java/org/apache/fop/area/BodyRegion.java | 3 + src/java/org/apache/fop/area/CTM.java | 2 + src/java/org/apache/fop/area/Footnote.java | 3 + src/java/org/apache/fop/area/LineArea.java | 5 + src/java/org/apache/fop/area/LinkResolver.java | 3 + src/java/org/apache/fop/area/MainReference.java | 2 + src/java/org/apache/fop/area/NormalFlow.java | 3 + src/java/org/apache/fop/area/Page.java | 3 + src/java/org/apache/fop/area/PageViewport.java | 2 +- src/java/org/apache/fop/area/RegionReference.java | 3 +- src/java/org/apache/fop/area/RegionViewport.java | 3 + src/java/org/apache/fop/area/Span.java | 3 + src/java/org/apache/fop/area/Trait.java | 8 + .../apache/fop/area/inline/AbstractTextArea.java | 4 + src/java/org/apache/fop/area/inline/Anchor.java | 2 + src/java/org/apache/fop/area/inline/Container.java | 3 + .../org/apache/fop/area/inline/FilledArea.java | 3 + src/java/org/apache/fop/area/inline/Image.java | 3 + .../org/apache/fop/area/inline/InlineArea.java | 5 + .../apache/fop/area/inline/InlineBlockParent.java | 3 + .../org/apache/fop/area/inline/InlineParent.java | 3 + src/java/org/apache/fop/area/inline/Leader.java | 3 + src/java/org/apache/fop/area/inline/Space.java | 2 + src/java/org/apache/fop/area/inline/SpaceArea.java | 2 + src/java/org/apache/fop/area/inline/TextArea.java | 2 + .../fop/area/inline/UnresolvedPageNumber.java | 3 + src/java/org/apache/fop/area/inline/Viewport.java | 3 + src/java/org/apache/fop/area/inline/WordArea.java | 2 + .../org/apache/fop/cli/CommandLineOptions.java | 206 ++++++++++----------- src/java/org/apache/fop/datatypes/LengthBase.java | 2 +- src/java/org/apache/fop/fo/FONode.java | 2 +- src/java/org/apache/fop/fo/FOText.java | 2 +- .../apache/fop/fo/extensions/xmp/XMPMetadata.java | 2 + .../org/apache/fop/fo/properties/Property.java | 4 +- src/java/org/apache/fop/fonts/FontInfo.java | 2 +- .../org/apache/fop/fonts/FontInfoConfigurator.java | 2 +- src/java/org/apache/fop/fonts/FontLoader.java | 2 +- src/java/org/apache/fop/fonts/apps/PFMReader.java | 4 +- .../fop/fonts/substitute/FontSubstitutions.java | 2 +- .../fop/fonts/substitute/FontWeightRange.java | 2 +- src/java/org/apache/fop/fonts/type1/PFMFile.java | 10 +- .../apache/fop/fonts/type1/Type1FontLoader.java | 4 +- .../org/apache/fop/hyphenation/ByteVector.java | 2 + .../org/apache/fop/hyphenation/CharVector.java | 2 + src/java/org/apache/fop/hyphenation/Hyphen.java | 2 + .../org/apache/fop/hyphenation/Hyphenator.java | 2 +- .../org/apache/fop/hyphenation/TernaryTree.java | 2 + .../org/apache/fop/layoutmgr/AbstractBreaker.java | 4 +- .../apache/fop/layoutmgr/BlockKnuthSequence.java | 2 + .../apache/fop/layoutmgr/BreakingAlgorithm.java | 2 +- .../apache/fop/layoutmgr/InlineKnuthSequence.java | 2 + .../layoutmgr/UnresolvedListElementWithLength.java | 2 +- .../apache/fop/layoutmgr/inline/ImageLayout.java | 2 +- .../layoutmgr/inline/LeafNodeLayoutManager.java | 2 +- .../fop/layoutmgr/inline/LineLayoutManager.java | 3 + src/java/org/apache/fop/pdf/PDFObject.java | 2 +- .../apache/fop/render/AbstractConfigurator.java | 2 +- .../fop/render/AbstractGenericSVGHandler.java | 2 +- .../org/apache/fop/render/AbstractRenderer.java | 2 +- .../fop/render/PrintRendererConfigurator.java | 2 +- src/java/org/apache/fop/render/XMLHandler.java | 2 +- .../apache/fop/render/XMLHandlerConfigurator.java | 2 +- .../org/apache/fop/render/XMLHandlerRegistry.java | 2 +- .../fop/render/afp/AFPRendererImageInfo.java | 2 +- .../render/afp/extensions/AFPExtensionHandler.java | 2 +- .../fop/render/awt/viewer/PageChangeEvent.java | 2 + .../org/apache/fop/render/bitmap/TIFFRenderer.java | 10 +- .../apache/fop/render/intermediate/IFParser.java | 2 +- .../apache/fop/render/intermediate/IFRenderer.java | 2 +- .../fop/render/intermediate/IFSerializer.java | 8 +- .../intermediate/extensions/AbstractAction.java | 8 +- .../render/intermediate/extensions/ActionSet.java | 8 +- .../extensions/DocumentNavigationHandler.java | 4 +- .../intermediate/extensions/GoToXYAction.java | 8 +- .../render/intermediate/extensions/URIAction.java | 6 +- .../render/pdf/PDFDocumentNavigationHandler.java | 12 +- .../render/pdf/extensions/PDFExtensionHandler.java | 2 +- src/java/org/apache/fop/render/ps/PSFontUtils.java | 2 +- .../apache/fop/render/ps/PSImageFormResource.java | 2 +- .../org/apache/fop/render/ps/ResourceHandler.java | 2 +- .../render/ps/extensions/PSExtensionHandler.java | 2 +- .../fop/render/rtf/TextAttributesConverter.java | 2 +- .../rtfdoc/ParagraphKeeptogetherContext.java | 13 -- .../fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java | 2 - .../fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java | 5 +- .../org/apache/fop/render/xml/XMLXMLHandler.java | 2 +- .../org/apache/fop/servlet/FopPrintServlet.java | 2 + src/java/org/apache/fop/servlet/FopServlet.java | 2 + src/java/org/apache/fop/tools/TestConverter.java | 18 +- src/java/org/apache/fop/tools/anttasks/Fop.java | 32 ++-- src/java/org/apache/fop/traits/BorderProps.java | 2 + src/java/org/apache/fop/util/ColorUtil.java | 2 +- 105 files changed, 348 insertions(+), 234 deletions(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/checkstyle-5.1.xml b/checkstyle-5.1.xml index dab1e5ebb..8a393d452 100644 --- a/checkstyle-5.1.xml +++ b/checkstyle-5.1.xml @@ -96,7 +96,7 @@ - + diff --git a/examples/embedding/java/embedding/ExampleFO2PDF.java b/examples/embedding/java/embedding/ExampleFO2PDF.java index 6ae674908..20d27c128 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDF.java +++ b/examples/embedding/java/embedding/ExampleFO2PDF.java @@ -94,8 +94,8 @@ public class ExampleFO2PDF { for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "") + + (String.valueOf(pageSequenceResults.getId()).length() > 0 + ? pageSequenceResults.getId() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); diff --git a/examples/embedding/java/embedding/MultipleFO2PDF.java b/examples/embedding/java/embedding/MultipleFO2PDF.java index a9ace7cf0..0da9ae14c 100644 --- a/examples/embedding/java/embedding/MultipleFO2PDF.java +++ b/examples/embedding/java/embedding/MultipleFO2PDF.java @@ -147,8 +147,8 @@ public class MultipleFO2PDF { for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "") + + (String.valueOf(pageSequenceResults.getId()).length() > 0 + ? pageSequenceResults.getId() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); diff --git a/src/java/org/apache/fop/afp/AbstractAFPPainter.java b/src/java/org/apache/fop/afp/AbstractAFPPainter.java index e0da25ff9..a2a128be5 100644 --- a/src/java/org/apache/fop/afp/AbstractAFPPainter.java +++ b/src/java/org/apache/fop/afp/AbstractAFPPainter.java @@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory; public abstract class AbstractAFPPainter { /** Static logging instance */ - protected static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); /** data stream */ protected final DataStream dataStream; diff --git a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java index 4b1439da0..af679fa25 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java @@ -45,7 +45,7 @@ public abstract class AbstractAFPObject implements Streamable { protected static final byte SF_CLASS = (byte)0xD3; /** the structure field header */ - protected static final byte[] SF_HEADER = new byte[] { + static final byte[] SF_HEADER = new byte[] { 0x5A, // Structured field identifier 0x00, // Length byte 1 0x10, // Length byte 2 diff --git a/src/java/org/apache/fop/apps/PageSequenceResults.java b/src/java/org/apache/fop/apps/PageSequenceResults.java index 241f4a5f9..f94fe8fdb 100644 --- a/src/java/org/apache/fop/apps/PageSequenceResults.java +++ b/src/java/org/apache/fop/apps/PageSequenceResults.java @@ -44,7 +44,7 @@ public class PageSequenceResults { * * @return The ID */ - public String getID() { + public String getId() { return this.id; } diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index ddf2f5198..f94c68454 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -38,6 +38,9 @@ import org.apache.fop.traits.BorderProps; * Base object for all areas. */ public class Area extends AreaTreeObject implements Serializable { + + private static final long serialVersionUID = 6342888466142626492L; + // stacking directions /** * Stacking left to right @@ -134,7 +137,7 @@ public class Area extends AreaTreeObject implements Serializable { /** * logging instance */ - protected static Log log = LogFactory.getLog(Area.class); + protected static final Log log = LogFactory.getLog(Area.class); /** diff --git a/src/java/org/apache/fop/area/AreaTreeModel.java b/src/java/org/apache/fop/area/AreaTreeModel.java index e5f6db17b..8659b4cca 100644 --- a/src/java/org/apache/fop/area/AreaTreeModel.java +++ b/src/java/org/apache/fop/area/AreaTreeModel.java @@ -42,7 +42,7 @@ public class AreaTreeModel { protected PageSequence currentPageSequence; // private List offDocumentItems = new java.util.ArrayList(); /** logger instance */ - protected static Log log = LogFactory.getLog(AreaTreeModel.class); + protected static final Log log = LogFactory.getLog(AreaTreeModel.class); /** * Create a new store pages model diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index 31c0e04fc..ae7c0a7c3 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -98,7 +98,7 @@ import org.apache.fop.util.XMLUtil; public class AreaTreeParser { /** Logger instance */ - protected static Log log = LogFactory.getLog(AreaTreeParser.class); + protected static final Log log = LogFactory.getLog(AreaTreeParser.class); private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); diff --git a/src/java/org/apache/fop/area/BeforeFloat.java b/src/java/org/apache/fop/area/BeforeFloat.java index 490476368..b64eff556 100644 --- a/src/java/org/apache/fop/area/BeforeFloat.java +++ b/src/java/org/apache/fop/area/BeforeFloat.java @@ -25,6 +25,9 @@ package org.apache.fop.area; * See fo:region-body definition in the XSL Rec for more information. */ public class BeforeFloat extends BlockParent { + + private static final long serialVersionUID = 4101415711488333380L; + // this is an optional block area that will be rendered // as the separator only if there are float areas private Block separator = null; diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java index ecb9c4990..e37931510 100644 --- a/src/java/org/apache/fop/area/Block.java +++ b/src/java/org/apache/fop/area/Block.java @@ -32,6 +32,9 @@ package org.apache.fop.area; * It holds child block areas such as other blocks or lines. */ public class Block extends BlockParent { + + private static final long serialVersionUID = 6843727817993665788L; + /** * Normally stacked with other blocks. */ diff --git a/src/java/org/apache/fop/area/BlockParent.java b/src/java/org/apache/fop/area/BlockParent.java index 1be0b785d..f2cf01cf2 100644 --- a/src/java/org/apache/fop/area/BlockParent.java +++ b/src/java/org/apache/fop/area/BlockParent.java @@ -27,6 +27,11 @@ import java.util.List; */ public class BlockParent extends Area { + /** + * + */ + private static final long serialVersionUID = 7076916890348533805L; + // this position is used for absolute position // or as an indent // this has the size in the block progression dimension diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java index 60bf1fb22..032b39f95 100644 --- a/src/java/org/apache/fop/area/BlockViewport.java +++ b/src/java/org/apache/fop/area/BlockViewport.java @@ -25,6 +25,9 @@ package org.apache.fop.area; * The block-container creates this area. */ public class BlockViewport extends Block { + + private static final long serialVersionUID = -7840580922580735157L; + // clipping for this viewport private boolean clip = false; // transform if rotated or absolute diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index 7b183a188..2dd8a9a7c 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -30,6 +30,9 @@ import org.apache.fop.fo.pagination.RegionBody; * See fo:region-body definition in the XSL Rec for more information. */ public class BodyRegion extends RegionReference { + + private static final long serialVersionUID = -1848872997724078080L; + private BeforeFloat beforeFloat; // optional private MainReference mainReference; // mandatory private Footnote footnote; // optional diff --git a/src/java/org/apache/fop/area/CTM.java b/src/java/org/apache/fop/area/CTM.java index 099ab38fa..eb6207c42 100644 --- a/src/java/org/apache/fop/area/CTM.java +++ b/src/java/org/apache/fop/area/CTM.java @@ -34,6 +34,8 @@ import org.apache.fop.fo.Constants; */ public class CTM implements Serializable { + private static final long serialVersionUID = -8743287485623778341L; + private double a, b, c, d, e, f; private static final CTM CTM_LRTB = new CTM(1, 0, 0, 1, 0, 0); diff --git a/src/java/org/apache/fop/area/Footnote.java b/src/java/org/apache/fop/area/Footnote.java index a25f5467e..72b9f2ed0 100644 --- a/src/java/org/apache/fop/area/Footnote.java +++ b/src/java/org/apache/fop/area/Footnote.java @@ -27,6 +27,9 @@ package org.apache.fop.area; * See fo:region-body definition in the XSL Rec for more information. */ public class Footnote extends BlockParent { + + private static final long serialVersionUID = -7907428219886367161L; + private Block separator = null; // footnote has an optional separator diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index 0e6e6ac30..4d622bcec 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -32,12 +32,17 @@ import java.util.List; */ public class LineArea extends Area { + private static final long serialVersionUID = 7670235908329290684L; + /** * this class stores information about line width and potential adjustments * that can be used in order to re-compute adjustement and / or indents when a * page-number or a page-number-citation is resolved */ private final class LineAdjustingInfo implements Serializable { + + private static final long serialVersionUID = -6103629976229458273L; + private int lineAlignment; private int difference; private int availableStretch; diff --git a/src/java/org/apache/fop/area/LinkResolver.java b/src/java/org/apache/fop/area/LinkResolver.java index 51a952ddc..70bdfdf91 100644 --- a/src/java/org/apache/fop/area/LinkResolver.java +++ b/src/java/org/apache/fop/area/LinkResolver.java @@ -33,6 +33,9 @@ import org.apache.fop.area.Area; * Link resolving for resolving internal links. */ public class LinkResolver implements Resolvable, Serializable { + + private static final long serialVersionUID = -7102134165192960718L; + private boolean resolved = false; private String idRef; private Area area; diff --git a/src/java/org/apache/fop/area/MainReference.java b/src/java/org/apache/fop/area/MainReference.java index dd53113af..87e594169 100644 --- a/src/java/org/apache/fop/area/MainReference.java +++ b/src/java/org/apache/fop/area/MainReference.java @@ -31,6 +31,8 @@ import java.util.List; */ public class MainReference extends Area { + private static final long serialVersionUID = 7635126485620012448L; + private BodyRegion parent; private List spanAreas = new java.util.ArrayList(); private boolean isEmpty = true; diff --git a/src/java/org/apache/fop/area/NormalFlow.java b/src/java/org/apache/fop/area/NormalFlow.java index 5e0192389..3daf2dafd 100644 --- a/src/java/org/apache/fop/area/NormalFlow.java +++ b/src/java/org/apache/fop/area/NormalFlow.java @@ -25,6 +25,9 @@ package org.apache.fop.area; * See fo:region-body definition in the XSL Rec for more information. */ public class NormalFlow extends BlockParent { + + private static final long serialVersionUID = -3753538631016929004L; + /** * Constructor. * @param ipd of Normal flow object diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index 4607dfb74..242123baa 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -47,6 +47,9 @@ import org.apache.fop.layoutmgr.TraitSetter; * the top level page and regions. */ public class Page extends AreaTreeObject implements Serializable, Cloneable { + + private static final long serialVersionUID = 6272157047421543866L; + // contains before, start, body, end and after regions private RegionViewport regionBefore = null; private RegionViewport regionStart = null; diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index bccae8754..a4fcb61a8 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -87,7 +87,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl /** * logging instance */ - protected static Log log = LogFactory.getLog(PageViewport.class); + protected static final Log log = LogFactory.getLog(PageViewport.class); /** * Create a page viewport. diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java index 200f0bff3..0aec7a395 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.java @@ -31,13 +31,14 @@ import org.apache.fop.fo.pagination.Region; */ public class RegionReference extends Area implements Cloneable { + private static final long serialVersionUID = -298980963268244238L; + /** Reference to the region FO. */ //protected Region regionFO; private int regionClass; private String regionName; private CTM ctm; - // the list of block areas from the static flow private ArrayList blocks = new ArrayList(); diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index d55ecefbb..0654c5f6b 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.java @@ -30,6 +30,9 @@ import java.util.HashMap; * in the fo:region-body description in the XSL Recommendation. */ public class RegionViewport extends Area implements Cloneable { + + private static final long serialVersionUID = 505781815165102572L; + // this rectangle is relative to the page private RegionReference regionReference; private Rectangle2D viewArea; diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java index 69b37f4b3..e2ef90432 100644 --- a/src/java/org/apache/fop/area/Span.java +++ b/src/java/org/apache/fop/area/Span.java @@ -30,6 +30,9 @@ import java.util.List; * See fo:region-body definition in the XSL Rec for more information. */ public class Span extends Area { + + private static final long serialVersionUID = -5551430053660081549L; + // the list of flow reference areas in this span area private List flowAreas; private int colCount; diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 42c5462e4..4ad03b468 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -36,6 +36,8 @@ import org.apache.fop.util.ColorUtil; */ public final class Trait implements Serializable { + private static final long serialVersionUID = 3234280285391611437L; + private Trait() { } @@ -313,6 +315,8 @@ public final class Trait implements Serializable { */ public static class InternalLink implements Serializable { + private static final long serialVersionUID = -8993505060996723039L; + /** The unique key of the PageViewport. */ private String pvKey; @@ -447,6 +451,8 @@ public final class Trait implements Serializable { */ public static class ExternalLink implements Serializable { + private static final long serialVersionUID = -3720707599232620946L; + private String destination; private boolean newWindow; @@ -520,6 +526,8 @@ public final class Trait implements Serializable { */ public static class Background implements Serializable { + private static final long serialVersionUID = 8452078676273242870L; + /** The background color if any. */ private Color color = null; diff --git a/src/java/org/apache/fop/area/inline/AbstractTextArea.java b/src/java/org/apache/fop/area/inline/AbstractTextArea.java index b50f53a24..08997a817 100644 --- a/src/java/org/apache/fop/area/inline/AbstractTextArea.java +++ b/src/java/org/apache/fop/area/inline/AbstractTextArea.java @@ -24,6 +24,8 @@ package org.apache.fop.area.inline; */ public abstract class AbstractTextArea extends InlineParent { + private static final long serialVersionUID = -1246306443569094371L; + /** * this class stores information about spaces and potential adjustments * that can be used in order to re-compute adjustments when a @@ -31,6 +33,8 @@ public abstract class AbstractTextArea extends InlineParent { */ protected class TextAdjustingInfo extends InlineAdjustingInfo { + private static final long serialVersionUID = -2412095162983479947L; + /** difference between the optimal width of a space * and the default width of a space according to the font * (this is equivalent to the property word-spacing.optimum) diff --git a/src/java/org/apache/fop/area/inline/Anchor.java b/src/java/org/apache/fop/area/inline/Anchor.java index ec6dbbcfb..8ad663111 100644 --- a/src/java/org/apache/fop/area/inline/Anchor.java +++ b/src/java/org/apache/fop/area/inline/Anchor.java @@ -25,6 +25,8 @@ package org.apache.fop.area.inline; */ public class Anchor extends InlineArea { + private static final long serialVersionUID = 5227798744787823499L; + // has a keep with adjacent area // has reference to associated footnote or float out-of-line area diff --git a/src/java/org/apache/fop/area/inline/Container.java b/src/java/org/apache/fop/area/inline/Container.java index 98c0aaef0..f6dbf3a15 100644 --- a/src/java/org/apache/fop/area/inline/Container.java +++ b/src/java/org/apache/fop/area/inline/Container.java @@ -32,6 +32,9 @@ import java.util.ArrayList; * This allows an inline area to have blocks as children. */ public class Container extends Area { + + private static final long serialVersionUID = 5256423939348189260L; + /** * The list of block areas stacked inside this container */ diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java index 7df62e79b..06d0d3aa3 100644 --- a/src/java/org/apache/fop/area/inline/FilledArea.java +++ b/src/java/org/apache/fop/area/inline/FilledArea.java @@ -34,6 +34,9 @@ import java.util.Iterator; * this as a normal inline parent. */ public class FilledArea extends InlineParent { + + private static final long serialVersionUID = 8586584705587017474L; + private int unitWidth; /** diff --git a/src/java/org/apache/fop/area/inline/Image.java b/src/java/org/apache/fop/area/inline/Image.java index 7d802db49..baf3c183b 100644 --- a/src/java/org/apache/fop/area/inline/Image.java +++ b/src/java/org/apache/fop/area/inline/Image.java @@ -27,6 +27,9 @@ import org.apache.fop.area.Area; * The url of the image is used as a key to reference the image cache. */ public class Image extends Area { + + private static final long serialVersionUID = 4800834714349695386L; + private String url; /** diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 30afc149b..0889d1dad 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -32,12 +32,17 @@ import org.apache.fop.area.Trait; */ public class InlineArea extends Area { + private static final long serialVersionUID = -8940066479810170980L; + /** * this class stores information about potential adjustments * that can be used in order to re-compute adjustments when a * page-number or a page-number-citation is resolved */ protected class InlineAdjustingInfo implements Serializable { + + private static final long serialVersionUID = -5601387735459712149L; + /** stretch of the inline area */ protected int availableStretch; /** shrink of the inline area */ diff --git a/src/java/org/apache/fop/area/inline/InlineBlockParent.java b/src/java/org/apache/fop/area/inline/InlineBlockParent.java index e580b1667..fe024ac0f 100644 --- a/src/java/org/apache/fop/area/inline/InlineBlockParent.java +++ b/src/java/org/apache/fop/area/inline/InlineBlockParent.java @@ -29,6 +29,9 @@ import org.apache.fop.area.Block; */ public class InlineBlockParent extends InlineArea { + + private static final long serialVersionUID = -3661746143321407377L; + /** * The list of inline areas added to this inline parent. */ diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index cbc5b578c..5d4369103 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -29,6 +29,9 @@ import java.util.ArrayList; * This is an inline area that can have other inlines as children. */ public class InlineParent extends InlineArea { + + private static final long serialVersionUID = -3047168298770354813L; + /** * The list of inline areas added to this inline parent. */ diff --git a/src/java/org/apache/fop/area/inline/Leader.java b/src/java/org/apache/fop/area/inline/Leader.java index cd7b2e9f3..ff8ba12b0 100644 --- a/src/java/org/apache/fop/area/inline/Leader.java +++ b/src/java/org/apache/fop/area/inline/Leader.java @@ -32,6 +32,9 @@ public class Leader extends InlineArea { // if space replaced with a space // otherwise this is a holder for a line + + private static final long serialVersionUID = -8011373048313956301L; + private int ruleStyle = Constants.EN_SOLID; private int ruleThickness = 1000; diff --git a/src/java/org/apache/fop/area/inline/Space.java b/src/java/org/apache/fop/area/inline/Space.java index 9a24de0d3..bf683bb22 100644 --- a/src/java/org/apache/fop/area/inline/Space.java +++ b/src/java/org/apache/fop/area/inline/Space.java @@ -25,4 +25,6 @@ package org.apache.fop.area.inline; */ public class Space extends InlineArea { + private static final long serialVersionUID = -8748265505356839796L; + } diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java index 202408deb..6f0863789 100644 --- a/src/java/org/apache/fop/area/inline/SpaceArea.java +++ b/src/java/org/apache/fop/area/inline/SpaceArea.java @@ -24,6 +24,8 @@ package org.apache.fop.area.inline; */ public class SpaceArea extends InlineArea { + private static final long serialVersionUID = 2218803009825411416L; + /** * The space for this space area */ diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java index f736b894c..8fb9455ad 100644 --- a/src/java/org/apache/fop/area/inline/TextArea.java +++ b/src/java/org/apache/fop/area/inline/TextArea.java @@ -24,6 +24,8 @@ package org.apache.fop.area.inline; */ public class TextArea extends AbstractTextArea { + private static final long serialVersionUID = 7315900267242540809L; + /** * Create a text inline area */ diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java index 43a995670..3457ad698 100644 --- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java @@ -32,6 +32,9 @@ import java.util.List; */ public class UnresolvedPageNumber extends TextArea implements Resolvable { + + private static final long serialVersionUID = -1758090835371647980L; + private boolean resolved = false; private String pageIDRef; private String text; diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java index 489f5afda..206a965e2 100644 --- a/src/java/org/apache/fop/area/inline/Viewport.java +++ b/src/java/org/apache/fop/area/inline/Viewport.java @@ -32,6 +32,9 @@ import java.util.HashMap; * holds the area and positions it. */ public class Viewport extends InlineArea { + + private static final long serialVersionUID = 813338534627918689L; + // contents could be container, foreign object or image private Area content; // clipping for the viewport diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java index 4737d81d3..8bb6888ce 100644 --- a/src/java/org/apache/fop/area/inline/WordArea.java +++ b/src/java/org/apache/fop/area/inline/WordArea.java @@ -24,6 +24,8 @@ package org.apache.fop.area.inline; */ public class WordArea extends InlineArea { + private static final long serialVersionUID = 6444644662158970942L; + /** The text for this word area */ protected String word; diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index 2a5c0d272..eff7b76f0 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -89,23 +89,23 @@ public class CommandLineOptions { /* user configuration file */ private File userConfigFile = null; /* input fo file */ - private File fofile = null; + private File foFile = null; /* xsltfile (xslt transformation as input) */ - private File xsltfile = null; + private File xsltFile = null; /* xml file (xslt transformation as input) */ - private File xmlfile = null; + private File xmlFile = null; /* area tree input file */ - private File areatreefile = null; + private File areatreeFile = null; /* intermediate format input file */ - private File iffile = null; + private File ifFile = null; /* area tree input file */ - private File imagefile = null; + private File imageFile = null; /* output file */ - private File outfile = null; + private File outFile = null; /* input mode */ - private int inputmode = NOT_SET; + private int inputMode = NOT_SET; /* output mode */ - private String outputmode = null; + private String outputMode = null; /* true if System.in (stdin) should be used for the input file */ private boolean useStdIn = false; /* true if System.out (stdout) should be used for the output file */ @@ -194,7 +194,7 @@ public class CommandLineOptions { inputHandler = createInputHandler(); - if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) { + if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputMode)) { //set the system look&feel for the preview dialog try { UIManager.setLookAndFeel( @@ -207,7 +207,7 @@ public class CommandLineOptions { renderer.setRenderable(inputHandler); //set before user agent! renderer.setUserAgent(foUserAgent); foUserAgent.setRendererOverride(renderer); - } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode) + } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputMode) && mimicRenderer != null) { // render from FO to Intermediate Format Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer( @@ -220,7 +220,7 @@ public class CommandLineOptions { //Make sure the prepared XMLRenderer is used foUserAgent.setRendererOverride(xmlRenderer); - } else if (MimeConstants.MIME_FOP_IF.equals(outputmode) + } else if (MimeConstants.MIME_FOP_IF.equals(outputMode) && mimicRenderer != null) { // render from FO to Intermediate Format IFSerializer serializer = new IFSerializer(); @@ -447,7 +447,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - fofile = new File(filename); + foFile = new File(filename); } return 1; } @@ -460,7 +460,7 @@ public class CommandLineOptions { throw new FOPException("you must specify the stylesheet " + "file for the '-xsl' option"); } else { - xsltfile = new File(args[i + 1]); + xsltFile = new File(args[i + 1]); return 1; } } @@ -476,7 +476,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - xmlfile = new File(filename); + xmlFile = new File(filename); } return 1; } @@ -508,7 +508,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdOut = true; } else { - outfile = new File(filename); + outFile = new File(filename); } } @@ -701,16 +701,16 @@ public class CommandLineOptions { } private int parseUnknownOption(String[] args, int i) throws FOPException { - if (inputmode == NOT_SET) { - inputmode = FO_INPUT; + if (inputMode == NOT_SET) { + inputMode = FO_INPUT; String filename = args[i]; if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - fofile = new File(filename); + foFile = new File(filename); } - } else if (outputmode == null) { - outputmode = MimeConstants.MIME_PDF; + } else if (outputMode == null) { + outputMode = MimeConstants.MIME_PDF; setOutputFile(args[i]); } else { throw new FOPException("Don't know what to do with " @@ -765,7 +765,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - areatreefile = new File(filename); + areatreeFile = new File(filename); } return 1; } @@ -781,7 +781,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - iffile = new File(filename); + ifFile = new File(filename); } return 1; } @@ -797,7 +797,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - imagefile = new File(filename); + imageFile = new File(filename); } return 1; } @@ -867,8 +867,8 @@ public class CommandLineOptions { } private void setOutputMode(String mime) throws FOPException { - if (outputmode == null) { - outputmode = mime; + if (outputMode == null) { + outputMode = mime; } else { throw new FOPException("you can only set one output method"); } @@ -896,8 +896,8 @@ public class CommandLineOptions { } private void setInputFormat(int format) throws FOPException { - if (inputmode == NOT_SET || inputmode == format) { - inputmode = format; + if (inputMode == NOT_SET || inputMode == format) { + inputMode = format; } else { throw new FOPException("Only one input mode can be specified!"); } @@ -907,100 +907,100 @@ public class CommandLineOptions { * checks whether all necessary information has been given in a consistent way */ private void checkSettings() throws FOPException, FileNotFoundException { - if (inputmode == NOT_SET) { + if (inputMode == NOT_SET) { throw new FOPException("No input file specified"); } - if (outputmode == null) { + if (outputMode == null) { throw new FOPException("No output file specified"); } - if ((outputmode.equals(MimeConstants.MIME_FOP_AWT_PREVIEW) - || outputmode.equals(MimeConstants.MIME_FOP_PRINT)) - && outfile != null) { + if ((outputMode.equals(MimeConstants.MIME_FOP_AWT_PREVIEW) + || outputMode.equals(MimeConstants.MIME_FOP_PRINT)) + && outFile != null) { throw new FOPException("Output file may not be specified " + "for AWT or PRINT output"); } - if (inputmode == XSLT_INPUT) { + if (inputMode == XSLT_INPUT) { // check whether xml *and* xslt file have been set - if (xmlfile == null && !this.useStdIn) { + if (xmlFile == null && !this.useStdIn) { throw new FOPException("XML file must be specified for the transform mode"); } - if (xsltfile == null) { + if (xsltFile == null) { throw new FOPException("XSLT file must be specified for the transform mode"); } // warning if fofile has been set in xslt mode - if (fofile != null) { + if (foFile != null) { log.warn("Can't use fo file with transform mode! Ignoring.\n" + "Your input is " + "\n xmlfile: " - + xmlfile.getAbsolutePath() + + xmlFile.getAbsolutePath() + "\nxsltfile: " - + xsltfile.getAbsolutePath() + + xsltFile.getAbsolutePath() + "\n fofile: " - + fofile.getAbsolutePath()); + + foFile.getAbsolutePath()); } - if (xmlfile != null && !xmlfile.exists()) { + if (xmlFile != null && !xmlFile.exists()) { throw new FileNotFoundException("Error: xml file " - + xmlfile.getAbsolutePath() + + xmlFile.getAbsolutePath() + " not found "); } - if (!xsltfile.exists()) { + if (!xsltFile.exists()) { throw new FileNotFoundException("Error: xsl file " - + xsltfile.getAbsolutePath() + + xsltFile.getAbsolutePath() + " not found "); } - } else if (inputmode == FO_INPUT) { - if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputMode == FO_INPUT) { + if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); } - if (fofile != null && !fofile.exists()) { + if (foFile != null && !foFile.exists()) { throw new FileNotFoundException("Error: fo file " - + fofile.getAbsolutePath() + + foFile.getAbsolutePath() + " not found "); } - } else if (inputmode == AREATREE_INPUT) { - if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputMode == AREATREE_INPUT) { + if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); - } else if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { + } else if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { throw new FOPException( "Area Tree Output is not available if Area Tree is used as input!"); } - if (areatreefile != null && !areatreefile.exists()) { + if (areatreeFile != null && !areatreeFile.exists()) { throw new FileNotFoundException("Error: area tree file " - + areatreefile.getAbsolutePath() + + areatreeFile.getAbsolutePath() + " not found "); } - } else if (inputmode == IF_INPUT) { - if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputMode == IF_INPUT) { + if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); - } else if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { + } else if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { throw new FOPException( "Area Tree Output is not available if Intermediate Format" + " is used as input!"); - } else if (outputmode.equals(MimeConstants.MIME_FOP_IF)) { + } else if (outputMode.equals(MimeConstants.MIME_FOP_IF)) { throw new FOPException( "Intermediate Output is not available if Intermediate Format" + " is used as input!"); } - if (iffile != null && !iffile.exists()) { + if (ifFile != null && !ifFile.exists()) { throw new FileNotFoundException("Error: intermediate format file " - + iffile.getAbsolutePath() + + ifFile.getAbsolutePath() + " not found "); } - } else if (inputmode == IMAGE_INPUT) { - if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputMode == IMAGE_INPUT) { + if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); } - if (imagefile != null && !imagefile.exists()) { + if (imageFile != null && !imageFile.exists()) { throw new FileNotFoundException("Error: image file " - + imagefile.getAbsolutePath() + + imageFile.getAbsolutePath() + " not found "); } } @@ -1027,13 +1027,13 @@ public class CommandLineOptions { * @throws FOPException for invalid output formats */ protected String getOutputFormat() throws FOPException { - if (outputmode == null) { + if (outputMode == null) { throw new FOPException("Renderer has not been set!"); } - if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { + if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { renderingOptions.put("fineDetail", isCoarseAreaXml()); } - return outputmode; + return outputMode; } /** @@ -1042,21 +1042,21 @@ public class CommandLineOptions { * @throws IllegalArgumentException if invalid/missing parameters */ private InputHandler createInputHandler() { - switch (inputmode) { + switch (inputMode) { case FO_INPUT: - return new InputHandler(fofile); + return new InputHandler(foFile); case AREATREE_INPUT: - return new AreaTreeInputHandler(areatreefile); + return new AreaTreeInputHandler(areatreeFile); case IF_INPUT: - return new IFInputHandler(iffile); + return new IFInputHandler(ifFile); case XSLT_INPUT: - InputHandler handler = new InputHandler(xmlfile, xsltfile, xsltParams); + InputHandler handler = new InputHandler(xmlFile, xsltFile, xsltParams); if (useCatalogResolver) { handler.createCatalogResolver(foUserAgent); } return handler; case IMAGE_INPUT: - return new ImageInputHandler(imagefile, xsltfile, xsltParams); + return new ImageInputHandler(imageFile, xsltFile, xsltParams); default: throw new IllegalArgumentException("Error creating InputHandler object."); } @@ -1074,24 +1074,24 @@ public class CommandLineOptions { * Returns the XSL-FO file if set. * @return the XSL-FO file, null if not set */ - public File getFOFile() { - return fofile; + public File getFoFile() { + return foFile; } /** * Returns the input XML file if set. * @return the input XML file, null if not set */ - public File getXMLFile() { - return xmlfile; + public File getXmlFile() { + return xmlFile; } /** * Returns the stylesheet to be used for transformation to XSL-FO. * @return stylesheet */ - public File getXSLFile() { - return xsltfile; + public File getXslFile() { + return xsltFile; } /** @@ -1099,7 +1099,7 @@ public class CommandLineOptions { * @return the output file */ public File getOutputFile() { - return outfile; + return outFile; } /** @@ -1139,13 +1139,13 @@ public class CommandLineOptions { * @return either the fofile or the xmlfile */ public File getInputFile() { - switch (inputmode) { + switch (inputMode) { case FO_INPUT: - return fofile; + return foFile; case XSLT_INPUT: - return xmlfile; + return xmlFile; default: - return fofile; + return foFile; } } @@ -1270,7 +1270,7 @@ public class CommandLineOptions { */ private void dumpConfiguration() { log.info("Input mode: "); - switch (inputmode) { + switch (inputMode) { case NOT_SET: log.info("not set"); break; @@ -1279,7 +1279,7 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("fo input file: from stdin"); } else { - log.info("fo input file: " + fofile.toString()); + log.info("fo input file: " + foFile.toString()); } break; case XSLT_INPUT: @@ -1287,16 +1287,16 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("xml input file: from stdin"); } else { - log.info("xml input file: " + xmlfile.toString()); + log.info("xml input file: " + xmlFile.toString()); } - log.info("xslt stylesheet: " + xsltfile.toString()); + log.info("xslt stylesheet: " + xsltFile.toString()); break; case AREATREE_INPUT: log.info("AT "); if (isInputFromStdIn()) { log.info("area tree input file: from stdin"); } else { - log.info("area tree input file: " + areatreefile.toString()); + log.info("area tree input file: " + areatreeFile.toString()); } break; case IF_INPUT: @@ -1304,7 +1304,7 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("intermediate input file: from stdin"); } else { - log.info("intermediate input file: " + iffile.toString()); + log.info("intermediate input file: " + ifFile.toString()); } break; case IMAGE_INPUT: @@ -1312,28 +1312,28 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("image input file: from stdin"); } else { - log.info("image input file: " + imagefile.toString()); + log.info("image input file: " + imageFile.toString()); } break; default: log.info("unknown input type"); } log.info("Output mode: "); - if (outputmode == null) { + if (outputMode == null) { log.info("not set"); - } else if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) { + } else if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputMode)) { log.info("awt on screen"); - if (outfile != null) { + if (outFile != null) { log.error("awt mode, but outfile is set:"); - log.error("out file: " + outfile.toString()); + log.error("out file: " + outFile.toString()); } - } else if (MimeConstants.MIME_FOP_PRINT.equals(outputmode)) { + } else if (MimeConstants.MIME_FOP_PRINT.equals(outputMode)) { log.info("print directly"); - if (outfile != null) { + if (outFile != null) { log.error("print mode, but outfile is set:"); - log.error("out file: " + outfile.toString()); + log.error("out file: " + outFile.toString()); } - } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode)) { + } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputMode)) { log.info("area tree"); if (mimicRenderer != null) { log.info("mimic renderer: " + mimicRenderer); @@ -1341,17 +1341,17 @@ public class CommandLineOptions { if (isOutputToStdOut()) { log.info("output file: to stdout"); } else { - log.info("output file: " + outfile.toString()); + log.info("output file: " + outFile.toString()); } - } else if (MimeConstants.MIME_FOP_IF.equals(outputmode)) { + } else if (MimeConstants.MIME_FOP_IF.equals(outputMode)) { log.info("intermediate format"); - log.info("output file: " + outfile.toString()); + log.info("output file: " + outFile.toString()); } else { - log.info(outputmode); + log.info(outputMode); if (isOutputToStdOut()) { log.info("output file: to stdout"); } else { - log.info("output file: " + outfile.toString()); + log.info("output file: " + outFile.toString()); } } diff --git a/src/java/org/apache/fop/datatypes/LengthBase.java b/src/java/org/apache/fop/datatypes/LengthBase.java index 137ca94fa..00eaee8c8 100644 --- a/src/java/org/apache/fop/datatypes/LengthBase.java +++ b/src/java/org/apache/fop/datatypes/LengthBase.java @@ -62,7 +62,7 @@ public class LengthBase implements PercentBase { /** * logging instance */ - protected static Log log = LogFactory.getLog(LengthBase.class); + protected static final Log log = LogFactory.getLog(LengthBase.class); /** * The FO for which this property is to be calculated. diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index a6be832f0..c9c04aa4e 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -69,7 +69,7 @@ public abstract class FONode implements Cloneable { protected Locator locator; /** Logger for fo-tree related messages **/ - protected static Log log = LogFactory.getLog(FONode.class); + protected static final Log log = LogFactory.getLog(FONode.class); /** * Base constructor diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 5db11f731..c78421cbe 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -619,7 +619,7 @@ public class FOText extends FONode implements CharSequence { } /** @return the baseline-shift property */ - public Length getBaseLineShift() { + public Length getBaselineShift() { return baselineShift; } diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java index 224741294..6dcc31385 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java @@ -33,6 +33,8 @@ import org.xml.sax.SAXException; */ public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable { + private static final long serialVersionUID = 591347206217931578L; + /** The category URI for this extension attachment. */ public static final String CATEGORY = XMPConstants.XMP_NAMESPACE; diff --git a/src/java/org/apache/fop/fo/properties/Property.java b/src/java/org/apache/fop/fo/properties/Property.java index 29e8faac5..a04f96a3c 100644 --- a/src/java/org/apache/fop/fo/properties/Property.java +++ b/src/java/org/apache/fop/fo/properties/Property.java @@ -36,7 +36,7 @@ import org.apache.fop.fo.Constants; public class Property { /** Logger for all property classes */ - protected static Log log = LogFactory.getLog(PropertyMaker.class); + protected static final Log log = LogFactory.getLog(PropertyMaker.class); /** * The original specified value for properties which inherit @@ -197,6 +197,6 @@ public class Property { if (obj != this) { return obj.toString(); } - return null; + return ""; } } diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index a7b840fcc..e36b5ff68 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -41,7 +41,7 @@ import org.apache.commons.logging.LogFactory; public class FontInfo { /** logging instance */ - protected static Log log = LogFactory.getLog(FontInfo.class); + protected static final Log log = LogFactory.getLog(FontInfo.class); /** Map containing fonts that have been used */ private Map/**/ usedFonts = null; //(String = font key) diff --git a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java index 9a11f84bc..911e57646 100644 --- a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java @@ -44,7 +44,7 @@ import org.apache.fop.util.LogUtil; */ public class FontInfoConfigurator { /** logger instance */ - protected static Log log = LogFactory.getLog(FontInfoConfigurator.class); + protected static final Log log = LogFactory.getLog(FontInfoConfigurator.class); private Configuration cfg; private FontManager fontManager; diff --git a/src/java/org/apache/fop/fonts/FontLoader.java b/src/java/org/apache/fop/fonts/FontLoader.java index 93d4ae03f..02c09a1a1 100644 --- a/src/java/org/apache/fop/fonts/FontLoader.java +++ b/src/java/org/apache/fop/fonts/FontLoader.java @@ -40,7 +40,7 @@ import org.apache.fop.fonts.type1.Type1FontLoader; public abstract class FontLoader { /** logging instance */ - protected static Log log = LogFactory.getLog(FontLoader.class); + protected static final Log log = LogFactory.getLog(FontLoader.class); /** URI representing the font file */ protected String fontFileURI = null; diff --git a/src/java/org/apache/fop/fonts/apps/PFMReader.java b/src/java/org/apache/fop/fonts/apps/PFMReader.java index e5e8ca524..bc294057b 100644 --- a/src/java/org/apache/fop/fonts/apps/PFMReader.java +++ b/src/java/org/apache/fop/fonts/apps/PFMReader.java @@ -173,7 +173,7 @@ public class PFMReader extends AbstractFontReader { public void preview(PFMFile pfm) { if (log != null && log.isInfoEnabled()) { log.info("Font: " + pfm.getWindowsName()); - log.info("Name: " + pfm.getPostscriptName()); + log.info("Name: " + pfm.getPostScriptName()); log.info("CharSet: " + pfm.getCharSetName()); log.info("CapHeight: " + pfm.getCapHeight()); log.info("XHeight: " + pfm.getXHeight()); @@ -217,7 +217,7 @@ public class PFMReader extends AbstractFontReader { Element el = doc.createElement("font-name"); root.appendChild(el); - el.appendChild(doc.createTextNode(pfm.getPostscriptName())); + el.appendChild(doc.createTextNode(pfm.getPostScriptName())); // Currently unused. // String s = pfm.getPostscriptName(); diff --git a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java index 313ad04a8..e018bb2c2 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java +++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java @@ -35,7 +35,7 @@ public class FontSubstitutions extends java.util.ArrayList/**/ { private static final long serialVersionUID = -9173104935431899722L; /** logging instance */ - protected static Log log = LogFactory.getLog(FontSubstitutions.class); + protected static final Log log = LogFactory.getLog(FontSubstitutions.class); /** * Adjusts a given fontInfo using this font substitution catalog diff --git a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java index 29ae0556d..34e04eb67 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java +++ b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java @@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory; public class FontWeightRange { /** logging instance */ - protected static Log log = LogFactory.getLog("org.apache.fop.render.fonts"); + protected static final Log log = LogFactory.getLog("org.apache.fop.render.fonts"); /** * Returns an FontWeightRange object holding the diff --git a/src/java/org/apache/fop/fonts/type1/PFMFile.java b/src/java/org/apache/fop/fonts/type1/PFMFile.java index d1a3d79ff..b5faddac1 100644 --- a/src/java/org/apache/fop/fonts/type1/PFMFile.java +++ b/src/java/org/apache/fop/fonts/type1/PFMFile.java @@ -38,7 +38,7 @@ public class PFMFile { // Header stuff private String windowsName; - private String postscriptName; + private String postScriptName; private short dfItalic; private int dfWeight; private short dfCharSet; @@ -164,7 +164,7 @@ public class PFMFile { inStream.reset(); inStream.skip(driverInfoOffset); - postscriptName = inStream.readString(); + postScriptName = inStream.readString(); if (extMetricsOffset != 0) { inStream.reset(); @@ -279,8 +279,8 @@ public class PFMFile { * * @return The Postscript name. */ - public String getPostscriptName() { - return postscriptName; + public String getPostScriptName() { + return postScriptName; } /** @@ -304,7 +304,7 @@ public class PFMFile { case 0: return "WinAnsi"; // AKA ISOAdobe case 2: - if ("Symbol".equals(getPostscriptName())) { + if ("Symbol".equals(getPostScriptName())) { return "Symbol"; } break; diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index d5036de7b..0c0c6187c 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java @@ -226,8 +226,8 @@ public class Type1FontLoader extends FontLoader { names.add(afm.getFamilyName()); returnFont.setFamilyNames(names); } else { - returnFont.setFontName(pfm.getPostscriptName()); - String fullName = pfm.getPostscriptName(); + returnFont.setFontName(pfm.getPostScriptName()); + String fullName = pfm.getPostScriptName(); fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name returnFont.setFullName(fullName); //emulate afm.getFullName() Set names = new java.util.HashSet(); diff --git a/src/java/org/apache/fop/hyphenation/ByteVector.java b/src/java/org/apache/fop/hyphenation/ByteVector.java index d1448abdc..0df1bd925 100644 --- a/src/java/org/apache/fop/hyphenation/ByteVector.java +++ b/src/java/org/apache/fop/hyphenation/ByteVector.java @@ -29,6 +29,8 @@ import java.io.Serializable; */ public class ByteVector implements Serializable { + private static final long serialVersionUID = 1554572867863466772L; + /** * Capacity increment size */ diff --git a/src/java/org/apache/fop/hyphenation/CharVector.java b/src/java/org/apache/fop/hyphenation/CharVector.java index 0ba42362b..97a63392e 100644 --- a/src/java/org/apache/fop/hyphenation/CharVector.java +++ b/src/java/org/apache/fop/hyphenation/CharVector.java @@ -29,6 +29,8 @@ import java.io.Serializable; */ public class CharVector implements Cloneable, Serializable { + private static final long serialVersionUID = 4263472982169004048L; + /** * Capacity increment size */ diff --git a/src/java/org/apache/fop/hyphenation/Hyphen.java b/src/java/org/apache/fop/hyphenation/Hyphen.java index ca876e1ec..ae33ec616 100644 --- a/src/java/org/apache/fop/hyphenation/Hyphen.java +++ b/src/java/org/apache/fop/hyphenation/Hyphen.java @@ -39,6 +39,8 @@ import java.io.Serializable; */ public class Hyphen implements Serializable { + private static final long serialVersionUID = 8989909741110279085L; + /** pre break string */ public String preBreak; // CSOK: VisibilityModifier diff --git a/src/java/org/apache/fop/hyphenation/Hyphenator.java b/src/java/org/apache/fop/hyphenation/Hyphenator.java index 76e8b6327..455520b09 100644 --- a/src/java/org/apache/fop/hyphenation/Hyphenator.java +++ b/src/java/org/apache/fop/hyphenation/Hyphenator.java @@ -43,7 +43,7 @@ import org.xml.sax.InputSource; public final class Hyphenator { /** logging instance */ - protected static Log log = LogFactory.getLog(Hyphenator.class); + protected static final Log log = LogFactory.getLog(Hyphenator.class); private static HyphenationTreeCache hTreeCache = null; diff --git a/src/java/org/apache/fop/hyphenation/TernaryTree.java b/src/java/org/apache/fop/hyphenation/TernaryTree.java index a3a823324..206b81f3f 100644 --- a/src/java/org/apache/fop/hyphenation/TernaryTree.java +++ b/src/java/org/apache/fop/hyphenation/TernaryTree.java @@ -75,6 +75,8 @@ public class TernaryTree implements Cloneable, Serializable { * if it ain't broken, don't fix it. */ + private static final long serialVersionUID = 3175412271203716160L; + /** * Pointer to low branch and to rest of the key when it is * stored directly in this node, we don't have unions in java! diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index cc18c5b36..76616bfb5 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -40,7 +40,7 @@ import org.apache.fop.util.ListUtil; public abstract class AbstractBreaker { /** logging instance */ - protected static Log log = LogFactory.getLog(AbstractBreaker.class); + protected static final Log log = LogFactory.getLog(AbstractBreaker.class); /** * A page break position. @@ -93,6 +93,8 @@ public abstract class AbstractBreaker { */ public class BlockSequence extends BlockKnuthSequence { + private static final long serialVersionUID = -5348831120146774118L; + /** Number of elements to ignore at the beginning of the list. */ int ignoreAtStart = 0; // CSOK: VisibilityModifier /** Number of elements to ignore at the end of the list. */ diff --git a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java index fac5bf075..0be0c9437 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java @@ -27,6 +27,8 @@ import java.util.List; */ public class BlockKnuthSequence extends KnuthSequence { + private static final long serialVersionUID = 1648962416582509095L; + private boolean isClosed = false; /** diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java index 15f8ffa8d..7ac23f74f 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java @@ -42,7 +42,7 @@ import org.apache.fop.fo.Constants; public abstract class BreakingAlgorithm { /** the logger for the class */ - protected static Log log = LogFactory.getLog(BreakingAlgorithm.class); + protected static final Log log = LogFactory.getLog(BreakingAlgorithm.class); /** Maximum adjustment ration */ protected static final int INFINITE_RATIO = 1000; diff --git a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java index 63a2f7c5e..81df3c992 100644 --- a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java @@ -32,6 +32,8 @@ import org.apache.fop.layoutmgr.inline.KnuthInlineBox; */ public class InlineKnuthSequence extends KnuthSequence { + private static final long serialVersionUID = 1354774188859946549L; + private boolean isClosed = false; /** diff --git a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java index d1b16a523..0667b9355 100644 --- a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java +++ b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java @@ -30,7 +30,7 @@ import org.apache.fop.traits.MinOptMax; public abstract class UnresolvedListElementWithLength extends UnresolvedListElement { /** Logger instance */ - protected static Log log = LogFactory.getLog(UnresolvedListElementWithLength.class); + protected static final Log log = LogFactory.getLog(UnresolvedListElementWithLength.class); private MinOptMax length; private boolean conditional; diff --git a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java index 338a58d9c..73235d2d1 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java @@ -37,7 +37,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty; public class ImageLayout implements Constants { /** logging instance */ - protected static Log log = LogFactory.getLog(ImageLayout.class); + protected static final Log log = LogFactory.getLog(ImageLayout.class); //Input private GraphicsProperties props; diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java index df7371fe5..c4a76f2f5 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java @@ -56,7 +56,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager /** * logging instance */ - protected static Log log = LogFactory.getLog(LeafNodeLayoutManager.class); + protected static final Log log = LogFactory.getLog(LeafNodeLayoutManager.class); /** * The inline area that this leafnode will add. diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 3a03257f8..661f6ec80 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -184,6 +184,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager // this class represents a paragraph private class Paragraph extends InlineKnuthSequence { + + private static final long serialVersionUID = 5862072380375189105L; + /** Number of elements to ignore at the beginning of the list. */ private int ignoreAtStart = 0; /** Number of elements to ignore at the end of the list. */ diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java index 21ff82394..4bb9a7d34 100644 --- a/src/java/org/apache/fop/pdf/PDFObject.java +++ b/src/java/org/apache/fop/pdf/PDFObject.java @@ -42,7 +42,7 @@ import org.apache.commons.logging.LogFactory; public abstract class PDFObject implements PDFWritable { /** logger for all PDFObjects (and descendants) */ - protected static Log log = LogFactory.getLog(PDFObject.class.getName()); + protected static final Log log = LogFactory.getLog(PDFObject.class.getName()); /** * the object's number diff --git a/src/java/org/apache/fop/render/AbstractConfigurator.java b/src/java/org/apache/fop/render/AbstractConfigurator.java index 096007b98..874bb4d1b 100644 --- a/src/java/org/apache/fop/render/AbstractConfigurator.java +++ b/src/java/org/apache/fop/render/AbstractConfigurator.java @@ -30,7 +30,7 @@ import org.apache.fop.apps.FOUserAgent; */ public abstract class AbstractConfigurator { /** logger instance */ - protected static Log log = LogFactory.getLog(AbstractConfigurator.class); + protected static final Log log = LogFactory.getLog(AbstractConfigurator.class); private static final String MIME = "mime"; diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index 392eb875e..f2c86b35f 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -178,7 +178,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC } /** {@inheritDoc} */ - public String getNamespace() { + public String getNameSpace() { return SVGDOMImplementation.SVG_NAMESPACE_URI; } diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 72be1b0b8..d70d8113f 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -79,7 +79,7 @@ public abstract class AbstractRenderer implements Renderer, Constants { /** logging instance */ - protected static Log log = LogFactory.getLog("org.apache.fop.render"); + protected static final Log log = LogFactory.getLog("org.apache.fop.render"); /** * user agent diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java index dd7a05067..8f94684b2 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java @@ -48,7 +48,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator implements RendererConfigurator, IFDocumentHandlerConfigurator { /** logger instance */ - protected static Log log = LogFactory.getLog(PrintRendererConfigurator.class); + protected static final Log log = LogFactory.getLog(PrintRendererConfigurator.class); /** * Default constructor diff --git a/src/java/org/apache/fop/render/XMLHandler.java b/src/java/org/apache/fop/render/XMLHandler.java index f8152fcbf..1060bec51 100644 --- a/src/java/org/apache/fop/render/XMLHandler.java +++ b/src/java/org/apache/fop/render/XMLHandler.java @@ -60,6 +60,6 @@ public interface XMLHandler { * @return the XML namespace for the XML dialect this XMLHandler supports, * null if all XML content is handled by this instance. */ - String getNamespace(); + String getNameSpace(); } diff --git a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java b/src/java/org/apache/fop/render/XMLHandlerConfigurator.java index fb2420572..b93d4003a 100644 --- a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java +++ b/src/java/org/apache/fop/render/XMLHandlerConfigurator.java @@ -32,7 +32,7 @@ import org.apache.fop.apps.FOUserAgent; public class XMLHandlerConfigurator extends AbstractRendererConfigurator { /** logger instance */ - protected static Log log = LogFactory.getLog(XMLHandlerConfigurator.class); + protected static final Log log = LogFactory.getLog(XMLHandlerConfigurator.class); /** * Default constructor diff --git a/src/java/org/apache/fop/render/XMLHandlerRegistry.java b/src/java/org/apache/fop/render/XMLHandlerRegistry.java index 81d9fcc93..84177df45 100644 --- a/src/java/org/apache/fop/render/XMLHandlerRegistry.java +++ b/src/java/org/apache/fop/render/XMLHandlerRegistry.java @@ -85,7 +85,7 @@ public class XMLHandlerRegistry { * @param handler the XMLHandler instance */ public void addXMLHandler(XMLHandler handler) { - String ns = handler.getNamespace(); + String ns = handler.getNameSpace(); if (ns == null) { setDefaultXMLHandler(handler); } else { diff --git a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java index 2687d9071..cffcf8a25 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java @@ -124,7 +124,7 @@ public class AFPRendererImageInfo { * * @return the uri */ - public String getURI() { + public String getUri() { return this.uri; } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java index f2e77ec33..d916738eb 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java @@ -41,7 +41,7 @@ public class AFPExtensionHandler extends DefaultHandler implements ContentHandlerFactory.ObjectSource { /** Logger instance */ - protected static Log log = LogFactory.getLog(AFPExtensionHandler.class); + protected static final Log log = LogFactory.getLog(AFPExtensionHandler.class); private StringBuffer content = new StringBuffer(); private Attributes lastAttributes; diff --git a/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java b/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java index 045ce7fe4..78f09b537 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java +++ b/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java @@ -27,6 +27,8 @@ import java.util.EventObject; */ public class PageChangeEvent extends EventObject { + private static final long serialVersionUID = -5969283475959932887L; + private int oldPage; private int newPage; diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java index 7dd3bcd95..5a9cfa21b 100644 --- a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java +++ b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java @@ -31,6 +31,7 @@ import java.awt.image.SinglePixelPackedSampleModel; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; +import java.util.NoSuchElementException; import org.apache.commons.logging.Log; @@ -133,7 +134,11 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants { multiWriter.close(); } } else { - writer.writeImage((RenderedImage) pageImagesItr.next(), outputStream, writerParams); + RenderedImage renderedImage = null; + if (pageImagesItr.hasNext()) { + renderedImage = (RenderedImage) pageImagesItr.next(); + } + writer.writeImage(renderedImage, outputStream, writerParams); if (pageImagesItr.hasNext()) { BitmapRendererEventProducer eventProducer = BitmapRendererEventProducer.Provider.get( @@ -186,8 +191,7 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants { try { pageImage = getPageImage(current++); } catch (FOPException e) { - log.error(e); - return null; + throw new NoSuchElementException(e.getMessage()); } if (COMPRESSION_CCITT_T4.equalsIgnoreCase(writerParams.getCompressionMethod()) diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index da5d8a623..645d1ebc6 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -71,7 +71,7 @@ import org.apache.fop.util.XMLUtil; public class IFParser implements IFConstants { /** Logger instance */ - protected static Log log = LogFactory.getLog(IFParser.class); + protected static final Log log = LogFactory.getLog(IFParser.class); private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index bdeb1e9a1..046d1703b 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -110,7 +110,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { //if optimizations can be done to avoid int->float->int conversions. /** logging instance */ - protected static Log log = LogFactory.getLog(IFRenderer.class); + protected static final Log log = LogFactory.getLog(IFRenderer.class); /** XML MIME type */ public static final String IF_MIME_TYPE = MimeConstants.MIME_FOP_IF; diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index edeef9766..dcc0d3523 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -668,8 +668,8 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler throw new NullPointerException("action must not be null"); } if (!action.isComplete()) { - assert action.hasID(); - incompleteActions.put(action.getID(), action); + assert action.hasId(); + incompleteActions.put(action.getId(), action); } } @@ -744,8 +744,8 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler /** {@inheritDoc} */ public void addResolvedAction(AbstractAction action) throws IFException { assert action.isComplete(); - assert action.hasID(); - AbstractAction noted = (AbstractAction)incompleteActions.remove(action.getID()); + assert action.hasId(); + AbstractAction noted = (AbstractAction)incompleteActions.remove(action.getId()); if (noted != null) { completeActions.add(action); } else { diff --git a/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java b/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java index 340b2e068..8d8a30cf6 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java @@ -33,7 +33,7 @@ public abstract class AbstractAction implements XMLizable { * Sets an ID to make the action referencable. * @param id the ID */ - public void setID(String id) { + public void setId(String id) { this.id = id; } @@ -41,7 +41,7 @@ public abstract class AbstractAction implements XMLizable { * Returns an optional ID for this action. * @return the ID or null */ - public String getID() { + public String getId() { return this.id; } @@ -65,7 +65,7 @@ public abstract class AbstractAction implements XMLizable { * Indicates whether the action has an ID and is therefore referencable. * @return true if the action has an ID */ - public boolean hasID() { + public boolean hasId() { return this.id != null; } @@ -90,7 +90,7 @@ public abstract class AbstractAction implements XMLizable { * Returns a string that is used to prefix a generated ID to make it unique. * @return the prefix string */ - public String getIDPrefix() { + public String getIdPrefix() { return null; } diff --git a/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java b/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java index b980f1051..719d2225b 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java @@ -39,7 +39,7 @@ public class ActionSet { */ public synchronized String generateNewID(AbstractAction action) { this.lastGeneratedID++; - String prefix = action.getIDPrefix(); + String prefix = action.getIdPrefix(); if (prefix == null) { throw new IllegalArgumentException("Action class is not compatible"); } @@ -62,12 +62,12 @@ public class ActionSet { * @return the action instance that should be used in place of the given one */ public AbstractAction put(AbstractAction action) { - if (!action.hasID()) { - action.setID(generateNewID(action)); + if (!action.hasId()) { + action.setId(generateNewID(action)); } AbstractAction effAction = normalize(action); if (effAction == action) { - this.actionRegistry.put(action.getID(), action); + this.actionRegistry.put(action.getId(), action); } return effAction; } diff --git a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java index 5ca480f4a..1d5bc23fe 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java @@ -41,7 +41,7 @@ public class DocumentNavigationHandler extends DefaultHandler implements DocumentNavigationExtensionConstants { /** Logger instance */ - protected static Log log = LogFactory.getLog(DocumentNavigationHandler.class); + protected static final Log log = LogFactory.getLog(DocumentNavigationHandler.class); private StringBuffer content = new StringBuffer(); private Stack objectStack = new Stack(); @@ -132,7 +132,7 @@ public class DocumentNavigationHandler extends DefaultHandler boolean newWindow = "new".equals(showDestination); URIAction action = new URIAction(gotoURI, newWindow); if (id != null) { - action.setID(id); + action.setId(id); } if (structurePointer != null) { action.setStructurePointer(structurePointer); diff --git a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java index a2b4f31b6..d905c7800 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java @@ -52,7 +52,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx * or null, if the position isn't known, yet */ public GoToXYAction(String id, int pageIndex, Point targetLocation) { - setID(id); + setId(id); if (pageIndex < 0 && targetLocation != null) { throw new IllegalArgumentException( "Page index may not be null if target location is known!"); @@ -144,7 +144,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx AttributesImpl atts = new AttributesImpl(); if (this.isCompleteExceptTargetLocation()) { final Point reportedTargetLocation = this.getTargetLocation(); - atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); + atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getId()); atts.addAttribute(null, "page-index", "page-index", XMLUtil.CDATA, Integer.toString(pageIndex)); atts.addAttribute(null, "x", "x", XMLUtil.CDATA, @@ -152,7 +152,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx atts.addAttribute(null, "y", "y", XMLUtil.CDATA, Integer.toString(reportedTargetLocation.y)); } else { - atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID()); + atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getId()); } handler.startElement(GOTO_XY.getNamespaceURI(), GOTO_XY.getLocalName(), GOTO_XY.getQName(), atts); @@ -162,7 +162,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx /** {@inheritDoc} */ public String toString() { - return "GoToXY: ID=" + getID() + return "GoToXY: ID=" + getId() + ", page=" + getPageIndex() + ", loc=" + getTargetLocation() + ", " + (isComplete() ? "complete" : "INCOMPLETE"); diff --git a/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java b/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java index 22e7a270c..4251619ff 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java @@ -82,15 +82,15 @@ public class URIAction extends AbstractAction implements DocumentNavigationExten } /** {@inheritDoc} */ - public String getIDPrefix() { + public String getIdPrefix() { return "fop-" + GOTO_URI.getLocalName(); } /** {@inheritDoc} */ public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); - if (hasID()) { - atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); + if (hasId()) { + atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getId()); } atts.addAttribute(null, "uri", "uri", XMLUtil.CDATA, getURI()); if (isNewWindow()) { diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java index c215243a7..4a51cb176 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java @@ -129,7 +129,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler /** {@inheritDoc} */ public void addResolvedAction(AbstractAction action) throws IFException { assert action.isComplete(); - PDFAction pdfAction = (PDFAction)this.incompleteActions.remove(action.getID()); + PDFAction pdfAction = (PDFAction)this.incompleteActions.remove(action.getId()); if (pdfAction == null) { getAction(action); } else if (pdfAction instanceof PDFGoTo) { @@ -145,11 +145,11 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler if (action == null) { return null; } - PDFAction pdfAction = (PDFAction)this.completeActions.get(action.getID()); + PDFAction pdfAction = (PDFAction)this.completeActions.get(action.getId()); if (pdfAction != null) { return pdfAction; } else if (action instanceof GoToXYAction) { - pdfAction = (PDFAction) incompleteActions.get(action.getID()); + pdfAction = (PDFAction) incompleteActions.get(action.getId()); if (pdfAction != null) { return pdfAction; } else { @@ -159,7 +159,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler if (action.isComplete()) { updateTargetLocation(pdfGoTo, a); } else { - this.incompleteActions.put(action.getID(), pdfGoTo); + this.incompleteActions.put(action.getId(), pdfGoTo); } return pdfGoTo; } @@ -173,7 +173,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler //Some PDF actions are pooled getPDFDoc().registerObject(pdfAction); } - this.completeActions.put(action.getID(), pdfAction); + this.completeActions.put(action.getId(), pdfAction); return pdfAction; } else { throw new UnsupportedOperationException("Unsupported action type: " @@ -195,7 +195,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler //Queue this object now that it's complete getPDFDoc().addObject(pdfGoTo); - this.completeActions.put(action.getID(), pdfGoTo); + this.completeActions.put(action.getId(), pdfGoTo); } } diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java b/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java index 04c95545c..e7e863a23 100644 --- a/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java +++ b/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java @@ -37,7 +37,7 @@ public class PDFExtensionHandler extends DefaultHandler implements ContentHandlerFactory.ObjectSource { /** Logger instance */ - protected static Log log = LogFactory.getLog(PDFExtensionHandler.class); + protected static final Log log = LogFactory.getLog(PDFExtensionHandler.class); private Attributes lastAttributes; diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java index 8acc390d0..0d0975045 100644 --- a/src/java/org/apache/fop/render/ps/PSFontUtils.java +++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java @@ -54,7 +54,7 @@ import org.apache.fop.fonts.Typeface; public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { /** logging instance */ - protected static Log log = LogFactory.getLog(PSFontUtils.class); + protected static final Log log = LogFactory.getLog(PSFontUtils.class); /** * Generates the PostScript code for the font dictionary. This method should only be diff --git a/src/java/org/apache/fop/render/ps/PSImageFormResource.java b/src/java/org/apache/fop/render/ps/PSImageFormResource.java index 11c3205e6..4c40c6f92 100644 --- a/src/java/org/apache/fop/render/ps/PSImageFormResource.java +++ b/src/java/org/apache/fop/render/ps/PSImageFormResource.java @@ -53,7 +53,7 @@ public class PSImageFormResource extends PSResource { * Returns the image URI. * @return the image URI */ - public String getImageURI() { + public String getImageUri() { return this.uri; } diff --git a/src/java/org/apache/fop/render/ps/ResourceHandler.java b/src/java/org/apache/fop/render/ps/ResourceHandler.java index 502242c17..06d6b9034 100644 --- a/src/java/org/apache/fop/render/ps/ResourceHandler.java +++ b/src/java/org/apache/fop/render/ps/ResourceHandler.java @@ -281,7 +281,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { private void generateFormForImage(PSGenerator gen, PSImageFormResource form) throws IOException { - final String uri = form.getImageURI(); + final String uri = form.getImageUri(); ImageManager manager = userAgent.getFactory().getImageManager(); ImageInfo info = null; diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java index bf970d0a6..d499ef6ab 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java @@ -37,7 +37,7 @@ public class PSExtensionHandler extends DefaultHandler implements ContentHandlerFactory.ObjectSource { /** Logger instance */ - protected static Log log = LogFactory.getLog(PSExtensionHandler.class); + protected static final Log log = LogFactory.getLog(PSExtensionHandler.class); private StringBuffer content = new StringBuffer(); private Attributes lastAttributes; diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index d377f740d..29bbecded 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -149,7 +149,7 @@ final class TextAttributesConverter { attrFont(fobj.getCommonFont(), attrib); attrFontColor(fobj.getColor(), attrib); attrTextDecoration(fobj.getTextDecoration(), attrib); - attrBaseLineShift(fobj.getBaseLineShift(), attrib); + attrBaseLineShift(fobj.getBaselineShift(), attrib); return attrib; } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java index f231a1f06..146a8c19c 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java @@ -37,23 +37,10 @@ public final class ParagraphKeeptogetherContext { private static int paraKeepTogetherOpen = 0; private static boolean paraResetProperties = false; - private static ParagraphKeeptogetherContext instance = null; private ParagraphKeeptogetherContext() { } - /** - * Singelton. - * - * @return The instance of ParagraphKeeptogetherContext - */ - public static ParagraphKeeptogetherContext getInstance() { - if (instance == null) { - instance = new ParagraphKeeptogetherContext(); - } - return instance; - } - /** * @return the level of current "keep whith next" paragraph */ diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java index d7b77f633..b9e53d42f 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java @@ -39,14 +39,12 @@ public class RtfJforCmd extends RtfContainer { private static final String PARA_KEEP_OFF = "para-keep:off"; private final RtfAttributes attrib; - private ParagraphKeeptogetherContext paragraphKeeptogetherContext; RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException { super((RtfContainer)parent, w); attrib = attrs; - paragraphKeeptogetherContext = ParagraphKeeptogetherContext.getInstance(); } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java index 128c9a3df..927159ffc 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java @@ -54,7 +54,7 @@ public class RtfTextrun extends RtfContainer { /** * logging instance */ - protected static Log log = LogFactory.getLog(RtfTextrun.class); + protected static final Log log = LogFactory.getLog(RtfTextrun.class); /** Manager for handling space-* property. */ private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager(); @@ -271,7 +271,6 @@ public class RtfTextrun extends RtfContainer { //add RtfSpaceSplitter to inherit accumulated space rtfSpaceManager.pushRtfSpaceSplitter(attrs); rtfSpaceManager.setCandidate(attrs); - RtfString r = new RtfString(this, writer, s); rtfSpaceManager.popRtfSpaceSplitter(); } @@ -301,7 +300,7 @@ public class RtfTextrun extends RtfContainer { ListIterator lit = children.listIterator(children.size()); while (lit.hasPrevious() && (lit.previous() instanceof RtfCloseGroupMark)) { - tmp.push(new Integer(((RtfCloseGroupMark)lit.next()).getBreakType())); + tmp.push(Integer.valueOf(((RtfCloseGroupMark)lit.next()).getBreakType())); lit.remove(); deletedCloseGroupCount++; } diff --git a/src/java/org/apache/fop/render/xml/XMLXMLHandler.java b/src/java/org/apache/fop/render/xml/XMLXMLHandler.java index d1cf1cf9a..f181e1911 100644 --- a/src/java/org/apache/fop/render/xml/XMLXMLHandler.java +++ b/src/java/org/apache/fop/render/xml/XMLXMLHandler.java @@ -48,7 +48,7 @@ public class XMLXMLHandler implements XMLHandler { } /** {@inheritDoc} */ - public String getNamespace() { + public String getNameSpace() { return null; //Handle all XML content } diff --git a/src/java/org/apache/fop/servlet/FopPrintServlet.java b/src/java/org/apache/fop/servlet/FopPrintServlet.java index d446dff54..5c243ecae 100644 --- a/src/java/org/apache/fop/servlet/FopPrintServlet.java +++ b/src/java/org/apache/fop/servlet/FopPrintServlet.java @@ -61,6 +61,8 @@ import org.apache.fop.apps.MimeConstants; */ public class FopPrintServlet extends FopServlet { + private static final long serialVersionUID = 1645706757391617935L; + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java index 304cf21b9..7eb8a2f89 100644 --- a/src/java/org/apache/fop/servlet/FopServlet.java +++ b/src/java/org/apache/fop/servlet/FopServlet.java @@ -70,6 +70,8 @@ import org.apache.fop.apps.MimeConstants; */ public class FopServlet extends HttpServlet { + private static final long serialVersionUID = -908918093488215264L; + /** Name of the parameter used for the XSL-FO file */ protected static final String FO_REQUEST_PARAM = "fo"; /** Name of the parameter used for the XML file */ diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java index 0c6e09bd0..ba03ee567 100644 --- a/src/java/org/apache/fop/tools/TestConverter.java +++ b/src/java/org/apache/fop/tools/TestConverter.java @@ -56,7 +56,7 @@ public class TestConverter { private String outputFormat = MimeConstants.MIME_FOP_AREA_TREE; private File destdir; private File compare = null; - private String baseDir = "./"; + private String basedir = "./"; private Map differ = new java.util.HashMap(); /** @@ -95,7 +95,7 @@ public class TestConverter { } else if (args[count].equals("-d")) { tc.setDebug(true); } else if (args[count].equals("-b")) { - tc.setBaseDir(args[++count]); + tc.setBasedir(args[++count]); } else if (args[count].equals("-results")) { results = args[++count]; } else { @@ -138,8 +138,8 @@ public class TestConverter { * Sets the base directory. * @param str base directory */ - public void setBaseDir(String str) { - baseDir = str; + public void setBasedir(String str) { + basedir = str; } /** @@ -167,11 +167,11 @@ public class TestConverter { logger.debug("running tests in file:" + fname); try { if (compDir != null) { - compare = new File(baseDir + "/" + compDir); + compare = new File(basedir + "/" + compDir); } - destdir = new File(baseDir + "/" + dest); + destdir = new File(basedir + "/" + dest); destdir.mkdirs(); - File f = new File(baseDir + "/" + fname); + File f = new File(basedir + "/" + fname); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder db = factory.newDocumentBuilder(); Document doc = db.parse(f); @@ -271,7 +271,7 @@ public class TestConverter { res = resNode.getNodeValue(); } try { - File xmlFile = new File(baseDir + "/" + xml); + File xmlFile = new File(basedir + "/" + xml); String baseURL = null; try { baseURL = xmlFile.getParentFile().toURI().toURL().toExternalForm(); @@ -284,7 +284,7 @@ public class TestConverter { inputHandler = new InputHandler(xmlFile); } else { inputHandler = new InputHandler(xmlFile, - new File(baseDir + "/" + new File(basedir + "/" + xsl), null); } diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java index 58dd1fb5b..3aeac1215 100644 --- a/src/java/org/apache/fop/tools/anttasks/Fop.java +++ b/src/java/org/apache/fop/tools/anttasks/Fop.java @@ -85,7 +85,7 @@ public class Fop extends Task { * Sets the filename for the userconfig.xml. * @param userConfig Configuration to use */ - public void setUserconfig(File userConfig) { + public void setUserConfig(File userConfig) { this.userConfig = userConfig; } @@ -93,7 +93,7 @@ public class Fop extends Task { * Returns the file for the userconfig.xml. * @return the userconfig.xml file */ - public File getUserconfig() { + public File getUserConfig() { return this.userConfig; } @@ -101,7 +101,7 @@ public class Fop extends Task { * Sets the input XSL-FO file. * @param foFile input XSL-FO file */ - public void setFofile(File foFile) { + public void setFoFile(File foFile) { this.foFile = foFile; } @@ -109,7 +109,7 @@ public class Fop extends Task { * Gets the input XSL-FO file. * @return input XSL-FO file */ - public File getFofile() { + public File getFoFile() { return foFile; } @@ -267,7 +267,7 @@ public class Fop extends Task { * default is false. * @param throwExceptions true if exceptions should be thrown */ - public void setThrowexceptions(boolean throwExceptions) { + public void setThrowExceptions(boolean throwExceptions) { this.throwExceptions = throwExceptions; } @@ -275,7 +275,7 @@ public class Fop extends Task { * Gets the throw exceptions attribute * @return the throw exceptions attribute */ - public boolean getThrowexceptions() { + public boolean getThrowExceptions() { return this.throwExceptions; } @@ -408,8 +408,8 @@ class FOPTaskStarter { FOPTaskStarter(Fop task) throws SAXException, IOException { this.task = task; - if (task.getUserconfig() != null) { - fopFactory.setUserConfig(task.getUserconfig()); + if (task.getUserConfig() != null) { + fopFactory.setUserConfig(task.getUserConfig()); } } @@ -497,8 +497,8 @@ class FOPTaskStarter { } } else { try { - if (task.getFofile() != null) { - this.baseURL = task.getFofile().getParentFile().toURI().toURL(). + if (task.getFoFile() != null) { + this.baseURL = task.getFoFile().getParentFile().toURI().toURL(). toExternalForm(); } } catch (MalformedURLException mfue) { @@ -517,8 +517,8 @@ class FOPTaskStarter { int skippedcount = 0; // deal with single source file - if (task.getFofile() != null) { - if (task.getFofile().exists()) { + if (task.getFoFile() != null) { + if (task.getFoFile().exists()) { File outf = task.getOutfile(); if (outf == null) { throw new BuildException("outfile is required when fofile is used"); @@ -530,11 +530,11 @@ class FOPTaskStarter { // OR output file doesn't exist OR // output file is older than input file if (task.getForce() || !outf.exists() - || (task.getFofile().lastModified() > outf.lastModified() )) { - render(task.getFofile(), outf, outputFormat); + || (task.getFoFile().lastModified() > outf.lastModified() )) { + render(task.getFoFile(), outf, outputFormat); actioncount++; } else if (outf.exists() - && (task.getFofile().lastModified() <= outf.lastModified() )) { + && (task.getFoFile().lastModified() <= outf.lastModified() )) { skippedcount++; } } @@ -653,7 +653,7 @@ class FOPTaskStarter { inputHandler.renderTo(userAgent, outputFormat, out); success = true; } catch (Exception ex) { - if (task.getThrowexceptions()) { + if (task.getThrowExceptions()) { throw new BuildException(ex); } throw ex; diff --git a/src/java/org/apache/fop/traits/BorderProps.java b/src/java/org/apache/fop/traits/BorderProps.java index 25ac86ced..a76c6e8a3 100644 --- a/src/java/org/apache/fop/traits/BorderProps.java +++ b/src/java/org/apache/fop/traits/BorderProps.java @@ -34,6 +34,8 @@ import org.apache.fop.util.ColorUtil; */ public class BorderProps implements Serializable { + private static final long serialVersionUID = -886871454032189183L; + /** Separate border model */ public static final int SEPARATE = 0; /** Collapsing border model, for borders inside a table */ diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java index 8fe6c707f..21277d60a 100644 --- a/src/java/org/apache/fop/util/ColorUtil.java +++ b/src/java/org/apache/fop/util/ColorUtil.java @@ -53,7 +53,7 @@ public final class ColorUtil { private static Map colorMap = null; /** Logger instance */ - protected static Log log = LogFactory.getLog(ColorUtil.class); + protected static final Log log = LogFactory.getLog(ColorUtil.class); static { initializeColorMap(); -- cgit v1.2.3 From bf82c8fb0162ff0c8f31092b73756746b424c3a4 Mon Sep 17 00:00:00 2001 From: Simon Pepping Date: Fri, 19 Nov 2010 11:25:15 +0000 Subject: Reverting renaming of public methods of rev. 1036179 git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1036809 13f79535-47bb-0310-9956-ffa450edef68 --- .../embedding/java/embedding/ExampleFO2PDF.java | 4 +- .../embedding/java/embedding/MultipleFO2PDF.java | 4 +- .../org/apache/fop/apps/PageSequenceResults.java | 2 +- src/java/org/apache/fop/area/BlockParent.java | 3 - .../org/apache/fop/cli/CommandLineOptions.java | 206 ++++++++++----------- src/java/org/apache/fop/fo/FOText.java | 2 +- src/java/org/apache/fop/fonts/apps/PFMReader.java | 4 +- src/java/org/apache/fop/fonts/type1/PFMFile.java | 10 +- .../apache/fop/fonts/type1/Type1FontLoader.java | 4 +- .../fop/render/AbstractGenericSVGHandler.java | 2 +- src/java/org/apache/fop/render/XMLHandler.java | 2 +- .../org/apache/fop/render/XMLHandlerRegistry.java | 2 +- .../fop/render/afp/AFPRendererImageInfo.java | 2 +- .../fop/render/intermediate/IFSerializer.java | 8 +- .../intermediate/extensions/AbstractAction.java | 8 +- .../render/intermediate/extensions/ActionSet.java | 8 +- .../extensions/DocumentNavigationHandler.java | 2 +- .../intermediate/extensions/GoToXYAction.java | 8 +- .../render/intermediate/extensions/URIAction.java | 6 +- .../render/pdf/PDFDocumentNavigationHandler.java | 12 +- .../apache/fop/render/ps/PSImageFormResource.java | 2 +- .../org/apache/fop/render/ps/ResourceHandler.java | 2 +- .../fop/render/rtf/TextAttributesConverter.java | 2 +- .../org/apache/fop/render/xml/XMLXMLHandler.java | 2 +- src/java/org/apache/fop/tools/TestConverter.java | 18 +- src/java/org/apache/fop/tools/anttasks/Fop.java | 32 ++-- .../org/apache/fop/render/svg/SVGSVGHandler.java | 8 +- 27 files changed, 181 insertions(+), 184 deletions(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/examples/embedding/java/embedding/ExampleFO2PDF.java b/examples/embedding/java/embedding/ExampleFO2PDF.java index 20d27c128..6ae674908 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDF.java +++ b/examples/embedding/java/embedding/ExampleFO2PDF.java @@ -94,8 +94,8 @@ public class ExampleFO2PDF { for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getId()).length() > 0 - ? pageSequenceResults.getId() : "") + + (String.valueOf(pageSequenceResults.getID()).length() > 0 + ? pageSequenceResults.getID() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); diff --git a/examples/embedding/java/embedding/MultipleFO2PDF.java b/examples/embedding/java/embedding/MultipleFO2PDF.java index 0da9ae14c..a9ace7cf0 100644 --- a/examples/embedding/java/embedding/MultipleFO2PDF.java +++ b/examples/embedding/java/embedding/MultipleFO2PDF.java @@ -147,8 +147,8 @@ public class MultipleFO2PDF { for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getId()).length() > 0 - ? pageSequenceResults.getId() : "") + + (String.valueOf(pageSequenceResults.getID()).length() > 0 + ? pageSequenceResults.getID() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); diff --git a/src/java/org/apache/fop/apps/PageSequenceResults.java b/src/java/org/apache/fop/apps/PageSequenceResults.java index f94fe8fdb..241f4a5f9 100644 --- a/src/java/org/apache/fop/apps/PageSequenceResults.java +++ b/src/java/org/apache/fop/apps/PageSequenceResults.java @@ -44,7 +44,7 @@ public class PageSequenceResults { * * @return The ID */ - public String getId() { + public String getID() { return this.id; } diff --git a/src/java/org/apache/fop/area/BlockParent.java b/src/java/org/apache/fop/area/BlockParent.java index f2cf01cf2..18f9056da 100644 --- a/src/java/org/apache/fop/area/BlockParent.java +++ b/src/java/org/apache/fop/area/BlockParent.java @@ -27,9 +27,6 @@ import java.util.List; */ public class BlockParent extends Area { - /** - * - */ private static final long serialVersionUID = 7076916890348533805L; // this position is used for absolute position diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index eff7b76f0..2a5c0d272 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -89,23 +89,23 @@ public class CommandLineOptions { /* user configuration file */ private File userConfigFile = null; /* input fo file */ - private File foFile = null; + private File fofile = null; /* xsltfile (xslt transformation as input) */ - private File xsltFile = null; + private File xsltfile = null; /* xml file (xslt transformation as input) */ - private File xmlFile = null; + private File xmlfile = null; /* area tree input file */ - private File areatreeFile = null; + private File areatreefile = null; /* intermediate format input file */ - private File ifFile = null; + private File iffile = null; /* area tree input file */ - private File imageFile = null; + private File imagefile = null; /* output file */ - private File outFile = null; + private File outfile = null; /* input mode */ - private int inputMode = NOT_SET; + private int inputmode = NOT_SET; /* output mode */ - private String outputMode = null; + private String outputmode = null; /* true if System.in (stdin) should be used for the input file */ private boolean useStdIn = false; /* true if System.out (stdout) should be used for the output file */ @@ -194,7 +194,7 @@ public class CommandLineOptions { inputHandler = createInputHandler(); - if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputMode)) { + if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) { //set the system look&feel for the preview dialog try { UIManager.setLookAndFeel( @@ -207,7 +207,7 @@ public class CommandLineOptions { renderer.setRenderable(inputHandler); //set before user agent! renderer.setUserAgent(foUserAgent); foUserAgent.setRendererOverride(renderer); - } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputMode) + } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode) && mimicRenderer != null) { // render from FO to Intermediate Format Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer( @@ -220,7 +220,7 @@ public class CommandLineOptions { //Make sure the prepared XMLRenderer is used foUserAgent.setRendererOverride(xmlRenderer); - } else if (MimeConstants.MIME_FOP_IF.equals(outputMode) + } else if (MimeConstants.MIME_FOP_IF.equals(outputmode) && mimicRenderer != null) { // render from FO to Intermediate Format IFSerializer serializer = new IFSerializer(); @@ -447,7 +447,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - foFile = new File(filename); + fofile = new File(filename); } return 1; } @@ -460,7 +460,7 @@ public class CommandLineOptions { throw new FOPException("you must specify the stylesheet " + "file for the '-xsl' option"); } else { - xsltFile = new File(args[i + 1]); + xsltfile = new File(args[i + 1]); return 1; } } @@ -476,7 +476,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - xmlFile = new File(filename); + xmlfile = new File(filename); } return 1; } @@ -508,7 +508,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdOut = true; } else { - outFile = new File(filename); + outfile = new File(filename); } } @@ -701,16 +701,16 @@ public class CommandLineOptions { } private int parseUnknownOption(String[] args, int i) throws FOPException { - if (inputMode == NOT_SET) { - inputMode = FO_INPUT; + if (inputmode == NOT_SET) { + inputmode = FO_INPUT; String filename = args[i]; if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - foFile = new File(filename); + fofile = new File(filename); } - } else if (outputMode == null) { - outputMode = MimeConstants.MIME_PDF; + } else if (outputmode == null) { + outputmode = MimeConstants.MIME_PDF; setOutputFile(args[i]); } else { throw new FOPException("Don't know what to do with " @@ -765,7 +765,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - areatreeFile = new File(filename); + areatreefile = new File(filename); } return 1; } @@ -781,7 +781,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - ifFile = new File(filename); + iffile = new File(filename); } return 1; } @@ -797,7 +797,7 @@ public class CommandLineOptions { if (isSystemInOutFile(filename)) { this.useStdIn = true; } else { - imageFile = new File(filename); + imagefile = new File(filename); } return 1; } @@ -867,8 +867,8 @@ public class CommandLineOptions { } private void setOutputMode(String mime) throws FOPException { - if (outputMode == null) { - outputMode = mime; + if (outputmode == null) { + outputmode = mime; } else { throw new FOPException("you can only set one output method"); } @@ -896,8 +896,8 @@ public class CommandLineOptions { } private void setInputFormat(int format) throws FOPException { - if (inputMode == NOT_SET || inputMode == format) { - inputMode = format; + if (inputmode == NOT_SET || inputmode == format) { + inputmode = format; } else { throw new FOPException("Only one input mode can be specified!"); } @@ -907,100 +907,100 @@ public class CommandLineOptions { * checks whether all necessary information has been given in a consistent way */ private void checkSettings() throws FOPException, FileNotFoundException { - if (inputMode == NOT_SET) { + if (inputmode == NOT_SET) { throw new FOPException("No input file specified"); } - if (outputMode == null) { + if (outputmode == null) { throw new FOPException("No output file specified"); } - if ((outputMode.equals(MimeConstants.MIME_FOP_AWT_PREVIEW) - || outputMode.equals(MimeConstants.MIME_FOP_PRINT)) - && outFile != null) { + if ((outputmode.equals(MimeConstants.MIME_FOP_AWT_PREVIEW) + || outputmode.equals(MimeConstants.MIME_FOP_PRINT)) + && outfile != null) { throw new FOPException("Output file may not be specified " + "for AWT or PRINT output"); } - if (inputMode == XSLT_INPUT) { + if (inputmode == XSLT_INPUT) { // check whether xml *and* xslt file have been set - if (xmlFile == null && !this.useStdIn) { + if (xmlfile == null && !this.useStdIn) { throw new FOPException("XML file must be specified for the transform mode"); } - if (xsltFile == null) { + if (xsltfile == null) { throw new FOPException("XSLT file must be specified for the transform mode"); } // warning if fofile has been set in xslt mode - if (foFile != null) { + if (fofile != null) { log.warn("Can't use fo file with transform mode! Ignoring.\n" + "Your input is " + "\n xmlfile: " - + xmlFile.getAbsolutePath() + + xmlfile.getAbsolutePath() + "\nxsltfile: " - + xsltFile.getAbsolutePath() + + xsltfile.getAbsolutePath() + "\n fofile: " - + foFile.getAbsolutePath()); + + fofile.getAbsolutePath()); } - if (xmlFile != null && !xmlFile.exists()) { + if (xmlfile != null && !xmlfile.exists()) { throw new FileNotFoundException("Error: xml file " - + xmlFile.getAbsolutePath() + + xmlfile.getAbsolutePath() + " not found "); } - if (!xsltFile.exists()) { + if (!xsltfile.exists()) { throw new FileNotFoundException("Error: xsl file " - + xsltFile.getAbsolutePath() + + xsltfile.getAbsolutePath() + " not found "); } - } else if (inputMode == FO_INPUT) { - if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputmode == FO_INPUT) { + if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); } - if (foFile != null && !foFile.exists()) { + if (fofile != null && !fofile.exists()) { throw new FileNotFoundException("Error: fo file " - + foFile.getAbsolutePath() + + fofile.getAbsolutePath() + " not found "); } - } else if (inputMode == AREATREE_INPUT) { - if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputmode == AREATREE_INPUT) { + if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); - } else if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { + } else if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { throw new FOPException( "Area Tree Output is not available if Area Tree is used as input!"); } - if (areatreeFile != null && !areatreeFile.exists()) { + if (areatreefile != null && !areatreefile.exists()) { throw new FileNotFoundException("Error: area tree file " - + areatreeFile.getAbsolutePath() + + areatreefile.getAbsolutePath() + " not found "); } - } else if (inputMode == IF_INPUT) { - if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputmode == IF_INPUT) { + if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); - } else if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { + } else if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { throw new FOPException( "Area Tree Output is not available if Intermediate Format" + " is used as input!"); - } else if (outputMode.equals(MimeConstants.MIME_FOP_IF)) { + } else if (outputmode.equals(MimeConstants.MIME_FOP_IF)) { throw new FOPException( "Intermediate Output is not available if Intermediate Format" + " is used as input!"); } - if (ifFile != null && !ifFile.exists()) { + if (iffile != null && !iffile.exists()) { throw new FileNotFoundException("Error: intermediate format file " - + ifFile.getAbsolutePath() + + iffile.getAbsolutePath() + " not found "); } - } else if (inputMode == IMAGE_INPUT) { - if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { + } else if (inputmode == IMAGE_INPUT) { + if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { throw new FOPException( "FO output mode is only available if you use -xml and -xsl"); } - if (imageFile != null && !imageFile.exists()) { + if (imagefile != null && !imagefile.exists()) { throw new FileNotFoundException("Error: image file " - + imageFile.getAbsolutePath() + + imagefile.getAbsolutePath() + " not found "); } } @@ -1027,13 +1027,13 @@ public class CommandLineOptions { * @throws FOPException for invalid output formats */ protected String getOutputFormat() throws FOPException { - if (outputMode == null) { + if (outputmode == null) { throw new FOPException("Renderer has not been set!"); } - if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { + if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { renderingOptions.put("fineDetail", isCoarseAreaXml()); } - return outputMode; + return outputmode; } /** @@ -1042,21 +1042,21 @@ public class CommandLineOptions { * @throws IllegalArgumentException if invalid/missing parameters */ private InputHandler createInputHandler() { - switch (inputMode) { + switch (inputmode) { case FO_INPUT: - return new InputHandler(foFile); + return new InputHandler(fofile); case AREATREE_INPUT: - return new AreaTreeInputHandler(areatreeFile); + return new AreaTreeInputHandler(areatreefile); case IF_INPUT: - return new IFInputHandler(ifFile); + return new IFInputHandler(iffile); case XSLT_INPUT: - InputHandler handler = new InputHandler(xmlFile, xsltFile, xsltParams); + InputHandler handler = new InputHandler(xmlfile, xsltfile, xsltParams); if (useCatalogResolver) { handler.createCatalogResolver(foUserAgent); } return handler; case IMAGE_INPUT: - return new ImageInputHandler(imageFile, xsltFile, xsltParams); + return new ImageInputHandler(imagefile, xsltfile, xsltParams); default: throw new IllegalArgumentException("Error creating InputHandler object."); } @@ -1074,24 +1074,24 @@ public class CommandLineOptions { * Returns the XSL-FO file if set. * @return the XSL-FO file, null if not set */ - public File getFoFile() { - return foFile; + public File getFOFile() { + return fofile; } /** * Returns the input XML file if set. * @return the input XML file, null if not set */ - public File getXmlFile() { - return xmlFile; + public File getXMLFile() { + return xmlfile; } /** * Returns the stylesheet to be used for transformation to XSL-FO. * @return stylesheet */ - public File getXslFile() { - return xsltFile; + public File getXSLFile() { + return xsltfile; } /** @@ -1099,7 +1099,7 @@ public class CommandLineOptions { * @return the output file */ public File getOutputFile() { - return outFile; + return outfile; } /** @@ -1139,13 +1139,13 @@ public class CommandLineOptions { * @return either the fofile or the xmlfile */ public File getInputFile() { - switch (inputMode) { + switch (inputmode) { case FO_INPUT: - return foFile; + return fofile; case XSLT_INPUT: - return xmlFile; + return xmlfile; default: - return foFile; + return fofile; } } @@ -1270,7 +1270,7 @@ public class CommandLineOptions { */ private void dumpConfiguration() { log.info("Input mode: "); - switch (inputMode) { + switch (inputmode) { case NOT_SET: log.info("not set"); break; @@ -1279,7 +1279,7 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("fo input file: from stdin"); } else { - log.info("fo input file: " + foFile.toString()); + log.info("fo input file: " + fofile.toString()); } break; case XSLT_INPUT: @@ -1287,16 +1287,16 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("xml input file: from stdin"); } else { - log.info("xml input file: " + xmlFile.toString()); + log.info("xml input file: " + xmlfile.toString()); } - log.info("xslt stylesheet: " + xsltFile.toString()); + log.info("xslt stylesheet: " + xsltfile.toString()); break; case AREATREE_INPUT: log.info("AT "); if (isInputFromStdIn()) { log.info("area tree input file: from stdin"); } else { - log.info("area tree input file: " + areatreeFile.toString()); + log.info("area tree input file: " + areatreefile.toString()); } break; case IF_INPUT: @@ -1304,7 +1304,7 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("intermediate input file: from stdin"); } else { - log.info("intermediate input file: " + ifFile.toString()); + log.info("intermediate input file: " + iffile.toString()); } break; case IMAGE_INPUT: @@ -1312,28 +1312,28 @@ public class CommandLineOptions { if (isInputFromStdIn()) { log.info("image input file: from stdin"); } else { - log.info("image input file: " + imageFile.toString()); + log.info("image input file: " + imagefile.toString()); } break; default: log.info("unknown input type"); } log.info("Output mode: "); - if (outputMode == null) { + if (outputmode == null) { log.info("not set"); - } else if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputMode)) { + } else if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) { log.info("awt on screen"); - if (outFile != null) { + if (outfile != null) { log.error("awt mode, but outfile is set:"); - log.error("out file: " + outFile.toString()); + log.error("out file: " + outfile.toString()); } - } else if (MimeConstants.MIME_FOP_PRINT.equals(outputMode)) { + } else if (MimeConstants.MIME_FOP_PRINT.equals(outputmode)) { log.info("print directly"); - if (outFile != null) { + if (outfile != null) { log.error("print mode, but outfile is set:"); - log.error("out file: " + outFile.toString()); + log.error("out file: " + outfile.toString()); } - } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputMode)) { + } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode)) { log.info("area tree"); if (mimicRenderer != null) { log.info("mimic renderer: " + mimicRenderer); @@ -1341,17 +1341,17 @@ public class CommandLineOptions { if (isOutputToStdOut()) { log.info("output file: to stdout"); } else { - log.info("output file: " + outFile.toString()); + log.info("output file: " + outfile.toString()); } - } else if (MimeConstants.MIME_FOP_IF.equals(outputMode)) { + } else if (MimeConstants.MIME_FOP_IF.equals(outputmode)) { log.info("intermediate format"); - log.info("output file: " + outFile.toString()); + log.info("output file: " + outfile.toString()); } else { - log.info(outputMode); + log.info(outputmode); if (isOutputToStdOut()) { log.info("output file: to stdout"); } else { - log.info("output file: " + outFile.toString()); + log.info("output file: " + outfile.toString()); } } diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index c78421cbe..5db11f731 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -619,7 +619,7 @@ public class FOText extends FONode implements CharSequence { } /** @return the baseline-shift property */ - public Length getBaselineShift() { + public Length getBaseLineShift() { return baselineShift; } diff --git a/src/java/org/apache/fop/fonts/apps/PFMReader.java b/src/java/org/apache/fop/fonts/apps/PFMReader.java index bc294057b..e5e8ca524 100644 --- a/src/java/org/apache/fop/fonts/apps/PFMReader.java +++ b/src/java/org/apache/fop/fonts/apps/PFMReader.java @@ -173,7 +173,7 @@ public class PFMReader extends AbstractFontReader { public void preview(PFMFile pfm) { if (log != null && log.isInfoEnabled()) { log.info("Font: " + pfm.getWindowsName()); - log.info("Name: " + pfm.getPostScriptName()); + log.info("Name: " + pfm.getPostscriptName()); log.info("CharSet: " + pfm.getCharSetName()); log.info("CapHeight: " + pfm.getCapHeight()); log.info("XHeight: " + pfm.getXHeight()); @@ -217,7 +217,7 @@ public class PFMReader extends AbstractFontReader { Element el = doc.createElement("font-name"); root.appendChild(el); - el.appendChild(doc.createTextNode(pfm.getPostScriptName())); + el.appendChild(doc.createTextNode(pfm.getPostscriptName())); // Currently unused. // String s = pfm.getPostscriptName(); diff --git a/src/java/org/apache/fop/fonts/type1/PFMFile.java b/src/java/org/apache/fop/fonts/type1/PFMFile.java index b5faddac1..d1a3d79ff 100644 --- a/src/java/org/apache/fop/fonts/type1/PFMFile.java +++ b/src/java/org/apache/fop/fonts/type1/PFMFile.java @@ -38,7 +38,7 @@ public class PFMFile { // Header stuff private String windowsName; - private String postScriptName; + private String postscriptName; private short dfItalic; private int dfWeight; private short dfCharSet; @@ -164,7 +164,7 @@ public class PFMFile { inStream.reset(); inStream.skip(driverInfoOffset); - postScriptName = inStream.readString(); + postscriptName = inStream.readString(); if (extMetricsOffset != 0) { inStream.reset(); @@ -279,8 +279,8 @@ public class PFMFile { * * @return The Postscript name. */ - public String getPostScriptName() { - return postScriptName; + public String getPostscriptName() { + return postscriptName; } /** @@ -304,7 +304,7 @@ public class PFMFile { case 0: return "WinAnsi"; // AKA ISOAdobe case 2: - if ("Symbol".equals(getPostScriptName())) { + if ("Symbol".equals(getPostscriptName())) { return "Symbol"; } break; diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index 0c0c6187c..d5036de7b 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java @@ -226,8 +226,8 @@ public class Type1FontLoader extends FontLoader { names.add(afm.getFamilyName()); returnFont.setFamilyNames(names); } else { - returnFont.setFontName(pfm.getPostScriptName()); - String fullName = pfm.getPostScriptName(); + returnFont.setFontName(pfm.getPostscriptName()); + String fullName = pfm.getPostscriptName(); fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name returnFont.setFullName(fullName); //emulate afm.getFullName() Set names = new java.util.HashSet(); diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index f2c86b35f..392eb875e 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -178,7 +178,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC } /** {@inheritDoc} */ - public String getNameSpace() { + public String getNamespace() { return SVGDOMImplementation.SVG_NAMESPACE_URI; } diff --git a/src/java/org/apache/fop/render/XMLHandler.java b/src/java/org/apache/fop/render/XMLHandler.java index 1060bec51..f8152fcbf 100644 --- a/src/java/org/apache/fop/render/XMLHandler.java +++ b/src/java/org/apache/fop/render/XMLHandler.java @@ -60,6 +60,6 @@ public interface XMLHandler { * @return the XML namespace for the XML dialect this XMLHandler supports, * null if all XML content is handled by this instance. */ - String getNameSpace(); + String getNamespace(); } diff --git a/src/java/org/apache/fop/render/XMLHandlerRegistry.java b/src/java/org/apache/fop/render/XMLHandlerRegistry.java index 84177df45..81d9fcc93 100644 --- a/src/java/org/apache/fop/render/XMLHandlerRegistry.java +++ b/src/java/org/apache/fop/render/XMLHandlerRegistry.java @@ -85,7 +85,7 @@ public class XMLHandlerRegistry { * @param handler the XMLHandler instance */ public void addXMLHandler(XMLHandler handler) { - String ns = handler.getNameSpace(); + String ns = handler.getNamespace(); if (ns == null) { setDefaultXMLHandler(handler); } else { diff --git a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java index cffcf8a25..2687d9071 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java @@ -124,7 +124,7 @@ public class AFPRendererImageInfo { * * @return the uri */ - public String getUri() { + public String getURI() { return this.uri; } diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index dcc0d3523..edeef9766 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -668,8 +668,8 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler throw new NullPointerException("action must not be null"); } if (!action.isComplete()) { - assert action.hasId(); - incompleteActions.put(action.getId(), action); + assert action.hasID(); + incompleteActions.put(action.getID(), action); } } @@ -744,8 +744,8 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler /** {@inheritDoc} */ public void addResolvedAction(AbstractAction action) throws IFException { assert action.isComplete(); - assert action.hasId(); - AbstractAction noted = (AbstractAction)incompleteActions.remove(action.getId()); + assert action.hasID(); + AbstractAction noted = (AbstractAction)incompleteActions.remove(action.getID()); if (noted != null) { completeActions.add(action); } else { diff --git a/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java b/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java index 8d8a30cf6..340b2e068 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java @@ -33,7 +33,7 @@ public abstract class AbstractAction implements XMLizable { * Sets an ID to make the action referencable. * @param id the ID */ - public void setId(String id) { + public void setID(String id) { this.id = id; } @@ -41,7 +41,7 @@ public abstract class AbstractAction implements XMLizable { * Returns an optional ID for this action. * @return the ID or null */ - public String getId() { + public String getID() { return this.id; } @@ -65,7 +65,7 @@ public abstract class AbstractAction implements XMLizable { * Indicates whether the action has an ID and is therefore referencable. * @return true if the action has an ID */ - public boolean hasId() { + public boolean hasID() { return this.id != null; } @@ -90,7 +90,7 @@ public abstract class AbstractAction implements XMLizable { * Returns a string that is used to prefix a generated ID to make it unique. * @return the prefix string */ - public String getIdPrefix() { + public String getIDPrefix() { return null; } diff --git a/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java b/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java index 719d2225b..b980f1051 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/ActionSet.java @@ -39,7 +39,7 @@ public class ActionSet { */ public synchronized String generateNewID(AbstractAction action) { this.lastGeneratedID++; - String prefix = action.getIdPrefix(); + String prefix = action.getIDPrefix(); if (prefix == null) { throw new IllegalArgumentException("Action class is not compatible"); } @@ -62,12 +62,12 @@ public class ActionSet { * @return the action instance that should be used in place of the given one */ public AbstractAction put(AbstractAction action) { - if (!action.hasId()) { - action.setId(generateNewID(action)); + if (!action.hasID()) { + action.setID(generateNewID(action)); } AbstractAction effAction = normalize(action); if (effAction == action) { - this.actionRegistry.put(action.getId(), action); + this.actionRegistry.put(action.getID(), action); } return effAction; } diff --git a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java index 1d5bc23fe..1e613d7eb 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java @@ -132,7 +132,7 @@ public class DocumentNavigationHandler extends DefaultHandler boolean newWindow = "new".equals(showDestination); URIAction action = new URIAction(gotoURI, newWindow); if (id != null) { - action.setId(id); + action.setID(id); } if (structurePointer != null) { action.setStructurePointer(structurePointer); diff --git a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java index d905c7800..a2b4f31b6 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java @@ -52,7 +52,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx * or null, if the position isn't known, yet */ public GoToXYAction(String id, int pageIndex, Point targetLocation) { - setId(id); + setID(id); if (pageIndex < 0 && targetLocation != null) { throw new IllegalArgumentException( "Page index may not be null if target location is known!"); @@ -144,7 +144,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx AttributesImpl atts = new AttributesImpl(); if (this.isCompleteExceptTargetLocation()) { final Point reportedTargetLocation = this.getTargetLocation(); - atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getId()); + atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); atts.addAttribute(null, "page-index", "page-index", XMLUtil.CDATA, Integer.toString(pageIndex)); atts.addAttribute(null, "x", "x", XMLUtil.CDATA, @@ -152,7 +152,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx atts.addAttribute(null, "y", "y", XMLUtil.CDATA, Integer.toString(reportedTargetLocation.y)); } else { - atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getId()); + atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID()); } handler.startElement(GOTO_XY.getNamespaceURI(), GOTO_XY.getLocalName(), GOTO_XY.getQName(), atts); @@ -162,7 +162,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx /** {@inheritDoc} */ public String toString() { - return "GoToXY: ID=" + getId() + return "GoToXY: ID=" + getID() + ", page=" + getPageIndex() + ", loc=" + getTargetLocation() + ", " + (isComplete() ? "complete" : "INCOMPLETE"); diff --git a/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java b/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java index 4251619ff..22e7a270c 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java @@ -82,15 +82,15 @@ public class URIAction extends AbstractAction implements DocumentNavigationExten } /** {@inheritDoc} */ - public String getIdPrefix() { + public String getIDPrefix() { return "fop-" + GOTO_URI.getLocalName(); } /** {@inheritDoc} */ public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); - if (hasId()) { - atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getId()); + if (hasID()) { + atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); } atts.addAttribute(null, "uri", "uri", XMLUtil.CDATA, getURI()); if (isNewWindow()) { diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java index 4a51cb176..c215243a7 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java @@ -129,7 +129,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler /** {@inheritDoc} */ public void addResolvedAction(AbstractAction action) throws IFException { assert action.isComplete(); - PDFAction pdfAction = (PDFAction)this.incompleteActions.remove(action.getId()); + PDFAction pdfAction = (PDFAction)this.incompleteActions.remove(action.getID()); if (pdfAction == null) { getAction(action); } else if (pdfAction instanceof PDFGoTo) { @@ -145,11 +145,11 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler if (action == null) { return null; } - PDFAction pdfAction = (PDFAction)this.completeActions.get(action.getId()); + PDFAction pdfAction = (PDFAction)this.completeActions.get(action.getID()); if (pdfAction != null) { return pdfAction; } else if (action instanceof GoToXYAction) { - pdfAction = (PDFAction) incompleteActions.get(action.getId()); + pdfAction = (PDFAction) incompleteActions.get(action.getID()); if (pdfAction != null) { return pdfAction; } else { @@ -159,7 +159,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler if (action.isComplete()) { updateTargetLocation(pdfGoTo, a); } else { - this.incompleteActions.put(action.getId(), pdfGoTo); + this.incompleteActions.put(action.getID(), pdfGoTo); } return pdfGoTo; } @@ -173,7 +173,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler //Some PDF actions are pooled getPDFDoc().registerObject(pdfAction); } - this.completeActions.put(action.getId(), pdfAction); + this.completeActions.put(action.getID(), pdfAction); return pdfAction; } else { throw new UnsupportedOperationException("Unsupported action type: " @@ -195,7 +195,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler //Queue this object now that it's complete getPDFDoc().addObject(pdfGoTo); - this.completeActions.put(action.getId(), pdfGoTo); + this.completeActions.put(action.getID(), pdfGoTo); } } diff --git a/src/java/org/apache/fop/render/ps/PSImageFormResource.java b/src/java/org/apache/fop/render/ps/PSImageFormResource.java index 4c40c6f92..11c3205e6 100644 --- a/src/java/org/apache/fop/render/ps/PSImageFormResource.java +++ b/src/java/org/apache/fop/render/ps/PSImageFormResource.java @@ -53,7 +53,7 @@ public class PSImageFormResource extends PSResource { * Returns the image URI. * @return the image URI */ - public String getImageUri() { + public String getImageURI() { return this.uri; } diff --git a/src/java/org/apache/fop/render/ps/ResourceHandler.java b/src/java/org/apache/fop/render/ps/ResourceHandler.java index 06d6b9034..502242c17 100644 --- a/src/java/org/apache/fop/render/ps/ResourceHandler.java +++ b/src/java/org/apache/fop/render/ps/ResourceHandler.java @@ -281,7 +281,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { private void generateFormForImage(PSGenerator gen, PSImageFormResource form) throws IOException { - final String uri = form.getImageUri(); + final String uri = form.getImageURI(); ImageManager manager = userAgent.getFactory().getImageManager(); ImageInfo info = null; diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index 29bbecded..d377f740d 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -149,7 +149,7 @@ final class TextAttributesConverter { attrFont(fobj.getCommonFont(), attrib); attrFontColor(fobj.getColor(), attrib); attrTextDecoration(fobj.getTextDecoration(), attrib); - attrBaseLineShift(fobj.getBaselineShift(), attrib); + attrBaseLineShift(fobj.getBaseLineShift(), attrib); return attrib; } diff --git a/src/java/org/apache/fop/render/xml/XMLXMLHandler.java b/src/java/org/apache/fop/render/xml/XMLXMLHandler.java index f181e1911..d1cf1cf9a 100644 --- a/src/java/org/apache/fop/render/xml/XMLXMLHandler.java +++ b/src/java/org/apache/fop/render/xml/XMLXMLHandler.java @@ -48,7 +48,7 @@ public class XMLXMLHandler implements XMLHandler { } /** {@inheritDoc} */ - public String getNameSpace() { + public String getNamespace() { return null; //Handle all XML content } diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java index ba03ee567..0c6e09bd0 100644 --- a/src/java/org/apache/fop/tools/TestConverter.java +++ b/src/java/org/apache/fop/tools/TestConverter.java @@ -56,7 +56,7 @@ public class TestConverter { private String outputFormat = MimeConstants.MIME_FOP_AREA_TREE; private File destdir; private File compare = null; - private String basedir = "./"; + private String baseDir = "./"; private Map differ = new java.util.HashMap(); /** @@ -95,7 +95,7 @@ public class TestConverter { } else if (args[count].equals("-d")) { tc.setDebug(true); } else if (args[count].equals("-b")) { - tc.setBasedir(args[++count]); + tc.setBaseDir(args[++count]); } else if (args[count].equals("-results")) { results = args[++count]; } else { @@ -138,8 +138,8 @@ public class TestConverter { * Sets the base directory. * @param str base directory */ - public void setBasedir(String str) { - basedir = str; + public void setBaseDir(String str) { + baseDir = str; } /** @@ -167,11 +167,11 @@ public class TestConverter { logger.debug("running tests in file:" + fname); try { if (compDir != null) { - compare = new File(basedir + "/" + compDir); + compare = new File(baseDir + "/" + compDir); } - destdir = new File(basedir + "/" + dest); + destdir = new File(baseDir + "/" + dest); destdir.mkdirs(); - File f = new File(basedir + "/" + fname); + File f = new File(baseDir + "/" + fname); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder db = factory.newDocumentBuilder(); Document doc = db.parse(f); @@ -271,7 +271,7 @@ public class TestConverter { res = resNode.getNodeValue(); } try { - File xmlFile = new File(basedir + "/" + xml); + File xmlFile = new File(baseDir + "/" + xml); String baseURL = null; try { baseURL = xmlFile.getParentFile().toURI().toURL().toExternalForm(); @@ -284,7 +284,7 @@ public class TestConverter { inputHandler = new InputHandler(xmlFile); } else { inputHandler = new InputHandler(xmlFile, - new File(basedir + "/" + new File(baseDir + "/" + xsl), null); } diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java index 3aeac1215..58dd1fb5b 100644 --- a/src/java/org/apache/fop/tools/anttasks/Fop.java +++ b/src/java/org/apache/fop/tools/anttasks/Fop.java @@ -85,7 +85,7 @@ public class Fop extends Task { * Sets the filename for the userconfig.xml. * @param userConfig Configuration to use */ - public void setUserConfig(File userConfig) { + public void setUserconfig(File userConfig) { this.userConfig = userConfig; } @@ -93,7 +93,7 @@ public class Fop extends Task { * Returns the file for the userconfig.xml. * @return the userconfig.xml file */ - public File getUserConfig() { + public File getUserconfig() { return this.userConfig; } @@ -101,7 +101,7 @@ public class Fop extends Task { * Sets the input XSL-FO file. * @param foFile input XSL-FO file */ - public void setFoFile(File foFile) { + public void setFofile(File foFile) { this.foFile = foFile; } @@ -109,7 +109,7 @@ public class Fop extends Task { * Gets the input XSL-FO file. * @return input XSL-FO file */ - public File getFoFile() { + public File getFofile() { return foFile; } @@ -267,7 +267,7 @@ public class Fop extends Task { * default is false. * @param throwExceptions true if exceptions should be thrown */ - public void setThrowExceptions(boolean throwExceptions) { + public void setThrowexceptions(boolean throwExceptions) { this.throwExceptions = throwExceptions; } @@ -275,7 +275,7 @@ public class Fop extends Task { * Gets the throw exceptions attribute * @return the throw exceptions attribute */ - public boolean getThrowExceptions() { + public boolean getThrowexceptions() { return this.throwExceptions; } @@ -408,8 +408,8 @@ class FOPTaskStarter { FOPTaskStarter(Fop task) throws SAXException, IOException { this.task = task; - if (task.getUserConfig() != null) { - fopFactory.setUserConfig(task.getUserConfig()); + if (task.getUserconfig() != null) { + fopFactory.setUserConfig(task.getUserconfig()); } } @@ -497,8 +497,8 @@ class FOPTaskStarter { } } else { try { - if (task.getFoFile() != null) { - this.baseURL = task.getFoFile().getParentFile().toURI().toURL(). + if (task.getFofile() != null) { + this.baseURL = task.getFofile().getParentFile().toURI().toURL(). toExternalForm(); } } catch (MalformedURLException mfue) { @@ -517,8 +517,8 @@ class FOPTaskStarter { int skippedcount = 0; // deal with single source file - if (task.getFoFile() != null) { - if (task.getFoFile().exists()) { + if (task.getFofile() != null) { + if (task.getFofile().exists()) { File outf = task.getOutfile(); if (outf == null) { throw new BuildException("outfile is required when fofile is used"); @@ -530,11 +530,11 @@ class FOPTaskStarter { // OR output file doesn't exist OR // output file is older than input file if (task.getForce() || !outf.exists() - || (task.getFoFile().lastModified() > outf.lastModified() )) { - render(task.getFoFile(), outf, outputFormat); + || (task.getFofile().lastModified() > outf.lastModified() )) { + render(task.getFofile(), outf, outputFormat); actioncount++; } else if (outf.exists() - && (task.getFoFile().lastModified() <= outf.lastModified() )) { + && (task.getFofile().lastModified() <= outf.lastModified() )) { skippedcount++; } } @@ -653,7 +653,7 @@ class FOPTaskStarter { inputHandler.renderTo(userAgent, outputFormat, out); success = true; } catch (Exception ex) { - if (task.getThrowExceptions()) { + if (task.getThrowexceptions()) { throw new BuildException(ex); } throw ex; diff --git a/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java b/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java index ea73da0a1..c46c35b99 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java @@ -38,7 +38,7 @@ public class SVGSVGHandler implements XMLHandler, SVGRendererContextConstants { /** {@inheritDoc} */ public void handleXML(RendererContext context, org.w3c.dom.Document doc, String ns) throws Exception { - if (getNameSpace().equals(ns)) { + if (getNamespace().equals(ns)) { if (!(doc instanceof SVGDocument)) { DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); doc = DOMUtilities.deepCloneDocument(doc, impl); @@ -46,7 +46,7 @@ public class SVGSVGHandler implements XMLHandler, SVGRendererContextConstants { SVGSVGElement svg = ((SVGDocument) doc).getRootElement(); SVGDocument targetDoc = (SVGDocument)context.getProperty(SVG_DOCUMENT); SVGElement currentPageG = (SVGElement)context.getProperty(SVG_PAGE_G); - Element view = targetDoc.createElementNS(getNameSpace(), "svg"); + Element view = targetDoc.createElementNS(getNamespace(), "svg"); Node newsvg = targetDoc.importNode(svg, true); //view.setAttributeNS(null, "viewBox", "0 0 "); int xpos = ((Integer)context.getProperty(XPOS)).intValue(); @@ -57,7 +57,7 @@ public class SVGSVGHandler implements XMLHandler, SVGRendererContextConstants { // this fixes a problem where the xmlns is repeated sometimes Element ele = (Element) newsvg; ele.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", - getNameSpace()); + getNamespace()); if (ele.hasAttributeNS(null, "xmlns")) { ele.removeAttributeNS(null, "xmlns"); } @@ -74,7 +74,7 @@ public class SVGSVGHandler implements XMLHandler, SVGRendererContextConstants { } /** {@inheritDoc} */ - public String getNameSpace() { + public String getNamespace() { return SVGRenderer.MIME_TYPE; } -- cgit v1.2.3 From 55fbf510250ace0c4891060934da0c6bc61beb96 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Thu, 25 Nov 2010 21:04:09 +0000 Subject: Another go at removing all trailing whitespace git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1039179 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/hyphenation/UnicodeClasses.java | 28 ++++++++-------- .../unicode/java/org/apache/fop/util/License.java | 8 ++--- src/java/org/apache/fop/afp/AFPConstants.java | 4 +-- .../org/apache/fop/afp/AFPDataObjectFactory.java | 2 +- src/java/org/apache/fop/afp/fonts/AFPFontInfo.java | 6 ++-- .../org/apache/fop/afp/modca/GraphicsObject.java | 2 +- .../apache/fop/afp/modca/IncludePageOverlay.java | 4 +-- .../apache/fop/afp/modca/IncludePageSegment.java | 8 ++--- .../org/apache/fop/afp/modca/InterchangeSet.java | 28 ++++++++-------- .../org/apache/fop/afp/modca/InvokeMediumMap.java | 2 +- .../org/apache/fop/afp/modca/MapPageOverlay.java | 4 +-- src/java/org/apache/fop/afp/modca/PageSegment.java | 16 ++++----- .../apache/fop/afp/modca/TagLogicalElement.java | 6 ++-- .../fop/afp/modca/TagLogicalElementBean.java | 6 ++-- src/java/org/apache/fop/area/LineArea.java | 2 +- src/java/org/apache/fop/area/Trait.java | 2 +- src/java/org/apache/fop/area/inline/Image.java | 2 +- .../apache/fop/fo/properties/BreakPropertySet.java | 6 ++-- .../fop/fo/properties/DimensionPropertyMaker.java | 2 +- src/java/org/apache/fop/fonts/FontAdder.java | 4 +-- src/java/org/apache/fop/fonts/FontCache.java | 38 +++++++++++----------- src/java/org/apache/fop/fonts/FontDetector.java | 4 +-- src/java/org/apache/fop/fonts/FontManager.java | 6 ++-- .../apache/fop/fonts/FontManagerConfigurator.java | 2 +- src/java/org/apache/fop/fonts/Typeface.java | 4 +-- .../fop/hyphenation/HyphenationTreeCache.java | 4 +-- .../org/apache/fop/hyphenation/PatternParser.java | 12 +++---- .../fop/hyphenation/SerializeHyphPattern.java | 4 +-- .../apache/fop/layoutmgr/BreakingAlgorithm.java | 2 +- .../layoutmgr/inline/LeafNodeLayoutManager.java | 2 +- src/java/org/apache/fop/pdf/PDFObject.java | 2 +- .../apache/fop/render/AbstractConfigurator.java | 2 +- .../apache/fop/render/DummyPercentBaseContext.java | 2 +- .../afp/extensions/AFPInvokeMediumMapElement.java | 2 +- .../intermediate/extensions/GoToXYAction.java | 10 +++--- .../fop/render/pdf/AbstractImageAdapter.java | 2 +- .../apache/fop/render/pdf/PDFImageHandlerSVG.java | 2 +- .../org/apache/fop/render/ps/PSEventProducer.java | 2 +- .../fop/render/rtf/rtflib/rtfdoc/RtfPage.java | 2 +- .../render/rtf/rtflib/tools/BuilderContext.java | 2 +- .../org/apache/fop/render/mif/RefElement.java | 2 +- 41 files changed, 125 insertions(+), 125 deletions(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java b/src/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java index 263a1c694..467df6b3a 100644 --- a/src/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java +++ b/src/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java @@ -50,7 +50,7 @@ import org.apache.fop.util.License; * The methods fromJava and fromTeX are commented out because they are not Java 1.4 compliant. */ public final class UnicodeClasses { - + /** directory containing unicode properties files */ public static final String UNICODE_DIR = "http://www.unicode.org/Public/UNIDATA/"; @@ -73,7 +73,7 @@ public final class UnicodeClasses { w.write("\n"); w.write("\n"); } - + /** * Generate classes.xml from Java's compiled-in Unicode Character Database * @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) @@ -99,7 +99,7 @@ public final class UnicodeClasses { ow.write("\n"); // loop over the first Unicode plane for (int code = Character.MIN_VALUE; code <= maxChar; ++code) { - + // skip surrogate area if (code == Character.MIN_SURROGATE) { code = Character.MAX_SURROGATE; @@ -114,7 +114,7 @@ public final class UnicodeClasses { || Character.getType(code) == Character.OTHER_LETTER)) { continue; } - + // skip a number of blocks Character.UnicodeBlock ubi = Character.UnicodeBlock.of(code); if (ubi.equals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS) @@ -146,18 +146,18 @@ public final class UnicodeClasses { ow.flush(); ow.close(); } - - + + /** * The column numbers in the UCD file */ public static final int UNICODE = 0, GENERAL_CATEGORY = 2, SIMPLE_UPPERCASE_MAPPING = 12, SIMPLE_LOWERCASE_MAPPING = 13, SIMPLE_TITLECASE_MAPPING = 14, NUM_FIELDS = 15; - + /** * Generate classes.xml from Unicode Character Database files * @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) - * @param unidataPath path to the directory with UCD files + * @param unidataPath path to the directory with UCD files * @param outfilePath output file * @throws IOException if the input files are not found * @throws URISyntaxException if {@code unidataPath} cannot be converted to a URI @@ -175,7 +175,7 @@ public final class UnicodeClasses { throw new FileNotFoundException ("URI with file or http scheme required for UNIDATA input directory"); } - + File f = new File(outfilePath); if (f.exists()) { f.delete(); @@ -183,7 +183,7 @@ public final class UnicodeClasses { f.createNewFile(); FileOutputStream fw = new FileOutputStream(f); OutputStreamWriter ow = new OutputStreamWriter(fw, "utf-8"); - + URI inuri = unidata.resolve("Blocks.txt"); InputStream inis = null; if (scheme.equals("file")) { @@ -253,7 +253,7 @@ public final class UnicodeClasses { if (j < blockNames.length) { continue; } - + int uppercode = -1, titlecode = -1; if (!"".equals(fields[SIMPLE_UPPERCASE_MAPPING])) { uppercode = Integer.parseInt(fields[SIMPLE_UPPERCASE_MAPPING], 16); @@ -284,7 +284,7 @@ public final class UnicodeClasses { /** * Generate classes.xml from XeTeX's Unicode letters file * @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) - * @param lettersPath path to XeTeX's Unicode letters file unicode-letters-XeTeX.tex + * @param lettersPath path to XeTeX's Unicode letters file unicode-letters-XeTeX.tex * @param outfilePath output file * @throws IOException in case of an I/O exception */ @@ -345,7 +345,7 @@ public final class UnicodeClasses { inbr.close(); } - + /** * @param args [--hexcode] [--java|--ucd|--tex] outfile [infile] * @throws IOException if the input file cannot be found @@ -375,7 +375,7 @@ public final class UnicodeClasses { if (++i < args.length) { infile = args[i]; } - + if (type.equals("java") && infile != null) { System.err.println("Type java does not allow an infile"); System.exit(1); diff --git a/src/codegen/unicode/java/org/apache/fop/util/License.java b/src/codegen/unicode/java/org/apache/fop/util/License.java index ea28f6f09..0a9b6d339 100644 --- a/src/codegen/unicode/java/org/apache/fop/util/License.java +++ b/src/codegen/unicode/java/org/apache/fop/util/License.java @@ -28,7 +28,7 @@ import java.io.Writer; * Write the Apache license text in various forms */ public final class License { - + private License() { } @@ -56,10 +56,10 @@ public final class License { * The subversion Id keyword line */ public static final String ID = "$Id$"; - + /** * Calculate the maximum line length in the Apache license text - * for use in formatting + * for use in formatting */ private static int maxLength; static { @@ -103,7 +103,7 @@ public final class License { w.write("\n"); w.write("\n"); } - + /** * For testing purposes * @param args optional, --java or --xml diff --git a/src/java/org/apache/fop/afp/AFPConstants.java b/src/java/org/apache/fop/afp/AFPConstants.java index 3462ddfe6..6b26c18fd 100644 --- a/src/java/org/apache/fop/afp/AFPConstants.java +++ b/src/java/org/apache/fop/afp/AFPConstants.java @@ -39,13 +39,13 @@ public interface AFPConstants { * The encoding to use to convert to US ASCII (7 bit) */ String US_ASCII_ENCODING = "US-ASCII"; - + /** * The scaling of the default transform is set to * approximately 72 user space coordinates per square inch */ int DPI_72 = 72; - + /** * 72dpi in millipoints */ diff --git a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java index 58321e546..d7e8ea5f9 100644 --- a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java +++ b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java @@ -167,7 +167,7 @@ public class AFPDataObjectFactory { //set color converter (i.e. an rgb to grayscale converter) graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter()); - + // paint to graphics object Graphics2DImagePainter painter = graphicsObjectInfo.getPainter(); Rectangle2D area = graphicsObjectInfo.getArea(); diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java b/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java index 0259435c6..02e542419 100644 --- a/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java +++ b/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java @@ -32,7 +32,7 @@ public class AFPFontInfo { /** * Main constructor - * + * * @param afpFont The AFP Font * @param tripletList List of font triplets to associate with this font */ @@ -43,7 +43,7 @@ public class AFPFontInfo { /** * Returns the afp font - * + * * @return the afp font */ public AFPFont getAFPFont() { @@ -52,7 +52,7 @@ public class AFPFontInfo { /** * Returns the list of font triplets associated with this font. - * + * * @return List of font triplets */ public List/**/ getFontTriplets() { diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java index 11af83cab..0c3781be1 100644 --- a/src/java/org/apache/fop/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java @@ -386,7 +386,7 @@ public class GraphicsObject extends AbstractDataObject { /** the internal graphics state */ private static final class GraphicsState { - + private GraphicsState() { } diff --git a/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java b/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java index 44f0edc5b..5a3d13f61 100644 --- a/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java +++ b/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java @@ -56,7 +56,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject { /** * Constructor for the Include Page Overlay - * + * * @param overlayName Name of the page segment * @param x The x position * @param y The y position @@ -64,7 +64,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject { */ public IncludePageOverlay(String overlayName, int x, int y, int orientation) { super(overlayName); - + this.x = x; this.y = y; setOrientation(orientation); diff --git a/src/java/org/apache/fop/afp/modca/IncludePageSegment.java b/src/java/org/apache/fop/afp/modca/IncludePageSegment.java index 7355e3b1a..c6eceafea 100644 --- a/src/java/org/apache/fop/afp/modca/IncludePageSegment.java +++ b/src/java/org/apache/fop/afp/modca/IncludePageSegment.java @@ -46,22 +46,22 @@ public class IncludePageSegment extends AbstractNamedAFPObject { * The x position where we need to put this object on the page */ private int x; - + /** * The y position where we need to put this object on the page */ private int y; - + /** * Constructor for the Include Page Segment - * + * * @param name Name of the page segment * @param x The x position * @param y The y position */ public IncludePageSegment(String name, int x, int y) { super(name); - + this.x = x; this.y = y; } diff --git a/src/java/org/apache/fop/afp/modca/InterchangeSet.java b/src/java/org/apache/fop/afp/modca/InterchangeSet.java index f4b020239..35919af15 100644 --- a/src/java/org/apache/fop/afp/modca/InterchangeSet.java +++ b/src/java/org/apache/fop/afp/modca/InterchangeSet.java @@ -5,9 +5,9 @@ * 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. @@ -25,10 +25,10 @@ package org.apache.fop.afp.modca; public class InterchangeSet { /** interchange set 1 string value */ public static final String MODCA_PRESENTATION_INTERCHANGE_SET_1 = "MO:DCA-P IS/1"; - + /** interchange set 2 string value */ public static final String MODCA_PRESENTATION_INTERCHANGE_SET_2 = "MO:DCA-P IS/2"; - + /** resource interchange set string value */ public static final String MODCA_RESOURCE_INTERCHANGE_SET = "MO:DCA-L"; @@ -47,7 +47,7 @@ public class InterchangeSet { /** * Returns the interchange set value of a given string - * + * * @param str an interchange set value * @return an interchange set */ @@ -65,7 +65,7 @@ public class InterchangeSet { /** * Main constructor - * + * * @param value the interchange set value */ public InterchangeSet(int value) { @@ -74,39 +74,39 @@ public class InterchangeSet { /** * Returns true if complies with MOD:CA interchange set 1 - * + * * @return true if complies with MOD:CA interchange set 1 */ protected boolean is1() { return value == SET_1; } - + /** * Returns true if complies with MOD:CA interchange set 2 - * + * * @return true if complies with MOD:CA interchange set 2 */ public boolean is2() { return value == SET_2; } - + /** * Returns true if complies with MOD:CA resource set - * + * * @return true if complies with MOD:CA resource set */ public boolean isResource() { return value == RESOURCE_SET; } - + /** {@inheritDoc} */ public String toString() { return NAMES[value]; } - + /** * Returns true if MOD:CA interchange set 2 (resource groups) is supported - * + * * @return true if MOD:CA interchange set 2 (resource groups) is supported */ public boolean supportsLevel2() { diff --git a/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java b/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java index f910a0b9c..02031003b 100644 --- a/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java +++ b/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java @@ -34,7 +34,7 @@ public class InvokeMediumMap extends AbstractNamedAFPObject { /** * Constructor for the Invoke Medium Map - * + * * @param name the name of the medium map */ public InvokeMediumMap(String name) { diff --git a/src/java/org/apache/fop/afp/modca/MapPageOverlay.java b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java index 6f5855c93..cf22e3502 100644 --- a/src/java/org/apache/fop/afp/modca/MapPageOverlay.java +++ b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java @@ -35,7 +35,7 @@ import org.apache.fop.afp.util.BinaryUtils; public class MapPageOverlay extends AbstractAFPObject { private static final int MAX_SIZE = 253; - + /** * The collection of overlays (maximum of 254 stored as byte[]) */ @@ -53,7 +53,7 @@ public class MapPageOverlay extends AbstractAFPObject { } return this.overLays; } - + /** * Add an overlay to to the map page overlay object. * diff --git a/src/java/org/apache/fop/afp/modca/PageSegment.java b/src/java/org/apache/fop/afp/modca/PageSegment.java index b765d6c2f..333608d7f 100644 --- a/src/java/org/apache/fop/afp/modca/PageSegment.java +++ b/src/java/org/apache/fop/afp/modca/PageSegment.java @@ -5,9 +5,9 @@ * 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. @@ -32,10 +32,10 @@ import java.util.List; public class PageSegment extends AbstractNamedAFPObject { private List/**/ objects = null; - + /** * Main constructor - * + * * @param name the name of this object */ public PageSegment(String name) { @@ -44,7 +44,7 @@ public class PageSegment extends AbstractNamedAFPObject { /** * Returns a list of objects contained withing this page segment - * + * * @return a list of objects contained within this page segment */ public List/**/ getObjects() { @@ -56,13 +56,13 @@ public class PageSegment extends AbstractNamedAFPObject { /** * Adds a resource object (image/graphic) to this page segment - * + * * @param object the resource objec to add to this page segment */ public void addObject(AbstractAFPObject object) { getObjects().add(object); } - + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; @@ -82,7 +82,7 @@ public class PageSegment extends AbstractNamedAFPObject { copySF(data, Type.END, Category.PAGE_SEGMENT); os.write(data); } - + /** {@inheritDoc} */ public String toString() { return this.name; diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java index 12cb427ef..ab2c52143 100644 --- a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java +++ b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java @@ -102,11 +102,11 @@ public class TagLogicalElement extends AbstractTripletStructuredObject { FullyQualifiedNameTriplet.FORMAT_CHARSTR, name); setAttributeValue(value); - setAttributeQualifier(tleID, 1); - + setAttributeQualifier(tleID, 1); + byte[] data = new byte[SF_HEADER.length]; copySF(data, Type.ATTRIBUTE, Category.PROCESS_ELEMENT); - + int tripletDataLength = getTripletDataLength(); byte[] l = BinaryUtils.convert(data.length + tripletDataLength - 1, 2); data[1] = l[0]; diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java b/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java index 5d4523777..923a5d590 100644 --- a/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java +++ b/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java @@ -34,7 +34,7 @@ public class TagLogicalElementBean { /** * Constructor for the TagLogicalElementBean. - * + * * @param key the key attribute * @param value the value attribute */ @@ -45,7 +45,7 @@ public class TagLogicalElementBean { /** * Getter for the key attribute. - * + * * @return the key */ public String getKey() { @@ -54,7 +54,7 @@ public class TagLogicalElementBean { /** * Getter for the value attribute. - * + * * @return the value */ public String getValue() { diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index 4d622bcec..c89b5be5b 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -40,7 +40,7 @@ public class LineArea extends Area { * page-number or a page-number-citation is resolved */ private final class LineAdjustingInfo implements Serializable { - + private static final long serialVersionUID = -6103629976229458273L; private int lineAlignment; diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 4ad03b468..8114666bc 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -199,7 +199,7 @@ public final class Trait implements Serializable { public static final Integer OVERLINE_COLOR = new Integer(35); /** Trait for color of linethrough decorations when rendering inline parent. */ public static final Integer LINETHROUGH_COLOR = new Integer(36); - + /** The ptr trait. Used for accessibility */ public static final Integer PTR = new Integer(37); diff --git a/src/java/org/apache/fop/area/inline/Image.java b/src/java/org/apache/fop/area/inline/Image.java index baf3c183b..e6e355254 100644 --- a/src/java/org/apache/fop/area/inline/Image.java +++ b/src/java/org/apache/fop/area/inline/Image.java @@ -31,7 +31,7 @@ public class Image extends Area { private static final long serialVersionUID = 4800834714349695386L; private String url; - + /** * Create a new image with the given url. * diff --git a/src/java/org/apache/fop/fo/properties/BreakPropertySet.java b/src/java/org/apache/fop/fo/properties/BreakPropertySet.java index 2babe0f19..c70bc9fb2 100644 --- a/src/java/org/apache/fop/fo/properties/BreakPropertySet.java +++ b/src/java/org/apache/fop/fo/properties/BreakPropertySet.java @@ -5,9 +5,9 @@ * 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. @@ -29,5 +29,5 @@ public interface BreakPropertySet { /** @return the "break-before" property. */ int getBreakBefore(); - + } diff --git a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java index df8583089..0bef5e916 100644 --- a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java @@ -30,7 +30,7 @@ import org.apache.fop.fo.expr.PropertyException; * Window - Preferences - Java - Code Generation - Code and Comments */ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { - + private int[][] extraCorresponding = null; /** diff --git a/src/java/org/apache/fop/fonts/FontAdder.java b/src/java/org/apache/fop/fonts/FontAdder.java index f0e511c42..884a874a8 100644 --- a/src/java/org/apache/fop/fonts/FontAdder.java +++ b/src/java/org/apache/fop/fonts/FontAdder.java @@ -26,7 +26,7 @@ import java.util.List; import org.apache.fop.fonts.autodetect.FontInfoFinder; /** - * Adds a list of fonts to a given font info list + * Adds a list of fonts to a given font info list */ public class FontAdder { private FontEventListener listener; @@ -44,7 +44,7 @@ public class FontAdder { this.resolver = resolver; this.listener = listener; } - + /** * Iterates over font url list adding to font info list * @param fontURLList font file list diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index 29470a2a9..61eca0963 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -106,7 +106,7 @@ public final class FontCache implements Serializable { /** * Returns the default font cache file. - * + * * @param forWriting * true if the user directory should be created * @return the default font cache file @@ -133,7 +133,7 @@ public final class FontCache implements Serializable { /** * Reads the default font cache file and returns its contents. - * + * * @return the font cache deserialized from the file (or null if no cache * file exists or if it could not be read) */ @@ -143,7 +143,7 @@ public final class FontCache implements Serializable { /** * Reads a font cache file and returns its contents. - * + * * @param cacheFile * the cache file * @return the font cache deserialized from the file (or null if no cache @@ -186,7 +186,7 @@ public final class FontCache implements Serializable { /** * Writes the font cache to disk. - * + * * @throws FOPException * fop exception */ @@ -196,7 +196,7 @@ public final class FontCache implements Serializable { /** * Writes the font cache to disk. - * + * * @param cacheFile * the file to write to * @throws FOPException @@ -226,7 +226,7 @@ public final class FontCache implements Serializable { /** * creates a key given a font info for the font mapping - * + * * @param fontInfo * font info * @return font cache key @@ -242,7 +242,7 @@ public final class FontCache implements Serializable { /** * cache has been updated since it was read - * + * * @return if this cache has changed */ public boolean hasChanged() { @@ -251,7 +251,7 @@ public final class FontCache implements Serializable { /** * is this font in the cache? - * + * * @param embedUrl * font info * @return boolean @@ -262,7 +262,7 @@ public final class FontCache implements Serializable { /** * is this font info in the cache? - * + * * @param fontInfo * font info * @return font @@ -275,7 +275,7 @@ public final class FontCache implements Serializable { /** * Tries to identify a File instance from an array of URLs. If there's no * file URL in the array, the method returns null. - * + * * @param urls * array of possible font urls * @return file font file @@ -313,7 +313,7 @@ public final class FontCache implements Serializable { /** * Adds a font info to cache - * + * * @param fontInfo * font info */ @@ -346,7 +346,7 @@ public final class FontCache implements Serializable { /** * Returns a font from the cache. - * + * * @param embedUrl * font info * @return CachedFontFile object @@ -360,7 +360,7 @@ public final class FontCache implements Serializable { * Returns the EmbedFontInfo instances belonging to a font file. If the font * file was modified since it was cached the entry is removed and null is * returned. - * + * * @param embedUrl * the font URL * @param lastModified @@ -380,7 +380,7 @@ public final class FontCache implements Serializable { /** * removes font from cache - * + * * @param embedUrl * embed url */ @@ -398,7 +398,7 @@ public final class FontCache implements Serializable { /** * has this font previously failed to load? - * + * * @param embedUrl * embed url * @param lastModified @@ -425,7 +425,7 @@ public final class FontCache implements Serializable { /** * Registers a failed font with the cache - * + * * @param embedUrl * embed url * @param lastModified @@ -463,7 +463,7 @@ public final class FontCache implements Serializable { /** * Retrieve the last modified date/time of a URL. - * + * * @param url * the URL * @return the last modified date/time @@ -520,7 +520,7 @@ public final class FontCache implements Serializable { /** * Gets the modified timestamp for font file (not always available) - * + * * @return modified timestamp */ public long lastModified() { @@ -530,7 +530,7 @@ public final class FontCache implements Serializable { /** * Gets the modified timestamp for font file (used for the purposes of * font info caching) - * + * * @param lastModified * modified font file timestamp */ diff --git a/src/java/org/apache/fop/fonts/FontDetector.java b/src/java/org/apache/fop/fonts/FontDetector.java index 828cad2b5..5450b4ff9 100644 --- a/src/java/org/apache/fop/fonts/FontDetector.java +++ b/src/java/org/apache/fop/fonts/FontDetector.java @@ -41,7 +41,7 @@ public class FontDetector { private static final String[] FONT_MIMETYPES = { "application/x-font", "application/x-font-truetype" }; - + private FontManager fontManager; private FontAdder fontAdder; private boolean strict; @@ -75,7 +75,7 @@ public class FontDetector { List/**/ fontURLList = fontFileFinder.find( fontBase.getAbsolutePath()); fontAdder.add(fontURLList, fontInfoList); - + //Can only use the font base URL if it's a file URL } } catch (IOException e) { diff --git a/src/java/org/apache/fop/fonts/FontManager.java b/src/java/org/apache/fop/fonts/FontManager.java index 519dab6d5..44b2f030b 100644 --- a/src/java/org/apache/fop/fonts/FontManager.java +++ b/src/java/org/apache/fop/fonts/FontManager.java @@ -175,11 +175,11 @@ public class FontManager { } return fontCache; } - + /** * Saves the FontCache as necessary - * - * @throws FOPException fop exception + * + * @throws FOPException fop exception */ public void saveCache() throws FOPException { if (useCache) { diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java index 7792b118d..b0a4aada0 100644 --- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java @@ -85,7 +85,7 @@ public class FontManagerConfigurator { // global font configuration Configuration fontsCfg = cfg.getChild("fonts", false); if (fontsCfg != null) { - + // font substitution Configuration substitutionsCfg = fontsCfg.getChild("substitutions", false); if (substitutionsCfg != null) { diff --git a/src/java/org/apache/fop/fonts/Typeface.java b/src/java/org/apache/fop/fonts/Typeface.java index f4e317de3..f0419464c 100644 --- a/src/java/org/apache/fop/fonts/Typeface.java +++ b/src/java/org/apache/fop/fonts/Typeface.java @@ -139,9 +139,9 @@ public abstract class Typeface implements FontMetrics { } } } - + /** {@inheritDoc} */ public String toString() { return getFullName(); - } + } } diff --git a/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java b/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java index 40a44a942..00a622be5 100644 --- a/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java +++ b/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java @@ -73,7 +73,7 @@ public class HyphenationTreeCache { * @param lang the language * @param country the country (may be null or "none") * @param hyphPatNames the map of user-configured hyphenation pattern file names - * @return the hyphenation pattern file name or null + * @return the hyphenation pattern file name or null */ public static String constructUserKey(String lang, String country, Map hyphPatNames) { String userKey = null; @@ -84,7 +84,7 @@ public class HyphenationTreeCache { } return userKey; } - + /** * Cache a hyphenation tree under its key. * @param key the key (ex. "de_CH" or "en") diff --git a/src/java/org/apache/fop/hyphenation/PatternParser.java b/src/java/org/apache/fop/hyphenation/PatternParser.java index 4c4edd78e..404f10c7f 100644 --- a/src/java/org/apache/fop/hyphenation/PatternParser.java +++ b/src/java/org/apache/fop/hyphenation/PatternParser.java @@ -273,14 +273,14 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { parser = mainParser; } } - + // // ContentHandler methods // /** * {@inheritDoc} - * @throws SAXException + * @throws SAXException */ public void startElement(String uri, String local, String raw, Attributes attrs) throws SAXException { @@ -463,9 +463,9 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { public void addPattern(String p, String v) { testOut.println("pattern: " + p + " : " + v); } - + private PrintStream testOut = System.out; - + /** * Set test out stream. * @param testOut the testOut to set @@ -473,7 +473,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { public void setTestOut(PrintStream testOut) { this.testOut = testOut; } - + /** * Close test out file. */ @@ -503,5 +503,5 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { } } - + } diff --git a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java index d2a259db0..067e2009e 100644 --- a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java +++ b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java @@ -27,10 +27,10 @@ import java.io.ObjectOutputStream; /** * Serialize hyphenation patterns * For all xml files in the source directory a pattern file is built in the target directory - * This class may be called from the ant build file in a java task + * This class may be called from the ant build file in a java task */ public class SerializeHyphPattern { - + private boolean errorDump = false; /** diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java index 7ac23f74f..edea3aa79 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java @@ -59,7 +59,7 @@ public abstract class BreakingAlgorithm { /** Holder for symbolic literals for the fitness classes */ static final class FitnessClasses { - + private FitnessClasses() { } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java index c4a76f2f5..458110a89 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java @@ -91,7 +91,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager * @param ipd inline progression dimension * @param bHyph true if hyphenated * @param alignmentContext an alignment context - */ + */ public AreaInfo(short iLS, MinOptMax ipd, boolean bHyph, AlignmentContext alignmentContext) { iLScount = iLS; diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java index 4bb9a7d34..09b8673a8 100644 --- a/src/java/org/apache/fop/pdf/PDFObject.java +++ b/src/java/org/apache/fop/pdf/PDFObject.java @@ -401,7 +401,7 @@ public abstract class PDFObject implements PDFWritable { * identical, this method is not required to check everything. In the case * of PDFObjects, this means that the overriding function does not have to * check for {@link #getObjectID()}. - * + * * @param o * object to compare to. * @return true if the other object has the same content. diff --git a/src/java/org/apache/fop/render/AbstractConfigurator.java b/src/java/org/apache/fop/render/AbstractConfigurator.java index 874bb4d1b..4adc1451e 100644 --- a/src/java/org/apache/fop/render/AbstractConfigurator.java +++ b/src/java/org/apache/fop/render/AbstractConfigurator.java @@ -33,7 +33,7 @@ public abstract class AbstractConfigurator { protected static final Log log = LogFactory.getLog(AbstractConfigurator.class); private static final String MIME = "mime"; - + /** fop factory configuration */ protected FOUserAgent userAgent = null; diff --git a/src/java/org/apache/fop/render/DummyPercentBaseContext.java b/src/java/org/apache/fop/render/DummyPercentBaseContext.java index f9ecf63fe..c04c1d000 100644 --- a/src/java/org/apache/fop/render/DummyPercentBaseContext.java +++ b/src/java/org/apache/fop/render/DummyPercentBaseContext.java @@ -39,7 +39,7 @@ public final class DummyPercentBaseContext implements PercentBaseContext { public static DummyPercentBaseContext getInstance() { return singleton; } - + /** {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fo) { return 0; diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java index f36bd3e12..813cf6ddd 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java @@ -44,7 +44,7 @@ public class AFPInvokeMediumMapElement extends AbstractAFPExtensionObject { super.startOfNode(); if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { - + invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), "rule.childOfPageSequence"); } diff --git a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java index a2b4f31b6..4bd548c73 100644 --- a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java +++ b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java @@ -74,7 +74,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx *

* This function will always return a valid value for safety. Use * {@link #isComplete()} to check if the link is actually complete. - * + * * @return the page index (0-based) */ public int getPageIndex() { @@ -90,7 +90,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx *

* This function will always return a valid value for safety. Use * {@link #isComplete()} to check if the link is actually complete. - * + * * @return the target location (coordinates in millipoints) */ public Point getTargetLocation() { @@ -112,7 +112,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx private boolean isCompleteExceptTargetLocation() { return (getPageIndex() >= 0); } - + /** {@inheritDoc} */ public boolean isComplete() { return this.isCompleteExceptTargetLocation() && (this.targetLocation != null); @@ -147,9 +147,9 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); atts.addAttribute(null, "page-index", "page-index", XMLUtil.CDATA, Integer.toString(pageIndex)); - atts.addAttribute(null, "x", "x", XMLUtil.CDATA, + atts.addAttribute(null, "x", "x", XMLUtil.CDATA, Integer.toString(reportedTargetLocation.x)); - atts.addAttribute(null, "y", "y", XMLUtil.CDATA, + atts.addAttribute(null, "y", "y", XMLUtil.CDATA, Integer.toString(reportedTargetLocation.y)); } else { atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID()); diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java index 00dfdfa03..2130ef685 100644 --- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java +++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java @@ -134,7 +134,7 @@ public abstract class AbstractImageAdapter implements PDFImage { // sRGB hasn't been set up for the PDF document // so install but don't set to DefaultRGB cs = PDFICCBasedColorSpace.setupsRGBColorSpace(doc); - } + } pdfICCStream = cs.getICCStream(); } return pdfICCStream; diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java index 05726be22..d46621068 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java @@ -84,7 +84,7 @@ public class PDFImageHandlerSVG implements ImageHandler { userAgent.getFactory().getImageManager(), userAgent.getImageSessionContext(), new AffineTransform()); - + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) //to it. Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument()); diff --git a/src/java/org/apache/fop/render/ps/PSEventProducer.java b/src/java/org/apache/fop/render/ps/PSEventProducer.java index 512a4a687..702380a4d 100644 --- a/src/java/org/apache/fop/render/ps/PSEventProducer.java +++ b/src/java/org/apache/fop/render/ps/PSEventProducer.java @@ -29,7 +29,7 @@ public interface PSEventProducer extends EventProducer { /** Provider class for the event producer. */ final class Provider { - + private Provider() { } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java index 657900574..f014186ed 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java @@ -62,7 +62,7 @@ extends RtfContainer { public static final String FOOTERY = "footery"; /** constant for itap level */ public static final String ITAP = "itap"; - + /** String array of RtfPage attributes */ public static final String[] PAGE_ATTR = new String[]{ PAGE_WIDTH, PAGE_HEIGHT, LANDSCAPE, MARGIN_TOP, MARGIN_BOTTOM, diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java index 547c959d3..1591bbe26 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java @@ -111,7 +111,7 @@ public class BuilderContext { return result; } - /** + /** * Push an RtfContainer on our stack. * @param c the container */ diff --git a/src/sandbox/org/apache/fop/render/mif/RefElement.java b/src/sandbox/org/apache/fop/render/mif/RefElement.java index b23dffa2b..0849f4f69 100644 --- a/src/sandbox/org/apache/fop/render/mif/RefElement.java +++ b/src/sandbox/org/apache/fop/render/mif/RefElement.java @@ -38,7 +38,7 @@ public class RefElement extends MIFElement { super(name); } - /** + /** * @param key a key * @return an mif element */ -- cgit v1.2.3 From ce6d9e1eeef5f7b17fada9f07145e7e430586bf1 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 13 Dec 2010 14:49:56 +0000 Subject: Adjust to changes in XML Graphics Commons: - equals() to ColorUtil.isSameColor() - ICCColorSpaceExt to ICCColorSpaceWithIntent - int to RenderingIntent enum git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Color@1045155 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/afp/modca/GraphicsObject.java | 9 ++++++++- src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java | 4 ++-- src/java/org/apache/fop/apps/FopFactory.java | 14 +++++++++++--- .../org/apache/fop/fo/properties/ColorProperty.java | 9 ++++++++- src/java/org/apache/fop/pdf/PDFPaintingState.java | 20 +++++++++++++++++--- .../apache/fop/render/intermediate/IFSerializer.java | 15 ++++++++++++++- .../org/apache/fop/render/intermediate/IFState.java | 5 +++-- .../fop/render/java2d/Java2DGraphicsState.java | 15 ++++++++++++--- src/java/org/apache/fop/traits/BorderProps.java | 6 +++++- .../org/apache/fop/util/AbstractPaintingState.java | 10 ++++++---- src/java/org/apache/fop/util/ColorSpaceCache.java | 14 ++++++++------ src/java/org/apache/fop/util/ColorUtil.java | 16 +++++++++------- test/java/org/apache/fop/util/ColorUtilTestCase.java | 9 +++++---- 13 files changed, 108 insertions(+), 38 deletions(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java index b677a0f7c..350a602bf 100644 --- a/src/java/org/apache/fop/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java @@ -26,6 +26,7 @@ import java.util.Iterator; import java.util.List; import org.apache.xmlgraphics.java2d.color.ColorConverter; +import org.apache.xmlgraphics.java2d.color.ColorUtil; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; @@ -82,6 +83,7 @@ public class GraphicsObject extends AbstractDataObject { } /** {@inheritDoc} */ + @Override public void setViewport(AFPDataObjectInfo dataObjectInfo) { super.setViewport(dataObjectInfo); @@ -145,7 +147,7 @@ public class GraphicsObject extends AbstractDataObject { * @param color the active color to use */ public void setColor(Color color) { - if (!color.equals(graphicsState.color)) { + if (!ColorUtil.isSameColor(color, graphicsState.color)) { addObject(new GraphicsSetProcessColor(colorConverter.convert(color))); graphicsState.color = color; } @@ -341,6 +343,7 @@ public class GraphicsObject extends AbstractDataObject { } /** {@inheritDoc} */ + @Override public String toString() { return "GraphicsObject: " + getName(); } @@ -354,6 +357,7 @@ public class GraphicsObject extends AbstractDataObject { } /** {@inheritDoc} */ + @Override public void setComplete(boolean complete) { Iterator it = objects.iterator(); while (it.hasNext()) { @@ -364,6 +368,7 @@ public class GraphicsObject extends AbstractDataObject { } /** {@inheritDoc} */ + @Override protected void writeStart(OutputStream os) throws IOException { super.writeStart(os); byte[] data = new byte[17]; @@ -372,12 +377,14 @@ public class GraphicsObject extends AbstractDataObject { } /** {@inheritDoc} */ + @Override protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); writeObjects(objects, os); } /** {@inheritDoc} */ + @Override protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; copySF(data, Type.END, Category.GRAPHICS); diff --git a/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java b/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java index 054292cc1..2962dc76c 100644 --- a/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java +++ b/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java @@ -27,6 +27,7 @@ import java.io.OutputStream; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.xmlgraphics.java2d.color.CIELabColorSpace; +import org.apache.xmlgraphics.java2d.color.ColorUtil; import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives; /** @@ -314,8 +315,7 @@ public abstract class PtocaBuilder implements PtocaConstants { * @throws IOException if an I/O error occurs */ public void setExtendedTextColor(Color col) throws IOException { - //Check in both directions - if (col.equals(currentColor) && currentColor.equals(col)) { + if (ColorUtil.isSameColor(col, currentColor)) { return; } if (col instanceof ColorWithAlternatives) { diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java index 15279dc01..7e97442e6 100644 --- a/src/java/org/apache/fop/apps/FopFactory.java +++ b/src/java/org/apache/fop/apps/FopFactory.java @@ -40,7 +40,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.ImageContext; import org.apache.xmlgraphics.image.loader.ImageManager; -import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt; +import org.apache.xmlgraphics.java2d.color.RenderingIntent; import org.apache.fop.fo.ElementMapping; import org.apache.fop.fo.ElementMappingRegistry; @@ -157,6 +157,7 @@ public class FopFactory implements ImageContext { this.fontManager = new FontManager() { /** {@inheritDoc} */ + @Override public void setFontBaseURL(String fontBase) throws MalformedURLException { super.setFontBaseURL(getFOURIResolver().checkBaseURL(fontBase)); } @@ -373,6 +374,7 @@ public class FopFactory implements ImageContext { * @throws MalformedURLException if there's a problem with a file URL * @deprecated use getFontManager().setFontBaseURL(fontBase) instead */ + @Deprecated public void setFontBaseURL(String fontBase) throws MalformedURLException { getFontManager().setFontBaseURL(fontBase); } @@ -381,6 +383,7 @@ public class FopFactory implements ImageContext { * @return the font base URL * @deprecated use getFontManager().setFontBaseURL(fontBase) instead */ + @Deprecated public String getFontBaseURL() { return getFontManager().getFontBaseURL(); } @@ -491,6 +494,7 @@ public class FopFactory implements ImageContext { * @return true if kerning on base 14 fonts is enabled * @deprecated use getFontManager().isBase14KerningEnabled() instead */ + @Deprecated public boolean isBase14KerningEnabled() { return getFontManager().isBase14KerningEnabled(); } @@ -500,6 +504,7 @@ public class FopFactory implements ImageContext { * @param value true if kerning should be activated * @deprecated use getFontManager().setBase14KerningEnabled(boolean) instead */ + @Deprecated public void setBase14KerningEnabled(boolean value) { getFontManager().setBase14KerningEnabled(value); } @@ -708,6 +713,7 @@ public class FopFactory implements ImageContext { * @param useCache use cache or not * @deprecated use getFontManager().setUseCache(boolean) instead */ + @Deprecated public void setUseCache(boolean useCache) { getFontManager().setUseCache(useCache); } @@ -717,6 +723,7 @@ public class FopFactory implements ImageContext { * @return whether this factory is uses the cache * @deprecated use getFontManager().useCache() instead */ + @Deprecated public boolean useCache() { return getFontManager().useCache(); } @@ -726,6 +733,7 @@ public class FopFactory implements ImageContext { * @return the font cache * @deprecated use getFontManager().getFontCache() instead */ + @Deprecated public FontCache getFontCache() { return getFontManager().getFontCache(); } @@ -771,11 +779,11 @@ public class FopFactory implements ImageContext { * @param profileName the profile name * @param baseUri a base URI to resolve relative URIs * @param iccProfileSrc ICC Profile source to return a ColorSpace for - * @param renderingIntent overriding rendering intent (see {@link ICCColorSpaceExt}.*) + * @param renderingIntent overriding rendering intent * @return ICC ColorSpace object or null if ColorSpace could not be created */ public ColorSpace getColorSpace(String profileName, String baseUri, String iccProfileSrc, - int renderingIntent) { + RenderingIntent renderingIntent) { return colorSpaceCache.get(profileName, baseUri, iccProfileSrc, renderingIntent); } diff --git a/src/java/org/apache/fop/fo/properties/ColorProperty.java b/src/java/org/apache/fop/fo/properties/ColorProperty.java index 925d275af..4bbf94b74 100644 --- a/src/java/org/apache/fop/fo/properties/ColorProperty.java +++ b/src/java/org/apache/fop/fo/properties/ColorProperty.java @@ -69,6 +69,7 @@ public final class ColorProperty extends Property { * @throws PropertyException * for invalid or inconsistent FO input */ + @Override public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { @@ -118,11 +119,13 @@ public final class ColorProperty extends Property { * @param foUserAgent FOP user agent * @return float the AWT color represented by this ColorType instance */ + @Override public Color getColor(FOUserAgent foUserAgent) { return color; } /** {@inheritDoc} */ + @Override public String toString() { return ColorUtil.colorToString(color); } @@ -138,23 +141,27 @@ public final class ColorProperty extends Property { /** * @return this.colorType cast as an Object */ + @Override public Object getObject() { return this; } /** {@inheritDoc} */ + @Override public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof ColorProperty) { - return ((ColorProperty) o).color.equals(this.color); + return org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor( + ((ColorProperty) o).color, this.color); } return false; } /** {@inheritDoc} */ + @Override public int hashCode() { return this.color.hashCode(); } diff --git a/src/java/org/apache/fop/pdf/PDFPaintingState.java b/src/java/org/apache/fop/pdf/PDFPaintingState.java index ebe2b383b..29d022f61 100644 --- a/src/java/org/apache/fop/pdf/PDFPaintingState.java +++ b/src/java/org/apache/fop/pdf/PDFPaintingState.java @@ -19,12 +19,15 @@ package org.apache.fop.pdf; +import java.awt.Color; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import java.util.Iterator; +import org.apache.xmlgraphics.java2d.color.ColorUtil; + import org.apache.fop.util.AbstractPaintingState; /** @@ -63,13 +66,18 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState */ public boolean setPaint(Paint p) { PDFData data = getPDFData(); - Paint paint = data.paint; - if (paint == null) { + Paint currentPaint = data.paint; + if (currentPaint == null) { if (p != null) { data.paint = p; return true; } - } else if (!paint.equals(p)) { + } else if (p instanceof Color && currentPaint instanceof Color) { + if (!ColorUtil.isSameColor((Color)p, (Color)currentPaint)) { + data.paint = p; + return true; + } + } else if (!currentPaint.equals(p)) { data.paint = p; return true; } @@ -180,11 +188,13 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState } /** {@inheritDoc} */ + @Override protected AbstractData instantiateData() { return new PDFData(); } /** {@inheritDoc} */ + @Override protected AbstractPaintingState instantiate() { return new PDFPaintingState(); } @@ -194,6 +204,7 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState * This call should be used when the q operator is used * so that the state is known when popped. */ + @Override public void save() { AbstractData data = getData(); AbstractData copy = (AbstractData)data.clone(); @@ -222,6 +233,7 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState private float characterSpacing = 0f; /** {@inheritDoc} */ + @Override public Object clone() { PDFData obj = (PDFData)super.clone(); obj.paint = this.paint; @@ -237,6 +249,7 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState } /** {@inheritDoc} */ + @Override public String toString() { return super.toString() + ", paint=" + paint @@ -249,6 +262,7 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState } /** {@inheritDoc} */ + @Override protected AbstractData instantiate() { return new PDFData(); } diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index 37806cb8e..2c45bfcd6 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -33,6 +33,7 @@ import java.util.Map; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; + import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -75,6 +76,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override protected String getMainNamespace() { return NAMESPACE; } @@ -101,6 +103,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public IFDocumentNavigationHandler getDocumentNavigationHandler() { return this; } @@ -146,6 +149,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void startDocument() throws IFException { super.startDocument(); try { @@ -161,6 +165,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void startDocumentHeader() throws IFException { try { handler.startElement(EL_HEADER); @@ -170,6 +175,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void endDocumentHeader() throws IFException { try { handler.endElement(EL_HEADER); @@ -179,6 +185,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void startDocumentTrailer() throws IFException { try { handler.startElement(EL_TRAILER); @@ -188,6 +195,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void endDocumentTrailer() throws IFException { try { handler.endElement(EL_TRAILER); @@ -264,6 +272,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void startPageHeader() throws IFException { try { handler.startElement(EL_PAGE_HEADER); @@ -273,6 +282,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void endPageHeader() throws IFException { try { handler.endElement(EL_PAGE_HEADER); @@ -303,6 +313,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void startPageTrailer() throws IFException { try { handler.startElement(EL_PAGE_TRAILER); @@ -312,6 +323,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ + @Override public void endPageTrailer() throws IFException { try { commitNavigation(); @@ -604,7 +616,8 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } } if (color != null) { - changed = !color.equals(state.getTextColor()); + changed = !org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor( + color, state.getTextColor()); if (changed) { state.setTextColor(color); addAttribute(atts, "color", toString(color)); diff --git a/src/java/org/apache/fop/render/intermediate/IFState.java b/src/java/org/apache/fop/render/intermediate/IFState.java index 5d669d3ef..e5b031dd3 100644 --- a/src/java/org/apache/fop/render/intermediate/IFState.java +++ b/src/java/org/apache/fop/render/intermediate/IFState.java @@ -21,6 +21,8 @@ package org.apache.fop.render.intermediate; import java.awt.Color; +import org.apache.xmlgraphics.java2d.color.ColorUtil; + public class IFState { private IFState parent; @@ -178,8 +180,7 @@ public class IFState { * @param color the new text color */ public void setTextColor(Color color) { - //Check in both directions due to limitations of java.awt.Color - if (!color.equals(this.textColor) || !this.textColor.equals(color)) { + if (!ColorUtil.isSameColor(color, this.textColor)) { this.fontChanged = true; } this.textColor = color; diff --git a/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java b/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java index a40ee1d5c..b0c003b91 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java +++ b/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java @@ -28,6 +28,8 @@ import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.GeneralPath; +import org.apache.xmlgraphics.java2d.color.ColorUtil; + import org.apache.fop.fo.Constants; import org.apache.fop.fonts.FontInfo; @@ -103,7 +105,7 @@ public class Java2DGraphicsState { * @return true if the background color has changed */ public boolean updateColor(Color col) { - if (!col.equals(getGraph().getColor())) { + if (!ColorUtil.isSameColor(col, getGraph().getColor())) { getGraph().setColor(col); return true; } else { @@ -217,12 +219,18 @@ public class Java2DGraphicsState { * @return true if the new paint changes the current paint */ public boolean updatePaint(Paint p) { - if (getGraph().getPaint() == null) { + Paint currentPaint = getGraph().getPaint(); + if (currentPaint == null) { if (p != null) { getGraph().setPaint(p); return true; } - } else if (!p.equals(getGraph().getPaint())) { + } else if (p instanceof Color && currentPaint instanceof Color) { + if (!ColorUtil.isSameColor((Color)p, (Color)currentPaint)) { + getGraph().setPaint(p); + return true; + } + } else if (!p.equals(currentPaint)) { getGraph().setPaint(p); return true; } @@ -271,6 +279,7 @@ public class Java2DGraphicsState { } /** {@inheritDoc} */ + @Override public String toString() { String s = "Java2DGraphicsState " + currentGraphics.toString() + ", Stroke (width: " + currentStrokeWidth + " style: " diff --git a/src/java/org/apache/fop/traits/BorderProps.java b/src/java/org/apache/fop/traits/BorderProps.java index 5bd4feec5..d6265fb50 100644 --- a/src/java/org/apache/fop/traits/BorderProps.java +++ b/src/java/org/apache/fop/traits/BorderProps.java @@ -96,11 +96,13 @@ public class BorderProps implements Serializable { } /** {@inheritDoc} */ + @Override public int hashCode() { return toString().hashCode(); } /** {@inheritDoc} */ + @Override public boolean equals(Object obj) { if (obj == null) { return false; @@ -110,7 +112,8 @@ public class BorderProps implements Serializable { if (obj instanceof BorderProps) { BorderProps other = (BorderProps)obj; return (style == other.style) - && color.equals(other.color) + && org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor( + color, other.color) && width == other.width && mode == other.mode; } @@ -161,6 +164,7 @@ public class BorderProps implements Serializable { } /** {@inheritDoc} */ + @Override public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append('('); diff --git a/src/java/org/apache/fop/util/AbstractPaintingState.java b/src/java/org/apache/fop/util/AbstractPaintingState.java index a5280c361..bd1bbb87b 100644 --- a/src/java/org/apache/fop/util/AbstractPaintingState.java +++ b/src/java/org/apache/fop/util/AbstractPaintingState.java @@ -76,8 +76,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { */ public boolean setColor(Color col) { Color other = getData().color; - //Check in both directions due to limitations of java.awt.Color - if (!col.equals(other) || !other.equals(col)) { + if (!org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor(col, other)) { getData().color = col; return true; } @@ -117,8 +116,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { */ public boolean setBackColor(Color col) { Color other = getData().backColor; - //Check in both directions due to limitations of java.awt.Color - if (!col.equals(other) || !other.equals(col)) { + if (!org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor(col, other)) { getData().backColor = col; return true; } @@ -368,6 +366,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { } /** {@inheritDoc} */ + @Override public Object clone() { AbstractPaintingState state = instantiate(); state.stateStack = new StateStack(this.stateStack); @@ -376,6 +375,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { } /** {@inheritDoc} */ + @Override public String toString() { return ", stateStack=" + stateStack + ", currentData=" + data; @@ -509,6 +509,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { } /** {@inheritDoc} */ + @Override public Object clone() { AbstractData data = instantiate(); data.color = this.color; @@ -525,6 +526,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { } /** {@inheritDoc} */ + @Override public String toString() { return "color=" + color + ", backColor=" + backColor diff --git a/src/java/org/apache/fop/util/ColorSpaceCache.java b/src/java/org/apache/fop/util/ColorSpaceCache.java index e124232f3..645245003 100644 --- a/src/java/org/apache/fop/util/ColorSpaceCache.java +++ b/src/java/org/apache/fop/util/ColorSpaceCache.java @@ -31,7 +31,8 @@ import javax.xml.transform.stream.StreamSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt; +import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent; +import org.apache.xmlgraphics.java2d.color.RenderingIntent; /** * Map with cached ICC based ColorSpace objects. @@ -41,7 +42,8 @@ public class ColorSpaceCache { private static Log log = LogFactory.getLog(ColorSpaceCache.class); private URIResolver resolver; - private Map colorSpaceMap = Collections.synchronizedMap(new java.util.HashMap()); + private Map colorSpaceMap + = Collections.synchronizedMap(new java.util.HashMap()); /** * Default constructor @@ -63,11 +65,11 @@ public class ColorSpaceCache { * @param profileName the profile name * @param base a base URI to resolve relative URIs * @param iccProfileSrc ICC Profile source to return a ColorSpace for - * @param renderingIntent overriding rendering intent (see {@link ICCColorSpaceExt}.*) + * @param renderingIntent overriding rendering intent * @return ICC ColorSpace object or null if ColorSpace could not be created */ public ColorSpace get(String profileName, String base, String iccProfileSrc, - int renderingIntent) { + RenderingIntent renderingIntent) { String key = profileName + ":" + base + iccProfileSrc; ColorSpace colorSpace = null; if (!colorSpaceMap.containsKey(key)) { @@ -91,7 +93,7 @@ public class ColorSpaceCache { // iccProfile = ICC_Profile.getInstance(iccProfileSrc); } if (iccProfile != null) { - colorSpace = new ICCColorSpaceExt(iccProfile, renderingIntent, + colorSpace = new ICCColorSpaceWithIntent(iccProfile, renderingIntent, profileName, iccProfileSrc); } } catch (Exception e) { @@ -108,7 +110,7 @@ public class ColorSpaceCache { log.warn("Color profile '" + iccProfileSrc + "' not found."); } } else { - colorSpace = (ColorSpace)colorSpaceMap.get(key); + colorSpace = colorSpaceMap.get(key); } return colorSpace; } diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java index 608023b76..5a53a816c 100644 --- a/src/java/org/apache/fop/util/ColorUtil.java +++ b/src/java/org/apache/fop/util/ColorUtil.java @@ -34,8 +34,8 @@ import org.apache.xmlgraphics.java2d.color.ColorSpaceOrigin; import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives; import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; -import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt; import org.apache.xmlgraphics.java2d.color.NamedColorSpace; +import org.apache.xmlgraphics.java2d.color.RenderingIntent; import org.apache.xmlgraphics.java2d.color.profile.NamedColorProfile; import org.apache.xmlgraphics.java2d.color.profile.NamedColorProfileParser; @@ -69,7 +69,7 @@ public final class ColorUtil { * This map is used to predefine given colors, as well as speeding up * parsing of already parsed colors. */ - private static Map colorMap = null; + private static Map colorMap = null; /** Logger instance */ protected static Log log = LogFactory.getLog(ColorUtil.class); @@ -116,7 +116,7 @@ public final class ColorUtil { return null; } - Color parsedColor = (Color) colorMap.get(value.toLowerCase()); + Color parsedColor = colorMap.get(value.toLowerCase()); if (parsedColor == null) { if (value.startsWith("#")) { @@ -172,7 +172,7 @@ public final class ColorUtil { throw new PropertyException("Unknown color format: " + value + ". Must be system-color(x)"); } - return (Color) colorMap.get(value); + return colorMap.get(value); } /** @@ -408,7 +408,8 @@ public final class ColorUtil { /* Ask FOP factory to get ColorSpace for the specified ICC profile source */ if (foUserAgent != null && iccProfileSrc != null) { assert colorSpace == null; - int renderingIntent = ICCColorSpaceExt.AUTO; //TODO connect to fo:color-profile + RenderingIntent renderingIntent = RenderingIntent.AUTO; + //TODO connect to fo:color-profile/@rendering-intent colorSpace = foUserAgent.getFactory().getColorSpace(iccProfileName, foUserAgent.getBaseURL(), iccProfileSrc, renderingIntent); @@ -496,7 +497,8 @@ public final class ColorUtil { /* Ask FOP factory to get ColorSpace for the specified ICC profile source */ if (foUserAgent != null && iccProfileSrc != null) { - int renderingIntent = ICCColorSpaceExt.AUTO; //TODO connect to fo:color-profile + RenderingIntent renderingIntent = RenderingIntent.AUTO; + //TODO connect to fo:color-profile/@rendering-intent colorSpace = (ICC_ColorSpace)foUserAgent.getFactory().getColorSpace( iccProfileName, foUserAgent.getBaseURL(), iccProfileSrc, @@ -804,7 +806,7 @@ public final class ColorUtil { * Initializes the colorMap with some predefined values. */ private static void initializeColorMap() { - colorMap = Collections.synchronizedMap(new java.util.HashMap()); + colorMap = Collections.synchronizedMap(new java.util.HashMap()); colorMap.put("aliceblue", createColor(240, 248, 255)); colorMap.put("antiquewhite", createColor(250, 235, 215)); diff --git a/test/java/org/apache/fop/util/ColorUtilTestCase.java b/test/java/org/apache/fop/util/ColorUtilTestCase.java index 7721ae320..bc871794c 100644 --- a/test/java/org/apache/fop/util/ColorUtilTestCase.java +++ b/test/java/org/apache/fop/util/ColorUtilTestCase.java @@ -27,8 +27,8 @@ import junit.framework.TestCase; import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives; -import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt; import org.apache.xmlgraphics.java2d.color.NamedColorSpace; +import org.apache.xmlgraphics.java2d.color.RenderingIntent; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; @@ -89,7 +89,8 @@ public class ColorUtilTestCase extends TestCase { */ col2 = ColorUtil.parseColorString(null, "fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.5,0.5,0.5,0.0)"); - assertFalse(col1.equals(col2)); + assertTrue(col1.equals(col2)); + assertFalse(org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor(col1, col2)); } /** @@ -118,7 +119,7 @@ public class ColorUtilTestCase extends TestCase { URI sRGBLoc = new URI( "file:src/java/org/apache/fop/pdf/sRGB%20Color%20Space%20Profile.icm"); ColorSpace cs = fopFactory.getColorSpace("sRGBAlt", null, sRGBLoc.toASCIIString(), - ICCColorSpaceExt.AUTO); + RenderingIntent.AUTO); assertNotNull("Color profile not found", cs); FOUserAgent ua = fopFactory.newFOUserAgent(); @@ -265,7 +266,7 @@ public class ColorUtilTestCase extends TestCase { FopFactory fopFactory = FopFactory.newInstance(); URI ncpLoc = new URI("file:test/resources/color/ncp-example.icc"); ColorSpace cs = fopFactory.getColorSpace("NCP", null, ncpLoc.toASCIIString(), - ICCColorSpaceExt.AUTO); + RenderingIntent.AUTO); assertNotNull("Color profile not found", cs); FOUserAgent ua = fopFactory.newFOUserAgent(); -- cgit v1.2.3 From 5d664ac15dd06286fa9e221dddc946cf27585deb Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 14 Mar 2011 20:46:03 +0000 Subject: Bugzilla #49910: clipping rectangle is wrong on side-regions Partial fix that works only when the reference-orientation property is set to 0 or 180 on side-regions git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1081554 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/BlockViewport.java | 20 +++++---- src/java/org/apache/fop/area/RegionViewport.java | 14 ++++-- src/java/org/apache/fop/area/Viewport.java | 44 +++++++++++++++++++ src/java/org/apache/fop/area/inline/Viewport.java | 24 ++++++----- .../fop/render/AbstractPathOrientedRenderer.java | 10 ++--- .../org/apache/fop/render/AbstractRenderer.java | 9 ++-- .../apache/fop/render/intermediate/IFRenderer.java | 29 ++----------- .../apache/fop/render/java2d/Java2DRenderer.java | 2 +- .../org/apache/fop/render/txt/TXTRenderer.java | 3 +- .../org/apache/fop/render/xml/XMLRenderer.java | 10 ++--- test/java/org/apache/fop/StandardTestSuite.java | 2 + .../org/apache/fop/area/BlockViewportTestCase.java | 44 +++++++++++++++++++ .../apache/fop/area/RegionViewportTestCase.java | 50 ++++++++++++++++++++++ .../java/org/apache/fop/area/ViewportTestCase.java | 40 +++++++++++++++++ .../org/apache/fop/area/ViewportTestSuite.java | 47 ++++++++++++++++++++ .../fop/area/inline/InlineViewportTestCase.java | 46 ++++++++++++++++++++ 16 files changed, 331 insertions(+), 63 deletions(-) create mode 100644 src/java/org/apache/fop/area/Viewport.java create mode 100644 test/java/org/apache/fop/area/BlockViewportTestCase.java create mode 100644 test/java/org/apache/fop/area/RegionViewportTestCase.java create mode 100644 test/java/org/apache/fop/area/ViewportTestCase.java create mode 100644 test/java/org/apache/fop/area/ViewportTestSuite.java create mode 100644 test/java/org/apache/fop/area/inline/InlineViewportTestCase.java (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java index 032b39f95..770ff31fb 100644 --- a/src/java/org/apache/fop/area/BlockViewport.java +++ b/src/java/org/apache/fop/area/BlockViewport.java @@ -19,12 +19,14 @@ package org.apache.fop.area; +import java.awt.Rectangle; + /** * A BlockViewport. * This is used for block level Viewport/reference pairs. * The block-container creates this area. */ -public class BlockViewport extends Block { +public class BlockViewport extends Block implements Viewport { private static final long serialVersionUID = -7840580922580735157L; @@ -78,14 +80,16 @@ public class BlockViewport extends Block { clip = cl; } - /** - * Get the clipping for this viewport. - * - * @return the clipping for the viewport - * true if the contents should be clipped for this viewport - */ - public boolean getClip() { + public boolean hasClip() { return clip; } + + public Rectangle getClipRectangle() { + if (clip) { + return new Rectangle(getIPD(), getBPD()); + } else { + return null; + } + } } diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index 0654c5f6b..305dc5c10 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.java @@ -19,6 +19,7 @@ package org.apache.fop.area; +import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.util.HashMap; @@ -29,7 +30,7 @@ import java.util.HashMap; * region-reference-area as its child. These areas are described * in the fo:region-body description in the XSL Recommendation. */ -public class RegionViewport extends Area implements Cloneable { +public class RegionViewport extends Area implements Cloneable, Viewport { private static final long serialVersionUID = 505781815165102572L; @@ -75,11 +76,18 @@ public class RegionViewport extends Area implements Cloneable { clip = c; } - /** @return true if the viewport should be clipped. */ - public boolean isClip() { + public boolean hasClip() { return this.clip; } + public Rectangle getClipRectangle() { + if (clip) { + return new Rectangle(getIPD(), getBPD()); + } else { + return null; + } + } + /** * Get the view area of this viewport. * diff --git a/src/java/org/apache/fop/area/Viewport.java b/src/java/org/apache/fop/area/Viewport.java new file mode 100644 index 000000000..a92d826cc --- /dev/null +++ b/src/java/org/apache/fop/area/Viewport.java @@ -0,0 +1,44 @@ +/* + * 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.area; + +import java.awt.Rectangle; + +/** + * A viewport-area that may clip its content. + */ +public interface Viewport { + + /** + * Returns true if this area will clip overflowing content. + * + * @return {@code true} if the overflow trait has the value "hidden", "scroll" or + * "error-if-overflow" + */ + boolean hasClip(); + + /** + * Returns the clipping rectangle of this viewport area. + * + * @return the clipping rectangle expressed in the viewport's coordinate system, or + * null if clipping is disabled + */ + Rectangle getClipRectangle(); +} diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java index 206a965e2..610697c36 100644 --- a/src/java/org/apache/fop/area/inline/Viewport.java +++ b/src/java/org/apache/fop/area/inline/Viewport.java @@ -19,19 +19,20 @@ package org.apache.fop.area.inline; -import org.apache.fop.area.Area; - -import java.io.IOException; +import java.awt.Rectangle; import java.awt.geom.Rectangle2D; +import java.io.IOException; import java.util.HashMap; +import org.apache.fop.area.Area; + /** * Inline viewport area. * This is an inline-level viewport area for inline container, * external graphic and instream foreign object. This viewport * holds the area and positions it. */ -public class Viewport extends InlineArea { +public class Viewport extends InlineArea implements org.apache.fop.area.Viewport { private static final long serialVersionUID = 813338534627918689L; @@ -60,15 +61,18 @@ public class Viewport extends InlineArea { this.clip = c; } - /** - * Get the clip of this viewport. - * - * @return true if this viewport should clip - */ - public boolean getClip() { + public boolean hasClip() { return this.clip; } + public Rectangle getClipRectangle() { + if (clip) { + return new Rectangle(getIPD(), getBPD()); + } else { + return null; + } + } + /** * Set the position and size of the content of this viewport. * diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index cfce3a875..50a95b09a 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -542,7 +542,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { } //Clipping - if (bv.getClip()) { + if (bv.hasClip()) { clipRect(0f, 0f, width, height); } @@ -593,8 +593,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { //Now adjust for border/padding currentBPPosition += borderPaddingBefore; - Rectangle2D clippingRect = null; - if (bv.getClip()) { + Rectangle clippingRect = null; + if (bv.hasClip()) { clippingRect = new Rectangle(currentIPPosition, currentBPPosition, bv.getIPD(), bv.getBPD()); } @@ -701,14 +701,14 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { drawBackAndBorders(viewport, x, y, width + bpwidth, height + bpheight); - if (viewport.getClip()) { + if (viewport.hasClip()) { saveGraphicsState(); clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height); } super.renderViewport(viewport); - if (viewport.getClip()) { + if (viewport.hasClip()) { restoreGraphicsState(); } } diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 273f0bc16..4e0b13c56 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -278,7 +278,6 @@ public abstract class AbstractRenderer * @param port The region viewport to be rendered */ protected void renderRegionViewport(RegionViewport port) { - Rectangle2D view = port.getViewArea(); // The CTM will transform coordinates relative to // this region-reference area into page coords, so // set origin for the region to 0,0. @@ -289,7 +288,7 @@ public abstract class AbstractRenderer handleRegionTraits(port); // shouldn't the viewport have the CTM - startVParea(regionReference.getCTM(), port.isClip() ? view : null); + startVParea(regionReference.getCTM(), port.getClipRectangle()); // do after starting viewport area if (regionReference.getRegionClass() == FO_REGION_BODY) { renderBodyRegion((BodyRegion) regionReference); @@ -306,7 +305,7 @@ public abstract class AbstractRenderer * @param clippingRect the clipping rectangle if the viewport should be clipping, * null if no clipping is performed. */ - protected abstract void startVParea(CTM ctm, Rectangle2D clippingRect); + protected abstract void startVParea(CTM ctm, Rectangle clippingRect); /** * Signals exit from a viewport area. Subclasses can restore transformation matrices @@ -461,8 +460,8 @@ public abstract class AbstractRenderer int saveIP = currentIPPosition; int saveBP = currentBPPosition; - Rectangle2D clippingRect = null; - if (bv.getClip()) { + Rectangle clippingRect = null; + if (bv.hasClip()) { clippingRect = new Rectangle(saveIP, saveBP, bv.getIPD(), bv.getBPD()); } diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index 046d1703b..dfa2477b6 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -37,7 +37,6 @@ import java.util.Stack; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; - import org.xml.sax.SAXException; import org.apache.batik.parser.AWTTransformProducer; @@ -788,18 +787,11 @@ public class IFRenderer extends AbstractPathOrientedRenderer { contentRectTransform.translate(borderPaddingStart, borderPaddingBefore); concatenateTransformationMatrixMpt(contentRectTransform, false); - //Clipping - Rectangle clipRect = null; - if (bv.getClip()) { - clipRect = new Rectangle(0, 0, dim.width, dim.height); - //clipRect(0f, 0f, width, height); - } - //saveGraphicsState(); //Set up coordinate system for content rectangle AffineTransform contentTransform = ctm.toAffineTransform(); //concatenateTransformationMatrixMpt(contentTransform); - startViewport(contentTransform, clipRect); + startViewport(contentTransform, bv.getClipRectangle()); currentIPPosition = 0; currentBPPosition = 0; @@ -831,13 +823,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { //Now adjust for border/padding currentBPPosition += borderPaddingBefore; - Rectangle2D clippingRect = null; - if (bv.getClip()) { - clippingRect = new Rectangle(currentIPPosition, currentBPPosition, - bv.getIPD(), bv.getBPD()); - } - - startVParea(ctm, clippingRect); + startVParea(ctm, bv.getClipRectangle()); currentIPPosition = 0; currentBPPosition = 0; renderBlocks(bv, children); @@ -863,19 +849,12 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - protected void startVParea(CTM ctm, Rectangle2D clippingRect) { + protected void startVParea(CTM ctm, Rectangle clippingRect) { if (log.isTraceEnabled()) { log.trace("startVParea() ctm=" + ctm + ", clippingRect=" + clippingRect); } AffineTransform at = new AffineTransform(ctm.toArray()); - Rectangle clipRect = null; - if (clippingRect != null) { - clipRect = new Rectangle( - (int)clippingRect.getMinX() - currentIPPosition, - (int)clippingRect.getMinY() - currentBPPosition, - (int)clippingRect.getWidth(), (int)clippingRect.getHeight()); - } - startViewport(at, clipRect); + startViewport(at, clippingRect); if (log.isTraceEnabled()) { log.trace("startVPArea: " + at + " --> " + graphicContext.getTransform()); } diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 353aefa25..26f98ddd1 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -445,7 +445,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** {@inheritDoc} */ - protected void startVParea(CTM ctm, Rectangle2D clippingRect) { + protected void startVParea(CTM ctm, Rectangle clippingRect) { saveGraphicsState(); diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java index aa36ea28f..386f95838 100644 --- a/src/java/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java @@ -21,6 +21,7 @@ package org.apache.fop.render.txt; import java.awt.Color; import java.awt.Point; +import java.awt.Rectangle; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.io.IOException; @@ -560,7 +561,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { /** * {@inheritDoc} */ - protected void startVParea(CTM ctm, Rectangle2D clippingRect) { + protected void startVParea(CTM ctm, Rectangle clippingRect) { currentState.push(ctm); } diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 85995e8b2..a7f085d7f 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -21,6 +21,7 @@ package org.apache.fop.render.xml; // Java import java.awt.Color; +import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.OutputStream; @@ -518,7 +519,7 @@ public class XMLRenderer extends AbstractXMLRenderer { addAreaAttributes(port); addTraitAttributes(port); addAttribute("rect", port.getViewArea()); - if (port.isClip()) { + if (port.hasClip()) { addAttribute("clipped", "true"); } startElement("regionViewport", atts); @@ -558,9 +559,8 @@ public class XMLRenderer extends AbstractXMLRenderer { } } - /** {@inheritDoc} */ @Override - protected void startVParea(CTM ctm, Rectangle2D clippingRect) { + protected void startVParea(CTM ctm, Rectangle clippingRect) { //only necessary for graphical output } @@ -679,7 +679,7 @@ public class XMLRenderer extends AbstractXMLRenderer { addAttribute("top-position", bvp.getYOffset()); } addAttribute("ctm", bvp.getCTM().toString()); - if (bvp.getClip()) { + if (bvp.hasClip()) { addAttribute("clipped", "true"); } } else { @@ -749,7 +749,7 @@ public class XMLRenderer extends AbstractXMLRenderer { addTraitAttributes(viewport); addAttribute("offset", viewport.getOffset()); addAttribute("pos", viewport.getContentPosition()); - if (viewport.getClip()) { + if (viewport.hasClip()) { addAttribute("clip", "true"); } startElement("viewport", atts); diff --git a/test/java/org/apache/fop/StandardTestSuite.java b/test/java/org/apache/fop/StandardTestSuite.java index 61a9bdc5e..480ab8bd0 100644 --- a/test/java/org/apache/fop/StandardTestSuite.java +++ b/test/java/org/apache/fop/StandardTestSuite.java @@ -22,6 +22,7 @@ package org.apache.fop; import junit.framework.Test; import junit.framework.TestSuite; +import org.apache.fop.area.ViewportTestSuite; import org.apache.fop.fonts.DejaVuLGCSerifTest; import org.apache.fop.image.loader.batik.ImageLoaderTestCase; import org.apache.fop.image.loader.batik.ImagePreloaderTestCase; @@ -65,6 +66,7 @@ public class StandardTestSuite { suite.addTest(new TestSuite(PageBoundariesTest.class)); suite.addTest(new TestSuite(PageScaleTest.class)); suite.addTest(new TestSuite(MinOptMaxTest.class)); + suite.addTest(ViewportTestSuite.suite()); //$JUnit-END$ return suite; } diff --git a/test/java/org/apache/fop/area/BlockViewportTestCase.java b/test/java/org/apache/fop/area/BlockViewportTestCase.java new file mode 100644 index 000000000..a2a897322 --- /dev/null +++ b/test/java/org/apache/fop/area/BlockViewportTestCase.java @@ -0,0 +1,44 @@ +/* + * 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.area; + + +/** + * Tests the {@linkplain BlockViewport} class. + */ +public class BlockViewportTestCase extends ViewportTestCase { + + public void testNonClip() throws Exception { + BlockViewport bv = new BlockViewport(); + bv.setIPD(100); + bv.setBPD(50); + checkNonClip(bv); + } + + public void testClip() throws Exception { + BlockViewport bv = new BlockViewport(); + int ipd = 100; + int bpd = 50; + bv.setIPD(ipd); + bv.setBPD(bpd); + bv.setClip(true); + checkClip(bv, ipd, bpd); + } +} diff --git a/test/java/org/apache/fop/area/RegionViewportTestCase.java b/test/java/org/apache/fop/area/RegionViewportTestCase.java new file mode 100644 index 000000000..f55d08b66 --- /dev/null +++ b/test/java/org/apache/fop/area/RegionViewportTestCase.java @@ -0,0 +1,50 @@ +/* + * 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.area; + +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; + +/** + * Tests the {@linkplain RegionViewport} class. + */ +public class RegionViewportTestCase extends ViewportTestCase { + + private RegionViewport createRegionViewport(int x, int y, int ipd, int bpd) { + Rectangle2D v = new Rectangle(x, y, ipd, bpd); + RegionViewport viewport = new RegionViewport(v); + viewport.setIPD(ipd); + viewport.setBPD(bpd); + return viewport; + } + + public void testNonClip() throws Exception { + RegionViewport viewport = createRegionViewport(10, 10, 100, 20); + checkNonClip(viewport); + } + + public void testClip() throws Exception { + int ipd = 150; + int bpd = 20; + RegionViewport viewport = createRegionViewport(10, 10, ipd, bpd); + viewport.setClip(true); + checkClip(viewport, ipd, bpd); + } +} diff --git a/test/java/org/apache/fop/area/ViewportTestCase.java b/test/java/org/apache/fop/area/ViewportTestCase.java new file mode 100644 index 000000000..335ca2f8d --- /dev/null +++ b/test/java/org/apache/fop/area/ViewportTestCase.java @@ -0,0 +1,40 @@ +/* + * 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.area; + +import java.awt.Rectangle; + +import junit.framework.TestCase; + +/** + * Tests implementations of the {@linkplain Viewport} interface. + */ +public abstract class ViewportTestCase extends TestCase { + + protected void checkNonClip(Viewport v) throws Exception { + assertFalse(v.hasClip()); + assertNull(v.getClipRectangle()); + } + + protected void checkClip(Viewport v, int expectedWidth, int expectedHeight) throws Exception { + assertTrue(v.hasClip()); + assertEquals(new Rectangle(0, 0, expectedWidth, expectedHeight), v.getClipRectangle()); + } +} diff --git a/test/java/org/apache/fop/area/ViewportTestSuite.java b/test/java/org/apache/fop/area/ViewportTestSuite.java new file mode 100644 index 000000000..babbe8910 --- /dev/null +++ b/test/java/org/apache/fop/area/ViewportTestSuite.java @@ -0,0 +1,47 @@ +/* + * 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.area; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.fop.area.inline.InlineViewportTestCase; + +/** + * A suite of all the tests relating to the {@linkplain Viewport} interface. + */ +public final class ViewportTestSuite { + + private ViewportTestSuite() { } + + /** + * Returns the suite of {@linkplain Viewport} implementation tests. + * + * @return the tests + */ + public static Test suite() { + TestSuite suite = new TestSuite("Tests for viewport-areas"); + suite.addTestSuite(RegionViewportTestCase.class); + suite.addTestSuite(BlockViewportTestCase.class); + suite.addTestSuite(InlineViewportTestCase.class); + return suite; + } + +} diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java new file mode 100644 index 000000000..ccd866d64 --- /dev/null +++ b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java @@ -0,0 +1,46 @@ +/* + * 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.area.inline; + +import org.apache.fop.area.ViewportTestCase; + +/** + * Tests the {@linkplain Viewport} class. + */ +public class InlineViewportTestCase extends ViewportTestCase { + + public void testNonClip() throws Exception { + Viewport v = new Viewport(null); + v.setIPD(50); + v.setBPD(25); + checkNonClip(v); + } + + public void testClip() throws Exception { + Viewport v = new Viewport(null); + int ipd = 50; + int bpd = 25; + v.setIPD(ipd); + v.setBPD(bpd); + v.setClip(true); + checkClip(v, ipd, bpd); + } + +} -- cgit v1.2.3 From b8ac4207fe239a3433870691c79018b0137a30f6 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 15 Mar 2011 15:56:01 +0000 Subject: Renamed Viewport into InlineViewport Added {@inheritDoc} comments to make Checkstyle happy git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1081822 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/AreaTreeParser.java | 14 +- src/java/org/apache/fop/area/BlockViewport.java | 2 + src/java/org/apache/fop/area/RegionViewport.java | 2 + .../org/apache/fop/area/inline/FilledArea.java | 6 +- .../org/apache/fop/area/inline/InlineViewport.java | 141 +++++++++++++++++++++ src/java/org/apache/fop/area/inline/Viewport.java | 138 -------------------- .../layoutmgr/ExternalDocumentLayoutManager.java | 4 +- .../inline/AbstractGraphicsLayoutManager.java | 8 +- .../fop/render/AbstractPathOrientedRenderer.java | 6 +- .../org/apache/fop/render/AbstractRenderer.java | 8 +- .../apache/fop/render/intermediate/IFRenderer.java | 6 +- .../org/apache/fop/render/xml/XMLRenderer.java | 6 +- .../fop/area/inline/InlineViewportTestCase.java | 6 +- 13 files changed, 177 insertions(+), 170 deletions(-) create mode 100644 src/java/org/apache/fop/area/inline/InlineViewport.java delete mode 100644 src/java/org/apache/fop/area/inline/Viewport.java (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index 6c82257f3..d2f52f991 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -73,7 +73,7 @@ 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.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.area.inline.WordArea; import org.apache.fop.fo.ElementMappingRegistry; import org.apache.fop.fo.expr.PropertyException; @@ -217,7 +217,7 @@ public class AreaTreeParser { makers.put("word", new WordMaker()); makers.put("space", new SpaceMaker()); makers.put("leader", new LeaderMaker()); - makers.put("viewport", new ViewportMaker()); + makers.put("viewport", new InlineViewportMaker()); makers.put("image", new ImageMaker()); makers.put("foreignObject", new ForeignObjectMaker()); makers.put("bookmarkTree", new BookmarkTreeMaker()); @@ -265,8 +265,8 @@ public class AreaTreeParser { return (AbstractTextArea)findAreaType(AbstractTextArea.class); } - private Viewport getCurrentViewport() { - return (Viewport)findAreaType(Viewport.class); + private InlineViewport getCurrentViewport() { + return (InlineViewport)findAreaType(InlineViewport.class); } /** {@inheritDoc} */ @@ -902,10 +902,10 @@ public class AreaTreeParser { } } - private class ViewportMaker extends AbstractMaker { + private class InlineViewportMaker extends AbstractMaker { public void startElement(Attributes attributes) { - Viewport viewport = new Viewport(null); + InlineViewport viewport = new InlineViewport(null); transferForeignObjects(attributes, viewport); setAreaAttributes(attributes, viewport); setTraits(attributes, viewport, SUBSET_COMMON); @@ -921,7 +921,7 @@ public class AreaTreeParser { } public void endElement() { - assertObjectOfClass(areaStack.pop(), Viewport.class); + assertObjectOfClass(areaStack.pop(), InlineViewport.class); } } diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java index 770ff31fb..066f2f9e8 100644 --- a/src/java/org/apache/fop/area/BlockViewport.java +++ b/src/java/org/apache/fop/area/BlockViewport.java @@ -80,10 +80,12 @@ public class BlockViewport extends Block implements Viewport { clip = cl; } + /** {@inheritDoc} */ public boolean hasClip() { return clip; } + /** {@inheritDoc} */ public Rectangle getClipRectangle() { if (clip) { return new Rectangle(getIPD(), getBPD()); diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index 305dc5c10..6cc700a7b 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.java @@ -76,10 +76,12 @@ public class RegionViewport extends Area implements Cloneable, Viewport { clip = c; } + /** {@inheritDoc} */ public boolean hasClip() { return this.clip; } + /** {@inheritDoc} */ public Rectangle getClipRectangle() { if (clip) { return new Rectangle(getIPD(), getBPD()); diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java index 858951f75..e0207ada6 100644 --- a/src/java/org/apache/fop/area/inline/FilledArea.java +++ b/src/java/org/apache/fop/area/inline/FilledArea.java @@ -19,10 +19,10 @@ package org.apache.fop.area.inline; -import java.util.List; -import java.util.ListIterator; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; /** * Filled area. @@ -60,7 +60,7 @@ public class FilledArea extends InlineParent { InlineArea child = (InlineArea) childrenIterator.next(); if (child instanceof InlineParent) { setChildOffset(((InlineParent) child).getChildAreas().listIterator(), v); - } else if (child instanceof org.apache.fop.area.inline.Viewport) { + } else if (child instanceof InlineViewport) { // nothing } else { child.setOffset(v); diff --git a/src/java/org/apache/fop/area/inline/InlineViewport.java b/src/java/org/apache/fop/area/inline/InlineViewport.java new file mode 100644 index 000000000..68cc9a797 --- /dev/null +++ b/src/java/org/apache/fop/area/inline/InlineViewport.java @@ -0,0 +1,141 @@ +/* + * 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.area.inline; + +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.util.HashMap; + +import org.apache.fop.area.Area; +import org.apache.fop.area.Viewport; + +/** + * Inline viewport area. + * This is an inline-level viewport area for inline container, + * external graphic and instream foreign object. This viewport + * holds the area and positions it. + */ +public class InlineViewport extends InlineArea implements Viewport { + + private static final long serialVersionUID = 813338534627918689L; + + // contents could be container, foreign object or image + private Area content; + // clipping for the viewport + private boolean clip = false; + // position of the child area relative to this area + private Rectangle2D contentPosition; + + /** + * Create a new viewport area with the content area. + * + * @param child the child content area of this viewport + */ + public InlineViewport(Area child) { + this.content = child; + } + + /** + * Set the clip of this viewport. + * + * @param c true if this viewport should clip + */ + public void setClip(boolean c) { + this.clip = c; + } + + /** {@inheritDoc} */ + public boolean hasClip() { + return this.clip; + } + + /** {@inheritDoc} */ + public Rectangle getClipRectangle() { + if (clip) { + return new Rectangle(getIPD(), getBPD()); + } else { + return null; + } + } + + /** + * Set the position and size of the content of this viewport. + * + * @param cp the position and size to place the content + */ + public void setContentPosition(Rectangle2D cp) { + this.contentPosition = cp; + } + + /** + * Get the position and size of the content of this viewport. + * + * @return the position and size to place the content + */ + public Rectangle2D getContentPosition() { + return this.contentPosition; + } + + /** + * Sets the content area. + * @param content the content area + */ + public void setContent(Area content) { + this.content = content; + } + + /** + * Get the content area for this viewport. + * + * @return the content area + */ + public Area getContent() { + return this.content; + } + + private void writeObject(java.io.ObjectOutputStream out) + throws IOException { + out.writeBoolean(contentPosition != null); + if (contentPosition != null) { + out.writeFloat((float) contentPosition.getX()); + out.writeFloat((float) contentPosition.getY()); + out.writeFloat((float) contentPosition.getWidth()); + out.writeFloat((float) contentPosition.getHeight()); + } + out.writeBoolean(clip); + out.writeObject(props); + out.writeObject(content); + } + + private void readObject(java.io.ObjectInputStream in) + throws IOException, ClassNotFoundException { + if (in.readBoolean()) { + contentPosition = new Rectangle2D.Float(in.readFloat(), + in.readFloat(), + in.readFloat(), + in.readFloat()); + } + this.clip = in.readBoolean(); + this.props = (HashMap) in.readObject(); + this.content = (Area) in.readObject(); + } + +} diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java deleted file mode 100644 index 610697c36..000000000 --- a/src/java/org/apache/fop/area/inline/Viewport.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.area.inline; - -import java.awt.Rectangle; -import java.awt.geom.Rectangle2D; -import java.io.IOException; -import java.util.HashMap; - -import org.apache.fop.area.Area; - -/** - * Inline viewport area. - * This is an inline-level viewport area for inline container, - * external graphic and instream foreign object. This viewport - * holds the area and positions it. - */ -public class Viewport extends InlineArea implements org.apache.fop.area.Viewport { - - private static final long serialVersionUID = 813338534627918689L; - - // contents could be container, foreign object or image - private Area content; - // clipping for the viewport - private boolean clip = false; - // position of the child area relative to this area - private Rectangle2D contentPosition; - - /** - * Create a new viewport area with the content area. - * - * @param child the child content area of this viewport - */ - public Viewport(Area child) { - this.content = child; - } - - /** - * Set the clip of this viewport. - * - * @param c true if this viewport should clip - */ - public void setClip(boolean c) { - this.clip = c; - } - - public boolean hasClip() { - return this.clip; - } - - public Rectangle getClipRectangle() { - if (clip) { - return new Rectangle(getIPD(), getBPD()); - } else { - return null; - } - } - - /** - * Set the position and size of the content of this viewport. - * - * @param cp the position and size to place the content - */ - public void setContentPosition(Rectangle2D cp) { - this.contentPosition = cp; - } - - /** - * Get the position and size of the content of this viewport. - * - * @return the position and size to place the content - */ - public Rectangle2D getContentPosition() { - return this.contentPosition; - } - - /** - * Sets the content area. - * @param content the content area - */ - public void setContent(Area content) { - this.content = content; - } - - /** - * Get the content area for this viewport. - * - * @return the content area - */ - public Area getContent() { - return this.content; - } - - private void writeObject(java.io.ObjectOutputStream out) - throws IOException { - out.writeBoolean(contentPosition != null); - if (contentPosition != null) { - out.writeFloat((float) contentPosition.getX()); - out.writeFloat((float) contentPosition.getY()); - out.writeFloat((float) contentPosition.getWidth()); - out.writeFloat((float) contentPosition.getHeight()); - } - out.writeBoolean(clip); - out.writeObject(props); - out.writeObject(content); - } - - private void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException { - if (in.readBoolean()) { - contentPosition = new Rectangle2D.Float(in.readFloat(), - in.readFloat(), - in.readFloat(), - in.readFloat()); - } - this.clip = in.readBoolean(); - this.props = (HashMap) in.readObject(); - this.content = (Area) in.readObject(); - } - -} diff --git a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java index d807aee2d..9fb832da3 100644 --- a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java @@ -45,7 +45,7 @@ import org.apache.fop.area.PageSequence; import org.apache.fop.area.PageViewport; import org.apache.fop.area.RegionViewport; import org.apache.fop.area.inline.Image; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.datatypes.FODimension; import org.apache.fop.datatypes.URISpecification; import org.apache.fop.fo.Constants; @@ -184,7 +184,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan TraitSetter.setProducerID(imageArea, fobj.getId()); transferForeignAttributes(imageArea); - Viewport vp = new Viewport(imageArea); + InlineViewport vp = new InlineViewport(imageArea); TraitSetter.setProducerID(vp, fobj.getId()); vp.setIPD(imageSize.width); vp.setBPD(imageSize.height); diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java index fd4d803af..218497a53 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java @@ -24,7 +24,7 @@ import java.awt.Rectangle; import java.util.List; import org.apache.fop.area.Area; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.datatypes.LengthBase; import org.apache.fop.fo.FObj; import org.apache.fop.fo.flow.AbstractGraphics; @@ -54,7 +54,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage * * @return the viewport inline area */ - private Viewport getInlineArea() { + private InlineViewport getInlineArea() { final AbstractGraphics fobj = (AbstractGraphics)this.fobj; Dimension intrinsicSize = new Dimension( fobj.getIntrinsicWidth(), @@ -84,7 +84,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage TraitSetter.setProducerID(viewportArea, fobj.getId()); transferForeignAttributes(viewportArea); - Viewport vp = new Viewport(viewportArea); + InlineViewport vp = new InlineViewport(viewportArea); TraitSetter.addPtr(vp, fobj.getPtr()); // used for accessibility TraitSetter.setProducerID(vp, fobj.getId()); vp.setIPD(imageLayout.getViewportSize().width); @@ -106,7 +106,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - Viewport areaCurrent = getInlineArea(); + InlineViewport areaCurrent = getInlineArea(); setCurrentArea(areaCurrent); return super.getNextKnuthElements(context, alignment); } diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index 50a95b09a..45a02a977 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -44,7 +44,7 @@ import org.apache.fop.area.RegionViewport; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fonts.FontMetrics; @@ -685,7 +685,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * This renders an inline viewport by clipping if necessary. * @param viewport the viewport to handle */ - public void renderViewport(Viewport viewport) { + public void renderInlineViewport(InlineViewport viewport) { float x = currentIPPosition / 1000f; float y = (currentBPPosition + viewport.getOffset()) / 1000f; @@ -706,7 +706,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height); } - super.renderViewport(viewport); + super.renderInlineViewport(viewport); if (viewport.hasClip()) { restoreGraphicsState(); diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 4e0b13c56..7ff236d16 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -65,7 +65,7 @@ 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.Viewport; +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; @@ -632,8 +632,8 @@ public abstract class AbstractRenderer renderInlineBlockParent((InlineBlockParent) inlineArea); } else if (inlineArea instanceof Space) { renderInlineSpace((Space) inlineArea); - } else if (inlineArea instanceof Viewport) { - renderViewport((Viewport) inlineArea); + } else if (inlineArea instanceof InlineViewport) { + renderInlineViewport((InlineViewport) inlineArea); } else if (inlineArea instanceof Leader) { renderLeader((Leader) inlineArea); } @@ -734,7 +734,7 @@ public abstract class AbstractRenderer * Render the given Viewport. * @param viewport the viewport to render */ - protected void renderViewport(Viewport viewport) { + protected void renderInlineViewport(InlineViewport viewport) { Area content = viewport.getContent(); int saveBP = currentBPPosition; currentBPPosition += viewport.getOffset(); diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index dfa2477b6..c81a5cae9 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -73,7 +73,7 @@ import org.apache.fop.area.inline.InlineParent; 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; +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; @@ -838,12 +838,12 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - public void renderViewport(Viewport viewport) { + public void renderInlineViewport(InlineViewport viewport) { String ptr = (String) viewport.getTrait(Trait.PTR); establishStructurePointer(ptr); Dimension dim = new Dimension(viewport.getIPD(), viewport.getBPD()); viewportDimensionStack.push(dim); - super.renderViewport(viewport); + super.renderInlineViewport(viewport); viewportDimensionStack.pop(); resetStructurePointer(); } diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index a7f085d7f..21d28042d 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -79,7 +79,7 @@ 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.Viewport; +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; @@ -743,7 +743,7 @@ public class XMLRenderer extends AbstractXMLRenderer { * {@inheritDoc} */ @Override - protected void renderViewport(Viewport viewport) { + protected void renderInlineViewport(InlineViewport viewport) { atts.clear(); addAreaAttributes(viewport); addTraitAttributes(viewport); @@ -753,7 +753,7 @@ public class XMLRenderer extends AbstractXMLRenderer { addAttribute("clip", "true"); } startElement("viewport", atts); - super.renderViewport(viewport); + super.renderInlineViewport(viewport); endElement("viewport"); } diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java index ccd866d64..811158273 100644 --- a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java +++ b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java @@ -22,19 +22,19 @@ package org.apache.fop.area.inline; import org.apache.fop.area.ViewportTestCase; /** - * Tests the {@linkplain Viewport} class. + * Tests the {@linkplain InlineViewport} class. */ public class InlineViewportTestCase extends ViewportTestCase { public void testNonClip() throws Exception { - Viewport v = new Viewport(null); + InlineViewport v = new InlineViewport(null); v.setIPD(50); v.setBPD(25); checkNonClip(v); } public void testClip() throws Exception { - Viewport v = new Viewport(null); + InlineViewport v = new InlineViewport(null); int ipd = 50; int bpd = 25; v.setIPD(ipd); -- cgit v1.2.3 From 8c443ea8862b9a8258829f9c80790151d06fd2b0 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sat, 26 Mar 2011 23:08:43 +0000 Subject: Fixed regression introduced by Bugzilla 50593: bookmarks pointing to a non-existing internal destination should just trigger a warning. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1085824 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/AreaTreeHandler.java | 2 +- src/java/org/apache/fop/render/intermediate/IFSerializer.java | 8 ++++++-- status.xml | 4 ++++ test/layoutengine/standard-testcases/bookmarks_1.xml | 6 ++++++ 4 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 0e2b8bf71..f45245bfe 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -336,7 +336,7 @@ public class AreaTreeHandler extends FOEventHandler { String[] ids = res.getIDRefs(); for (String id : ids) { List pageVPList = idTracker.getPageViewportsContainingID(id); - if (pageVPList != null) { + if (pageVPList != null && !pageVPList.isEmpty()) { res.resolveIDRef(id, pageVPList); } else { AreaEventProducer eventProducer = AreaEventProducer.Provider.get( diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index 3e178d3cb..64bae054c 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -718,14 +718,18 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } private void serializeBookmark(Bookmark bookmark) throws SAXException, IFException { - noteAction(bookmark.getAction()); + if (bookmark.getAction() != null) { + noteAction(bookmark.getAction()); + } AttributesImpl atts = new AttributesImpl(); atts.addAttribute(null, "title", "title", XMLUtil.CDATA, bookmark.getTitle()); atts.addAttribute(null, "starting-state", "starting-state", XMLUtil.CDATA, bookmark.isShown() ? "show" : "hide"); handler.startElement(DocumentNavigationExtensionConstants.BOOKMARK, atts); - serializeXMLizable(bookmark.getAction()); + if (bookmark.getAction() != null) { + serializeXMLizable(bookmark.getAction()); + } Iterator iter = bookmark.getChildBookmarks().iterator(); while (iter.hasNext()) { Bookmark b = (Bookmark)iter.next(); diff --git a/status.xml b/status.xml index 3e8f4aa3e..8c34f688e 100644 --- a/status.xml +++ b/status.xml @@ -59,6 +59,10 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Fixed regression introduced by Bugzilla 50593: bookmarks pointing to a non-existing + internal destination should just trigger a warning. + Bugzilla 50965: Fixed a regression in BlockContainerLayoutManager where margins were no longer reset after forced breaks. diff --git a/test/layoutengine/standard-testcases/bookmarks_1.xml b/test/layoutengine/standard-testcases/bookmarks_1.xml index b4aa0990d..b22bf79b3 100644 --- a/test/layoutengine/standard-testcases/bookmarks_1.xml +++ b/test/layoutengine/standard-testcases/bookmarks_1.xml @@ -42,6 +42,12 @@ Section 2 + + + Section X + Fixed Block Container -- cgit v1.2.3 From 8ba2be7b375fffc306ff6eba5e29aa90baae2fca Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sun, 27 Mar 2011 14:32:21 +0000 Subject: Properly fix the case of unresolved bookmarks for the intermediate format: bypass serialization of the bookmarks, instead of only its action. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1085944 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/intermediate/IFSerializer.java | 17 ++++++++--------- test/layoutengine/standard-testcases/bookmarks_1.xml | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index 64bae054c..d906d4189 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -709,7 +709,9 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler Iterator iter = tree.getBookmarks().iterator(); while (iter.hasNext()) { Bookmark b = (Bookmark)iter.next(); - serializeBookmark(b); + if (b.getAction() != null) { + serializeBookmark(b); + } } handler.endElement(DocumentNavigationExtensionConstants.BOOKMARK_TREE); } catch (SAXException e) { @@ -718,25 +720,22 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } private void serializeBookmark(Bookmark bookmark) throws SAXException, IFException { - if (bookmark.getAction() != null) { - noteAction(bookmark.getAction()); - } + noteAction(bookmark.getAction()); AttributesImpl atts = new AttributesImpl(); atts.addAttribute(null, "title", "title", XMLUtil.CDATA, bookmark.getTitle()); atts.addAttribute(null, "starting-state", "starting-state", XMLUtil.CDATA, bookmark.isShown() ? "show" : "hide"); handler.startElement(DocumentNavigationExtensionConstants.BOOKMARK, atts); - if (bookmark.getAction() != null) { - serializeXMLizable(bookmark.getAction()); - } + serializeXMLizable(bookmark.getAction()); Iterator iter = bookmark.getChildBookmarks().iterator(); while (iter.hasNext()) { Bookmark b = (Bookmark)iter.next(); - serializeBookmark(b); + if (b.getAction() != null) { + serializeBookmark(b); + } } handler.endElement(DocumentNavigationExtensionConstants.BOOKMARK); - } /** {@inheritDoc} */ diff --git a/test/layoutengine/standard-testcases/bookmarks_1.xml b/test/layoutengine/standard-testcases/bookmarks_1.xml index 5b9b23718..85cb80cc3 100644 --- a/test/layoutengine/standard-testcases/bookmarks_1.xml +++ b/test/layoutengine/standard-testcases/bookmarks_1.xml @@ -44,10 +44,10 @@ Section X - --> Fixed Block Container -- cgit v1.2.3 From 427df0fa7d2f67a4d21740cbf7264d3b11739a41 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 18 Apr 2011 18:36:05 +0000 Subject: Added id element to intermediate format to track the origin of content. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1094690 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 7 +- .../fop-intermediate-format-ng-content.xsd | 5 + .../fop/render/intermediate/IFConstants.java | 2 + .../apache/fop/render/intermediate/IFContext.java | 21 +++ .../apache/fop/render/intermediate/IFParser.java | 35 ++-- .../apache/fop/render/intermediate/IFRenderer.java | 24 +++ .../fop/render/intermediate/IFSerializer.java | 18 +- status.xml | 3 + test/intermediate/block-container.xml | 64 +++++++ test/intermediate/block-container_nested.xml | 148 ++++++++++++++++ test/intermediate/block.xml | 63 +++++++ test/intermediate/block_nested.xml | 138 +++++++++++++++ test/intermediate/block_span_pages.xml | 126 ++++++++++++++ test/intermediate/images.xml | 93 ++++++++++ test/intermediate/inlines.xml | 107 ++++++++++++ test/intermediate/list.xml | 112 ++++++++++++ test/intermediate/table.xml | 146 ++++++++++++++++ test/java/org/apache/fop/check/Check.java | 27 +++ test/java/org/apache/fop/check/ChecksFactory.java | 97 +++++++++++ test/java/org/apache/fop/check/package-info.java | 25 +++ .../fop/intermediate/AbstractIFTestCase.java | 137 +++++++++++++++ .../intermediate/AbstractIntermediateTestCase.java | 20 +-- .../fop/intermediate/AreaTreeParserTestCase.java | 4 +- test/java/org/apache/fop/intermediate/IFCheck.java | 4 +- .../apache/fop/intermediate/IFChecksFactory.java | 49 ++++++ .../apache/fop/intermediate/IFParserTestCase.java | 117 ++----------- .../org/apache/fop/intermediate/IFTestCase.java | 77 +++++++++ .../java/org/apache/fop/intermediate/IFTester.java | 153 ++--------------- .../intermediate/IntermediateFormatTestSuite.java | 56 +++--- .../apache/fop/intermediate/LayoutIFTestSuite.java | 64 +++++++ .../org/apache/fop/intermediate/TestAssistant.java | 189 +++++++++++++++++++++ .../org/apache/fop/layoutengine/EvalCheck.java | 10 -- .../apache/fop/layoutengine/LayoutEngineCheck.java | 4 +- .../layoutengine/LayoutEngineChecksFactory.java | 62 +++++++ .../fop/layoutengine/LayoutEngineTestSuite.java | 48 +++--- .../fop/layoutengine/LayoutEngineTester.java | 156 ++++++++--------- .../org/apache/fop/layoutengine/ResultCheck.java | 13 +- .../apache/fop/layoutengine/TestEnvironment.java | 172 ------------------- .../org/apache/fop/layoutengine/TrueCheck.java | 8 - 39 files changed, 1998 insertions(+), 606 deletions(-) create mode 100644 test/intermediate/block-container.xml create mode 100644 test/intermediate/block-container_nested.xml create mode 100644 test/intermediate/block.xml create mode 100644 test/intermediate/block_nested.xml create mode 100644 test/intermediate/block_span_pages.xml create mode 100644 test/intermediate/images.xml create mode 100644 test/intermediate/inlines.xml create mode 100644 test/intermediate/list.xml create mode 100644 test/intermediate/table.xml create mode 100644 test/java/org/apache/fop/check/Check.java create mode 100644 test/java/org/apache/fop/check/ChecksFactory.java create mode 100644 test/java/org/apache/fop/check/package-info.java create mode 100644 test/java/org/apache/fop/intermediate/AbstractIFTestCase.java create mode 100644 test/java/org/apache/fop/intermediate/IFChecksFactory.java create mode 100644 test/java/org/apache/fop/intermediate/IFTestCase.java create mode 100644 test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java create mode 100644 test/java/org/apache/fop/intermediate/TestAssistant.java create mode 100644 test/java/org/apache/fop/layoutengine/LayoutEngineChecksFactory.java delete mode 100644 test/java/org/apache/fop/layoutengine/TestEnvironment.java (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/build.xml b/build.xml index 114a14e27..cfad23a74 100644 --- a/build.xml +++ b/build.xml @@ -927,7 +927,12 @@ list of possible build targets. testsuite="org.apache.fop.intermediate.AreaTreeXMLFormatTestSuite" outfile="TEST-area-tree-xml-format"/> - + + + + + + + + diff --git a/src/java/org/apache/fop/render/intermediate/IFConstants.java b/src/java/org/apache/fop/render/intermediate/IFConstants.java index 34fe2bd2c..2b16b343d 100644 --- a/src/java/org/apache/fop/render/intermediate/IFConstants.java +++ b/src/java/org/apache/fop/render/intermediate/IFConstants.java @@ -67,6 +67,8 @@ public interface IFConstants extends XMLConstants { String EL_FONT = "font"; /** element name text */ String EL_TEXT = "text"; + /** element name id */ + String EL_ID = "id"; /** Parent element of the logical structure tree. */ String EL_STRUCTURE_TREE = "structure-tree"; } diff --git a/src/java/org/apache/fop/render/intermediate/IFContext.java b/src/java/org/apache/fop/render/intermediate/IFContext.java index 804b353c1..b8be97253 100644 --- a/src/java/org/apache/fop/render/intermediate/IFContext.java +++ b/src/java/org/apache/fop/render/intermediate/IFContext.java @@ -48,6 +48,8 @@ public class IFContext { private String structurePointer; + private String id = ""; + /** * Main constructor. * @param ua the user agent @@ -155,4 +157,23 @@ public class IFContext { return this.structurePointer; } + /** + * Sets the ID of the object enclosing the content that will follow. + * + * @param id the ID of the nearest ancestor object for which the id property was set + */ + void setID(String id) { + assert id != null; + this.id = id; + } + + /** + * Returns the ID of the object enclosing the current content. + * + * @return the ID of the nearest ancestor object for which the id property was set + */ + String getID() { + return id; + } + } diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index 645d1ebc6..313cee685 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -24,6 +24,7 @@ import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.AffineTransform; +import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -76,7 +77,7 @@ public class IFParser implements IFConstants { private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - private static Set handledNamespaces = new java.util.HashSet(); + private static Set handledNamespaces = new java.util.HashSet(); static { handledNamespaces.add(XMLNS_NAMESPACE_URI); @@ -132,7 +133,7 @@ public class IFParser implements IFConstants { private static class Handler extends DefaultHandler { - private Map elementHandlers = new java.util.HashMap(); + private Map elementHandlers = new HashMap(); private IFDocumentHandler documentHandler; private IFPainter painter; @@ -188,6 +189,7 @@ public class IFParser implements IFConstants { //Page content elementHandlers.put(EL_VIEWPORT, new ViewportHandler()); elementHandlers.put(EL_GROUP, new GroupHandler()); + elementHandlers.put(EL_ID, new IDHandler()); elementHandlers.put(EL_FONT, new FontHandler()); elementHandlers.put(EL_TEXT, new TextHandler()); elementHandlers.put(EL_CLIP_RECT, new ClipRectHandler()); @@ -202,7 +204,7 @@ public class IFParser implements IFConstants { } } - private void establishForeignAttributes(Map foreignAttributes) { + private void establishForeignAttributes(Map foreignAttributes) { documentHandler.getContext().setForeignAttributes(foreignAttributes); } @@ -300,7 +302,7 @@ public class IFParser implements IFConstants { private boolean startIFElement(String localName, Attributes attributes) throws SAXException { lastAttributes = new AttributesImpl(attributes); - ElementHandler elementHandler = (ElementHandler)elementHandlers.get(localName); + ElementHandler elementHandler = elementHandlers.get(localName); content.setLength(0); ignoreCharacters = true; if (elementHandler != null) { @@ -346,7 +348,7 @@ public class IFParser implements IFConstants { } } else { if (NAMESPACE.equals(uri)) { - ElementHandler elementHandler = (ElementHandler)elementHandlers.get(localName); + ElementHandler elementHandler = elementHandlers.get(localName); if (elementHandler != null) { try { elementHandler.endElement(); @@ -432,7 +434,7 @@ public class IFParser implements IFConstants { documentHandler.getContext().setLanguage( XMLUtil.convertRFC3066ToLocale(xmllang)); } - Map foreignAttributes = getForeignAttributes(lastAttributes); + Map foreignAttributes = getForeignAttributes(lastAttributes); establishForeignAttributes(foreignAttributes); documentHandler.startPageSequence(id); resetForeignAttributes(); @@ -453,7 +455,7 @@ public class IFParser implements IFConstants { String pageMasterName = attributes.getValue("page-master-name"); int width = Integer.parseInt(attributes.getValue("width")); int height = Integer.parseInt(attributes.getValue("height")); - Map foreignAttributes = getForeignAttributes(lastAttributes); + Map foreignAttributes = getForeignAttributes(lastAttributes); establishForeignAttributes(foreignAttributes); documentHandler.startPage(index, name, pageMasterName, new Dimension(width, height)); @@ -486,6 +488,7 @@ public class IFParser implements IFConstants { public void endElement() throws IFException { painter = null; + documentHandler.getContext().setID(""); documentHandler.endPageContent(); } @@ -536,6 +539,16 @@ public class IFParser implements IFConstants { } + private class IDHandler extends AbstractElementHandler { + + @Override + public void startElement(Attributes attributes) throws IFException, SAXException { + String id = attributes.getValue("name"); + documentHandler.getContext().setID(id); + } + + } + private class FontHandler extends AbstractElementHandler { public void startElement(Attributes attributes) throws IFException { @@ -660,7 +673,7 @@ public class IFParser implements IFConstants { int y = Integer.parseInt(lastAttributes.getValue("y")); int width = Integer.parseInt(lastAttributes.getValue("width")); int height = Integer.parseInt(lastAttributes.getValue("height")); - Map foreignAttributes = getForeignAttributes(lastAttributes); + Map foreignAttributes = getForeignAttributes(lastAttributes); establishForeignAttributes(foreignAttributes); setStructurePointer(lastAttributes); if (foreignObject != null) { @@ -712,8 +725,8 @@ public class IFParser implements IFConstants { } } - private static Map getForeignAttributes(Attributes atts) { - Map foreignAttributes = null; + private static Map getForeignAttributes(Attributes atts) { + Map foreignAttributes = null; for (int i = 0, c = atts.getLength(); i < c; i++) { String ns = atts.getURI(i); if (ns.length() > 0) { @@ -721,7 +734,7 @@ public class IFParser implements IFConstants { continue; } if (foreignAttributes == null) { - foreignAttributes = new java.util.HashMap(); + foreignAttributes = new java.util.HashMap(); } QName qname = new QName(ns, atts.getQName(i)); foreignAttributes.put(qname, atts.getValue(i)); diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index c81a5cae9..24a2e8a75 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -153,6 +153,8 @@ public class IFRenderer extends AbstractPathOrientedRenderer { private TextUtil textUtil = new TextUtil(); + private Stack ids = new Stack(); + /** * Main constructor */ @@ -841,11 +843,13 @@ public class IFRenderer extends AbstractPathOrientedRenderer { public void renderInlineViewport(InlineViewport viewport) { String ptr = (String) viewport.getTrait(Trait.PTR); establishStructurePointer(ptr); + pushdID(viewport); Dimension dim = new Dimension(viewport.getIPD(), viewport.getBPD()); viewportDimensionStack.push(dim); super.renderInlineViewport(viewport); viewportDimensionStack.pop(); resetStructurePointer(); + popID(viewport); } /** {@inheritDoc} */ @@ -888,7 +892,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ protected void renderInlineArea(InlineArea inlineArea) { saveInlinePosIfTargetable(inlineArea); + pushdID(inlineArea); super.renderInlineArea(inlineArea); + popID(inlineArea); } /** {@inheritDoc} */ @@ -952,7 +958,25 @@ public class IFRenderer extends AbstractPathOrientedRenderer { log.trace("renderBlock() " + block); } saveBlockPosIfTargetable(block); + pushdID(block); super.renderBlock(block); + popID(block); + } + + private void pushdID(Area area) { + String prodID = (String) area.getTrait(Trait.PROD_ID); + if (prodID != null) { + ids.push(prodID); + documentHandler.getContext().setID(prodID); + } + } + + private void popID(Area area) { + String prodID = (String) area.getTrait(Trait.PROD_ID); + if (prodID != null) { + ids.pop(); + documentHandler.getContext().setID(ids.empty() ? "" : ids.peek()); + } } private Typeface getTypeface(String fontName) { diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index d906d4189..471a982ca 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -69,6 +69,8 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler /** Holds the intermediate format state */ private IFState state; + private String currentID = ""; + /** * Default constructor. */ @@ -306,6 +308,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler public void endPageContent() throws IFException { try { this.state = null; + currentID = ""; handler.endElement(EL_PAGE_CONTENT); } catch (SAXException e) { throw new IFException("SAX error in endPageContent()", e); @@ -417,6 +420,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler /** {@inheritDoc} */ public void drawImage(String uri, Rectangle rect) throws IFException { try { + addID(); AttributesImpl atts = new AttributesImpl(); addAttribute(atts, XLINK_HREF, uri); addAttribute(atts, "x", Integer.toString(rect.x)); @@ -445,6 +449,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler /** {@inheritDoc} */ public void drawImage(Document doc, Rectangle rect) throws IFException { try { + addID(); AttributesImpl atts = new AttributesImpl(); addAttribute(atts, "x", Integer.toString(rect.x)); addAttribute(atts, "y", Integer.toString(rect.y)); @@ -534,6 +539,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler public void drawLine(Point start, Point end, int width, Color color, RuleStyle style) throws IFException { try { + addID(); AttributesImpl atts = new AttributesImpl(); addAttribute(atts, "x1", Integer.toString(start.x)); addAttribute(atts, "y1", Integer.toString(start.y)); @@ -552,6 +558,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text) throws IFException { try { + addID(); AttributesImpl atts = new AttributesImpl(); addAttribute(atts, "x", Integer.toString(x)); addAttribute(atts, "y", Integer.toString(y)); @@ -671,7 +678,16 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } } - // ---=== IFDocumentNavigationHandler ===--- + private void addID() throws SAXException { + String id = getContext().getID(); + if (!currentID.equals(id)) { + AttributesImpl atts = new AttributesImpl(); + addAttribute(atts, "name", id); + handler.startElement(EL_ID, atts); + handler.endElement(EL_ID); + currentID = id; + } + } private Map incompleteActions = new java.util.HashMap(); private List completeActions = new java.util.LinkedList(); diff --git a/status.xml b/status.xml index ec037b6e0..9378e627f 100644 --- a/status.xml +++ b/status.xml @@ -59,6 +59,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Added id element to intermediate format to track the origin of content. + Bugzilla 50988: Fixed a NullPointerException in case a white-space fo:character was removed due to white-space handling. diff --git a/test/intermediate/block-container.xml b/test/intermediate/block-container.xml new file mode 100644 index 000000000..5749de28f --- /dev/null +++ b/test/intermediate/block-container.xml @@ -0,0 +1,64 @@ + + + + +

+ This test checks that IDs coming from a block-container properly appear in the IF output. +

+ + + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + In vel libero libero, a semper est. Vivamus dapibus ante id + lorem mattis eget mattis urna sodales. Vestibulum nec dui urna, in porta + mi. + Proin varius egestas erat. Proin ante eros, consequat eget + semper a, molestie non arcu. Praesent hendrerit dolor vel leo luctus dapibus. + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/intermediate/block-container_nested.xml b/test/intermediate/block-container_nested.xml new file mode 100644 index 000000000..40f9903ff --- /dev/null +++ b/test/intermediate/block-container_nested.xml @@ -0,0 +1,148 @@ + + + + +

+ This test checks that IDs coming from a block-container properly appear in the IF output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + + In vel libero libero, a semper est. Vivamus dapibus ante id lorem mattis eget + mattis urna sodales. + + Vestibulum nec dui urna, in porta mi. Proin varius egestas + erat. Donec pharetra iaculis dolor, ut rutrum nunc facilisis + at. + + Proin ante eros, consequat eget semper a, molestie non arcu. Praesent hendrerit dolor vel + leo luctus dapibus. + + Nullam quam nisl, iaculis ut fermentum et, vestibulum id elit. + Suspendisse fermentum fermentum ullamcorper. + + Sed ultrices posuere posuere. Praesent vitae ligula odio. + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + + In vel libero libero, a semper est. Vivamus dapibus ante id lorem mattis eget + mattis urna sodales. + Mauris tincidunt, risus eget vulputate elementum, + turpis lorem aliquet purus, eu sagittis neque sapien vel lectus. + + Vestibulum nec dui urna, in porta mi. Proin varius egestas erat. Donec + pharetra iaculis dolor, ut rutrum nunc facilisis at. + + Proin ante eros, consequat eget semper a, molestie non arcu. Praesent hendrerit dolor vel + leo luctus dapibus. + Vivamus ut sollicitudin metus. Curabitur sit amet aliquam + enim. + + Nullam quam nisl, iaculis ut fermentum et, vestibulum id elit. + Suspendisse fermentum fermentum ullamcorper. + + Vivamus tellus libero, porttitor a lacinia a, tempor eu dui. Pellentesque + fermentum odio tempor lorem interdum pharetra. + + Donec auctor venenatis convallis. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/intermediate/block.xml b/test/intermediate/block.xml new file mode 100644 index 000000000..1801bb7c6 --- /dev/null +++ b/test/intermediate/block.xml @@ -0,0 +1,63 @@ + + + + +

+ This test checks that IDs coming from a block properly appear in the IF output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + In vel libero + libero, a semper est. Vivamus dapibus ante id lorem mattis eget mattis urna sodales. + Vestibulum nec dui urna, in porta mi. + Proin varius egestas erat. Proin ante eros, consequat eget + semper a, molestie non arcu. Praesent hendrerit dolor vel leo luctus dapibus. + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/intermediate/block_nested.xml b/test/intermediate/block_nested.xml new file mode 100644 index 000000000..5ec8af00f --- /dev/null +++ b/test/intermediate/block_nested.xml @@ -0,0 +1,138 @@ + + + + +

+ This test checks that IDs coming from a block properly appear in the IF output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + In vel libero libero, a semper + est. Vivamus dapibus ante id lorem mattis eget mattis urna sodales. + Vestibulum nec dui urna, in + porta mi. Proin varius egestas erat. Donec pharetra iaculis dolor, ut rutrum nunc + facilisis at. + Proin ante eros, consequat eget semper a, molestie non arcu. Praesent hendrerit dolor vel + leo luctus dapibus. + Nullam quam nisl, iaculis ut fermentum et, vestibulum id elit. + Suspendisse fermentum fermentum ullamcorper. + Sed ultrices posuere posuere. + Praesent vitae ligula odio. + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + In vel libero libero, a semper + est. Vivamus dapibus ante id lorem mattis eget mattis urna sodales. + Mauris tincidunt, risus eget vulputate elementum, + turpis lorem aliquet purus, eu sagittis neque sapien vel lectus. + Vestibulum nec dui urna, in + porta mi. Proin varius egestas erat. Donec pharetra iaculis dolor, ut rutrum nunc + facilisis at. + Proin ante eros, consequat eget semper a, molestie non arcu. Praesent hendrerit dolor vel + leo luctus dapibus. + Vivamus ut sollicitudin metus. Curabitur sit amet aliquam enim. + Nullam quam nisl, iaculis ut fermentum et, vestibulum id elit. + Suspendisse fermentum fermentum ullamcorper. + Vivamus tellus libero, porttitor a + lacinia a, tempor eu dui. Pellentesque fermentum odio tempor lorem interdum + pharetra. + Donec auctor venenatis convallis. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/intermediate/block_span_pages.xml b/test/intermediate/block_span_pages.xml new file mode 100644 index 000000000..43aff0ac4 --- /dev/null +++ b/test/intermediate/block_span_pages.xml @@ -0,0 +1,126 @@ + + + + +

+ This test checks that IDs coming from a block that spans over different pages properly appear + in the IF output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. + In vel libero libero, a + semper est. Vivamus dapibus ante id lorem mattis eget mattis urna sodales. Proin ante + eros, consequat eget semper a, molestie non arcu. Praesent hendrerit dolor vel leo + luctus dapibus. + Nullam quam nisl, iaculis ut fermentum et, vestibulum id elit. + Suspendisse fermentum fermentum ullamcorper. + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. + In vel libero libero, a semper + est. Vivamus dapibus ante id lorem mattis eget mattis urna sodales. + Vestibulum nec dui urna, in + porta mi. Proin varius egestas erat. Donec pharetra iaculis dolor, ut rutrum nunc + facilisis at. Sed ultrices posuere posuere. Praesent vitae ligula odio. Vivamus + porttitor sollicitudin tortor eu vulputate. + Proin ante eros, consequat eget semper a, molestie non arcu. Praesent hendrerit dolor vel + leo luctus dapibus. + Nullam quam nisl, iaculis ut fermentum et, vestibulum id elit. + Suspendisse fermentum fermentum ullamcorper. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/intermediate/images.xml b/test/intermediate/images.xml new file mode 100644 index 000000000..08ca83f5c --- /dev/null +++ b/test/intermediate/images.xml @@ -0,0 +1,93 @@ + + + + +

+ This test checks that IDs coming from images properly appear in the IF output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. In vel + libero libero, a semper est. + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. + + + + + + + + Vivamus porttitor sollicitudin tortor eu vulputate. In vel + libero libero, a semper est. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/intermediate/inlines.xml b/test/intermediate/inlines.xml new file mode 100644 index 000000000..eb588992a --- /dev/null +++ b/test/intermediate/inlines.xml @@ -0,0 +1,107 @@ + + + + +

+ This test checks that IDs coming from various inline elements properly appear in the IF + output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, onsectetur adipiscing + elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. In vel + libero libero, a semper est. Vivamus dapibus ante id lorem mattis eget mattis urna + sodales. This is page number . Vestibulum + nec dui urna, in porta mi. The fo:character object is on page . Proin varius egestas erat. + Proin ante eros, consequat eget semper a, molestie non arcu. The last page of this document + is page . Praesent hendrerit dolor vel leo luctus dapibus. + + Lorem ipsum dolor sit amet, consectetur adipiscing + elit. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/intermediate/list.xml b/test/intermediate/list.xml new file mode 100644 index 000000000..81283ce5e --- /dev/null +++ b/test/intermediate/list.xml @@ -0,0 +1,112 @@ + + + + +

+ This test checks that IDs coming from the various elements of a list properly appear in the IF + output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + + + + + + + Item 1 + id="list-item-body" + + + + + + + + Item 2 + id="list-item_2" + + + + + + + + Item 3 + id="list-block" + + + + In vel libero + libero, a semper est. Vivamus dapibus ante id lorem mattis eget mattis urna sodales. + Vestibulum nec dui urna, in porta mi. + Proin varius egestas erat. Proin ante eros, consequat eget + semper a, molestie non arcu. Praesent hendrerit dolor vel leo luctus dapibus. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/intermediate/table.xml b/test/intermediate/table.xml new file mode 100644 index 000000000..4e3d10cbf --- /dev/null +++ b/test/intermediate/table.xml @@ -0,0 +1,146 @@ + + + + +

+ This test checks that IDs coming from the various elements of a table properly appear in the IF output. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum leo a diam + bibendum auctor. Vivamus porttitor sollicitudin tortor eu vulputate. + + + + Header 1.1 + id="table-cell_header_1.1" + + + Header 1.2 id="table-header" + + + + + + Cell 1.1 id="table-cell_1.1" + + + Cell 1.2 id="table-row_1" + + + + + Cell 2.1 id="table-body_1" + + + Cell 2.2 id="table-body_1" + + + + + + + Cell 3.1 id="table-cell_3.1" + + + Cell 3.2 id="table-row_3" + + + + + Cell 4.1 id="block" + + + Cell 4.2 id="table" + + + + + Proin varius egestas erat. Proin ante eros, consequat eget + semper a, molestie non arcu. Praesent hendrerit dolor vel leo luctus dapibus. + Mauris ac erat est, sit amet + dignissim elit. Ut pulvinar diam ut lorem pellentesque tempus. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/test/java/org/apache/fop/check/Check.java b/test/java/org/apache/fop/check/Check.java new file mode 100644 index 000000000..ffc7e3cbc --- /dev/null +++ b/test/java/org/apache/fop/check/Check.java @@ -0,0 +1,27 @@ +/* + * 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.check; + +/** + * A marker interface to identify checks in XML test cases. + */ +public interface Check { + +} diff --git a/test/java/org/apache/fop/check/ChecksFactory.java b/test/java/org/apache/fop/check/ChecksFactory.java new file mode 100644 index 000000000..a493c09f2 --- /dev/null +++ b/test/java/org/apache/fop/check/ChecksFactory.java @@ -0,0 +1,97 @@ +/* + * 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.check; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * A factory class for creating checks that belong to a same family. + * @param a family of checks + */ +public abstract class ChecksFactory { + + /** + * A factory to create a particular kind of check. + */ + protected static interface CheckFactory { + + /** + * Creates a {@link Check} instance from the given XML element. + * + * @param element an element representing a check + * @return the corresponding check + */ + C createCheck(Element element); + } + + private final Map> checkFactories + = new HashMap>(); + + /** Default constructor. */ + protected ChecksFactory() { } + + /** + * Registers a factory for a new kind of check. + * + * @param elementName the name of the element under which the check is identified in + * the XML test case + * @param factory the corresponding factory + */ + protected void registerCheckFactory(String elementName, CheckFactory factory) { + checkFactories.put(elementName, factory); + } + + /** + * Creates a new {@link Check} instance corresponding to the given element. + * + * @param element an element in the XML test case that identifies a particular check + * @return the corresponding check + * @throws IllegalArgumentException if not check corresponding to the given element + * has been found + */ + public final C createCheck(Element element) { + String name = element.getTagName(); + CheckFactory factory = checkFactories.get(name); + if (factory == null) { + throw new IllegalArgumentException("No check class found for " + name); + } else { + return factory.createCheck(element); + } + } + + public final List createCheckList(Element container) { + List checks = new ArrayList(); + NodeList nodes = container.getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + Node node = nodes.item(i); + if (node instanceof Element) { + checks.add(createCheck((Element) node)); + } + } + return checks; + } +} diff --git a/test/java/org/apache/fop/check/package-info.java b/test/java/org/apache/fop/check/package-info.java new file mode 100644 index 000000000..5785f7a4b --- /dev/null +++ b/test/java/org/apache/fop/check/package-info.java @@ -0,0 +1,25 @@ +/* + * 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$ */ + +/** + * A framework for creating checks from elements stored in an XML test case. The test case + * typically contains the XML document under test, along with a series of checks expressed + * as XML elements. + */ +package org.apache.fop.check; diff --git a/test/java/org/apache/fop/intermediate/AbstractIFTestCase.java b/test/java/org/apache/fop/intermediate/AbstractIFTestCase.java new file mode 100644 index 000000000..56d613e20 --- /dev/null +++ b/test/java/org/apache/fop/intermediate/AbstractIFTestCase.java @@ -0,0 +1,137 @@ +/* + * 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.intermediate; + +import java.io.File; +import java.io.IOException; + +import javax.xml.XMLConstants; +import javax.xml.transform.Result; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXResult; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +import org.w3c.dom.Document; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.Fop; +import org.apache.fop.render.intermediate.IFContext; +import org.apache.fop.render.intermediate.IFDocumentHandler; +import org.apache.fop.render.intermediate.IFSerializer; + +/** + * A common super-class for intermediate format test cases. + */ +abstract class AbstractIFTestCase extends AbstractIntermediateTestCase { + + private static final Schema IF_SCHEMA; + + static { + Schema ifSchema = null; + try { + SchemaFactory sFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + File ifSchemaFile = new File( + "src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd"); + ifSchema = sFactory.newSchema(ifSchemaFile); + } catch (IllegalArgumentException iae) { + System.err.println("No suitable SchemaFactory for XML Schema validation found!"); + } catch (SAXException e) { + throw new ExceptionInInitializerError(e); + } + IF_SCHEMA = ifSchema; + } + + /** + * Creates a new test case. + * + * @param testFile the file containing the document and the tests + * @throws IOException if an I/O error occurs while loading the test case + */ + public AbstractIFTestCase(File testFile) throws IOException { + super(testFile); + } + + @Override + protected String getIntermediateFileExtension() { + return ".if.xml"; + } + + @Override + protected Document buildIntermediateDocument(Templates templates) throws Exception { + Transformer transformer = templates.newTransformer(); + setErrorListener(transformer); + + //Set up XMLRenderer to render to a DOM + DOMResult domResult = new DOMResult(); + + FOUserAgent userAgent = createUserAgent(); + + //Create an instance of the target renderer so the XMLRenderer can use its font setup + IFDocumentHandler targetHandler = userAgent.getRendererFactory().createDocumentHandler( + userAgent, getTargetMIME()); + + //Setup painter + IFSerializer serializer = new IFSerializer(); + serializer.setContext(new IFContext(userAgent)); + serializer.mimicDocumentHandler(targetHandler); + serializer.setResult(domResult); + + userAgent.setDocumentHandlerOverride(serializer); + + Fop fop = fopFactory.newFop(userAgent); + Result res = new SAXResult(fop.getDefaultHandler()); + transformer.transform(new DOMSource(testDoc), res); + + return (Document) domResult.getNode(); + } + + @Override + protected void validate(Document doc) throws SAXException, IOException { + if (IF_SCHEMA == null) { + return; //skip validation; + } + Validator validator = IF_SCHEMA.newValidator(); + validator.setErrorHandler(new ErrorHandler() { + + public void error(SAXParseException exception) throws SAXException { + throw exception; + } + + public void fatalError(SAXParseException exception) throws SAXException { + throw exception; + } + + public void warning(SAXParseException exception) throws SAXException { + //ignore + } + + }); + validator.validate(new DOMSource(doc)); + } + +} diff --git a/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java b/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java index 826a5c777..d16621382 100644 --- a/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java +++ b/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java @@ -44,7 +44,6 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; import org.apache.fop.events.model.EventSeverity; -import org.apache.fop.layoutengine.TestEnvironment; import org.apache.fop.util.ConsoleEventListenerForTests; /** @@ -53,15 +52,13 @@ import org.apache.fop.util.ConsoleEventListenerForTests; public abstract class AbstractIntermediateTestCase extends XMLTestCase { /** the test environment */ - protected static TestEnvironment env = new TestEnvironment(); + protected static TestAssistant testAssistant = new TestAssistant(); /** the FOP factory */ protected FopFactory fopFactory; - /** the main base directory for tests */ - protected File mainDir = new File("test/layoutengine"); /** the directory containing the tests */ - protected File testDir = new File(mainDir, "standard-testcases"); + protected File testDir = new File("test/layoutengine/standard-testcases"); /** the output directory for any files generated by the tests */ protected File outputDir; @@ -87,11 +84,11 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { protected void setUp() throws Exception { super.setUp(); setupOutputDirectory(); - this.testDoc = env.loadTestCase(testFile); - this.fopFactory = env.getFopFactory(testDoc); - intermediate = buildIntermediateDocument(env.getTestcase2FOStylesheet()); + this.testDoc = testAssistant.loadTestCase(testFile); + this.fopFactory = testAssistant.getFopFactory(testDoc); + intermediate = buildIntermediateDocument(testAssistant.getTestcase2FOStylesheet()); if (outputDir != null) { - env.saveDOM(intermediate, new File(outputDir, + testAssistant.saveDOM(intermediate, new File(outputDir, getName() + ".1" + getIntermediateFileExtension())); } } @@ -148,7 +145,8 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { userAgent.getEventBroadcaster().addEventListener( new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.FATAL)); } catch (MalformedURLException e) { - //ignore, won't happen + // Shouldn't happen + throw new AssertionError(); } return userAgent; } @@ -175,7 +173,7 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { Document doc = parseAndRenderToIntermediateFormat(src); if (outputDir != null) { File tgtFile = new File(outputDir, getName() + ".2" + getIntermediateFileExtension()); - env.saveDOM(doc, tgtFile); + testAssistant.saveDOM(doc, tgtFile); } assertXMLEqual(intermediate, doc); diff --git a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java index 3d029778d..e3135c5a3 100644 --- a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java @@ -72,7 +72,7 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTestCase { setErrorListener(transformer); //Set up XMLRenderer to render to a DOM - TransformerHandler handler = env.getTransformerFactory().newTransformerHandler(); + TransformerHandler handler = testAssistant.getTransformerFactory().newTransformerHandler(); DOMResult domResult = new DOMResult(); handler.setResult(domResult); @@ -113,7 +113,7 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTestCase { AreaTreeParser parser = new AreaTreeParser(); //Set up XMLRenderer to render to a DOM - TransformerHandler handler = env.getTransformerFactory().newTransformerHandler(); + TransformerHandler handler = testAssistant.getTransformerFactory().newTransformerHandler(); DOMResult domResult = new DOMResult(); handler.setResult(domResult); XMLRenderer renderer = new XMLRenderer(); diff --git a/test/java/org/apache/fop/intermediate/IFCheck.java b/test/java/org/apache/fop/intermediate/IFCheck.java index dc5404818..dfd76f3b3 100644 --- a/test/java/org/apache/fop/intermediate/IFCheck.java +++ b/test/java/org/apache/fop/intermediate/IFCheck.java @@ -21,10 +21,12 @@ package org.apache.fop.intermediate; import org.w3c.dom.Document; +import org.apache.fop.check.Check; + /** * Check interface for intermediate format checks. */ -public interface IFCheck { +public interface IFCheck extends Check { /** * Called to perform the check. diff --git a/test/java/org/apache/fop/intermediate/IFChecksFactory.java b/test/java/org/apache/fop/intermediate/IFChecksFactory.java new file mode 100644 index 000000000..2eab74130 --- /dev/null +++ b/test/java/org/apache/fop/intermediate/IFChecksFactory.java @@ -0,0 +1,49 @@ +/* + * 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.intermediate; + +import org.w3c.dom.Element; + +import org.apache.fop.check.ChecksFactory; +import org.apache.fop.layoutengine.EvalCheck; +import org.apache.fop.layoutengine.TrueCheck; + +/** + * A factory class for creating {@link IFCheck} instances. + */ +final class IFChecksFactory extends ChecksFactory { + + IFChecksFactory() { + registerCheckFactory("true", new CheckFactory() { + + public IFCheck createCheck(Element element) { + return new TrueCheck(element); + } + + }); + registerCheckFactory("eval", new CheckFactory() { + + public IFCheck createCheck(Element element) { + return new EvalCheck(element); + } + + }); + } +} diff --git a/test/java/org/apache/fop/intermediate/IFParserTestCase.java b/test/java/org/apache/fop/intermediate/IFParserTestCase.java index 15fc74bc9..afdd757c9 100644 --- a/test/java/org/apache/fop/intermediate/IFParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/IFParserTestCase.java @@ -23,59 +23,23 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; -import javax.xml.XMLConstants; -import javax.xml.transform.Result; import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamResult; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; import org.w3c.dom.Document; -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.fonts.FontInfo; -import org.apache.fop.layoutengine.TestEnvironment; import org.apache.fop.render.intermediate.IFContext; import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFParser; -import org.apache.fop.render.intermediate.IFRenderer; import org.apache.fop.render.intermediate.IFSerializer; /** * Tests the intermediate format parser. */ -public class IFParserTestCase extends AbstractIntermediateTestCase { - - private static TestEnvironment env = new TestEnvironment(); - private static Schema ifSchema; - - private static Schema getIFSchema() throws SAXException { - if (ifSchema == null) { - SchemaFactory sFactory; - try { - sFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - } catch (IllegalArgumentException iae) { - System.out.println("No suitable SchemaFactory for XML Schema validation found!"); - return null; - } - File ifSchemaFile = new File( - "src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd"); - ifSchema = sFactory.newSchema(ifSchemaFile); - } - return ifSchema; - } +public class IFParserTestCase extends AbstractIFTestCase { /** * Constructor for the test suite that is used for each test file. @@ -87,76 +51,7 @@ public class IFParserTestCase extends AbstractIntermediateTestCase { } /** {@inheritDoc} */ - protected String getTargetMIME() { - return MimeConstants.MIME_PDF; - } - - /** {@inheritDoc} */ - protected String getIntermediateFileExtension() { - return ".if.xml"; - } - - /** {@inheritDoc} */ - protected Document buildIntermediateDocument(Templates templates) - throws Exception { - Transformer transformer = templates.newTransformer(); - setErrorListener(transformer); - - //Set up XMLRenderer to render to a DOM - DOMResult domResult = new DOMResult(); - - FOUserAgent userAgent = createUserAgent(); - - //Create an instance of the target renderer so the XMLRenderer can use its font setup - IFDocumentHandler targetHandler = userAgent.getRendererFactory().createDocumentHandler( - userAgent, getTargetMIME()); - - //Setup painter - IFSerializer serializer = new IFSerializer(); - serializer.setContext(new IFContext(userAgent)); - serializer.mimicDocumentHandler(targetHandler); - serializer.setResult(domResult); - - //Setup renderer - IFRenderer renderer = new IFRenderer(); - renderer.setUserAgent(userAgent); - - renderer.setDocumentHandler(serializer); - userAgent.setRendererOverride(renderer); - - Fop fop = fopFactory.newFop(userAgent); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(new DOMSource(testDoc), res); - - return (Document)domResult.getNode(); - } - - /** {@inheritDoc} */ - protected void validate(Document doc) throws SAXException, IOException { - Schema schema = getIFSchema(); - if (schema == null) { - return; //skip validation; - } - Validator validator = schema.newValidator(); - validator.setErrorHandler(new ErrorHandler() { - - public void error(SAXParseException exception) throws SAXException { - throw exception; - } - - public void fatalError(SAXParseException exception) throws SAXException { - throw exception; - } - - public void warning(SAXParseException exception) throws SAXException { - //ignore - } - - }); - validator.validate(new DOMSource(doc)); - } - - /** {@inheritDoc} */ + @Override protected void parseAndRender(Source src, OutputStream out) throws Exception { IFParser parser = new IFParser(); @@ -170,6 +65,7 @@ public class IFParserTestCase extends AbstractIntermediateTestCase { } /** {@inheritDoc} */ + @Override protected Document parseAndRenderToIntermediateFormat(Source src) throws Exception { IFParser parser = new IFParser(); @@ -185,4 +81,11 @@ public class IFParserTestCase extends AbstractIntermediateTestCase { return (Document)domResult.getNode(); } + /** {@inheritDoc} */ + @Override + public void runTest() throws Exception { + testParserToIntermediateFormat(); + testParserToPDF(); + } + } diff --git a/test/java/org/apache/fop/intermediate/IFTestCase.java b/test/java/org/apache/fop/intermediate/IFTestCase.java new file mode 100644 index 000000000..30cb56b07 --- /dev/null +++ b/test/java/org/apache/fop/intermediate/IFTestCase.java @@ -0,0 +1,77 @@ +/* + * 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.intermediate; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; + +import javax.xml.transform.Source; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + + +/** + * Test case for the IF output. + */ +public class IFTestCase extends AbstractIFTestCase { + + private final IFTester ifTester; + + /** + * Creates a new test case. + * + * @param test the file containing the test case + * @param ifTester the helper instance that will perform checks + * @throws IOException if an I/O error occurs while loading the test case + */ + public IFTestCase(File test, IFTester ifTester) throws IOException { + super(test); + this.ifTester = ifTester; + this.testDir = test.getParentFile(); + } + + /** {@inheritDoc} */ + @Override + protected void runTest() throws Exception { + Element testRoot = testAssistant.getTestRoot(testFile); + NodeList nodes = testRoot.getElementsByTagName("if-checks"); + if (nodes.getLength() == 0) { + throw new RuntimeException("No IF check found"); + } + Element ifChecks = (Element) nodes.item(0); + + Document doc = buildIntermediateDocument(testAssistant.getTestcase2FOStylesheet()); + ifTester.doIFChecks(getName(), ifChecks, doc); + } + + @Override + protected void parseAndRender(Source src, OutputStream out) throws Exception { + throw new IllegalStateException("Not applicable to this test"); + } + + @Override + protected Document parseAndRenderToIntermediateFormat(Source src) throws Exception { + throw new IllegalStateException("Not applicable to this test"); + } + +} diff --git a/test/java/org/apache/fop/intermediate/IFTester.java b/test/java/org/apache/fop/intermediate/IFTester.java index 7534309e7..46303d874 100644 --- a/test/java/org/apache/fop/intermediate/IFTester.java +++ b/test/java/org/apache/fop/intermediate/IFTester.java @@ -20,182 +20,63 @@ package org.apache.fop.intermediate; import java.io.File; -import java.lang.reflect.Constructor; -import java.util.Iterator; import java.util.List; -import java.util.Map; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.area.AreaTreeModel; -import org.apache.fop.area.AreaTreeParser; -import org.apache.fop.area.RenderPagesModel; -import org.apache.fop.events.model.EventSeverity; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.layoutengine.EvalCheck; -import org.apache.fop.layoutengine.TrueCheck; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFRenderer; -import org.apache.fop.render.intermediate.IFSerializer; -import org.apache.fop.util.ConsoleEventListenerForTests; -import org.apache.fop.util.DelegatingContentHandler; /** * Does tests on the intermediate format. */ public class IFTester { - private static final Map IF_CHECK_CLASSES = new java.util.HashMap(); - - static { - IF_CHECK_CLASSES.put("true", TrueCheck.class); - IF_CHECK_CLASSES.put("eval", EvalCheck.class); - } - - private FopFactory fopFactory = FopFactory.newInstance(); + private final IFChecksFactory ifChecksFactory = new IFChecksFactory(); - private SAXTransformerFactory tfactory - = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); + private final TransformerFactory tfactory; private File backupDir; /** - * Main constructor + * Main constructor. + * + * @param transformerFactory the factory used to serialize the intermediate format files * @param backupDir an optional directory in which to write the serialized - * intermediate format file (may be null) + * IF files (may be null) */ - public IFTester(File backupDir) { + public IFTester(TransformerFactory transformerFactory, File backupDir) { + this.tfactory = transformerFactory; this.backupDir = backupDir; } - /** - * Factory method to create IF checks from DOM elements. - * @param el DOM element to create the check from - * @return The newly create check - */ - protected IFCheck createIFCheck(Element el) { - String name = el.getTagName(); - Class clazz = (Class)IF_CHECK_CLASSES.get(name); - if (clazz != null) { - try { - Constructor c = clazz.getDeclaredConstructor(new Class[] {Node.class}); - IFCheck instance = (IFCheck)c.newInstance(new Object[] {el}); - return instance; - } catch (Exception e) { - throw new RuntimeException("Error while instantiating check '" - + name + "': " + e.getMessage()); - } - } else { - throw new IllegalArgumentException("No check class found: " + name); - } - } - - private Document createIF(File testFile, Document areaTreeXML) throws TransformerException { - try { - FOUserAgent ua = fopFactory.newFOUserAgent(); - ua.setBaseURL(testFile.getParentFile().toURI().toURL().toExternalForm()); - ua.getEventBroadcaster().addEventListener( - new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); - - IFRenderer ifRenderer = new IFRenderer(); - ifRenderer.setUserAgent(ua); - - IFSerializer serializer = new IFSerializer(); - serializer.setContext(new IFContext(ua)); - DOMResult result = new DOMResult(); - serializer.setResult(result); - ifRenderer.setDocumentHandler(serializer); - - ua.setRendererOverride(ifRenderer); - FontInfo fontInfo = new FontInfo(); - //Construct the AreaTreeModel that will received the individual pages - final AreaTreeModel treeModel = new RenderPagesModel(ua, - null, fontInfo, null); - - //Iterate over all intermediate files - AreaTreeParser parser = new AreaTreeParser(); - ContentHandler handler = parser.getContentHandler(treeModel, ua); - - DelegatingContentHandler proxy = new DelegatingContentHandler() { - - public void endDocument() throws SAXException { - super.endDocument(); - //Signal the end of the processing. - //The renderer can finalize the target document. - treeModel.endDocument(); - } - - }; - proxy.setDelegateContentHandler(handler); - - Transformer transformer = tfactory.newTransformer(); - transformer.transform(new DOMSource(areaTreeXML), new SAXResult(proxy)); - - return (Document)result.getNode(); - } catch (Exception e) { - throw new TransformerException( - "Error while generating intermediate format file: " + e.getMessage(), e); - } - } - /** * Runs the intermediate format checks. - * @param testFile the original test file + * @param testName the name of the test case * @param checksRoot the root element containing the IF checks - * @param areaTreeXML the area tree XML + * @param ifDocument the IF XML * @throws TransformerException if an error occurs while transforming the content */ - public void doIFChecks(File testFile, Element checksRoot, Document areaTreeXML) - throws TransformerException { - Document ifDocument = createIF(testFile, areaTreeXML); + public void doIFChecks(String testName, Element checksRoot, Document ifDocument) + throws TransformerException { if (this.backupDir != null) { Transformer transformer = tfactory.newTransformer(); Source src = new DOMSource(ifDocument); - File targetFile = new File(this.backupDir, testFile.getName() + ".if.xml"); + File targetFile = new File(this.backupDir, testName + ".if.xml"); Result res = new StreamResult(targetFile); transformer.transform(src, res); } - - //First create check before actually running them - List checks = new java.util.ArrayList(); - NodeList nodes = checksRoot.getChildNodes(); - for (int i = 0; i < nodes.getLength(); i++) { - Node node = nodes.item(i); - if (node instanceof Element) { - checks.add(createIFCheck((Element)node)); - } - } - + List checks = ifChecksFactory.createCheckList(checksRoot); if (checks.size() == 0) { - throw new RuntimeException("No checks are available!"); + throw new RuntimeException("No available IF check"); } - - //Run the actual tests now that we know that the checks themselves are ok - doIFChecks(checks, ifDocument); - } - - private void doIFChecks(List checks, Document ifDocument) { - Iterator i = checks.iterator(); - while (i.hasNext()) { - IFCheck check = (IFCheck)i.next(); + for (IFCheck check : checks) { check.check(ifDocument); } } diff --git a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java index 438ff7672..824fee6fd 100644 --- a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java +++ b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java @@ -20,52 +20,48 @@ package org.apache.fop.intermediate; import java.io.File; +import java.io.FilenameFilter; import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; + +import javax.xml.transform.TransformerFactory; import junit.framework.Test; import junit.framework.TestSuite; -import org.apache.fop.layoutengine.LayoutEngineTestSuite; - /** - * JUnit test suite for the intermediate format + * A test suite for testing the Intermediate Format output. */ -public class IntermediateFormatTestSuite { +public final class IntermediateFormatTestSuite { + + private IntermediateFormatTestSuite() { + // This is a utility class + } /** - * @return the test suite with all the tests (one for each XML file) - * @throws IOException in case of an I/O problem + * Creates a suite of Intermediate Format tests. + * + * @return the test suite + * @throws IOException if an I/O error occurs while loading one of the tests */ public static Test suite() throws IOException { - TestSuite suite = new TestSuite(); - Collection files = LayoutEngineTestSuite.getTestFiles(); + File backupDir = new File("build/test-results/intermediate"); + backupDir.mkdirs(); - Iterator i = files.iterator(); - while (i.hasNext()) { - File f = (File)i.next(); - addIFTestCase(suite, f); - } + IFTester ifTester = new IFTester(TransformerFactory.newInstance(), backupDir); - return suite; - } + TestSuite suite = new TestSuite(); + File testDir = new File("test/intermediate"); + String[] tests = testDir.list(new FilenameFilter() { - private static void addIFTestCase(TestSuite suite, - final File f) throws IOException { - suite.addTest(new IFParserTestCase(f) { - public void runTest() throws Exception { - try { - testParserToIntermediateFormat(); - testParserToPDF(); - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog( - this.getClass()).error("Error on " + f.getName()); - throw e; - } + public boolean accept(File dir, String name) { + return name.endsWith(".xml"); } }); + for (String test : tests) { + File testFile = new File(testDir, test); + suite.addTest(new IFTestCase(testFile, ifTester)); + } + return suite; } - } diff --git a/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java b/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java new file mode 100644 index 000000000..720556a6b --- /dev/null +++ b/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.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.intermediate; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Iterator; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.fop.layoutengine.LayoutEngineTestSuite; + +/** + * JUnit test suite for the intermediate format + */ +public final class LayoutIFTestSuite { + + private LayoutIFTestSuite() { + // This is a utility class + } + + /** + * @return the test suite with all the tests (one for each XML file) + * @throws IOException in case of an I/O problem + */ + public static Test suite() throws IOException { + TestSuite suite = new TestSuite(); + + Collection files = LayoutEngineTestSuite.getTestFiles(); + + Iterator i = files.iterator(); + while (i.hasNext()) { + File f = (File)i.next(); + addIFTestCase(suite, f); + } + + return suite; + } + + private static void addIFTestCase(TestSuite suite, + final File f) throws IOException { + suite.addTest(new IFParserTestCase(f)); + } + +} diff --git a/test/java/org/apache/fop/intermediate/TestAssistant.java b/test/java/org/apache/fop/intermediate/TestAssistant.java new file mode 100644 index 000000000..7fd08dc3d --- /dev/null +++ b/test/java/org/apache/fop/intermediate/TestAssistant.java @@ -0,0 +1,189 @@ +/* + * 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.intermediate; + +import java.io.File; +import java.io.IOException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXTransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import org.apache.xpath.XPathAPI; +import org.apache.xpath.objects.XObject; + +import org.apache.fop.apps.FopFactory; + +/** + * Helper class for running FOP tests. + */ +public class TestAssistant { + + // configure fopFactory as desired + private FopFactory fopFactory = FopFactory.newInstance(); + private FopFactory fopFactoryWithBase14Kerning = FopFactory.newInstance(); + + private SAXTransformerFactory tfactory + = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); + + private DocumentBuilderFactory domBuilderFactory; + + private Templates testcase2fo; + private Templates testcase2checks; + + /** + * Main constructor. + */ + public TestAssistant() { + fopFactory.getFontManager().setBase14KerningEnabled(false); + fopFactoryWithBase14Kerning.getFontManager().setBase14KerningEnabled(true); + domBuilderFactory = DocumentBuilderFactory.newInstance(); + domBuilderFactory.setNamespaceAware(true); + domBuilderFactory.setValidating(false); + } + + /** + * Returns the stylesheet for convert extracting the XSL-FO part from the test case. + * @return the stylesheet + * @throws TransformerConfigurationException if an error occurs loading the stylesheet + */ + public Templates getTestcase2FOStylesheet() throws TransformerConfigurationException { + if (testcase2fo == null) { + //Load and cache stylesheet + Source src = new StreamSource(new File("test/layoutengine/testcase2fo.xsl")); + testcase2fo = tfactory.newTemplates(src); + } + return testcase2fo; + } + + /** + * Returns the stylesheet for convert extracting the checks from the test case. + * @return the stylesheet + * @throws TransformerConfigurationException if an error occurs loading the stylesheet + */ + private Templates getTestcase2ChecksStylesheet() throws TransformerConfigurationException { + if (testcase2checks == null) { + //Load and cache stylesheet + Source src = new StreamSource(new File("test/layoutengine/testcase2checks.xsl")); + testcase2checks = tfactory.newTemplates(src); + } + return testcase2checks; + } + + /** + * Returns the element from the given XML file that encloses the tests. + * + * @param testFile a test case + * @return the parent element of the group(s) of checks + * @throws TransformerException if an error occurs while extracting the test element + */ + public Element getTestRoot(File testFile) throws TransformerException { + Transformer transformer = getTestcase2ChecksStylesheet().newTransformer(); + DOMResult res = new DOMResult(); + transformer.transform(new StreamSource(testFile), res); + Document doc = (Document) res.getNode(); + return doc.getDocumentElement(); + } + + public FopFactory getFopFactory(boolean base14KerningEnabled) { + FopFactory effFactory = (base14KerningEnabled ? fopFactoryWithBase14Kerning : fopFactory); + return effFactory; + } + + public FopFactory getFopFactory(Document testDoc) { + boolean base14KerningEnabled = isBase14KerningEnabled(testDoc); + FopFactory effFactory = getFopFactory(base14KerningEnabled); + + boolean strictValidation = isStrictValidation(testDoc); + effFactory.setStrictValidation(strictValidation); + + return effFactory; + } + + private boolean isBase14KerningEnabled(Document testDoc) { + try { + XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning"); + String s = xo.str(); + return ("true".equalsIgnoreCase(s)); + } catch (TransformerException e) { + throw new RuntimeException("Error while evaluating XPath expression", e); + } + } + + private boolean isStrictValidation(Document testDoc) { + try { + XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/strict-validation"); + return !("false".equalsIgnoreCase(xo.str())); + } catch (TransformerException e) { + throw new RuntimeException("Error while evaluating XPath expression", e); + } + } + + /** + * Loads a test case into a DOM document. + * @param testFile the test file + * @return the loaded test case + * @throws IOException if an I/O error occurs loading the test case + */ + public Document loadTestCase(File testFile) + throws IOException { + try { + DocumentBuilder builder = domBuilderFactory.newDocumentBuilder(); + Document testDoc = builder.parse(testFile); + return testDoc; + } catch (Exception e) { + throw new IOException("Error while loading test case: " + e.getMessage()); + } + } + + /** + * Serialize the DOM for later inspection. + * @param doc the DOM document + * @param target target file + * @throws TransformerException if a problem occurs during serialization + */ + public void saveDOM(Document doc, File target) throws TransformerException { + Transformer transformer = getTransformerFactory().newTransformer(); + Source src = new DOMSource(doc); + Result res = new StreamResult(target); + transformer.transform(src, res); + } + + /** + * Returns the SAXTransformerFactory. + * @return the SAXTransformerFactory + */ + public SAXTransformerFactory getTransformerFactory() { + return tfactory; + } +} diff --git a/test/java/org/apache/fop/layoutengine/EvalCheck.java b/test/java/org/apache/fop/layoutengine/EvalCheck.java index 32d9e689b..8065512a7 100644 --- a/test/java/org/apache/fop/layoutengine/EvalCheck.java +++ b/test/java/org/apache/fop/layoutengine/EvalCheck.java @@ -41,16 +41,6 @@ public class EvalCheck implements LayoutEngineCheck, IFCheck { private double tolerance; private PrefixResolver prefixResolver; - /** - * Creates a new instance - * @param expected expected value - * @param xpath XPath statement that needs to be evaluated - */ - public EvalCheck(String expected, String xpath) { - this.expected = expected; - this.xpath = xpath; - } - /** * Creates a new instance from a DOM node. * @param node DOM node that defines this check diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java b/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java index 155db2263..ca979efe5 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java @@ -19,10 +19,12 @@ package org.apache.fop.layoutengine; +import org.apache.fop.check.Check; + /** * Defines the interface for check operations. */ -public interface LayoutEngineCheck { +public interface LayoutEngineCheck extends Check { /** * Called to perform the check. diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineChecksFactory.java b/test/java/org/apache/fop/layoutengine/LayoutEngineChecksFactory.java new file mode 100644 index 000000000..bea54c5f8 --- /dev/null +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineChecksFactory.java @@ -0,0 +1,62 @@ +/* + * 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.layoutengine; + +import org.w3c.dom.Element; + +import org.apache.fop.check.ChecksFactory; + +/** + * A factory class for creating {@link LayoutEngineCheck} instances. + */ +final class LayoutEngineChecksFactory extends ChecksFactory { + + LayoutEngineChecksFactory() { + registerCheckFactory("true", new CheckFactory() { + + public LayoutEngineCheck createCheck(Element element) { + return new TrueCheck(element); + } + + }); + registerCheckFactory("eval", new CheckFactory() { + + public LayoutEngineCheck createCheck(Element element) { + return new EvalCheck(element); + } + + }); + registerCheckFactory("element-list", new CheckFactory() { + + public LayoutEngineCheck createCheck(Element element) { + return new ElementListCheck(element); + } + + }); + registerCheckFactory("result", new CheckFactory() { + + public LayoutEngineCheck createCheck(Element element) { + return new ResultCheck(element); + } + + }); + } + +} diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java index 32a48fb0b..397374657 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java @@ -56,12 +56,16 @@ import org.apache.fop.DebugHelper; /** * JUnit test suit for running layout engine test under JUnit control. */ -public class LayoutEngineTestSuite { +public final class LayoutEngineTestSuite { static { DebugHelper.registerStandardElementListObservers(); } + private LayoutEngineTestSuite() { + // This is a utility class + } + public static String[] readDisabledTestcases(File f) throws IOException { List lines = new java.util.ArrayList(); Source stylesheet = new StreamSource( @@ -178,45 +182,33 @@ public class LayoutEngineTestSuite { Iterator i = files.iterator(); while (i.hasNext()) { File f = (File)i.next(); - addTestCase(suite, tester, f); + suite.addTest(new LayoutEngineTestCase(f, tester)); } return suite; } - private static void addTestCase(TestSuite suite, - final LayoutEngineTester tester, final File f) { - suite.addTest(new LayoutEngineTestCase(f.getName()) { - public void runTest() throws Exception { - try { - prepare(tester, f); - testMain(); - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog( - this.getClass()).error("Error on " + f.getName()); - throw e; - } - } - }); - } - private static class LayoutEngineTestCase extends TestCase { - private LayoutEngineTester tester; - private File testFile; + private final File testFile; - public LayoutEngineTestCase(String name) { - super(name); - } + private final LayoutEngineTester tester; - public void prepare(LayoutEngineTester tester, File testFile) { - //super(testFile.getName()); - this.tester = tester; + LayoutEngineTestCase(File testFile, LayoutEngineTester tester) { + super(testFile.getName()); this.testFile = testFile; + this.tester = tester; } - public void testMain() throws Exception { - tester.runTest(testFile); + @Override + protected void runTest() throws Throwable { + try { + tester.runTest(testFile); + } catch (Exception e) { + org.apache.commons.logging.LogFactory.getLog( + this.getClass()).error("Error on " + getName()); + throw e; + } } } } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java index 2c0cf8504..51c05a95f 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java @@ -21,37 +21,42 @@ package org.apache.fop.layoutengine; import java.io.File; import java.io.IOException; -import java.lang.reflect.Constructor; -import java.util.Iterator; import java.util.List; -import java.util.Map; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamSource; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; - +import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FormattingResults; +import org.apache.fop.area.AreaTreeModel; +import org.apache.fop.area.AreaTreeParser; +import org.apache.fop.area.RenderPagesModel; import org.apache.fop.events.model.EventSeverity; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.intermediate.IFTester; +import org.apache.fop.intermediate.TestAssistant; import org.apache.fop.layoutmgr.ElementListObserver; +import org.apache.fop.render.intermediate.IFContext; +import org.apache.fop.render.intermediate.IFRenderer; +import org.apache.fop.render.intermediate.IFSerializer; import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.util.ConsoleEventListenerForTests; +import org.apache.fop.util.DelegatingContentHandler; /** * Class for testing the FOP's layout engine using testcases specified in XML @@ -59,19 +64,13 @@ import org.apache.fop.util.ConsoleEventListenerForTests; */ public class LayoutEngineTester { - private static final Map AT_CHECK_CLASSES = new java.util.HashMap(); - - private TestEnvironment env = new TestEnvironment(); + private TestAssistant testAssistant = new TestAssistant(); + private LayoutEngineChecksFactory layoutEngineChecksFactory = new LayoutEngineChecksFactory(); private File areaTreeBackupDir; private IFTester ifTester; - static { - AT_CHECK_CLASSES.put("true", TrueCheck.class); - AT_CHECK_CLASSES.put("eval", EvalCheck.class); - AT_CHECK_CLASSES.put("element-list", ElementListCheck.class); - AT_CHECK_CLASSES.put("result", ResultCheck.class); - } + private TransformerFactory tfactory = TransformerFactory.newInstance(); /** * Constructs a new instance. @@ -80,7 +79,7 @@ public class LayoutEngineTester { */ public LayoutEngineTester(File areaTreeBackupDir) { this.areaTreeBackupDir = areaTreeBackupDir; - this.ifTester = new IFTester(areaTreeBackupDir); + this.ifTester = new IFTester(tfactory, areaTreeBackupDir); } /** @@ -100,18 +99,18 @@ public class LayoutEngineTester { ElementListObserver.addObserver(elCollector); Fop fop; - + FopFactory effFactory; try { - Document testDoc = env.loadTestCase(testFile); - FopFactory effFactory = env.getFopFactory(testDoc); + Document testDoc = testAssistant.loadTestCase(testFile); + effFactory = testAssistant.getFopFactory(testDoc); //Setup Transformer to convert the testcase XML to XSL-FO - Transformer transformer = env.getTestcase2FOStylesheet().newTransformer(); + Transformer transformer = testAssistant.getTestcase2FOStylesheet().newTransformer(); Source src = new DOMSource(testDoc); //Setup Transformer to convert the area tree to a DOM TransformerHandler athandler; - athandler = env.getTransformerFactory().newTransformerHandler(); + athandler = testAssistant.getTransformerFactory().newTransformerHandler(); athandler.setResult(domres); //Setup FOP for area tree rendering @@ -134,91 +133,96 @@ public class LayoutEngineTester { Document doc = (Document)domres.getNode(); if (this.areaTreeBackupDir != null) { - env.saveDOM(doc, + testAssistant.saveDOM(doc, new File(this.areaTreeBackupDir, testFile.getName() + ".at.xml")); } FormattingResults results = fop.getResults(); LayoutResult result = new LayoutResult(doc, elCollector, results); - checkAll(testFile, result); + checkAll(effFactory, testFile, result); } - /** - * Factory method to create AT checks from DOM elements. - * @param el DOM element to create the check from - * @return The newly create check - */ - protected LayoutEngineCheck createATCheck(Element el) { - String name = el.getTagName(); - Class clazz = (Class)AT_CHECK_CLASSES.get(name); - if (clazz != null) { - try { - Constructor c = clazz.getDeclaredConstructor(new Class[] {Node.class}); - LayoutEngineCheck instance = (LayoutEngineCheck)c.newInstance(new Object[] {el}); - return instance; - } catch (Exception e) { - throw new RuntimeException("Error while instantiating check '" - + name + "': " + e.getMessage()); - } - } else { - throw new IllegalArgumentException("No check class found: " + name); - } - } - - /** * Perform all checks on the area tree and, optionally, on the intermediate format. * @param testFile Test case XML file * @param result The layout results * @throws TransformerException if a problem occurs in XSLT/JAXP */ - protected void checkAll(File testFile, LayoutResult result) throws TransformerException { - Transformer transformer = env.getTestcase2ChecksStylesheet().newTransformer(); - Source src = new StreamSource(testFile); - DOMResult res = new DOMResult(); - transformer.transform(src, res); - - Document doc = (Document)res.getNode(); - Element root = doc.getDocumentElement(); + protected void checkAll(FopFactory fopFactory, File testFile, LayoutResult result) + throws TransformerException { + Element testRoot = testAssistant.getTestRoot(testFile); NodeList nodes; //AT tests only when checks are available - nodes = root.getElementsByTagName("at-checks"); + nodes = testRoot.getElementsByTagName("at-checks"); if (nodes.getLength() > 0) { Element atChecks = (Element)nodes.item(0); doATChecks(atChecks, result); } //IF tests only when checks are available - nodes = root.getElementsByTagName("if-checks"); + nodes = testRoot.getElementsByTagName("if-checks"); if (nodes.getLength() > 0) { Element ifChecks = (Element)nodes.item(0); - ifTester.doIFChecks(testFile, ifChecks, result.getAreaTree()); + Document ifDocument = createIF(fopFactory, testFile, result.getAreaTree()); + ifTester.doIFChecks(testFile.getName(), ifChecks, ifDocument); } } - private void doATChecks(Element checksRoot, LayoutResult result) { - //First create check before actually running them - List checks = new java.util.ArrayList(); - NodeList nodes = checksRoot.getChildNodes(); - for (int i = 0; i < nodes.getLength(); i++) { - Node node = nodes.item(i); - if (node instanceof Element) { - checks.add(createATCheck((Element)node)); - } - } + private Document createIF(FopFactory fopFactory, File testFile, Document areaTreeXML) + throws TransformerException { + try { + FOUserAgent ua = fopFactory.newFOUserAgent(); + ua.setBaseURL(testFile.getParentFile().toURI().toURL().toExternalForm()); + ua.getEventBroadcaster().addEventListener( + new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); - if (checks.size() == 0) { - throw new RuntimeException("No checks are available!"); - } + IFRenderer ifRenderer = new IFRenderer(); + ifRenderer.setUserAgent(ua); + + IFSerializer serializer = new IFSerializer(); + serializer.setContext(new IFContext(ua)); + DOMResult result = new DOMResult(); + serializer.setResult(result); + ifRenderer.setDocumentHandler(serializer); + + ua.setRendererOverride(ifRenderer); + FontInfo fontInfo = new FontInfo(); + //Construct the AreaTreeModel that will received the individual pages + final AreaTreeModel treeModel = new RenderPagesModel(ua, + null, fontInfo, null); + + //Iterate over all intermediate files + AreaTreeParser parser = new AreaTreeParser(); + ContentHandler handler = parser.getContentHandler(treeModel, ua); + + DelegatingContentHandler proxy = new DelegatingContentHandler() { - //Run the actual tests now that we know that the checks themselves are ok - doATChecks(checks, result); + public void endDocument() throws SAXException { + super.endDocument(); + //Signal the end of the processing. + //The renderer can finalize the target document. + treeModel.endDocument(); + } + + }; + proxy.setDelegateContentHandler(handler); + + Transformer transformer = tfactory.newTransformer(); + transformer.transform(new DOMSource(areaTreeXML), new SAXResult(proxy)); + + return (Document)result.getNode(); + } catch (Exception e) { + throw new TransformerException( + "Error while generating intermediate format file: " + e.getMessage(), e); + } } - private void doATChecks(List checks, LayoutResult result) { - Iterator i = checks.iterator(); - while (i.hasNext()) { - LayoutEngineCheck check = (LayoutEngineCheck)i.next(); + private void doATChecks(Element checksRoot, LayoutResult result) { + List checks = layoutEngineChecksFactory.createCheckList(checksRoot); + if (checks.size() == 0) { + throw new RuntimeException("No available area tree check"); + } + for (LayoutEngineCheck check : checks) { check.check(result); } } diff --git a/test/java/org/apache/fop/layoutengine/ResultCheck.java b/test/java/org/apache/fop/layoutengine/ResultCheck.java index 54af77a43..ce95c5024 100644 --- a/test/java/org/apache/fop/layoutengine/ResultCheck.java +++ b/test/java/org/apache/fop/layoutengine/ResultCheck.java @@ -19,9 +19,10 @@ package org.apache.fop.layoutengine; -import org.apache.fop.apps.FormattingResults; import org.w3c.dom.Node; +import org.apache.fop.apps.FormattingResults; + /** * Simple check that requires a result property to evaluate to the expected value */ @@ -30,16 +31,6 @@ public class ResultCheck implements LayoutEngineCheck { private String expected; private String property; - /** - * Creates a new instance - * @param expected expected value - * @param property property of which the value needs to be evaluated - */ - public ResultCheck(String expected, String property) { - this.expected = expected; - this.property = property; - } - /** * Creates a new instance from a DOM node. * @param node DOM node that defines this check diff --git a/test/java/org/apache/fop/layoutengine/TestEnvironment.java b/test/java/org/apache/fop/layoutengine/TestEnvironment.java deleted file mode 100644 index ad976ff8c..000000000 --- a/test/java/org/apache/fop/layoutengine/TestEnvironment.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.layoutengine; - -import java.io.File; -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.w3c.dom.Document; - -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XObject; - -import org.apache.fop.apps.FopFactory; - -/** - * Test environment and helper code for running FOP tests. - */ -public class TestEnvironment { - - // configure fopFactory as desired - private FopFactory fopFactory = FopFactory.newInstance(); - private FopFactory fopFactoryWithBase14Kerning = FopFactory.newInstance(); - - private SAXTransformerFactory tfactory - = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - - private DocumentBuilderFactory domBuilderFactory; - - private Templates testcase2fo; - private Templates testcase2checks; - - /** - * Main constructor. - */ - public TestEnvironment() { - fopFactory.getFontManager().setBase14KerningEnabled(false); - fopFactoryWithBase14Kerning.getFontManager().setBase14KerningEnabled(true); - domBuilderFactory = DocumentBuilderFactory.newInstance(); - domBuilderFactory.setNamespaceAware(true); - domBuilderFactory.setValidating(false); - } - - /** - * Returns the stylesheet for convert extracting the XSL-FO part from the test case. - * @return the stylesheet - * @throws TransformerConfigurationException if an error occurs loading the stylesheet - */ - public Templates getTestcase2FOStylesheet() throws TransformerConfigurationException { - if (testcase2fo == null) { - //Load and cache stylesheet - Source src = new StreamSource(new File("test/layoutengine/testcase2fo.xsl")); - testcase2fo = tfactory.newTemplates(src); - } - return testcase2fo; - } - - /** - * Returns the stylesheet for convert extracting the checks from the test case. - * @return the stylesheet - * @throws TransformerConfigurationException if an error occurs loading the stylesheet - */ - public Templates getTestcase2ChecksStylesheet() throws TransformerConfigurationException { - if (testcase2checks == null) { - //Load and cache stylesheet - Source src = new StreamSource(new File("test/layoutengine/testcase2checks.xsl")); - testcase2checks = tfactory.newTemplates(src); - } - return testcase2checks; - } - - public FopFactory getFopFactory(boolean base14KerningEnabled) { - FopFactory effFactory = (base14KerningEnabled ? fopFactoryWithBase14Kerning : fopFactory); - return effFactory; - } - - public FopFactory getFopFactory(Document testDoc) { - boolean base14KerningEnabled = isBase14KerningEnabled(testDoc); - FopFactory effFactory = getFopFactory(base14KerningEnabled); - - boolean strictValidation = isStrictValidation(testDoc); - effFactory.setStrictValidation(strictValidation); - - return effFactory; - } - - private boolean isBase14KerningEnabled(Document testDoc) { - try { - XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning"); - String s = xo.str(); - return ("true".equalsIgnoreCase(s)); - } catch (TransformerException e) { - throw new RuntimeException("Error while evaluating XPath expression", e); - } - } - - private boolean isStrictValidation(Document testDoc) { - try { - XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/strict-validation"); - return !("false".equalsIgnoreCase(xo.str())); - } catch (TransformerException e) { - throw new RuntimeException("Error while evaluating XPath expression", e); - } - } - - /** - * Loads a test case into a DOM document. - * @param testFile the test file - * @return the loaded test case - * @throws IOException if an I/O error occurs loading the test case - */ - public Document loadTestCase(File testFile) - throws IOException { - try { - DocumentBuilder builder = domBuilderFactory.newDocumentBuilder(); - Document testDoc = builder.parse(testFile); - return testDoc; - } catch (Exception e) { - throw new IOException("Error while loading test case: " + e.getMessage()); - } - } - - /** - * Serialize the DOM for later inspection. - * @param doc the DOM document - * @param target target file - * @throws TransformerException if a problem occurs during serialization - */ - public void saveDOM(Document doc, File target) throws TransformerException { - Transformer transformer = getTransformerFactory().newTransformer(); - Source src = new DOMSource(doc); - Result res = new StreamResult(target); - transformer.transform(src, res); - } - - /** - * Returns the SAXTransformerFactory. - * @return the SAXTransformerFactory - */ - public SAXTransformerFactory getTransformerFactory() { - return tfactory; - } -} diff --git a/test/java/org/apache/fop/layoutengine/TrueCheck.java b/test/java/org/apache/fop/layoutengine/TrueCheck.java index 94ae942de..77d76b91d 100644 --- a/test/java/org/apache/fop/layoutengine/TrueCheck.java +++ b/test/java/org/apache/fop/layoutengine/TrueCheck.java @@ -41,14 +41,6 @@ public class TrueCheck implements LayoutEngineCheck, IFCheck { private String failureMessage; private PrefixResolver prefixResolver; - /** - * Creates a new instance - * @param xpath XPath statement that needs to be evaluated - */ - public TrueCheck(String xpath) { - this.xpath = xpath; - } - /** * Creates a new instance from a DOM node. * @param node DOM node that defines this check -- cgit v1.2.3 From 8c3aa5ee7fae54a61a0481f663281fe9e9518f82 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 22 Apr 2011 07:15:43 +0000 Subject: Added option for PostScript output to optimize for file size rather than quality. Fixed some missing PostScript command mappings. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1095878 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/trunk/output.xml | 7 +++++ .../fop/render/intermediate/AbstractIFPainter.java | 27 +++++++++++++++++++ .../org/apache/fop/render/ps/PSBorderPainter.java | 17 +++++++----- src/java/org/apache/fop/render/ps/PSPainter.java | 15 +++++++---- .../fop/render/ps/PSRendererConfigurator.java | 5 ++++ .../org/apache/fop/render/ps/PSRenderingMode.java | 31 ++++++++++++++++++++++ .../org/apache/fop/render/ps/PSRenderingUtil.java | 20 ++++++++++++++ 7 files changed, 110 insertions(+), 12 deletions(-) create mode 100644 src/java/org/apache/fop/render/ps/PSRenderingMode.java (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index c174bf2b5..bc4d87088 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -287,6 +287,7 @@ out = proc.getOutputStream();]]> false false true + quality ]]>

The default value for the "auto-rotate-landscape" setting is "false". Setting it @@ -319,6 +320,12 @@ out = proc.getOutputStream();]]> the particular postscript implementation issuing unwanted postscript subsystem initgraphics/erasepage calls on each setpagedevice call.

+

+ The default value for the "rendering" setting is "quality". Setting it to "size" + optimizes rendering for smaller file sizes which can involve minor compromises in + rendering quality. For example, solid borders are then painted as plain rectangles + instead of the elaborate painting instructions required for mixed-color borders. +

Limitations diff --git a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java index 1b870a7c5..2226274ab 100644 --- a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java +++ b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java @@ -46,6 +46,7 @@ import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.fop.ResourceEventProducer; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; +import org.apache.fop.fo.Constants; import org.apache.fop.render.ImageHandler; import org.apache.fop.render.ImageHandlerRegistry; import org.apache.fop.render.ImageHandlerUtil; @@ -342,6 +343,32 @@ public abstract class AbstractIFPainter implements IFPainter { } } + /** + * Indicates whether the given border segments (if present) have only solid borders, i.e. + * could be painted in a simplified fashion keeping the output file smaller. + * @param before the border segment on the before-side (top) + * @param after the border segment on the after-side (bottom) + * @param start the border segment on the start-side (left) + * @param end the border segment on the end-side (right) + * @return true if any border segment has a non-solid border style + */ + protected boolean hasOnlySolidBorders(BorderProps before, BorderProps after, + BorderProps start, BorderProps end) { + if (before != null && before.style != Constants.EN_SOLID) { + return false; + } + if (after != null && after.style != Constants.EN_SOLID) { + return false; + } + if (start != null && start.style != Constants.EN_SOLID) { + return false; + } + if (end != null && end.style != Constants.EN_SOLID) { + return false; + } + return true; + } + /** {@inheritDoc} */ public void drawLine(Point start, Point end, int width, Color color, RuleStyle style) throws IFException { diff --git a/src/java/org/apache/fop/render/ps/PSBorderPainter.java b/src/java/org/apache/fop/render/ps/PSBorderPainter.java index 1e2964eed..a52974d36 100644 --- a/src/java/org/apache/fop/render/ps/PSBorderPainter.java +++ b/src/java/org/apache/fop/render/ps/PSBorderPainter.java @@ -62,9 +62,10 @@ public class PSBorderPainter extends BorderPainter { private static void drawLine(PSGenerator gen, float startx, float starty, float endx, float endy) throws IOException { gen.writeln(gen.formatDouble(startx) + " " - + gen.formatDouble(starty) + " M " + + gen.formatDouble(starty) + " " + gen.mapCommand("moveto") + " " + gen.formatDouble(endx) + " " - + gen.formatDouble(endy) + " lineto stroke newpath"); + + gen.formatDouble(endy) + " " + gen.mapCommand("lineto") + " " + + gen.mapCommand("stroke") + " " + gen.mapCommand("newpath")); } /** @@ -260,7 +261,8 @@ public class PSBorderPainter extends BorderPainter { lineTo(end.x, starty + 2 * half); lineTo(start.x, starty + 2 * half); closePath(); - generator.writeln(" fill newpath"); + generator.write(" " + generator.mapCommand("fill")); + generator.writeln(" " + generator.mapCommand("newpath")); generator.useColor(color); if (style == RuleStyle.GROOVE) { moveTo(start.x, starty); @@ -276,7 +278,8 @@ public class PSBorderPainter extends BorderPainter { lineTo(end.x - half, starty + half); } closePath(); - generator.writeln(" fill newpath"); + generator.write(" " + generator.mapCommand("fill")); + generator.writeln(" " + generator.mapCommand("newpath")); break; default: throw new UnsupportedOperationException("rule style not supported"); @@ -293,13 +296,13 @@ public class PSBorderPainter extends BorderPainter { /** {@inheritDoc} */ protected void moveTo(int x, int y) throws IOException { generator.writeln(generator.formatDouble(toPoints(x)) + " " - + generator.formatDouble(toPoints(y)) + " M"); + + generator.formatDouble(toPoints(y)) + " " + generator.mapCommand("moveto")); } /** {@inheritDoc} */ protected void lineTo(int x, int y) throws IOException { generator.writeln(generator.formatDouble(toPoints(x)) + " " - + generator.formatDouble(toPoints(y)) + " lineto"); + + generator.formatDouble(toPoints(y)) + " " + generator.mapCommand("lineto")); } /** {@inheritDoc} */ @@ -314,7 +317,7 @@ public class PSBorderPainter extends BorderPainter { /** {@inheritDoc} */ protected void clip() throws IOException { - generator.writeln("clip newpath"); + generator.writeln(generator.mapCommand("clip") + " " + generator.mapCommand("newpath")); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/ps/PSPainter.java b/src/java/org/apache/fop/render/ps/PSPainter.java index b8a6d40f6..1b1f9437d 100644 --- a/src/java/org/apache/fop/render/ps/PSPainter.java +++ b/src/java/org/apache/fop/render/ps/PSPainter.java @@ -202,7 +202,7 @@ public class PSPainter extends AbstractIFPainter { endTextObject(); generator.defineRect(rect.x / 1000.0, rect.y / 1000.0, rect.width / 1000.0, rect.height / 1000.0); - generator.writeln("clip newpath"); + generator.writeln(generator.mapCommand("clip") + " " + generator.mapCommand("newpath")); } catch (IOException ioe) { throw new IFException("I/O error in clipRect()", ioe); } @@ -226,7 +226,7 @@ public class PSPainter extends AbstractIFPainter { } generator.defineRect(rect.x / 1000.0, rect.y / 1000.0, rect.width / 1000.0, rect.height / 1000.0); - generator.writeln("fill"); + generator.writeln(generator.mapCommand("fill")); } catch (IOException ioe) { throw new IFException("I/O error in fillRect()", ioe); } @@ -239,7 +239,12 @@ public class PSPainter extends AbstractIFPainter { if (before != null || after != null || start != null || end != null) { try { endTextObject(); - this.borderPainter.drawBorders(rect, before, after, start, end); + if (getPSUtil().getRenderingMode() == PSRenderingMode.SIZE + && hasOnlySolidBorders(before, after, start, end)) { + super.drawBorderRect(rect, before, after, start, end); + } else { + this.borderPainter.drawBorders(rect, before, after, start, end); + } } catch (IOException ioe) { throw new IFException("I/O error in drawBorderRect()", ioe); } @@ -478,9 +483,9 @@ public class PSPainter extends AbstractIFPainter { spb.append(formatMptAsPt(generator, letterSpacing)) .append(" 0 "); sb.insert(0, spb.toString()); - sb.append(" ashow"); + sb.append(" " + generator.mapCommand("ashow")); } else { - sb.append(" show"); + sb.append(" " + generator.mapCommand("show")); } } generator.writeln(sb.toString()); diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java index 2280bf0dc..68f7e9d62 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java +++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java @@ -66,6 +66,11 @@ public class PSRendererConfigurator extends PrintRendererConfigurator if (child != null) { psUtil.setOptimizeResources(child.getValueAsBoolean(false)); } + child = cfg.getChild("rendering"); + if (child != null) { + psUtil.setRenderingMode(PSRenderingMode.valueOf( + child.getValue(psUtil.getRenderingMode().toString()).toUpperCase())); + } psUtil.setSafeSetPageDevice( cfg.getChild("safe-set-page-device").getValueAsBoolean(false)); psUtil.setDSCComplianceEnabled( diff --git a/src/java/org/apache/fop/render/ps/PSRenderingMode.java b/src/java/org/apache/fop/render/ps/PSRenderingMode.java new file mode 100644 index 000000000..dc48b56ac --- /dev/null +++ b/src/java/org/apache/fop/render/ps/PSRenderingMode.java @@ -0,0 +1,31 @@ +/* + * 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.ps; + +/** + * Enumeration that specifies the rendering mode for PostScript output. {@link #SIZE} tries + * to produce smaller files at the expense of quality, whereas {@link #QUALITY} tries to + * produce the best possible quality. + */ +enum PSRenderingMode { + + SIZE, QUALITY; + +} diff --git a/src/java/org/apache/fop/render/ps/PSRenderingUtil.java b/src/java/org/apache/fop/render/ps/PSRenderingUtil.java index d7890d144..b22391718 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderingUtil.java +++ b/src/java/org/apache/fop/render/ps/PSRenderingUtil.java @@ -56,6 +56,12 @@ public class PSRenderingUtil implements PSConfigurationConstants { /** Determines whether the PS file is generated in two passes to minimize file size */ private boolean optimizeResources = false; + /** + * Determines whether the generated PostScript code is optimized for minimum file size + * of best quality. + */ + private PSRenderingMode renderingMode = PSRenderingMode.QUALITY; + PSRenderingUtil(FOUserAgent userAgent) { this.userAgent = userAgent; initialize(); @@ -287,5 +293,19 @@ public class PSRenderingUtil implements PSConfigurationConstants { return optimizeResources; } + /** + * Sets the rendering mode. + * @param renderingMode the rendering mode + */ + public void setRenderingMode(PSRenderingMode renderingMode) { + this.renderingMode = renderingMode; + } + /** + * Returns the rendering mode. + * @return the rendering mode + */ + public PSRenderingMode getRenderingMode() { + return this.renderingMode; + } } -- cgit v1.2.3 From 79b6690593ef89e6549a9803eea478ab8134802b Mon Sep 17 00:00:00 2001 From: Peter Hancock Date: Mon, 20 Jun 2011 09:51:42 +0000 Subject: Added an IFDocumentHandler filter for triggering rendering events. Created an Event that captures an end page event with the page number. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1137566 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/RendererEventProducer.java | 7 +++ .../apache/fop/render/RendererEventProducer.xml | 1 + .../org/apache/fop/render/RendererFactory.java | 3 +- .../render/intermediate/EventProducingFilter.java | 54 ++++++++++++++++++++++ status.xml | 5 ++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/java/org/apache/fop/render/intermediate/EventProducingFilter.java (limited to 'src/java/org/apache/fop/render/intermediate') diff --git a/src/java/org/apache/fop/render/RendererEventProducer.java b/src/java/org/apache/fop/render/RendererEventProducer.java index 87b01b1cc..1f4be8e7e 100644 --- a/src/java/org/apache/fop/render/RendererEventProducer.java +++ b/src/java/org/apache/fop/render/RendererEventProducer.java @@ -53,4 +53,11 @@ public interface RendererEventProducer extends EventProducer { * @event.severity ERROR */ void ioError(Object source, IOException ioe); + + /** + * Triggered at the end of page rendering. + * @param source the event source + * @param number the page number + */ + void endPage(Object source, int number); } diff --git a/src/java/org/apache/fop/render/RendererEventProducer.xml b/src/java/org/apache/fop/render/RendererEventProducer.xml index abb15a89a..abc45eb6f 100644 --- a/src/java/org/apache/fop/render/RendererEventProducer.xml +++ b/src/java/org/apache/fop/render/RendererEventProducer.xml @@ -18,4 +18,5 @@ I/O error while writing to target file.[ Reason: {ioe}] + Rendered page #{number}. diff --git a/src/java/org/apache/fop/render/RendererFactory.java b/src/java/org/apache/fop/render/RendererFactory.java index febe5a9ea..bc598450f 100644 --- a/src/java/org/apache/fop/render/RendererFactory.java +++ b/src/java/org/apache/fop/render/RendererFactory.java @@ -35,6 +35,7 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.area.AreaTreeHandler; import org.apache.fop.fo.FOEventHandler; import org.apache.fop.render.intermediate.AbstractIFDocumentHandlerMaker; +import org.apache.fop.render.intermediate.EventProducingFilter; import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; import org.apache.fop.render.intermediate.IFRenderer; @@ -389,7 +390,7 @@ public class RendererFactory { if (configurator != null) { configurator.configure(documentHandler); } - return documentHandler; + return new EventProducingFilter(documentHandler, userAgent); } /** diff --git a/src/java/org/apache/fop/render/intermediate/EventProducingFilter.java b/src/java/org/apache/fop/render/intermediate/EventProducingFilter.java new file mode 100644 index 000000000..8ebc2fc46 --- /dev/null +++ b/src/java/org/apache/fop/render/intermediate/EventProducingFilter.java @@ -0,0 +1,54 @@ +/* + * 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.intermediate; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.render.RendererEventProducer; +import org.apache.fop.render.intermediate.util.IFDocumentHandlerProxy; + +/** + * A filter that uses the Event Notification System to broadcast IF events. + * + */ +public class EventProducingFilter extends IFDocumentHandlerProxy { + + private int pageNumberEnded; + + private FOUserAgent userAgent; + + /** + * Constructor + * @param ifDocumentHandler the IFDocumentHandler to filter + * @param userAgent the FOUerAgent + */ + public EventProducingFilter(IFDocumentHandler ifDocumentHandler, FOUserAgent userAgent) { + super(ifDocumentHandler); + this.userAgent = userAgent; + } + + @Override + public void endPage() throws IFException { + super.endPage(); + pageNumberEnded++; + RendererEventProducer.Provider.get(userAgent.getEventBroadcaster()) + .endPage(this, pageNumberEnded); + } + +} \ No newline at end of file diff --git a/status.xml b/status.xml index f1b5de7b7..ec3f9b6ff 100644 --- a/status.xml +++ b/status.xml @@ -30,6 +30,7 @@