pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1756834 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel: PDPage.java common/COSArrayList.java
Date Thu, 18 Aug 2016 17:04:45 GMT
Author: jahewson
Date: Thu Aug 18 17:04:45 2016
New Revision: 1756834

URL: http://svn.apache.org/viewvc?rev=1756834&view=rev
Log:
PDFBOX-3467: don't modify during getAnnotations

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1756834&r1=1756833&r2=1756834&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Thu Aug 18 17:04:45
2016
@@ -647,8 +647,7 @@ public class PDPage implements COSObject
         COSArray annots = (COSArray) page.getDictionaryObject(COSName.ANNOTS);
         if (annots == null)
         {
-            // unmodifiable list prevents silent errors due to 2.1 API change
-            return Collections.unmodifiableList(Collections.<PDAnnotation>emptyList());
+            return new COSArrayList<PDAnnotation>(page, COSName.ANNOTS);
         }
         else
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java?rev=1756834&r1=1756833&r2=1756834&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java Thu
Aug 18 17:04:45 2016
@@ -68,6 +68,22 @@ public class COSArrayList<E> implements
     }
 
     /**
+     * This constructor is to be used if the array doesn't exist, but is to be created and
added to
+     * the parent dictionary as soon as the first element is added to the array.
+     *
+     * @param dictionary The dictionary that holds the item, and will hold the array if an
item is
+     * added.
+     * @param dictionaryKey The key into the dictionary to set the item.
+     */
+    public COSArrayList(COSDictionary dictionary, COSName dictionaryKey)
+    {
+        array = new COSArray();
+        actual = new ArrayList<E>();
+        parentDict = dictionary;
+        dictKey = dictionaryKey;
+    }
+
+    /**
      * This is a really special constructor.  Sometimes the PDF spec says
      * that a dictionary entry can either be a single item or an array of those
      * items.  But in the PDModel interface we really just want to always return



Mime
View raw message