You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2020/09/12 08:50:49 UTC

svn commit: r1881654 - /pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java

Author: tilman
Date: Sat Sep 12 08:50:49 2020
New Revision: 1881654

URL: http://svn.apache.org/viewvc?rev=1881654&view=rev
Log:
PDFBOX-4892: refactor

Modified:
    pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java

Modified: pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1881654&r1=1881653&r2=1881654&view=diff
==============================================================================
--- pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java (original)
+++ pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java Sat Sep 12 08:50:49 2020
@@ -763,33 +763,34 @@ public final class PDAcroForm implements
     private boolean resolveNeedsTranslation(PDAppearanceStream appearanceStream)
     {
         PDResources resources = appearanceStream.getResources();
-        if (resources != null && resources.getXObjectNames().iterator().hasNext())
+        if (resources == null || !resources.getXObjectNames().iterator().hasNext())
         {
-            Iterator<COSName> xObjectNames = resources.getXObjectNames().iterator();
-
-            while (xObjectNames.hasNext())
+            return true;
+        }
+        Iterator<COSName> xObjectNames = resources.getXObjectNames().iterator();
+        while (xObjectNames.hasNext())
+        {
+            try
             {
-                try
+                // if the BBox of the PDFormXObject does not start at 0,0
+                // there is no need do translate as this is done by the BBox definition.
+                COSName name = xObjectNames.next();
+                PDXObject xObject = resources.getXObject(name);
+                if (xObject instanceof PDFormXObject)
                 {
-                    // if the BBox of the PDFormXObject does not start at 0,0
-                    // there is no need do translate as this is done by the BBox definition.
-                    PDXObject xObject = resources.getXObject(xObjectNames.next());
-                    if (xObject instanceof PDFormXObject)
+                    PDRectangle bbox = ((PDFormXObject) xObject).getBBox();
+                    float llX = bbox.getLowerLeftX();
+                    float llY = bbox.getLowerLeftY();
+                    if (Float.compare(llX, 0) != 0 && Float.compare(llY, 0) != 0)
                     {
-                        PDRectangle bbox = ((PDFormXObject)xObject).getBBox();
-                        float llX = bbox.getLowerLeftX();
-                        float llY = bbox.getLowerLeftY();
-                        if (Float.compare(llX, 0) != 0 && Float.compare(llY, 0) != 0)
-                        {
-                            return false;
-                        }
+                        return false;
                     }
                 }
-                catch (IOException e)
-                {
-                    // we can safely ignore the exception here
-                    // as this might only cause a misplacement
-                }
+            }
+            catch (IOException e)
+            {
+                // we can safely ignore the exception here
+                // as this might only cause a misplacement
             }
         }