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 2020/04/08 15:16:02 UTC

svn commit: r1876300 - /pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java

Author: tilman
Date: Wed Apr  8 15:16:02 2020
New Revision: 1876300

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

Modified:
    pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java

Modified: pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=1876300&r1=1876299&r2=1876300&view=diff
==============================================================================
--- pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java (original)
+++ pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java Wed Apr  8 15:16:02 2020
@@ -140,10 +140,10 @@ public final class PDResources implement
         }
 
         PDFont font = null;
-        COSDictionary dict = (COSDictionary)get(COSName.FONT, name);
-        if (dict != null)
+        COSBase base = get(COSName.FONT, name);
+        if (base instanceof COSDictionary)
         {
-            font = PDFontFactory.createFont(dict, cache);
+            font = PDFontFactory.createFont((COSDictionary) base, cache);
         }
         
         if (cache != null && indirect != null)
@@ -244,10 +244,10 @@ public final class PDResources implement
 
         // get the instance
         PDExtendedGraphicsState extGState = null;
-        COSDictionary dict = (COSDictionary)get(COSName.EXT_G_STATE, name);
-        if (dict != null)
+        COSBase base = get(COSName.EXT_G_STATE, name);
+        if (base instanceof COSDictionary)
         {
-            extGState = new PDExtendedGraphicsState(dict);
+            extGState = new PDExtendedGraphicsState((COSDictionary) base);
         }
 
         if (cache != null)
@@ -280,10 +280,10 @@ public final class PDResources implement
 
         // get the instance
         PDShading shading = null;
-        COSDictionary dict = (COSDictionary)get(COSName.SHADING, name);
-        if (dict != null)
+        COSBase base = get(COSName.SHADING, name);
+        if (base instanceof COSDictionary)
         {
-            shading = PDShading.create(dict);
+            shading = PDShading.create((COSDictionary) base);
         }
         
         if (cache != null)
@@ -316,10 +316,10 @@ public final class PDResources implement
 
         // get the instance
         PDAbstractPattern pattern = null;
-        COSDictionary dict = (COSDictionary)get(COSName.PATTERN, name);
-        if (dict != null)
+        COSBase base = get(COSName.PATTERN, name);
+        if (base instanceof COSDictionary)
         {
-            pattern = PDAbstractPattern.create(dict);
+            pattern = PDAbstractPattern.create((COSDictionary) base);
         }
 
         if (cache != null)
@@ -350,10 +350,10 @@ public final class PDResources implement
 
         // get the instance
         PDPropertyList propertyList = null;
-        COSDictionary dict = (COSDictionary)get(COSName.PROPERTIES, name);
-        if (dict != null)
+        COSBase base = get(COSName.PROPERTIES, name);
+        if (base instanceof COSDictionary)
         {
-            propertyList = PDPropertyList.create(dict);
+            propertyList = PDPropertyList.create((COSDictionary) base);
         }
 
         if (cache != null)