Merge from trunk
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-2_0@1681707 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build.xml b/build.xml
index 7bffbe5..427aa4c 100644
--- a/build.xml
+++ b/build.xml
@@ -160,6 +160,7 @@
<property name="javac.fork" value="no"/>
<property name="junit.fork" value="yes"/>
<property name="junit.haltonfailure" value="off"/>
+ <property name="junit.maxmemory" value="256m"/>
<property name="junit.printsummary" value="off"/>
<property name="junit.formatter.brief" value="on"/>
<property name="javadoc.packages" value="org.apache.fop.*"/>
@@ -225,7 +226,7 @@
<junit haltonfailure="${junit.haltonfailure}"
fork="${junit.fork}"
printsummary="${junit.printsummary}"
- maxmemory="256m"/>
+ maxmemory="${junit.maxmemory}"/>
</presetdef>
<!-- =================================================================== -->
@@ -815,9 +816,9 @@
<classpath>
<path refid="@{classpath}"/>
</classpath>
- <assertions>
- <enable/>
- </assertions>
+ <assertions>
+ <enable/>
+ </assertions>
<test name="@{testsuite}" todir="${junit.reports.dir}" outfile="@{outfile}"/>
</junit>
</sequential>
@@ -1153,7 +1154,7 @@
</classpath>
</taskdef>
<findbugs home="${findbugs.home.dir}" output="${findbugs.output.format}" reportLevel="low" effort="max"
- outputFile="${build.dir}/report_findbugs.${findbugs.output.extension}" excludeFilter="findbugs-exclude.xml" jvmargs="-Xmx1024m">
+ outputFile="${build.dir}/report_findbugs.${findbugs.output.extension}" excludeFilter="findbugs-exclude.xml" jvmargs="-Xmx1024m" warningsProperty="findbugs.warnings">
<sourcePath path="${src.java.dir}"/>
<class location="${build.classes.dir}"/>
<auxClasspath>
@@ -1166,6 +1167,7 @@
</path>
</auxClasspath>
</findbugs>
+ <fail if="findbugs.warnings"/>
</target>
<target name="findbugs-xml" depends="findbugs-avail" if="findbugs.present" description="Runs findbugs for a code quality report in XML">
<property name="findbugs.output.format" value="xml"/>
diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml
index e2f560e..73796c1 100644
--- a/findbugs-exclude.xml
+++ b/findbugs-exclude.xml
@@ -48,6 +48,42 @@
<!-- START - APPROVED EXCLUSIONS -->
<Match>
+ <Bug pattern="BC_BAD_CAST_TO_CONCRETE_COLLECTION"/>
+ <!-- TODO - Not sure what to do with those two... Seems messy/hacky -->
+ <And>
+ <Class name="org.apache.fop.area.AreaTreeObject"/>
+ <Method name="clone"/>
+ </And>
+ </Match>
+ <Match>
+ <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
+ <!-- TODO - See if these can be solved in a better way -->
+ <Or>
+ <And>
+ <Class name="org.apache.fop.layoutmgr.PageBreakingAlgorithm"/>
+ <Or>
+ <Method name="createFootnotePages"/>
+ <Method name="finish"/>
+ </Or>
+ </And>
+ <And>
+ <Class name="org.apache.fop.render.rtf.RTFHandler"/>
+ <Or>
+ <Method name="endCell"/>
+ <Method name="endFootnoteBody"/>
+ <Method name="endPart"/>
+ <Method name="endRow"/>
+ <Method name="startCell"/>
+ <Method name="startFootnoteBody"/>
+ <Method name="startListItem"/>
+ <Method name="startListLabel"/>
+ <Method name="startPart"/>
+ <Method name="startRow"/>
+ </Or>
+ </And>
+ </Or>
+ </Match>
+ <Match>
<Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
<Or>
<And>
@@ -86,6 +122,14 @@
</Or>
</Match>
<Match>
+ <!-- Only OK as long as the type of the base map remains plain HashMap... -->
+ <Bug pattern="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS"/>
+ <And>
+ <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
+ <Method name="sortDirTabMap"/>
+ </And>
+ </Match>
+ <Match>
<Bug pattern="EQ_ALWAYS_TRUE"/>
<Or>
<And>
@@ -122,6 +166,14 @@
</Or>
</Match>
<Match>
+ <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/>
+ <!-- TODO - fix potential file descriptor leak -->
+ <And>
+ <Class name="org.apache.fop.hyphenation.SerializeHyphPattern"/>
+ <Method name="serializeFile"/>
+ </And>
+ </Match>
+ <Match>
<Bug pattern="SE_INNER_CLASS"/>
<Or>
<Class name="org.apache.fop.afp.AFPPaintingState$AFPData"/>
@@ -141,6 +193,40 @@
</And>
</Or>
</Match>
+ <Match>
+ <Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
+ <Or>
+ <!-- TODO - fix later -->
+ <Class name="org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement"/>
+ <!-- FOs not yet implemented -->
+ <Class name="org.apache.fop.fo.flow.MultiProperties"/>
+ <Class name="org.apache.fop.fo.flow.MultiPropertySet"/>
+ <Class name="org.apache.fop.fo.flow.MultiToggle"/>
+ <Class name="org.apache.fop.fo.flow.table.TableAndCaption"/>
+ <Class name="org.apache.fop.fo.flow.table.TableCaption"/>
+ </Or>
+ </Match>
+ <Match>
+ <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+ <Or>
+ <!-- TODO - Implementation incomplete?
+ If not, remove unused field(s) and unused accessors -->
+ <Class name="org.apache.fop.complexscripts.fonts.GlyphProcessingState"/>
+ <Class name="org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager"/>
+ <Class name="org.apache.fop.pdf.PDFCMap"/>
+ <Class name="org.apache.fop.render.pdf.PDFSVGHandler$PDFInfo"/>
+ <Class name="org.apache.fop.svg.PDFGraphics2D"/>
+ <!-- Properties not yet implemented -->
+ <Class name="org.apache.fop.fo.flow.MultiToggle"/>
+ <Class name="org.apache.fop.fo.properties.CommonMarginInline"/>
+ <Class name="org.apache.fop.fo.properties.CommonRelativePosition"/>
+ </Or>
+ </Match>
+ <Match>
+ <Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
+ <!-- Properties not yet implemented -->
+ <Class name="org.apache.fop.fo.properties.CommonAural"/>
+ </Match>
<!-- END - APPROVED EXCLUSIONS -->
<!-- START - TEMPORARY (UNAPPROVED) EXCLUSIONS -->
@@ -161,6 +247,10 @@
<Bug pattern="DM_CONVERT_CASE"/>
</Match>
<Match>
+ <!-- 17 warnings -->
+ <Bug pattern="DM_DEFAULT_ENCODING"/>
+ </Match>
+ <Match>
<!-- 20 warnings -->
<Bug pattern="DM_FP_NUMBER_CTOR"/>
</Match>
diff --git a/lib/xmlgraphics-commons-2.0.1.jar b/lib/xmlgraphics-commons-2.0.1.jar
index 61be852..eba0b24 100644
--- a/lib/xmlgraphics-commons-2.0.1.jar
+++ b/lib/xmlgraphics-commons-2.0.1.jar
Binary files differ
diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java
index 5e6b5a7..6a4ce41 100644
--- a/src/java/org/apache/fop/afp/AFPStreamer.java
+++ b/src/java/org/apache/fop/afp/AFPStreamer.java
@@ -25,7 +25,6 @@
import java.io.OutputStream;
import java.net.URI;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.apache.commons.io.IOUtils;
@@ -160,10 +159,10 @@
*/
// write out any external resource groups
public void close() throws IOException {
- Iterator it = pathResourceGroupMap.values().iterator();
- while (it.hasNext()) {
- StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next();
- resourceGroup.close();
+ for (ResourceGroup resourceGroup : pathResourceGroupMap.values()) {
+ // TODO - Why not a Map<URI, StreamedResourceGroup>, if all the elements are expected to be of that type?
+ assert (resourceGroup instanceof StreamedResourceGroup);
+ ((StreamedResourceGroup) resourceGroup).close();
}
// close any open print-file resource group
if (printFileResourceGroup != null) {
diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
index 54826a2..f5808bd 100644
--- a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
+++ b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
@@ -133,7 +133,6 @@
dout.writeByte(a);
dout.writeByte(b);
} else {
- IOUtils.closeQuietly(dout);
IOUtils.closeQuietly(baout);
throw new IllegalStateException();
}
diff --git a/src/java/org/apache/fop/area/AreaTreeObject.java b/src/java/org/apache/fop/area/AreaTreeObject.java
index 83bf98b..02d81ef 100644
--- a/src/java/org/apache/fop/area/AreaTreeObject.java
+++ b/src/java/org/apache/fop/area/AreaTreeObject.java
@@ -41,13 +41,18 @@
protected List<ExtensionAttachment> extensionAttachments;
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
public Object clone() throws CloneNotSupportedException {
AreaTreeObject ato = (AreaTreeObject) super.clone();
if (foreignAttributes != null) {
- ato.foreignAttributes = (Map) ((HashMap) foreignAttributes).clone();
+ // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
+ ato.foreignAttributes = (Map<QName, String>)
+ ((HashMap<QName, String>)foreignAttributes).clone();
}
if (extensionAttachments != null) {
- ato.extensionAttachments = (List) ((ArrayList) extensionAttachments).clone();
+ // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
+ ato.extensionAttachments = (List<ExtensionAttachment>)
+ ((ArrayList<ExtensionAttachment>) extensionAttachments).clone();
}
return ato;
}
diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java
index e26429f..71de138 100644
--- a/src/java/org/apache/fop/area/Page.java
+++ b/src/java/org/apache/fop/area/Page.java
@@ -252,8 +252,7 @@
} else if (regionBody == null) {
return true;
} else {
- BodyRegion body = (BodyRegion)regionBody.getRegionReference();
- return body.isEmpty();
+ return regionBody.getRegionReference().isEmpty();
}
}
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
index 3235d8f..dd5c387 100644
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ b/src/java/org/apache/fop/area/PageViewport.java
@@ -364,8 +364,7 @@
* This will retrieve a marker with the class name
* and position.
*
- * @param name The class name of the marker to retrieve
- * @param pos the position to retrieve
+ * @param rm the retrieve-marker instance
* @return Object the marker found or null
*/
public Marker resolveMarker(AbstractRetrieveMarker rm) {
@@ -409,8 +408,8 @@
page = (Page) in.readObject();
unresolvedIDRefs = page.getUnresolvedReferences();
if (unresolvedIDRefs != null && pendingResolved != null) {
- for (String id : pendingResolved.keySet()) {
- resolveIDRef(id, pendingResolved.get(id));
+ for (Map.Entry<String, List<PageViewport>> e : pendingResolved.entrySet()) {
+ resolveIDRef(e.getKey(), e.getValue());
}
pendingResolved = null;
}
@@ -457,7 +456,9 @@
* @return BodyRegion object
*/
public BodyRegion getBodyRegion() {
- return (BodyRegion) getPage().getRegionViewport(FO_REGION_BODY).getRegionReference();
+ RegionReference regionReference = getPage().getRegionViewport(FO_REGION_BODY).getRegionReference();
+ assert (regionReference instanceof BodyRegion);
+ return (BodyRegion) regionReference;
}
/**
diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java
index e6b46fe..a22bb5b 100644
--- a/src/java/org/apache/fop/area/RegionReference.java
+++ b/src/java/org/apache/fop/area/RegionReference.java
@@ -134,6 +134,15 @@
addChildArea(block);
}
+ /**
+ * indicates whether the main reference area has any child areas added to it
+ *
+ * @return whether the main reference area has any child areas added to it
+ */
+ public boolean isEmpty() {
+ return true;
+ }
+
/** {@inheritDoc} */
public Object clone() throws CloneNotSupportedException {
RegionReference rr = (RegionReference) super.clone();
diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java
index e85d779..1733f7b 100644
--- a/src/java/org/apache/fop/area/inline/InlineArea.java
+++ b/src/java/org/apache/fop/area/inline/InlineArea.java
@@ -272,11 +272,12 @@
* @param ipdVariation the difference between new and old ipd
*/
protected void notifyIPDVariation(int ipdVariation) {
- if (getParentArea() instanceof InlineArea) {
- ((InlineArea) getParentArea()).handleIPDVariation(ipdVariation);
- } else if (getParentArea() instanceof LineArea) {
- ((LineArea) getParentArea()).handleIPDVariation(ipdVariation);
- } else if (getParentArea() == null) {
+ Area parentArea = getParentArea();
+ if (parentArea instanceof InlineArea) {
+ ((InlineArea) parentArea).handleIPDVariation(ipdVariation);
+ } else if (parentArea instanceof LineArea) {
+ ((LineArea) parentArea).handleIPDVariation(ipdVariation);
+ } else if (parentArea == null) {
// parent area not yet set: store the variations
storedIPDVariation += ipdVariation;
}
diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java
index 91a75d5..5a1b31c 100644
--- a/src/java/org/apache/fop/area/inline/TextArea.java
+++ b/src/java/org/apache/fop/area/inline/TextArea.java
@@ -144,12 +144,13 @@
* @return the text string
*/
public String getText() {
- StringBuffer text = new StringBuffer();
+ StringBuilder text = new StringBuilder();
// assemble the text
for (InlineArea inline : inlines) {
if (inline instanceof WordArea) {
text.append(((WordArea) inline).getWord());
} else {
+ assert (inline instanceof SpaceArea);
text.append(((SpaceArea) inline).getSpace());
}
}
diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java
index 82a188a..3223991 100644
--- a/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java
+++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java
@@ -119,6 +119,7 @@
* @param language language identifier
* @param feature feature identifier
* @param sct script context tester (or null)
+ * @return this instance
*/
protected GlyphProcessingState reset(GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct) {
this.gdef = null;
@@ -130,7 +131,7 @@
this.indexLast = gs.getGlyphCount();
this.consumed = 0;
this.lookupFlags = 0;
- this.classMatchSet = 0;
+ this.classMatchSet = 0; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
this.sct = sct;
this.gct = (sct != null) ? sct.getTester(feature) : null;
this.ignoreBase = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredBase(gi, flags); } };
diff --git a/src/java/org/apache/fop/fo/flow/MultiProperties.java b/src/java/org/apache/fop/fo/flow/MultiProperties.java
index 653c5f7..195dbd8 100644
--- a/src/java/org/apache/fop/fo/flow/MultiProperties.java
+++ b/src/java/org/apache/fop/fo/flow/MultiProperties.java
@@ -54,6 +54,7 @@
if (!notImplementedWarningGiven) {
getFOValidationEventProducer().unimplementedFeature(this, getName(),
getName(), getLocator());
+ // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
notImplementedWarningGiven = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
index 7a1c5a0..298ae62 100644
--- a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
+++ b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
@@ -50,6 +50,7 @@
if (!notImplementedWarningGiven) {
getFOValidationEventProducer().unimplementedFeature(this, getName(),
getName(), getLocator());
+ // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
notImplementedWarningGiven = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java
index 211c5b8..d9f4636 100644
--- a/src/java/org/apache/fop/fo/flow/MultiToggle.java
+++ b/src/java/org/apache/fop/fo/flow/MultiToggle.java
@@ -31,12 +31,12 @@
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_multi-toggle">
- * <code>fo:multi-toggle<code></a> property.
+ * <code>fo:multi-toggle</code></a> property.
*/
public class MultiToggle extends FObj {
// The value of properties relevant for fo:multi-toggle (commented out for performance).
// private CommonAccessibility commonAccessibility;
- public StringProperty prSwitchTo;
+ public StringProperty prSwitchTo; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
// End of property values
private static boolean notImplementedWarningGiven;
@@ -52,6 +52,7 @@
if (!notImplementedWarningGiven) {
getFOValidationEventProducer().unimplementedFeature(this, getName(),
getName(), getLocator());
+ // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
notImplementedWarningGiven = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
index e452f04..b7c7adc 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
@@ -72,6 +72,7 @@
if (!notImplementedWarningGiven) {
getFOValidationEventProducer().unimplementedFeature(this, getName(),
"fo:table-and-caption", getLocator());
+ // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
notImplementedWarningGiven = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableCaption.java b/src/java/org/apache/fop/fo/flow/table/TableCaption.java
index 454bcdd..5ecce65 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCaption.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCaption.java
@@ -67,6 +67,7 @@
if (!notImplementedWarningGiven) {
getFOValidationEventProducer().unimplementedFeature(this, getName(),
"fo:table-caption", getLocator());
+ // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
notImplementedWarningGiven = true;
}
}
diff --git a/src/java/org/apache/fop/fo/properties/CommonAural.java b/src/java/org/apache/fop/fo/properties/CommonAural.java
index a47f183..387562f 100644
--- a/src/java/org/apache/fop/fo/properties/CommonAural.java
+++ b/src/java/org/apache/fop/fo/properties/CommonAural.java
@@ -27,6 +27,7 @@
* Public "structure" allows direct member access.
*/
public class CommonAural {
+ // @SuppressFBWarnings("UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD")
/**
* The "azimuth" property.
*/
diff --git a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java b/src/java/org/apache/fop/fo/properties/CommonMarginInline.java
index 04f60ac..8d6b9a4 100644
--- a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java
+++ b/src/java/org/apache/fop/fo/properties/CommonMarginInline.java
@@ -30,7 +30,7 @@
* Public "structure" allows direct member access.
*/
public class CommonMarginInline {
-
+ // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
/**
* The "margin-top" property.
*/
diff --git a/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
index 872d723..964f7cd 100644
--- a/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
+++ b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
@@ -30,6 +30,7 @@
* Public "structure" allows direct member access.
*/
public class CommonRelativePosition {
+ // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
/**
* The "relative-position" property.
*/
diff --git a/src/java/org/apache/fop/fonts/truetype/OpenFont.java b/src/java/org/apache/fop/fonts/truetype/OpenFont.java
index b736c99..9d3a476 100644
--- a/src/java/org/apache/fop/fonts/truetype/OpenFont.java
+++ b/src/java/org/apache/fop/fonts/truetype/OpenFont.java
@@ -1603,10 +1603,12 @@
// Create winAnsiEncoded kerning table from kerningTab
// (could probably be simplified, for now we remap back to CID indexes and
// then to winAnsi)
- for (Integer unicodeKey1 : kerningTab.keySet()) {
- Integer cidKey1 = unicodeToGlyph(unicodeKey1.intValue());
+
+ for (Map.Entry<Integer, Map<Integer, Integer>> e1 : kerningTab.entrySet()) {
+ Integer unicodeKey1 = e1.getKey();
+ Integer cidKey1 = unicodeToGlyph(unicodeKey1);
Map<Integer, Integer> akpx = new HashMap<Integer, Integer>();
- Map<Integer, Integer> ckpx = kerningTab.get(unicodeKey1);
+ Map<Integer, Integer> ckpx = e1.getValue();
for (Map.Entry<Integer, Integer> e : ckpx.entrySet()) {
Integer unicodeKey2 = e.getKey();
@@ -1693,6 +1695,7 @@
return (int) (o1.getValue().getOffset() - o2.getValue().getOffset());
}
});
+ // @SuppressFBWarnings("DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS")
sortedSet.addAll(directoryTabs.entrySet());
return sortedSet;
}
diff --git a/src/java/org/apache/fop/hyphenation/Hyphenator.java b/src/java/org/apache/fop/hyphenation/Hyphenator.java
index 48af67d..ed99242 100644
--- a/src/java/org/apache/fop/hyphenation/Hyphenator.java
+++ b/src/java/org/apache/fop/hyphenation/Hyphenator.java
@@ -64,6 +64,14 @@
}
/**
+ * Clears the default hyphenation tree cache.<br>
+ * This method can be used if the underlying data files are changed at runtime.
+ */
+ public static synchronized void clearHyphenationTreeCache() {
+ hTreeCache = new HyphenationTreeCache();
+ }
+
+ /**
* Returns a hyphenation tree for a given language and country,
* with fallback from (lang,country) to (lang).
* The hyphenation trees are cached.
diff --git a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
index c5f5ccc..8d51edf 100644
--- a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
+++ b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
@@ -53,12 +53,14 @@
return name.endsWith(extension);
}
});
- for (int j = 0; j < sourceFiles.length; j++) {
- File infile = new File(sourceDir, sourceFiles[j]);
- String outfilename = sourceFiles[j].substring(0, sourceFiles[j].length()
- - extension.length()) + ".hyp";
- File outfile = new File(targetDir, outfilename);
- serializeFile(infile, outfile);
+ if (sourceFiles != null) {
+ for (String sourceFile : sourceFiles) {
+ File infile = new File(sourceDir, sourceFile);
+ String outfilename = sourceFile.substring(0, sourceFile.length()
+ - extension.length()) + ".hyp";
+ File outfile = new File(targetDir, outfilename);
+ serializeFile(infile, outfile);
+ }
}
}
@@ -73,6 +75,7 @@
HyphenationTree hTree = buildPatternFile(infile);
// serialize class
try {
+ // @SuppressFBWarnings("OS_OPEN_STREAM_EXCEPTION_PATH")
ObjectOutputStream out = new ObjectOutputStream(
new java.io.BufferedOutputStream(
new java.io.FileOutputStream(outfile)));
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 21dcf9e..802960c 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -618,10 +618,12 @@
}
}
} else if (innerPosition != null && innerPosition.getLM() != this) {
+ Position lastPosition = lastElement.getPosition();
+ assert (lastPosition instanceof NonLeafPosition);
// this adjustment concerns another LM
- NonLeafPosition savedPos = (NonLeafPosition) lastElement.getPosition();
+ NonLeafPosition savedPos = (NonLeafPosition) lastPosition;
lastElement.setPosition(innerPosition);
- int returnValue = ((BlockLevelLayoutManager)lastElement.getLayoutManager())
+ int returnValue = ((BlockLevelLayoutManager) lastElement.getLayoutManager())
.negotiateBPDAdjustment(adj, lastElement);
lastElement.setPosition(savedPos);
return returnValue;
@@ -635,7 +637,8 @@
/** {@inheritDoc} */
public void discardSpace(KnuthGlue spaceGlue) {
assert (spaceGlue != null && spaceGlue.getPosition() != null);
- Position innerPosition = spaceGlue.getPosition().getPosition();
+ Position mainPosition = spaceGlue.getPosition();
+ Position innerPosition = mainPosition.getPosition();
if (innerPosition == null || innerPosition.getLM() == this) {
// if this block has block-progression-unit > 0, innerPosition can be
@@ -652,8 +655,9 @@
//TODO Why are both cases handled in the same way?
}
} else {
+ assert (mainPosition instanceof NonLeafPosition);
// this element was not created by this BlockLM
- NonLeafPosition savedPos = (NonLeafPosition)spaceGlue.getPosition();
+ NonLeafPosition savedPos = (NonLeafPosition) mainPosition;
spaceGlue.setPosition(innerPosition);
((BlockLevelLayoutManager) spaceGlue.getLayoutManager()).discardSpace(spaceGlue);
spaceGlue.setPosition(savedPos);
diff --git a/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java
index 5c6f6c6..06e1484 100644
--- a/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java
@@ -133,7 +133,7 @@
while (!(lm instanceof BlockLayoutManager)) {
lm = lm.getParent();
}
- if (lm instanceof BlockLayoutManager) {
+ if (lm != null) {
startIndent = ((BlockLayoutManager) lm).startIndent;
}
return startIndent;
diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
index 227acbf..99f6367 100644
--- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -239,9 +239,10 @@
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
log.debug(" FLM.negotiateBPDAdjustment> " + adj);
- if (lastElement.getPosition() instanceof NonLeafPosition) {
+ Position lastPosition = lastElement.getPosition();
+ if (lastPosition instanceof NonLeafPosition) {
// this element was not created by this FlowLM
- NonLeafPosition savedPos = (NonLeafPosition)lastElement.getPosition();
+ NonLeafPosition savedPos = (NonLeafPosition) lastPosition;
lastElement.setPosition(savedPos.getPosition());
int returnValue = ((BlockLevelLayoutManager)lastElement.getLayoutManager())
.negotiateBPDAdjustment(adj, lastElement);
@@ -258,9 +259,10 @@
public void discardSpace(KnuthGlue spaceGlue) {
log.debug(" FLM.discardSpace> ");
- if (spaceGlue.getPosition() instanceof NonLeafPosition) {
+ Position gluePosition = spaceGlue.getPosition();
+ if (gluePosition instanceof NonLeafPosition) {
// this element was not created by this FlowLM
- NonLeafPosition savedPos = (NonLeafPosition)spaceGlue.getPosition();
+ NonLeafPosition savedPos = (NonLeafPosition) gluePosition;
spaceGlue.setPosition(savedPos.getPosition());
((BlockLevelLayoutManager) spaceGlue.getLayoutManager()).discardSpace(spaceGlue);
spaceGlue.setPosition(savedPos);
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
index 008ec22..9327f8f 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
@@ -941,6 +941,7 @@
@Override
protected void finish() {
for (int i = startLine; i < endLine; i++) {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
for (KnuthPageNode node = (KnuthPageNode) getNode(i);
node != null;
node = (KnuthPageNode) node.next) {
@@ -978,6 +979,7 @@
// footnoteElementIndex has already been set in getFootnoteSplit()
} else {
// cannot add any content: create a new node and start again
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
KnuthPageNode node = (KnuthPageNode)
createNode(lastNode.position, prevNode.line + 1, 1,
insertedFootnotesLength - prevNode.insertedFootnotes,
@@ -992,6 +994,7 @@
}
}
// create the last node
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
KnuthPageNode node = (KnuthPageNode)
createNode(lastNode.position, prevNode.line + 1, 1,
totalFootnotesLength - prevNode.insertedFootnotes, 0, 0,
diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
index 20c4616..7d84a91 100644
--- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.area.Area;
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.area.LineArea;
@@ -112,7 +113,9 @@
try {
ContentLayoutManager clm = getLayoutManagerMaker()
.makeContentLayoutManager(this, getPageSequence().getTitleFO());
- title = (LineArea) clm.getParentArea(null);
+ Area parentArea = clm.getParentArea(null);
+ assert (parentArea instanceof LineArea);
+ title = (LineArea) parentArea;
} catch (IllegalStateException e) {
// empty title; do nothing
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
index 1f4a06e..5e3820a 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
@@ -63,7 +63,7 @@
*/
protected InlineStackingLayoutManager(FObj node) {
super(node);
- extraBPD = MinOptMax.ZERO;
+ extraBPD = MinOptMax.ZERO; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 6f31f03..075199e 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -108,7 +108,7 @@
* Each value holds the start and end indexes into a List of
* inline break positions.
*/
- private static class LineBreakPosition extends LeafPosition {
+ static class LineBreakPosition extends LeafPosition {
private final int parIndex; // index of the Paragraph this Position refers to
private final int startIndex; //index of the first element this Position refers to
private final int availableShrink;
@@ -986,7 +986,7 @@
keep.getContext(),
context));
}
- endIndex = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos();
+ endIndex = llPoss.getChosenPosition(i).getLeafPos();
// create a list of the FootnoteBodyLM handling footnotes
// whose citations are in this line
List<FootnoteBodyLayoutManager> footnoteList = FootenoteUtil.getFootnotes(
@@ -994,7 +994,7 @@
List<FloatContentLayoutManager> floats = FloatContentLayoutManager.checkForFloats(seq,
startIndex, endIndex);
startIndex = endIndex + 1;
- LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i);
+ LineBreakPosition lbp = llPoss.getChosenPosition(i);
if (baselineOffset < 0) {
baselineOffset = lbp.spaceBefore + lbp.baseline;
}
@@ -1186,7 +1186,9 @@
/** {@inheritDoc} */
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
- LeafPosition pos = (LeafPosition)lastElement.getPosition();
+ Position lastPos = lastElement.getPosition();
+ assert (lastPos instanceof LeafPosition);
+ LeafPosition pos = (LeafPosition) lastPos;
//if (lastElement.isPenalty()) {
// totalAdj += lastElement.getWidth();
//}
@@ -1230,7 +1232,7 @@
// null penalty allowing a page break between lines
returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
}
- LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i);
+ LineBreakPosition lbp = llPoss.getChosenPosition(i);
//log.debug("LLM.getChangedKnuthElements> lineWidth= "
// + lbp.lineWidth + " difference= " + lbp.difference);
//log.debug(" shrink= "
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java
index 49c97b7..54ca3e5 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java
@@ -24,8 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.layoutmgr.Position;
-
/**
* Line layout possibilities.
*/
@@ -37,12 +35,12 @@
private final class Possibility {
private int lineCount;
private double demerits;
- private List breakPositions;
+ private List<LineLayoutManager.LineBreakPosition> breakPositions;
private Possibility(int lc, double dem) {
lineCount = lc;
demerits = dem;
- breakPositions = new java.util.ArrayList(lc);
+ breakPositions = new java.util.ArrayList<LineLayoutManager.LineBreakPosition>(lc);
}
private int getLineCount() {
@@ -53,15 +51,15 @@
return demerits;
}
- private void addBreakPosition(Position pos) {
+ private void addBreakPosition(LineLayoutManager.LineBreakPosition pos) {
// Positions are always added with index 0 because
// they are created backward, from the last one to
// the first one
breakPositions.add(0, pos);
}
- private Position getBreakPosition(int i) {
- return (Position)breakPositions.get(i);
+ private LineLayoutManager.LineBreakPosition getBreakPosition(int i) {
+ return breakPositions.get(i);
}
}
@@ -181,7 +179,7 @@
* @param pos a position
* @param i an index into posibilities list
*/
- public void addBreakPosition(Position pos, int i) {
+ public void addBreakPosition(LineLayoutManager.LineBreakPosition pos, int i) {
((Possibility)possibilitiesList.get(i)).addBreakPosition(pos);
}
@@ -245,7 +243,7 @@
* @param i the break position index
* @return the chosen position
*/
- public Position getChosenPosition(int i) {
+ public LineLayoutManager.LineBreakPosition getChosenPosition(int i) {
return ((Possibility)possibilitiesList.get(chosenIndex)).getBreakPosition(i);
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
index 2866b80..6384608 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
@@ -209,7 +209,9 @@
*/
GlyphMapping lastMapping = null;
while (posIter.hasNext()) {
- final LeafPosition tbpNext = (LeafPosition) posIter.next();
+ Position nextPos = posIter.next();
+ assert (nextPos instanceof LeafPosition);
+ final LeafPosition tbpNext = (LeafPosition) nextPos;
if (tbpNext == null) {
continue; //Ignore elements without Positions
}
@@ -961,7 +963,9 @@
ListIterator oldListIterator = oldList.listIterator();
KnuthElement knuthElement = (KnuthElement) oldListIterator.next();
Position pos = knuthElement.getPosition();
- LeafPosition leafPos = (LeafPosition) pos.getPosition(depth);
+ Position innerPosition = pos.getPosition(depth);
+ assert (innerPosition instanceof LeafPosition);
+ LeafPosition leafPos = (LeafPosition) innerPosition;
int index = leafPos.getLeafPos();
//element could refer to '-1' position, for non-collapsed spaces (?)
if (index > -1) {
@@ -1082,14 +1086,18 @@
ListIterator oldListIter;
for (oldListIter = oldList.listIterator(); oldListIter.hasNext();) {
Position pos = ((KnuthElement) oldListIter.next()).getPosition();
- startPos = (LeafPosition) pos.getPosition(depth);
+ Position innerPosition = pos.getPosition(depth);
+ assert (innerPosition == null || innerPosition instanceof LeafPosition);
+ startPos = (LeafPosition) innerPosition;
if (startPos != null && startPos.getLeafPos() != -1) {
break;
}
}
for (oldListIter = oldList.listIterator(oldList.size()); oldListIter.hasPrevious();) {
Position pos = ((KnuthElement) oldListIter.previous()).getPosition();
- endPos = (LeafPosition) pos.getPosition(depth);
+ Position innerPosition = pos.getPosition(depth);
+ assert (innerPosition instanceof LeafPosition);
+ endPos = (LeafPosition) innerPosition;
if (endPos != null && endPos.getLeafPos() != -1) {
break;
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index 4c45e62..40edca6 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -269,6 +269,7 @@
} else {
borderAfterWhich = ConditionalBorder.REST;
}
+ assert (currentGU instanceof EmptyGridUnit);
addAreaForEmptyGridUnit((EmptyGridUnit)currentGU,
currentRow.getIndex(), i,
actualRowHeight,
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
index 47561f3..342a2f3 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
@@ -43,9 +43,6 @@
/** Selects the table-footer elements for iteration. */
public static final int FOOTER = 2;
- /** The table on which this instance operates. */
- protected Table table;
-
/** Part of the table over which to iterate. One of BODY, HEADER or FOOTER. */
private int tablePart;
@@ -59,7 +56,6 @@
* @param tablePart indicates what part of the table to iterate over (HEADER, FOOTER, BODY)
*/
public TableRowIterator(Table table, int tablePart) {
- this.table = table;
this.tablePart = tablePart;
switch(tablePart) {
case HEADER:
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
index 0906e9f..7c98bd4 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
@@ -158,6 +158,7 @@
for (int i = 0; i < columnCount; i++) {
GridUnit gu = row.getGridUnit(i);
if (!gu.isEmpty() && gu.isPrimary()) {
+ assert (gu instanceof PrimaryGridUnit);
activeCellList.add(new ActiveCell((PrimaryGridUnit) gu, row, rowIndex,
previousRowsLength, getTableLM()));
}
diff --git a/src/java/org/apache/fop/pdf/PDFCMap.java b/src/java/org/apache/fop/pdf/PDFCMap.java
index 34bc0f9..c96cf9d 100644
--- a/src/java/org/apache/fop/pdf/PDFCMap.java
+++ b/src/java/org/apache/fop/pdf/PDFCMap.java
@@ -365,7 +365,7 @@
/**
* font's writing direction
*/
- protected byte wMode = WMODE_HORIZONTAL;
+ protected byte wMode = WMODE_HORIZONTAL; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
/**
* base CMap (String or PDFStream)
@@ -381,8 +381,8 @@
public PDFCMap(String name, PDFCIDSystemInfo sysInfo) {
super();
this.name = name;
- this.sysInfo = sysInfo;
- this.base = null;
+ this.sysInfo = sysInfo; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+ this.base = null; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
}
/**
diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java
index b1152df..ad117c9 100644
--- a/src/java/org/apache/fop/pdf/PDFFactory.java
+++ b/src/java/org/apache/fop/pdf/PDFFactory.java
@@ -1265,7 +1265,9 @@
log.error("Failed to embed font [" + desc + "] " + desc.getEmbedFontName(), ioe);
return null;
} finally {
- IOUtils.closeQuietly(in);
+ if (in != null) {
+ IOUtils.closeQuietly(in);
+ }
}
}
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java
index 72a517e..ae54e65 100644
--- a/src/java/org/apache/fop/render/AbstractRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractRenderer.java
@@ -301,6 +301,7 @@
startVParea(regionReference.getCTM(), port.getClipRectangle());
// do after starting viewport area
if (regionReference.getRegionClass() == FO_REGION_BODY) {
+ assert (regionReference instanceof BodyRegion);
renderBodyRegion((BodyRegion) regionReference);
} else {
renderRegion(regionReference);
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandler.java b/src/java/org/apache/fop/render/afp/AFPImageHandler.java
index 6404924..d3801c1 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandler.java
@@ -31,6 +31,7 @@
import org.apache.fop.afp.AFPResourceInfo;
import org.apache.fop.afp.AFPUnitConverter;
import org.apache.fop.render.ImageHandlerBase;
+import org.apache.fop.render.RendererContext;
/**
* A base abstract AFP image handler
@@ -71,8 +72,9 @@
(int)Math.round(position.getWidth()),
(int)Math.round(position.getHeight()));
- AFPRendererContext rendererContext
- = (AFPRendererContext)rendererImageInfo.getRendererContext();
+ RendererContext context = rendererImageInfo.getRendererContext();
+ assert (context instanceof AFPRendererContext);
+ AFPRendererContext rendererContext = (AFPRendererContext) context;
AFPInfo afpInfo = rendererContext.getInfo();
AFPPaintingState paintingState = afpInfo.getPaintingState();
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
index 2a0db08..ba0b543 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
@@ -82,7 +82,9 @@
throws IOException {
AFPRenderingContext afpContext = (AFPRenderingContext)context;
- AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPGraphicsObjectInfo);
+ AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info;
// set resource information
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java
index 7508c8c..e5f6f64 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java
@@ -90,7 +90,9 @@
throws IOException {
AFPRenderingContext afpContext = (AFPRenderingContext)context;
- AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPImageObjectInfo);
+ AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info;
AFPPaintingState paintingState = afpContext.getPaintingState();
// set resource information
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
index aea7fe8..57a5143 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
@@ -107,7 +107,9 @@
throws IOException {
AFPRenderingContext afpContext = (AFPRenderingContext)context;
- AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPImageObjectInfo);
+ AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info;
AFPPaintingState paintingState = afpContext.getPaintingState();
// set resource information
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
index 68d806a..f38da91 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
@@ -78,7 +78,9 @@
ImageXMLDOM imageSVG = (ImageXMLDOM)image;
FOUserAgent userAgent = afpContext.getUserAgent();
- AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPGraphicsObjectInfo);
+ AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info;
AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo();
setDefaultToInlineResourceLevel(graphicsObjectInfo);
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 30b3af9..a1c740d 100644
--- a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
+++ b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
@@ -43,7 +43,7 @@
public class ImageProxyPanel extends JPanel {
/** The reference to the BufferedImage storing the page data */
- private Reference imageRef;
+ private transient Reference imageRef;
/** The maximum and preferred size of the panel */
private Dimension size;
diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java
index 5197262..3d0bfd3 100644
--- a/src/java/org/apache/fop/render/intermediate/IFParser.java
+++ b/src/java/org/apache/fop/render/intermediate/IFParser.java
@@ -107,14 +107,16 @@
transformer.transform(src, res);
} catch (TransformerException te) {
+ Throwable cause = te.getCause();
//Unpack original IFException if applicable
- if (te.getCause() instanceof SAXException) {
- SAXException se = (SAXException)te.getCause();
- if (se.getCause() instanceof IFException) {
- throw (IFException)se.getCause();
+ if (cause instanceof SAXException) {
+ SAXException se = (SAXException) cause;
+ cause = se.getCause();
+ if (cause instanceof IFException) {
+ throw (IFException) cause;
}
- } else if (te.getCause() instanceof IFException) {
- throw (IFException)te.getCause();
+ } else if (cause instanceof IFException) {
+ throw (IFException) cause;
}
throw te;
}
@@ -375,9 +377,10 @@
}
private void handleIFException(IFException ife) throws SAXException {
- if (ife.getCause() instanceof SAXException) {
+ Throwable cause = ife.getCause();
+ if (cause instanceof SAXException) {
//unwrap
- throw (SAXException)ife.getCause();
+ throw (SAXException) cause;
} else {
//wrap
throw new SAXException(ife);
diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
index 176f747..e0843ef 100644
--- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
@@ -197,8 +197,9 @@
}
private void handleIFExceptionWithIOException(IFException ife) throws IOException {
- if (ife.getCause() instanceof IOException) {
- throw (IOException)ife.getCause();
+ Throwable cause = ife.getCause();
+ if (cause instanceof IOException) {
+ throw (IOException) cause;
} else {
handleIFException(ife);
}
@@ -1072,15 +1073,17 @@
String s = word.getWord();
int[][] dp = word.getGlyphPositionAdjustments();
+ Area parentArea = word.getParentArea();
+ assert (parentArea instanceof AbstractTextArea);
if (dp == null) {
renderTextWithAdjustments(s, word.getLetterAdjustArray(), word.isReversed(),
- font, (AbstractTextArea)word.getParentArea());
+ font, (AbstractTextArea) parentArea);
} else if (IFUtil.isDPOnlyDX(dp)) {
renderTextWithAdjustments(s, IFUtil.convertDPToDX(dp), word.isReversed(),
- font, (AbstractTextArea)word.getParentArea());
+ font, (AbstractTextArea) parentArea);
} else {
renderTextWithAdjustments(s, dp, word.isReversed(),
- font, (AbstractTextArea)word.getParentArea());
+ font, (AbstractTextArea) parentArea);
}
super.renderWord(word);
@@ -1091,7 +1094,9 @@
Font font = getFontFromArea(space.getParentArea());
String s = space.getSpace();
- AbstractTextArea textArea = (AbstractTextArea)space.getParentArea();
+ Area parentArea = space.getParentArea();
+ assert (parentArea instanceof AbstractTextArea);
+ AbstractTextArea textArea = (AbstractTextArea) parentArea;
renderTextWithAdjustments(s, (int[]) null, false, font, textArea);
/* COMBINED is always false
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
index e8da29b..df6f26c 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
@@ -388,6 +388,7 @@
} else if (type == PDFObjectType.Number) {
array.add(new PDFNumber(entry.getValueAsNumber()));
} else if (type == PDFObjectType.Reference) {
+ assert (entry instanceof PDFReferenceExtension);
array.add(resolveReference((PDFReferenceExtension) entry));
} else if (type == PDFObjectType.String) {
array.add(entry.getValue());
@@ -423,6 +424,7 @@
} else if (type == PDFObjectType.Number) {
dictionary.put(key, new PDFNumber(entry.getValueAsNumber()));
} else if (type == PDFObjectType.Reference) {
+ assert (entry instanceof PDFReferenceExtension);
dictionary.put(key, resolveReference((PDFReferenceExtension) entry));
} else if (type == PDFObjectType.String) {
dictionary.put(key, entry.getValue());
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java
index 1f3ba22..34b1127 100644
--- a/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java
@@ -44,8 +44,9 @@
}
public PDFArrayExtension getArrayExtension() {
- assert getExtension() instanceof PDFArrayExtension;
- return (PDFArrayExtension) getExtension();
+ PDFCollectionEntryExtension extension = getExtension();
+ assert (extension instanceof PDFArrayExtension);
+ return (PDFArrayExtension) extension;
}
@Override
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java
index 3da2242..d7b155e 100644
--- a/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java
@@ -64,8 +64,9 @@
}
public PDFDictionaryExtension getDictionaryExtension() {
- assert getExtension() instanceof PDFDictionaryExtension;
- return (PDFDictionaryExtension) getExtension();
+ PDFCollectionEntryExtension extension = getExtension();
+ assert extension instanceof PDFDictionaryExtension;
+ return (PDFDictionaryExtension) extension;
}
@Override
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java
index 37aeeb8..c774a09 100644
--- a/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java
@@ -52,7 +52,9 @@
} else if (refid.length() == 0) {
invalidPropertyValueError(ATT_REFID, refid, null);
} else {
- ((PDFReferenceExtension) getExtension()).setReferenceId(refid);
+ PDFCollectionEntryExtension extension = getExtension();
+ assert (extension instanceof PDFReferenceExtension);
+ ((PDFReferenceExtension) extension).setReferenceId(refid);
}
}
}
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index d9892ad..05c68be 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -687,6 +687,7 @@
try {
RtfAttributes atts = TableAttributesConverter.convertTablePartAttributes(part);
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
tbl.setHeaderAttribs(atts);
} catch (IOException ioe) {
@@ -703,6 +704,7 @@
}
try {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
tbl.setHeaderAttribs(null);
} catch (IOException ioe) {
@@ -738,6 +740,7 @@
try {
// create an RtfTableRow in the current RtfTable
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
final RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class,
true, null);
@@ -768,6 +771,7 @@
try {
TableContext tctx = builderContext.getTableContext();
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
final RtfTableRow row = (RtfTableRow)builderContext.getContainer(RtfTableRow.class,
true, null);
@@ -805,6 +809,7 @@
try {
TableContext tctx = builderContext.getTableContext();
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
final RtfTableRow row = (RtfTableRow)builderContext.getContainer(RtfTableRow.class,
true, null);
@@ -894,6 +899,7 @@
return;
}
try {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
RtfTableCell cell = (RtfTableCell)builderContext.getContainer(RtfTableCell.class, false, this);
cell.finish();
@@ -949,6 +955,7 @@
// create an RtfListItem in the current RtfList
try {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
RtfList list = (RtfList)builderContext.getContainer(
RtfList.class, true, this);
@@ -995,6 +1002,7 @@
}
try {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
RtfListItem item
= (RtfListItem)builderContext.getContainer(RtfListItem.class, true, this);
@@ -1325,6 +1333,7 @@
}
try {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
RtfFootnote rtfFootnote
= (RtfFootnote)builderContext.getContainer(
RtfFootnote.class,
@@ -1346,6 +1355,7 @@
}
try {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
RtfFootnote rtfFootnote
= (RtfFootnote)builderContext.getContainer(
RtfFootnote.class,
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
index 1b13fd7..b9f0b50 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
@@ -55,7 +55,7 @@
/** Create an RTF element as a child of given container with given attributes */
RtfElement(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
-
+ // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
id = idCounter++;
this.parent = parent;
attrib = (attr != null ? attr : new RtfAttributes());
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
index 040118e..5af417e 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
@@ -234,11 +234,6 @@
protected int height = -1;
/**
- * The desired percent value of the height
- */
- protected int heightPercent = -1;
-
- /**
* The desired height (in twips)
*/
protected int heightDesired = -1;
@@ -254,11 +249,6 @@
protected int width = -1;
/**
- * The desired percent value of the width
- */
- protected int widthPercent = -1;
-
- /**
* The desired width (in twips)
*/
protected int widthDesired = -1;
diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java
index d6da9d5..c50508e 100644
--- a/src/java/org/apache/fop/render/xml/XMLRenderer.java
+++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java
@@ -202,7 +202,7 @@
continue;
}
Object value = traitEntry.getValue();
- if (key == Trait.FONT) {
+ if (((Integer) key).intValue() == Trait.FONT) {
FontTriplet triplet = (FontTriplet)value;
addAttribute("font-name", triplet.getName());
addAttribute("font-style", triplet.getStyle());
@@ -245,8 +245,9 @@
} else if (clazz.equals(Color.class)) {
Color c = (Color)value;
addAttribute(name, ColorUtil.colorToString(c));
- } else if (key == Trait.START_INDENT || key == Trait.END_INDENT) {
- if (((Integer)value).intValue() != 0) {
+ } else if (((Integer) key).intValue() == Trait.START_INDENT
+ || ((Integer) key).intValue() == Trait.END_INDENT) {
+ if ((Integer) value != 0) {
addAttribute(name, value.toString());
}
} else {
@@ -513,7 +514,8 @@
renderRegion(region);
endElement("regionStart");
} else if (region.getRegionClass() == FO_REGION_BODY) {
- BodyRegion body = (BodyRegion)region;
+ assert (region instanceof BodyRegion);
+ BodyRegion body = (BodyRegion) region;
if (body.getColumnCount() != 1) {
addAttribute("columnGap", body.getColumnGap());
addAttribute("columnCount", body.getColumnCount());
diff --git a/src/java/org/apache/fop/svg/NativeTextPainter.java b/src/java/org/apache/fop/svg/NativeTextPainter.java
index 126e1ef..983a184 100644
--- a/src/java/org/apache/fop/svg/NativeTextPainter.java
+++ b/src/java/org/apache/fop/svg/NativeTextPainter.java
@@ -216,11 +216,11 @@
public List computeTextRuns(TextNode node, AttributedCharacterIterator nodeACI,
AttributedCharacterIterator [] chunkACIs) {
nodeACI.first();
- int defaultBidiLevel = (nodeACI.getAttribute(WRITING_MODE) == WRITING_MODE_RTL) ? 1 : 0;
+ int defaultBidiLevel = (((Integer) nodeACI.getAttribute(WRITING_MODE)).intValue() == WRITING_MODE_RTL) ? 1 : 0;
for (int i = 0, n = chunkACIs.length; i < n; ++i) {
chunkACIs[i] = new BidiAttributedCharacterIterator(chunkACIs[i], defaultBidiLevel);
}
- return super.computeTextRuns(node, nodeACI, chunkACIs, (int[][]) null);
+ return super.computeTextRuns(node, nodeACI, chunkACIs, null);
}
// We want to sub-divide text chunks into distinct runs at bidi level boundaries.
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index 5a02992..f415c54 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -295,7 +295,7 @@
*/
public void setPaintingState(PDFPaintingState state) {
paintingState = state;
- baseLevel = paintingState.getStackLevel();
+ baseLevel = paintingState.getStackLevel(); // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
}
/**
@@ -1029,7 +1029,8 @@
resourceContext.addXObject(imageInfo);
} else {
Raster r = pctx.getRaster(devX, devY, devW, devH);
- WritableRaster wr = (WritableRaster)r;
+ assert (r instanceof WritableRaster);
+ WritableRaster wr = (WritableRaster) r;
wr = wr.createWritableTranslatedChild(0, 0);
ColorModel pcm = pctx.getColorModel();
diff --git a/src/java/org/apache/fop/tools/anttasks/RunTest.java b/src/java/org/apache/fop/tools/anttasks/RunTest.java
index 1b56080..0d728ae 100644
--- a/src/java/org/apache/fop/tools/anttasks/RunTest.java
+++ b/src/java/org/apache/fop/tools/anttasks/RunTest.java
@@ -28,6 +28,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -226,14 +227,16 @@
* @return a list of urls to the runtime jar files.
*/
private URL[] createUrls(String mainJar) throws MalformedURLException {
- ArrayList urls = new ArrayList();
+ List<URL> urls = new ArrayList<URL>();
urls.add(new File(mainJar).toURI().toURL());
File[] libFiles = new File("lib").listFiles();
- for (int i = 0; i < libFiles.length; i++) {
- if (libFiles[i].getPath().endsWith(".jar")) {
- urls.add(libFiles[i].toURI().toURL());
+ if (libFiles != null) {
+ for (File libFile : libFiles) {
+ if (libFile.getPath().endsWith(".jar")) {
+ urls.add(libFile.toURI().toURL());
+ }
}
}
- return (URL[]) urls.toArray(new URL[urls.size()]);
+ return urls.toArray(new URL[urls.size()]);
}
}
diff --git a/test/layoutengine/standard-testcases/footnote_id.xml b/test/layoutengine/standard-testcases/footnote_id.xml
index e9e30e3..84593df 100644
--- a/test/layoutengine/standard-testcases/footnote_id.xml
+++ b/test/layoutengine/standard-testcases/footnote_id.xml
@@ -38,9 +38,7 @@
<fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>
<fo:footnote-body id="fnb1">
<fo:block text-align="left">
- <fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>
- http://xmlgrapics.apache.org/fop/
- </fo:block>
+ <fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>http://xmlgrapics.apache.org/fop/</fo:block>
</fo:footnote-body>
</fo:footnote>
</fo:block>
@@ -65,6 +63,6 @@
<!-- Check fo:footnote-body @id -->
<!-- TODO - figure out where @prod-id should go -->
<true xpath="((//page)[2]//block)[2]/lineArea[1]/inlineparent[1]/@internal-link" />
- <eval expected="(P1,fnb1)" xpath="((//page)[2]//block)[2]/lineArea[1]/inlineparent[1]/@internal-link"/>
+ <eval expected="(P1,fnb1)" xpath="((//page)[2]//block)[1]/lineArea[1]/inlineparent[2]/@internal-link"/>
</checks>
-</testcase>
\ No newline at end of file
+</testcase>