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 2017/11/11 09:55:39 UTC

svn commit: r1814932 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java

Author: tilman
Date: Sat Nov 11 09:55:39 2017
New Revision: 1814932

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

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java?rev=1814932&r1=1814931&r2=1814932&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java Sat Nov 11 09:55:39 2017
@@ -74,22 +74,20 @@ public class PDStructureTreeRoot extends
     public COSArray getKArray()
     {
         COSBase k = this.getCOSObject().getDictionaryObject(COSName.K);
-        if (k != null)
+        if (k instanceof COSDictionary)
         {
-            if (k instanceof COSDictionary)
-            {
-                COSDictionary kdict = (COSDictionary) k;
-                k = kdict.getDictionaryObject(COSName.K);
-                if (k instanceof COSArray)
-                {
-                    return (COSArray) k;
-                }
-            }
-            else
+            COSDictionary kdict = (COSDictionary) k;
+            k = kdict.getDictionaryObject(COSName.K);
+            if (k instanceof COSArray)
             {
                 return (COSArray) k;
             }
         }
+        else if (k instanceof COSArray)
+        {
+            return (COSArray) k;
+        }
+
         return null;
     }
 
@@ -120,10 +118,10 @@ public class PDStructureTreeRoot extends
      */
     public PDNameTreeNode<PDStructureElement> getIDTree()
     {
-        COSDictionary idTreeDic = (COSDictionary) this.getCOSObject().getDictionaryObject(COSName.ID_TREE);
-        if (idTreeDic != null)
+        COSBase base = this.getCOSObject().getDictionaryObject(COSName.ID_TREE);
+        if (base instanceof COSDictionary)
         {
-            return new PDStructureElementNameTreeNode(idTreeDic);
+            return new PDStructureElementNameTreeNode((COSDictionary) base);
         }
         return null;
     }
@@ -145,10 +143,10 @@ public class PDStructureTreeRoot extends
      */
     public PDNumberTreeNode getParentTree()
     {
-        COSDictionary parentTreeDic = (COSDictionary) this.getCOSObject().getDictionaryObject(COSName.PARENT_TREE);
-        if (parentTreeDic != null)
+        COSBase base = getCOSObject().getDictionaryObject(COSName.PARENT_TREE);
+        if (base instanceof COSDictionary)
         {
-            return new PDNumberTreeNode(parentTreeDic, COSBase.class);
+            return new PDNumberTreeNode((COSDictionary) base, COSBase.class);
         }
         return null;
     }