pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1594353 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/
Date Tue, 13 May 2014 19:58:00 GMT
Author: tilman
Date: Tue May 13 19:57:59 2014
New Revision: 1594353

URL: http://svn.apache.org/r1594353
Log:
PDFBOX-2070: pass original dictionary to the filter and the index, get decodeparms in the
filter itself

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCII85Filter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CryptFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/DCTFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/IdentityFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCII85Filter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCII85Filter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCII85Filter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCII85Filter.java Tue May
13 19:57:59 2014
@@ -30,8 +30,8 @@ import org.apache.pdfbox.io.IOUtils;
 final class ASCII85Filter extends Filter
 {
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         ASCII85InputStream is = null;
         try

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java Tue May
13 19:57:59 2014
@@ -49,8 +49,8 @@ final class ASCIIHexFilter extends Filte
     };
 
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         int value, firstByte, secondByte;
         while ((firstByte = encoded.read()) != -1)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxFilter.java Tue May
13 19:57:59 2014
@@ -43,15 +43,14 @@ final class CCITTFaxFilter extends Filte
     private static final Log log = LogFactory.getLog(CCITTFaxFilter.class);
 
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         DecodeResult result = new DecodeResult(new COSDictionary());
         result.getParameters().addAll(parameters);
 
         // get decode parameters
-        COSDictionary decodeParms = (COSDictionary)
-                parameters.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
+        COSDictionary decodeParms = getDecodeParams(parameters, index);
 
         // parse dimensions
         int cols = decodeParms.getInt(COSName.COLUMNS, 1728);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CryptFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CryptFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CryptFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/CryptFilter.java Tue May 13
19:57:59 2014
@@ -29,18 +29,18 @@ import org.apache.pdfbox.cos.COSName;
 final class CryptFilter extends Filter
 {
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         COSName encryptionName = (COSName) parameters.getDictionaryObject(COSName.NAME);
         if(encryptionName == null || encryptionName.equals(COSName.IDENTITY)) 
         {
             // currently the only supported implementation is the Identity crypt filter
             Filter identityFilter = new IdentityFilter();
-            identityFilter.decode(encoded, decoded, parameters);
+            identityFilter.decode(encoded, decoded, parameters, index);
             return new DecodeResult(parameters);
         }
-        else 
+        else
         {
             throw new IOException("Unsupported crypt filter " + encryptionName.getName());
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/DCTFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/DCTFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/DCTFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/DCTFilter.java Tue May 13 19:57:59
2014
@@ -47,8 +47,8 @@ final class DCTFilter extends Filter
     private static final Log LOG = LogFactory.getLog(DCTFilter.class);
 
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         // find suitable image reader
         Iterator readers = ImageIO.getImageReadersByFormatName("JPEG");

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java Tue May 13 19:57:59
2014
@@ -49,18 +49,8 @@ public abstract class Filter
      * @return repaired parameters dictionary, or the original parameters dictionary
      * @throws IOException if the stream cannot be decoded
      */
-    public final DecodeResult decode(InputStream encoded, OutputStream decoded, COSDictionary
parameters,
-                            int index) throws IOException
-    {
-        COSDictionary params = new COSDictionary();
-        params.addAll(parameters);
-        params.setItem(COSName.DECODE_PARMS, getDecodeParams(params, index));
-        return decode(encoded, decoded, params.asUnmodifiableDictionary());
-    }
-
-    // implemented in subclasses
-    protected abstract DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                   COSDictionary parameters) throws IOException;
+    public abstract DecodeResult decode(InputStream encoded, OutputStream decoded, COSDictionary
parameters,
+                            int index) throws IOException;
 
     /**
      * Encodes data.
@@ -81,7 +71,7 @@ public abstract class Filter
 
     // gets the decode params for a specific filter index, this is used to
     // normalise the DecodeParams entry so that it is always a dictionary
-    private COSDictionary getDecodeParams(COSDictionary dictionary, int index)
+    protected COSDictionary getDecodeParams(COSDictionary dictionary, int index)
     {
         COSBase obj = dictionary.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
         if (obj instanceof COSDictionary)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java Tue May 13
19:57:59 2014
@@ -43,14 +43,12 @@ final class FlateFilter extends Filter
     private static final int BUFFER_SIZE = 16348;
 
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         int predictor = -1;
 
-        COSDictionary decodeParams = (COSDictionary)
-                parameters.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
-
+        COSDictionary decodeParams = getDecodeParams(parameters, index);
         if (decodeParams != null)
         {
             predictor = decodeParams.getInt(COSName.PREDICTOR);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/IdentityFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/IdentityFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/IdentityFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/IdentityFilter.java Tue May
13 19:57:59 2014
@@ -30,10 +30,10 @@ import org.apache.pdfbox.cos.COSDictiona
 final class IdentityFilter extends Filter
 {
     private static final int BUFFER_SIZE = 1024;
-    
+
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters)
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index)
         throws IOException
     {
         byte[] buffer = new byte[BUFFER_SIZE];

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java Tue May 13
19:57:59 2014
@@ -52,8 +52,8 @@ final class JBIG2Filter extends Filter
     private static final Log LOG = LogFactory.getLog(JBIG2Filter.class);
 
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         // find suitable image reader
         Iterator readers = ImageIO.getImageReadersByFormatName("JBIG2");

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java Tue May 13 19:57:59
2014
@@ -31,7 +31,6 @@ import javax.imageio.stream.ImageInputSt
 
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDJPXColorSpace;
 
 /**
@@ -52,8 +51,8 @@ import org.apache.pdfbox.pdmodel.graphic
 public final class JPXFilter extends Filter
 {
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         DecodeResult result = new DecodeResult(new COSDictionary());
         result.getParameters().addAll(parameters);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java Tue May 13 19:57:59
2014
@@ -61,13 +61,12 @@ public class LZWFilter extends Filter
      * {@inheritDoc}
      */
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-            COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+            COSDictionary parameters, int index) throws IOException
     {
         int predictor = -1;
 
-        COSDictionary decodeParams = (COSDictionary)
-                parameters.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
+        COSDictionary decodeParams = getDecodeParams(parameters, index);
         if (decodeParams != null)
         {
             predictor = decodeParams.getInt(COSName.PREDICTOR);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java?rev=1594353&r1=1594352&r2=1594353&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java
Tue May 13 19:57:59 2014
@@ -36,8 +36,8 @@ final class RunLengthDecodeFilter extend
     private static final int RUN_LENGTH_EOD = 128;
 
     @Override
-    protected final DecodeResult decode(InputStream encoded, OutputStream decoded,
-                                         COSDictionary parameters) throws IOException
+    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
+                                         COSDictionary parameters, int index) throws IOException
     {
         int dupAmount;
         byte[] buffer = new byte[128];



Mime
View raw message