pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1866151 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
Date Fri, 30 Aug 2019 15:28:51 GMT
Author: tilman
Date: Fri Aug 30 15:28:51 2019
New Revision: 1866151

URL: http://svn.apache.org/viewvc?rev=1866151&view=rev
Log:
PDFBOX-4071: refactor / simplify / comment long method

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

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1866151&r1=1866150&r2=1866151&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
Fri Aug 30 15:28:51 2019
@@ -878,30 +878,18 @@ public final class PDAcroForm implements
     {
         for (PDField field : fields)
         {
+            COSArray array;
             if (field.getParent() == null)
             {
-                COSArray cosFields = (COSArray) dictionary.getDictionaryObject(COSName.FIELDS);
-                for (int i = 0; i < cosFields.size(); i++)
-                {
-                    COSDictionary element = (COSDictionary) cosFields.getObject(i);
-                    if (field.getCOSObject().equals(element))
-                    {
-                        cosFields.remove(i);
-                    }
-                }
+                // if the field has no parent, assume it is at root level list, remove it
from there
+                array = (COSArray) dictionary.getDictionaryObject(COSName.FIELDS);
             }
             else
             {
-                COSArray kids = (COSArray) field.getParent().getCOSObject().getDictionaryObject(COSName.KIDS);
-                for (int i = 0; i < kids.size(); i++)
-                {
-                    COSDictionary element = (COSDictionary) kids.getObject(i);
-                    if (field.getCOSObject().equals(element))
-                    {
-                        kids.remove(i);
-                    }
-                }
+                // if the field has a parent, then remove from the list there
+                array = (COSArray) field.getParent().getCOSObject().getDictionaryObject(COSName.KIDS);
             }
+            array.removeObject(field.getCOSObject());
         }
     }
 }



Mime
View raw message