Author: tilman
Date: Mon May 19 03:11:47 2025
New Revision: 1925691

URL: http://svn.apache.org/viewvc?rev=1925691&view=rev
Log:
PDFBOX-6008: pass document resource cache to softmask

Modified:
    
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
    
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java
    
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=1925691&r1=1925690&r2=1925691&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
 (original)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
 Mon May 19 03:11:47 2025
@@ -269,7 +269,7 @@ public final class PDResources implement
         COSBase base = get(COSName.EXT_G_STATE, name);
         if (base instanceof COSDictionary)
         {
-            extGState = new PDExtendedGraphicsState((COSDictionary) base);
+            extGState = new PDExtendedGraphicsState((COSDictionary) base, 
getResourceCache());
         }
 
         if (cache != null && indirect != null)

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java?rev=1925691&r1=1925690&r2=1925691&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java
 (original)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java
 Mon May 19 03:11:47 2025
@@ -24,6 +24,7 @@ import org.apache.pdfbox.cos.COSDictiona
 import org.apache.pdfbox.cos.COSFloat;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.pdmodel.ResourceCache;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.graphics.PDFontSetting;
 import org.apache.pdfbox.pdmodel.graphics.PDLineDashPattern;
@@ -37,6 +38,7 @@ import org.apache.pdfbox.pdmodel.graphic
 public class PDExtendedGraphicsState implements COSObjectable
 {
     private final COSDictionary dict;
+    private final ResourceCache cache;
 
     /**
      * Default constructor, creates blank graphics state.
@@ -45,6 +47,7 @@ public class PDExtendedGraphicsState imp
     {
         dict = new COSDictionary();
         dict.setItem(COSName.TYPE, COSName.EXT_G_STATE);
+        cache = null;
     }
 
     /**
@@ -54,7 +57,19 @@ public class PDExtendedGraphicsState imp
      */
     public PDExtendedGraphicsState(COSDictionary dictionary)
     {
+        this(dictionary, null);
+    }
+
+    /**
+     * Create a graphics state from an existing dictionary.
+     *
+     * @param dictionary The existing graphics state.
+     * @param resourceCache Resource cache, may be null.
+     */
+    public PDExtendedGraphicsState(COSDictionary dictionary, ResourceCache 
resourceCache)
+    {
         dict = dictionary;
+        cache = resourceCache;
     }
 
     /**
@@ -587,7 +602,7 @@ public class PDExtendedGraphicsState imp
     public PDSoftMask getSoftMask()
     {
         COSBase smask = dict.getDictionaryObject(COSName.SMASK);
-        return smask == null ? null : PDSoftMask.create(smask);
+        return smask == null ? null : PDSoftMask.create(smask, cache);
     }
 
     /**

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java?rev=1925691&r1=1925690&r2=1925691&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java
 (original)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDSoftMask.java
 Mon May 19 03:11:47 2025
@@ -24,6 +24,8 @@ import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.PDResources;
+import org.apache.pdfbox.pdmodel.ResourceCache;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.common.function.PDFunction;
 import org.apache.pdfbox.pdmodel.graphics.PDXObject;
@@ -46,6 +48,19 @@ public final class PDSoftMask implements
      */
     public static PDSoftMask create(COSBase dictionary)
     {
+        return create(dictionary, null);
+    }
+
+    /**
+     * Creates a new soft mask.
+     *
+     * @param dictionary SMask
+     * @param resourceCache Resource cache, may be null.
+     * 
+     * @return the newly created instance of PDSoftMask
+     */
+    public static PDSoftMask create(COSBase dictionary, ResourceCache 
resourceCache)
+    {
         if (dictionary instanceof COSName)
         {
             if (COSName.NONE.equals(dictionary))
@@ -60,7 +75,7 @@ public final class PDSoftMask implements
         }
         else if (dictionary instanceof COSDictionary)
         {
-            return new PDSoftMask((COSDictionary) dictionary);
+            return new PDSoftMask((COSDictionary) dictionary, resourceCache);
         }
         else
         {
@@ -72,6 +87,7 @@ public final class PDSoftMask implements
     private static final Log LOG = LogFactory.getLog(PDSoftMask.class);
 
     private final COSDictionary dictionary;
+    private final ResourceCache resourceCache;
     private COSName subType = null;
     private PDTransparencyGroup group = null;
     private COSArray backdropColor = null;
@@ -89,7 +105,19 @@ public final class PDSoftMask implements
      */
     public PDSoftMask(COSDictionary dictionary)
     {
+        this(dictionary, null);
+    }
+
+    /**
+     * Creates a new soft mask.
+     *
+     * @param dictionary The soft mask dictionary.
+     * @param resourceCache Resource cache, may be null.
+     */
+    public PDSoftMask(COSDictionary dictionary, ResourceCache resourceCache)
+    {
         this.dictionary = dictionary;
+        this.resourceCache = resourceCache;
     }
 
     @Override
@@ -125,7 +153,8 @@ public final class PDSoftMask implements
             COSBase cosGroup = getCOSObject().getDictionaryObject(COSName.G);
             if (cosGroup != null)
             {
-                PDXObject x = PDXObject.createXObject(cosGroup, null);
+                PDResources resources = new PDResources(new COSDictionary(), 
resourceCache);
+                PDXObject x = PDXObject.createXObject(cosGroup, resources);
                 if (x instanceof PDTransparencyGroup)
                 {
                     group = (PDTransparencyGroup) x;


Reply via email to