From cc8de5865414b12373ee68c97a3bbb3488c9acfa Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Wed, 8 Mar 2017 15:15:06 +0000 Subject: [PATCH] Fix findbugs 3 warnings git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1785982 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/complexscripts/bidi/UnicodeBidiAlgorithm.java | 2 +- .../fop/complexscripts/fonts/GlyphProcessingState.java | 1 + .../fonts/OTFAdvancedTypographicTableReader.java | 6 ------ .../apache/fop/complexscripts/util/NumberConverter.java | 2 +- .../apache/fop/layoutmgr/inline/FloatLayoutManager.java | 7 +------ .../org/apache/fop/layoutmgr/inline/TextLayoutManager.java | 2 +- fop-core/src/main/java/org/apache/fop/pdf/PDFFunction.java | 5 ----- .../main/java/org/apache/fop/render/rtf/RTFHandler.java | 6 ------ .../main/java/org/apache/fop/util/bitmap/DitherUtil.java | 2 +- 9 files changed, 6 insertions(+), 27 deletions(-) diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java index 6b47450b7..29516df15 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java @@ -382,7 +382,7 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { if ((bcPrev == EN) || (bcNext == EN)) { wca [ i ] = EN; } - } else if ((bc != BN) && (bc != ET)) { + } else if (bc != BN) { bcPrev = bc; } } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java index 8c30e92aa..02c2d1709 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java @@ -927,6 +927,7 @@ public class GlyphProcessingState { al.add(igs.getAssociation(i)); } gb.flip(); + assert igs != null; if (igs.compareGlyphs(gb) != 0) { this.igs = new GlyphSequence(igs.getCharacters(), gb, al); this.indexLast = gb.limit(); diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java index dd38ca952..6c939acae 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java @@ -150,14 +150,12 @@ public final class OTFAdvancedTypographicTableReader { log.debug(tableTag + " lang sys table non-required feature count: " + nf); } // read (non-required) feature indices - int[] fia = new int[nf]; List fl = new java.util.ArrayList(); for (int i = 0; i < nf; i++) { int fi = in.readTTFUShort(); if (log.isDebugEnabled()) { log.debug(tableTag + " lang sys table non-required feature index: " + fi); } - fia[i] = fi; fl.add("f" + fi); } if (seLanguages == null) { @@ -265,14 +263,12 @@ public final class OTFAdvancedTypographicTableReader { log.debug(tableTag + " feature table lookup list index count: " + nl); } // read lookup table indices - int[] lia = new int[nl]; List lul = new java.util.ArrayList(); for (int i = 0; i < nl; i++) { int li = in.readTTFUShort(); if (log.isDebugEnabled()) { log.debug(tableTag + " feature table lookup index: " + li); } - lia[i] = li; lul.add("lu" + li); } seFeatures.put("f" + featureIndex, new Object[] { featureTag, lul }); @@ -710,13 +706,11 @@ public final class OTFAdvancedTypographicTableReader { // read coverage table seMapping = readCoverageTable(tableTag + " single substitution coverage", subtableOffset + co); // read glyph substitutions - int[] gsa = new int[ng]; for (int i = 0, n = ng; i < n; i++) { int gs = in.readTTFUShort(); if (log.isDebugEnabled()) { log.debug(tableTag + " single substitution glyph[" + i + "]: " + gs); } - gsa[i] = gs; seEntries.add(gs); } } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java b/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java index 48f9af9e3..ec2c7d4ac 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java @@ -1260,7 +1260,6 @@ public class NumberConverter { sl.add(0x05F3); } if (hundreds > 0) { - assert hundreds < 10; if (hundreds < 5) { sl.add(map [ 18 + (hundreds - 1) ]); } else if (hundreds < 9) { @@ -1273,6 +1272,7 @@ public class NumberConverter { sl.add(0x05F4); sl.add(map [ 18 + (hundreds - 9) ]); } + assert hundreds < 10; } if (number == 15) { sl.add(map [ 9 - 1]); diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java index 4bb481dcd..fe63791bf 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java @@ -78,13 +78,8 @@ public class FloatLayoutManager extends InlineStackingLayoutManager { public void addAreas(PositionIterator posIter, LayoutContext context) { // "Unwrap" the NonLeafPositions stored in posIter - LinkedList positionList = new LinkedList(); - Position pos = null; while (posIter.hasNext()) { - pos = posIter.next(); - if (pos != null && pos.getPosition() != null) { - positionList.add(pos.getPosition()); - } + posIter.next(); } } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index ab7d0c01a..6d61aa89e 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -1347,7 +1347,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { // if a break occurs the content width increases, // otherwise nothing happens addElementsForAHyphen(baseList, alignment, hyphIPD, widthIfNoBreakOccurs, - mapping.breakOppAfter && mapping.isHyphenated); + mapping.breakOppAfter); } else if (suppressibleLetterSpace) { // the word fragment ends with a character that acts as a hyphen // if a break occurs the width does not increase, diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFFunction.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFFunction.java index 3ce581d7f..a76df9c51 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFFunction.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFFunction.java @@ -19,7 +19,6 @@ package org.apache.fop.pdf; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -109,10 +108,6 @@ public class PDFFunction extends PDFObject { public byte[] toByteString() { - List functionsStrings = new ArrayList(function.getFunctions().size()); - for (PDFFunction f : pdfFunctions) { - functionsStrings.add(f.referencePDF()); - } SubFunctionRenderer subFunctionRenderer = new SubFunctionRenderer() { public void outputFunction(StringBuilder out, int functionIndex) { diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java index b94a07e0b..36a201a8f 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java @@ -601,9 +601,6 @@ public class RTFHandler extends FOEventHandler { /** {@inheritDoc} */ public void endColumn(TableColumn tc) { - if (bDefer) { - return; - } } /** {@inheritDoc} */ @@ -1452,9 +1449,6 @@ public class RTFHandler extends FOEventHandler { /** {@inheritDoc} */ public void endPageNumber(PageNumber pagenum) { - if (bDefer) { - return; - } } /** {@inheritDoc} */ diff --git a/fop-core/src/main/java/org/apache/fop/util/bitmap/DitherUtil.java b/fop-core/src/main/java/org/apache/fop/util/bitmap/DitherUtil.java index 2fa2e9402..a63c00782 100644 --- a/fop-core/src/main/java/org/apache/fop/util/bitmap/DitherUtil.java +++ b/fop-core/src/main/java/org/apache/fop/util/bitmap/DitherUtil.java @@ -113,7 +113,7 @@ public final class DitherUtil { throw new IllegalArgumentException("Unsupported dither matrix: " + matrix); } if (doubleMatrix) { - if (doubleMatrix && (matrix != DITHER_MATRIX_4X4)) { + if (matrix != DITHER_MATRIX_4X4) { throw new IllegalArgumentException("doubleMatrix=true is only allowed for 4x4"); } dither = new byte[bayer.length / 8 * 4]; -- 2.39.5