pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1784645 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java
Date Mon, 27 Feb 2017 20:14:40 GMT
Author: tilman
Date: Mon Feb 27 20:14:40 2017
New Revision: 1784645

URL: http://svn.apache.org/viewvc?rev=1784645&view=rev
Log:
PDFBOX-2852: avoid ClassCastException

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java?rev=1784645&r1=1784644&r2=1784645&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java
Mon Feb 27 20:14:40 2017
@@ -18,6 +18,7 @@ package org.apache.pdfbox.pdmodel.intera
 
 import java.util.Iterator;
 
+import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.PDDictionaryWrapper;
@@ -51,14 +52,15 @@ public abstract class PDOutlineNode exte
      */
     PDOutlineNode getParent()
     {
-        COSDictionary item = (COSDictionary) getCOSObject().getDictionaryObject(COSName.PARENT);
-        if (item != null)
+        COSBase base = getCOSObject().getDictionaryObject(COSName.PARENT);
+        if (base instanceof COSDictionary)
         {
-            if (COSName.OUTLINES.equals(item.getCOSName(COSName.TYPE)))
+            COSDictionary parent = (COSDictionary) base;
+            if (COSName.OUTLINES.equals(parent.getCOSName(COSName.TYPE)))
             {
-                return new PDDocumentOutline(item);
+                return new PDDocumentOutline(parent);
             }
-            return new PDOutlineItem(item);
+            return new PDOutlineItem(parent);
         }
         return null;
     }
@@ -173,10 +175,10 @@ public abstract class PDOutlineNode exte
 
     PDOutlineItem getOutlineItem(COSName name)
     {
-        COSDictionary item = (COSDictionary) getCOSObject().getDictionaryObject(name);
-        if (item != null)
+        COSBase base = getCOSObject().getDictionaryObject(name);
+        if (base instanceof COSDictionary)
         {
-            return new PDOutlineItem(item);
+            return new PDOutlineItem((COSDictionary) base);
         }
         return null;
     }



Mime
View raw message