aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2014-08-07 06:46:57 +0000
committerGlenn Adams <gadams@apache.org>2014-08-07 06:46:57 +0000
commit84bc994a2232516d12253ba23b3a29fbc47ea291 (patch)
tree8ebb60448d57b8f934cbcb0b2d37331dc738dfe8 /src
parentc7d7ed1ee64ee057fc36b444161b0f982cd6e447 (diff)
downloadxmlgraphics-fop-84bc994a2232516d12253ba23b3a29fbc47ea291.tar.gz
xmlgraphics-fop-84bc994a2232516d12253ba23b3a29fbc47ea291.zip
Fix 2-instance findbug warnings.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1616416 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/afp/AFPPaintingState.java2
-rw-r--r--src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java14
-rw-r--r--src/java/org/apache/fop/cli/Main.java11
-rw-r--r--src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java2
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageProductionException.java2
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequence.java2
-rw-r--r--src/java/org/apache/fop/fo/properties/CharacterProperty.java2
-rw-r--r--src/java/org/apache/fop/fo/properties/GenericShorthandParser.java9
-rw-r--r--src/java/org/apache/fop/fonts/Glyphs.java2
-rw-r--r--src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java9
-rw-r--r--src/java/org/apache/fop/fonts/truetype/OpenFont.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractBreaker.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java37
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java2
-rw-r--r--src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java2
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java9
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java2
-rw-r--r--src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java87
-rw-r--r--src/java/org/apache/fop/render/ps/PSImageFormResource.java10
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java2
-rw-r--r--src/java/org/apache/fop/servlet/FopServlet.java2
-rw-r--r--src/java/org/apache/fop/tools/TestConverter.java15
-rw-r--r--src/java/org/apache/fop/tools/anttasks/RunTest.java11
-rw-r--r--src/java/org/apache/fop/util/AbstractPaintingState.java2
-rw-r--r--src/java/org/apache/fop/util/ColorWithFallback.java19
27 files changed, 165 insertions, 104 deletions
diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java
index 74506aa7e..5a606dfdf 100644
--- a/src/java/org/apache/fop/afp/AFPPaintingState.java
+++ b/src/java/org/apache/fop/afp/AFPPaintingState.java
@@ -57,7 +57,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
private float bitmapEncodingQuality;
/** color image handler */
- private ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
+ private transient ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
/**
* true if certain image formats may be embedded unchanged in their native
diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
index 01333f367..d9836f682 100644
--- a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
+++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
@@ -130,13 +130,17 @@ public abstract class AbstractGraphicsCoord extends AbstractGraphicsDrawingOrder
/** {@inheritDoc} */
public String toString() {
- String coordsStr = "";
+ StringBuffer sb = new StringBuffer();
for (int i = 0; i < coords.length; i++) {
- coordsStr += (i % 2 == 0) ? "x" : "y";
- coordsStr += (i / 2) + "=" + coords[i] + ",";
+ if (sb.length() > 0) {
+ sb.append(',');
+ }
+ sb.append((i % 2 == 0) ? 'x' : 'y');
+ sb.append(i / 2);
+ sb.append('=');
+ sb.append(coords[i]);
}
- coordsStr = coordsStr.substring(0, coordsStr.length() - 1);
- return getName() + "{" + coordsStr + "}";
+ return getName() + "{" + sb.toString() + "}";
}
/**
diff --git a/src/java/org/apache/fop/cli/Main.java b/src/java/org/apache/fop/cli/Main.java
index 6ae81ea21..648313efd 100644
--- a/src/java/org/apache/fop/cli/Main.java
+++ b/src/java/org/apache/fop/cli/Main.java
@@ -25,6 +25,8 @@ import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.List;
import org.apache.commons.io.IOUtils;
@@ -125,10 +127,15 @@ public final class Main {
*/
public static void startFOPWithDynamicClasspath(String[] args) {
try {
- URL[] urls = getJARList();
+ final URL[] urls = getJARList();
//System.out.println("CCL: "
// + Thread.currentThread().getContextClassLoader().toString());
- ClassLoader loader = new java.net.URLClassLoader(urls, null);
+ ClassLoader loader = (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new java.net.URLClassLoader(urls, null);
+ }
+ });
Thread.currentThread().setContextClassLoader(loader);
Class clazz = Class.forName("org.apache.fop.cli.Main", true, loader);
//System.out.println("CL: " + clazz.getClassLoader().toString());
diff --git a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
index 99855b815..49a67a154 100644
--- a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
@@ -104,7 +104,7 @@ public abstract class AbstractPageSequence extends FObj implements CommonAccessi
startingPageNumber++;
}
} else if (pageNumberType == EN_AUTO_EVEN) {
- if (startingPageNumber % 2 == 1) {
+ if (startingPageNumber % 2 != 0) {
startingPageNumber++;
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageProductionException.java b/src/java/org/apache/fop/fo/pagination/PageProductionException.java
index c64bdada3..c0f14b0ea 100644
--- a/src/java/org/apache/fop/fo/pagination/PageProductionException.java
+++ b/src/java/org/apache/fop/fo/pagination/PageProductionException.java
@@ -36,7 +36,7 @@ public class PageProductionException extends RuntimeException {
private static final long serialVersionUID = -5126033718398975158L;
private String localizedMessage;
- private Locator locator;
+ private transient Locator locator;
/**
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java
index 39a19b622..d17abf623 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -271,7 +271,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra
if (pageSequenceMaster == null) {
return simplePageMaster;
}
- boolean isOddPage = ((page % 2) == 1);
+ boolean isOddPage = ((page % 2) != 0);
if (log.isDebugEnabled()) {
log.debug("getNextSimplePageMaster(page=" + page
+ " isOdd=" + isOddPage
diff --git a/src/java/org/apache/fop/fo/properties/CharacterProperty.java b/src/java/org/apache/fop/fo/properties/CharacterProperty.java
index 3c2f56d50..c5aa2f939 100644
--- a/src/java/org/apache/fop/fo/properties/CharacterProperty.java
+++ b/src/java/org/apache/fop/fo/properties/CharacterProperty.java
@@ -90,7 +90,7 @@ public final class CharacterProperty extends Property {
* @return this.character cast as a String
*/
public String getString() {
- return new Character(character).toString();
+ return Character.toString(character);
}
@Override
diff --git a/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java b/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java
index 140b96aac..42b65486c 100644
--- a/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java
@@ -83,17 +83,20 @@ public class GenericShorthandParser implements ShorthandParser {
PropertyList propertyList)
throws PropertyException {
Property prop = null;
- String vProperty = "";
+ StringBuffer vProperty = new StringBuffer();
// Try each of the stored values in turn
Iterator iprop = property.getList().iterator();
while (iprop.hasNext() && prop == null) {
Property p = (Property)iprop.next();
if (p.getNCname() != null) {
- vProperty += p.getNCname() + " ";
+ if (vProperty.length() > 0) {
+ vProperty.append(' ');
+ }
+ vProperty.append(p.getNCname());
}
prop = maker.convertShorthandProperty(propertyList, p, null);
}
- propertyList.validatePropertyValue(vProperty.trim(), prop, property);
+ propertyList.validatePropertyValue(vProperty.toString(), prop, property);
return prop;
}
diff --git a/src/java/org/apache/fop/fonts/Glyphs.java b/src/java/org/apache/fop/fonts/Glyphs.java
index dfc44675b..04098f590 100644
--- a/src/java/org/apache/fop/fonts/Glyphs.java
+++ b/src/java/org/apache/fop/fonts/Glyphs.java
@@ -1277,7 +1277,7 @@ public final class Glyphs {
* @return the name of the glyph
*/
public static String charToGlyphName(char ch) {
- return stringToGlyph(new Character(ch).toString());
+ return stringToGlyph(Character.toString(ch));
}
/**
diff --git a/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java b/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java
index a9c471d5e..d9c6f3b3a 100644
--- a/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java
+++ b/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java
@@ -21,6 +21,7 @@ package org.apache.fop.fonts.truetype;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
/**
@@ -57,19 +58,17 @@ public class OFDirTabEntry {
offset = in.readTTFULong();
length = in.readTTFULong();
- String tagStr = new String(tag, "ISO-8859-1");
- return tagStr;
+ return getTagString();
}
@Override
public String toString() {
- return "Read dir tab ["
- + tag[0] + " " + tag[1] + " " + tag[2] + " " + tag[3] + "]"
+ return "Read dir tab [" + Arrays.toString(tag) + "]"
+ " offset: " + offset
+ " length: " + length
- + " name: " + tag;
+ + " name: " + getTagString();
}
/**
diff --git a/src/java/org/apache/fop/fonts/truetype/OpenFont.java b/src/java/org/apache/fop/fonts/truetype/OpenFont.java
index fc2acf8ca..b0288b998 100644
--- a/src/java/org/apache/fop/fonts/truetype/OpenFont.java
+++ b/src/java/org/apache/fop/fonts/truetype/OpenFont.java
@@ -266,7 +266,7 @@ public abstract class OpenFont {
/**
* Key-value helper class.
*/
- final static class UnicodeMapping implements Comparable {
+ static final class UnicodeMapping implements Comparable {
private final int unicodeIndex;
private final int glyphIndex;
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
index 941dc2b5d..834a72ee8 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
@@ -91,7 +91,7 @@ public abstract class AbstractBreaker {
* Helper class, extending the functionality of the
* basic {@link BlockKnuthSequence}.
*/
- public class BlockSequence extends BlockKnuthSequence {
+ public static class BlockSequence extends BlockKnuthSequence {
private static final long serialVersionUID = -5348831120146774118L;
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
index cad6fd3cf..ee4143982 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
@@ -38,7 +38,8 @@ import org.apache.fop.traits.MinOptMax;
public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLayoutManager {
/** The page number citation object */
- protected AbstractPageNumberCitation fobj;
+ protected AbstractPageNumberCitation citation;
+
/** Font for the page-number-citation */
protected Font font;
@@ -55,15 +56,15 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
*/
public AbstractPageNumberCitationLayoutManager(AbstractPageNumberCitation node) {
super(node);
- fobj = node;
+ citation = node;
}
/** {@inheritDoc} */
public void initialize() {
- FontInfo fi = fobj.getFOEventHandler().getFontInfo();
- FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
- font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
- setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground());
+ FontInfo fi = citation.getFOEventHandler().getFontInfo();
+ FontTriplet[] fontkeys = citation.getCommonFont().getFontState(fi);
+ font = fi.getFontInstance(fontkeys[0], citation.getCommonFont().fontSize.getValue(this));
+ setCommonBorderPaddingBackground(citation.getCommonBorderPaddingBackground());
}
/**
@@ -72,11 +73,11 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
protected AlignmentContext makeAlignmentContext(LayoutContext context) {
return new AlignmentContext(
font
- , fobj.getLineHeight().getOptimum(this).getLength().getValue(this)
- , fobj.getAlignmentAdjust()
- , fobj.getAlignmentBaseline()
- , fobj.getBaselineShift()
- , fobj.getDominantBaseline()
+ , citation.getLineHeight().getOptimum(this).getLength().getValue(this)
+ , citation.getAlignmentAdjust()
+ , citation.getAlignmentBaseline()
+ , citation.getBaselineShift()
+ , citation.getDominantBaseline()
, context.getAlignmentContext()
);
}
@@ -114,7 +115,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
protected InlineArea getEffectiveArea(LayoutContext layoutContext) {
InlineArea area = getPageNumberCitationArea();
if (!layoutContext.treatAsArtifact()) {
- TraitSetter.addStructureTreeElement(area, fobj.getStructureTreeElement());
+ TraitSetter.addStructureTreeElement(area, citation.getStructureTreeElement());
}
return area;
}
@@ -125,9 +126,9 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
text = new TextArea();
text.addWord(citationString, 0);
} else {
- UnresolvedPageNumber unresolved = new UnresolvedPageNumber(fobj.getRefId(), font,
+ UnresolvedPageNumber unresolved = new UnresolvedPageNumber(citation.getRefId(), font,
getReferenceType());
- getPSLM().addUnresolvedArea(fobj.getRefId(), unresolved);
+ getPSLM().addUnresolvedArea(citation.getRefId(), unresolved);
text = unresolved;
}
setTraits(text);
@@ -141,7 +142,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
protected abstract boolean getReferenceType();
private void setTraits(TextArea text) {
- TraitSetter.setProducerID(text, fobj.getId());
+ TraitSetter.setProducerID(text, citation.getId());
int bidiLevel = getBidiLevel();
text.setBidiLevel(bidiLevel);
int width = getStringWidth(citationString); // TODO: [GA] !I18N!
@@ -149,15 +150,15 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
text.setBPD(font.getAscender() - font.getDescender());
text.setBaselineOffset(font.getAscender());
TraitSetter.addFontTraits(text, font);
- text.addTrait(Trait.COLOR, fobj.getColor());
- TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
+ text.addTrait(Trait.COLOR, citation.getColor());
+ TraitSetter.addTextDecoration(text, citation.getTextDecoration());
}
/**
* @return bidi level governing abstract page number citation
*/
protected int getBidiLevel() {
- return fobj.getBidiLevel();
+ return citation.getBidiLevel();
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index aa8815ffc..d8ebc6dbf 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -191,7 +191,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
// this class represents a paragraph
- private class Paragraph extends InlineKnuthSequence {
+ private static class Paragraph extends InlineKnuthSequence {
private static final long serialVersionUID = 5862072380375189105L;
@@ -239,7 +239,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
// add the element representing text indentation
// at the beginning of the first paragraph
- if (isFirstInBlock && knuthParagraphs.size() == 0
+ if (layoutManager.isFirstInBlock && layoutManager.knuthParagraphs.size() == 0
&& textIndent != 0) {
this.add(new KnuthInlineBox(textIndent, null,
null, false));
@@ -250,7 +250,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
public void endParagraph() {
KnuthSequence finishedPar = this.endSequence();
if (finishedPar != null) {
- knuthParagraphs.add(finishedPar);
+ layoutManager.knuthParagraphs.add(finishedPar);
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
index 81846615f..c082bc41f 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
@@ -40,8 +40,8 @@ public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitat
@Override
protected PageViewport getCitedPage() {
- if (getPSLM().associateLayoutManagerID(fobj.getRefId())) {
- return getPSLM().getLastPVWithID(fobj.getRefId());
+ if (getPSLM().associateLayoutManagerID(citation.getRefId())) {
+ return getPSLM().getLastPVWithID(citation.getRefId());
} else {
return null;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
index a4976f833..556c2f575 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
@@ -40,7 +40,7 @@ public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationL
@Override
protected PageViewport getCitedPage() {
- return getPSLM().getFirstPVWithID(fobj.getRefId());
+ return getPSLM().getFirstPVWithID(citation.getRefId());
}
@Override
diff --git a/src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java b/src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java
index 0926b4e75..560c408c2 100644
--- a/src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java
+++ b/src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java
@@ -61,7 +61,7 @@ public class PDFJavaScriptLaunchAction extends PDFAction {
PDFJavaScriptLaunchAction launch = (PDFJavaScriptLaunchAction) obj;
- if (!launch.script.toString().equals(script.toString())) {
+ if (!launch.script.equals(script)) {
return false;
}
diff --git a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
index d0d35e84b..0067f8367 100644
--- a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
+++ b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
@@ -128,10 +128,11 @@ public class ImageProxyPanel extends JPanel {
image = (BufferedImage)imageRef.get();
}
- int x = (getWidth() - image.getWidth()) / 2;
- int y = (getHeight() - image.getHeight()) / 2;
-
- graphics.drawImage(image, x, y, image.getWidth(), image.getHeight(), null);
+ if (image != null) {
+ int x = (getWidth() - image.getWidth()) / 2;
+ int y = (getHeight() - image.getHeight()) / 2;
+ graphics.drawImage(image, x, y, image.getWidth(), image.getHeight(), null);
+ }
} catch (FOPException fopEx) {
fopEx.printStackTrace();
}
diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
index dc9256389..a0a7ddd01 100644
--- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
+++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
@@ -626,7 +626,7 @@ public class PreviewDialog extends JFrame implements StatusListener {
}
public void run() {
- processStatus.setText(message.toString());
+ processStatus.setText(message);
}
}
diff --git a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
index 9742036b7..5f69fbadb 100644
--- a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
@@ -116,52 +116,59 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter {
// TODO: Implement code to combine image with background color if transparency is not allowed
// here we need to inflate the PNG pixel data, which includes alpha, separate the alpha channel
// and then deflate it back again
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater());
- InputStream in = ((ImageRawStream) image).createInputStream();
+ ByteArrayOutputStream baos = null;
+ DeflaterOutputStream dos = null;
+ InputStream in = null;
try {
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
- // offset is the byte offset of the alpha component
- int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA
- int numColumns = image.getSize().getWidthPx();
- int bytesPerRow = numberOfInterleavedComponents * numColumns;
- int filter;
- // read line by line; the first byte holds the filter
- while ((filter = dataStream.read()) != -1) {
- byte[] bytes = new byte[bytesPerRow];
- dataStream.readFully(bytes, 0, bytesPerRow);
- dos.write((byte) filter);
- for (int j = 0; j < numColumns; j++) {
- dos.write(bytes, offset, 1);
- offset += numberOfInterleavedComponents;
+ baos = new ByteArrayOutputStream();
+ dos = new DeflaterOutputStream(baos, new Deflater());
+ in = ((ImageRawStream) image).createInputStream();
+ try {
+ InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
+ DataInputStream dataStream = new DataInputStream(infStream);
+ // offset is the byte offset of the alpha component
+ int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA
+ int numColumns = image.getSize().getWidthPx();
+ int bytesPerRow = numberOfInterleavedComponents * numColumns;
+ int filter;
+ // read line by line; the first byte holds the filter
+ while ((filter = dataStream.read()) != -1) {
+ byte[] bytes = new byte[bytesPerRow];
+ dataStream.readFully(bytes, 0, bytesPerRow);
+ dos.write((byte) filter);
+ for (int j = 0; j < numColumns; j++) {
+ dos.write(bytes, offset, 1);
+ offset += numberOfInterleavedComponents;
+ }
+ offset = numberOfInterleavedComponents - 1;
}
- offset = numberOfInterleavedComponents - 1;
+ } catch (IOException e) {
+ throw new RuntimeException("Error processing transparency channel:", e);
}
- dos.close();
- } catch (IOException e) {
- throw new RuntimeException("Error processing transparency channel:", e);
+ // set up alpha channel compression
+ FlateFilter transFlate;
+ try {
+ transFlate = new FlateFilter();
+ transFlate.setApplied(true);
+ transFlate.setPredictor(FlateFilter.PREDICTION_PNG_OPT);
+ transFlate.setColors(1);
+ transFlate.setColumns(image.getSize().getWidthPx());
+ transFlate.setBitsPerComponent(this.getBitsPerComponent());
+ } catch (PDFFilterException e) {
+ throw new RuntimeException("FlateFilter configuration error", e);
+ }
+ BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),
+ image.getSize().getHeightPx(), baos.toByteArray(), null);
+ IOUtils.closeQuietly(baos);
+ alphaMask.setPDFFilter(transFlate);
+ alphaMask.disallowMultipleFilters();
+ alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
+ softMask = doc.addImage(null, alphaMask).makeReference();
} finally {
IOUtils.closeQuietly(in);
+ IOUtils.closeQuietly(dos);
+ IOUtils.closeQuietly(baos);
}
- // set up alpha channel compression
- FlateFilter transFlate;
- try {
- transFlate = new FlateFilter();
- transFlate.setApplied(true);
- transFlate.setPredictor(FlateFilter.PREDICTION_PNG_OPT);
- transFlate.setColors(1);
- transFlate.setColumns(image.getSize().getWidthPx());
- transFlate.setBitsPerComponent(this.getBitsPerComponent());
- } catch (PDFFilterException e) {
- throw new RuntimeException("FlateFilter configuration error", e);
- }
- BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),
- image.getSize().getHeightPx(), baos.toByteArray(), null);
- alphaMask.setPDFFilter(transFlate);
- alphaMask.disallowMultipleFilters();
- alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
- softMask = doc.addImage(null, alphaMask).makeReference();
}
}
diff --git a/src/java/org/apache/fop/render/ps/PSImageFormResource.java b/src/java/org/apache/fop/render/ps/PSImageFormResource.java
index 11c3205e6..bc695f14a 100644
--- a/src/java/org/apache/fop/render/ps/PSImageFormResource.java
+++ b/src/java/org/apache/fop/render/ps/PSImageFormResource.java
@@ -57,4 +57,14 @@ public class PSImageFormResource extends PSResource {
return this.uri;
}
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
index d05ed8cc3..950921e77 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
@@ -41,14 +41,12 @@ abstract class RtfAfterBeforeBase
extends RtfContainer
implements IRtfParagraphContainer, IRtfExternalGraphicContainer, IRtfTableContainer,
IRtfTextrunContainer {
- protected RtfAttributes attrib;
private RtfParagraph para;
private RtfExternalGraphic externalGraphic;
private RtfTable table;
RtfAfterBeforeBase(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
super((RtfContainer)parent, w, attrs);
- attrib = attrs;
}
public RtfParagraph newParagraph() throws IOException {
diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java
index e1ada281c..f06486c2b 100644
--- a/src/java/org/apache/fop/servlet/FopServlet.java
+++ b/src/java/org/apache/fop/servlet/FopServlet.java
@@ -88,7 +88,7 @@ public class FopServlet extends HttpServlet {
/** The FopFactory used to create Fop instances */
protected FopFactory fopFactory;
/** URIResolver for use by this servlet */
- protected URIResolver uriResolver;
+ protected transient URIResolver uriResolver;
/**
* {@inheritDoc}
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index 4441f6164..027c35037 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -31,6 +31,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.FOUserAgent;
@@ -295,11 +296,15 @@ public class TestConverter {
outname + makeResultExtension());
outputFile.getParentFile().mkdirs();
- OutputStream outStream = new java.io.BufferedOutputStream(
- new java.io.FileOutputStream(outputFile));
- logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
- inputHandler.renderTo(userAgent, outputFormat, outStream);
- outStream.close();
+ OutputStream outStream = null;
+ try {
+ outStream = new java.io.BufferedOutputStream(
+ new java.io.FileOutputStream(outputFile));
+ logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
+ inputHandler.renderTo(userAgent, outputFormat, outStream);
+ } finally {
+ IOUtils.closeQuietly(outStream);
+ }
// check difference
if (compare != null) {
diff --git a/src/java/org/apache/fop/tools/anttasks/RunTest.java b/src/java/org/apache/fop/tools/anttasks/RunTest.java
index 6a959d758..1f46b4abe 100644
--- a/src/java/org/apache/fop/tools/anttasks/RunTest.java
+++ b/src/java/org/apache/fop/tools/anttasks/RunTest.java
@@ -25,6 +25,8 @@ import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
@@ -138,9 +140,14 @@ public class RunTest extends Task {
// return;
// } else {
try {
- ClassLoader loader = new URLClassLoader(createUrls(referenceJar));
+ final URL[] urls = createUrls(referenceJar);
+ ClassLoader loader = (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new URLClassLoader(urls);
+ }
+ });
boolean failed = false;
-
try {
Class cla = Class.forName("org.apache.fop.apps.Fop", true,
loader);
diff --git a/src/java/org/apache/fop/util/AbstractPaintingState.java b/src/java/org/apache/fop/util/AbstractPaintingState.java
index 3e966d202..ef4c29406 100644
--- a/src/java/org/apache/fop/util/AbstractPaintingState.java
+++ b/src/java/org/apache/fop/util/AbstractPaintingState.java
@@ -548,7 +548,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable {
+ ", fontName=" + fontName
+ ", fontSize=" + fontSize
+ ", lineWidth=" + lineWidth
- + ", dashArray=" + dashArray
+ + ", dashArray=" + Arrays.toString(dashArray)
+ ", transform=" + transform
+ ", layer=" + layer;
}
diff --git a/src/java/org/apache/fop/util/ColorWithFallback.java b/src/java/org/apache/fop/util/ColorWithFallback.java
index 0ec560367..a19d9c275 100644
--- a/src/java/org/apache/fop/util/ColorWithFallback.java
+++ b/src/java/org/apache/fop/util/ColorWithFallback.java
@@ -82,4 +82,23 @@ public class ColorWithFallback extends ColorWithAlternatives {
return this.fallback;
}
+ @Override
+ public int hashCode() {
+ return super.hashCode() ^ fallback.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (!super.equals(obj)) {
+ return false;
+ } else if (obj instanceof ColorWithFallback) {
+ ColorWithFallback other = (ColorWithFallback) obj;
+ return other.fallback.equals(fallback);
+ } else {
+ return false;
+ }
+ }
+
}