diff --git a/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreatePDFA.java b/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreatePDFA.java index 1d454db8535..871357d2d52 100644 --- a/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreatePDFA.java +++ b/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreatePDFA.java @@ -77,8 +77,8 @@ public static void main(String[] args) throws IOException, TransformerException // if (!font.isEmbedded()) { - throw new IllegalStateException("PDF/A compliance requires that all fonts used for" - + " text rendering in rendering modes other than rendering mode 3 are embedded."); + throw new IllegalStateException("PDF/A compliance requires that all fonts used for" + + " text rendering in rendering modes other than rendering mode 3 are embedded."); } // create a page with the message diff --git a/fontbox/src/test/java/org/apache/fontbox/encoding/EncodingTest.java b/fontbox/src/test/java/org/apache/fontbox/encoding/EncodingTest.java index a93ae14653e..f5e94b5d8a3 100644 --- a/fontbox/src/test/java/org/apache/fontbox/encoding/EncodingTest.java +++ b/fontbox/src/test/java/org/apache/fontbox/encoding/EncodingTest.java @@ -24,7 +24,7 @@ class EncodingTest @Test void testStandardEncoding() { - StandardEncoding standardEncoding = StandardEncoding.INSTANCE; + StandardEncoding standardEncoding = StandardEncoding.INSTANCE; // check some randomly chosen mappings assertEquals(".notdef", standardEncoding.getName(0)); assertEquals("space", standardEncoding.getName(32)); @@ -38,7 +38,7 @@ void testStandardEncoding() @Test void testMacRomanEncoding() { - MacRomanEncoding macRomanEncoding = MacRomanEncoding.INSTANCE; + MacRomanEncoding macRomanEncoding = MacRomanEncoding.INSTANCE; // check some randomly chosen mappings assertEquals(".notdef", macRomanEncoding.getName(0)); assertEquals("space", macRomanEncoding.getName(32)); diff --git a/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java b/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java index 53b1101fddd..adb1b8b3361 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java @@ -148,7 +148,7 @@ public final void setToNull() @Override public String toString() { - return "COSObject{" + getKey() + "}"; + return "COSObject{" + getKey() + "}"; } /** diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java index b4be7ed7be7..679f25288f8 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java @@ -910,11 +910,11 @@ private boolean validateStreamLength(long streamLength) throws IOException protected BruteForceParser getBruteForceParser() throws IOException { - if (bruteForceParser == null) - { + if (bruteForceParser == null) + { bruteForceParser = new BruteForceParser(document, this); } - return bruteForceParser; + return bruteForceParser; } /** diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java index 76f38be31b4..2a72415fe10 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java @@ -967,16 +967,16 @@ private String richContentsToString(Node node, boolean root) } else if (child instanceof CDATASection) { - sb.append(""); + sb.append(""); } else if (child instanceof Text) { - String cdata = ((Text) child).getData(); - if (cdata!=null) - { - cdata = cdata.replace("&", "&").replace("<", "<"); - } - sb.append(cdata); + String cdata = ((Text) child).getData(); + if (cdata!=null) + { + cdata = cdata.replace("&", "&").replace("<", "<"); + } + sb.append(cdata); } } if (root) @@ -992,7 +992,7 @@ else if (child instanceof Text) String attributeNodeValue = attribute.getNodeValue(); if (attributeNodeValue!=null) { - attributeNodeValue = attributeNodeValue.replace("\"", """); + attributeNodeValue = attributeNodeValue.replace("\"", """); } builder.append(String.format(" %s=\"%s\"", attribute.getNodeName(), attributeNodeValue)); diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java index 7d4caea9b3f..98dfaebeb2f 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java @@ -200,8 +200,8 @@ private static Map createBlendModeMap() */ private BlendMode(COSName name, BlendChannelFunction blendChannel, BlendFunction blend) { - this.name = name; - this.blendChannel = blendChannel; + this.name = name; + this.blendChannel = blendChannel; this.blend = blend; isSeparable = blendChannel != null; } @@ -213,7 +213,7 @@ private BlendMode(COSName name, BlendChannelFunction blendChannel, BlendFunction */ public COSName getCOSName() { - return name; + return name; } /** @@ -264,15 +264,15 @@ else if (cosBlendMode instanceof COSArray) COSArray cosBlendModeArray = (COSArray) cosBlendMode; for (int i = 0; i < cosBlendModeArray.size(); i++) { - COSBase cosBase = cosBlendModeArray.getObject(i); - if (cosBase instanceof COSName) - { + COSBase cosBase = cosBlendModeArray.getObject(i); + if (cosBase instanceof COSName) + { result = BLEND_MODES.get(cosBase); if (result != null) { break; } - } + } } } return result != null ? result : BlendMode.NORMAL; diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java index 743f8185c28..132748fba6c 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java @@ -262,7 +262,7 @@ private static ICC_Profile ensureDisplayProfile(ICC_Profile profile) if (profileData[ICC_Profile.icHdrRenderingIntent] == ICC_Profile.icPerceptual) { LOG.warn("ICC profile is Perceptual, ignoring, treating as Display class"); - intToBigEndian(ICC_Profile.icSigDisplayClass, profileData, ICC_Profile.icHdrDeviceClass); + intToBigEndian(ICC_Profile.icSigDisplayClass, profileData, ICC_Profile.icHdrDeviceClass); return ICC_Profile.getInstance(profileData); } } diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java index 33c7c836f8b..091a7af83b5 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType4.java @@ -91,7 +91,7 @@ public Paint toPaint(Matrix matrix) List collectTriangles(AffineTransform xform, Matrix matrix) throws IOException { - int bitsPerFlag = getBitsPerFlag(); + int bitsPerFlag = getBitsPerFlag(); COSDictionary dict = getCOSObject(); if (!(dict instanceof COSStream)) { diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java index 1377b05fe81..4bd27656c89 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java @@ -229,4 +229,14 @@ private boolean overlaps(Point2D p0, Point2D p1) { return Math.abs(p0.getX() - p1.getX()) < 0.001 && Math.abs(p0.getY() - p1.getY()) < 0.001; } + + static Point2D[] clonedPoint2DArray(Point2D[] input) + { + Point2D[] cloned = new Point2D[input.length]; + for (int i = 0; i < input.length; ++i) + { + cloned[i] = (Point2D) input[i].clone(); + } + return cloned; + } } diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/PlainTextFormatter.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/PlainTextFormatter.java index d4db0efe3e5..3e41fe2ec76 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/PlainTextFormatter.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/PlainTextFormatter.java @@ -146,7 +146,7 @@ public void format() throws IOException if (textContent != null && !textContent.getParagraphs().isEmpty()) { boolean isFirstParagraph = true; - for (Paragraph paragraph : textContent.getParagraphs()) + for (Paragraph paragraph : textContent.getParagraphs()) { if (wrapLines) { diff --git a/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/ControlCharacterTest.java b/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/ControlCharacterTest.java index 3133c40a2d1..e93ea274519 100644 --- a/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/ControlCharacterTest.java +++ b/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/ControlCharacterTest.java @@ -92,7 +92,7 @@ void characterNUL() throws IOException void characterTAB() throws IOException { PDField field = acroForm.getField("pdfbox-tab"); - field.setValue("TAB\tTAB"); + field.setValue("TAB\tTAB"); List pdfboxValues = getStringsFromStream(field); pdfboxValues.forEach(token -> assertEquals("TAB", token)); @@ -131,12 +131,12 @@ public void tearDown() throws IOException private List getStringsFromStream(PDField field) throws IOException { - PDAnnotationWidget widget = field.getWidgets().get(0); + PDAnnotationWidget widget = field.getWidgets().get(0); PDFStreamParser parser = new PDFStreamParser( widget.getNormalAppearanceStream()); - + List tokens = parser.parse(); - + // TODO: improve the string output to better match // trimming as Acrobat adds spaces to strings // where we don't diff --git a/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/MultilineFieldsTest.java b/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/MultilineFieldsTest.java index 08a4c05e546..3673b60f09d 100644 --- a/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/MultilineFieldsTest.java +++ b/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/MultilineFieldsTest.java @@ -162,15 +162,15 @@ void testMultilineBreak() throws IOException private float getFontSizeFromAppearanceStream(PDField field) throws IOException { - PDAnnotationWidget widget = field.getWidgets().get(0); + PDAnnotationWidget widget = field.getWidgets().get(0); PDFStreamParser parser = new PDFStreamParser(widget.getNormalAppearanceStream()); - - Object token = parser.parseNextToken(); - - while (token != null) - { + + Object token = parser.parseNextToken(); + + while (token != null) + { if (token instanceof COSName && ((COSName) token).getName().equals("Helv")) - { + { token = parser.parseNextToken(); if (token instanceof COSNumber) { @@ -184,17 +184,17 @@ private float getFontSizeFromAppearanceStream(PDField field) throws IOException private List getTextLinesFromAppearanceStream(PDField field) throws IOException { - PDAnnotationWidget widget = field.getWidgets().get(0); + PDAnnotationWidget widget = field.getWidgets().get(0); PDFStreamParser parser = new PDFStreamParser(widget.getNormalAppearanceStream()); - + Object token = parser.parseNextToken(); List lines = new ArrayList<>(); - - while (token != null) - { + + while (token != null) + { if (token instanceof COSString) - { + { lines.add(((COSString) token).getString()); } token = parser.parseNextToken(); diff --git a/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextTest.java b/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextTest.java index 3de5d85b3fa..ad5faf1794a 100644 --- a/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextTest.java +++ b/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextTest.java @@ -33,43 +33,43 @@ class PlainTextTest @Test void characterCR() { - PlainText text = new PlainText("CR\rCR"); - assertEquals(2,text.getParagraphs().size()); + PlainText text = new PlainText("CR\rCR"); + assertEquals(2,text.getParagraphs().size()); } @Test void characterLF() { - PlainText text = new PlainText("LF\nLF"); - assertEquals(2,text.getParagraphs().size()); + PlainText text = new PlainText("LF\nLF"); + assertEquals(2,text.getParagraphs().size()); } @Test void characterCRLF() { - PlainText text = new PlainText("CRLF\r\nCRLF"); - assertEquals(2,text.getParagraphs().size()); + PlainText text = new PlainText("CRLF\r\nCRLF"); + assertEquals(2,text.getParagraphs().size()); } @Test void characterLFCR() { - PlainText text = new PlainText("LFCR\n\rLFCR"); - assertEquals(3,text.getParagraphs().size()); + PlainText text = new PlainText("LFCR\n\rLFCR"); + assertEquals(3,text.getParagraphs().size()); } @Test void characterUnicodeLinebreak() { - PlainText text = new PlainText("linebreak\u2028linebreak"); - assertEquals(2,text.getParagraphs().size()); + PlainText text = new PlainText("linebreak\u2028linebreak"); + assertEquals(2,text.getParagraphs().size()); } @Test void characterUnicodeParagraphbreak() { - PlainText text = new PlainText("paragraphbreak\u2029paragraphbreak"); - assertEquals(2,text.getParagraphs().size()); + PlainText text = new PlainText("paragraphbreak\u2029paragraphbreak"); + assertEquals(2,text.getParagraphs().size()); } } diff --git a/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java b/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java index 971913b49cf..c230424d023 100644 --- a/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java +++ b/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java @@ -26,7 +26,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** +/* * to be used at runtime */ @Retention(RetentionPolicy.RUNTIME) diff --git a/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java b/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java index b9bb93b4bdd..b4a5270d3f7 100644 --- a/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java +++ b/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java @@ -847,11 +847,11 @@ else if ((ln != null) && !(ln.equals(element.getLocalName()))) */ private void removeComments(Node root) { - // will hold the nodes which are to be deleted - List forDeletion = new ArrayList<>(); - - NodeList nl = root.getChildNodes(); - + // will hold the nodes which are to be deleted + List forDeletion = new ArrayList<>(); + + NodeList nl = root.getChildNodes(); + if (nl.getLength()<=1) { // There is only one node so we do not remove it @@ -864,15 +864,15 @@ private void removeComments(Node root) if (node instanceof Comment) { // comments to be deleted - forDeletion.add(node); + forDeletion.add(node); } else if (node instanceof Text) { if (node.getTextContent().trim().isEmpty()) { - // TODO: verify why this is necessary - // empty text nodes to be deleted - forDeletion.add(node); + // TODO: verify why this is necessary + // empty text nodes to be deleted + forDeletion.add(node); } } else if (node instanceof Element)