You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2016/08/18 17:04:51 UTC

svn commit: r1756835 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel: PDPage.java common/COSArrayList.java

Author: jahewson
Date: Thu Aug 18 17:04:51 2016
New Revision: 1756835

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

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

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1756835&r1=1756834&r2=1756835&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Thu Aug 18 17:04:51 2016
@@ -647,9 +647,7 @@ public class PDPage implements COSObject
         COSArray annots = (COSArray) page.getDictionaryObject(COSName.ANNOTS);
         if (annots == null)
         {
-            annots = new COSArray();
-            page.setItem(COSName.ANNOTS, annots);
-            retval = new COSArrayList<PDAnnotation>(new ArrayList<PDAnnotation>(), annots);
+            return new COSArrayList<PDAnnotation>(page, COSName.ANNOTS);
         }
         else
         {

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java?rev=1756835&r1=1756834&r2=1756835&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java Thu Aug 18 17:04:51 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