[Git][java-team/xmlgraphics-commons][upstream] New upstream version 2.8

Mathieu Malaterre (@malat) gitlab at salsa.debian.org
Wed Jan 4 09:49:12 GMT 2023



Mathieu Malaterre pushed to branch upstream at Debian Java Maintainers / xmlgraphics-commons


Commits:
c4487dc7 by Mathieu Malaterre at 2023-01-04T10:45:57+01:00
New upstream version 2.8
- - - - -


25 changed files:

- README
- build.properties
- build.xml
- − lib/commons-io-1.3.1.jar
- + lib/commons-io-2.11.0.jar
- pom.xml
- src/main/java/org/apache/xmlgraphics/image/codec/png/PNGEncodeParam.java
- src/main/java/org/apache/xmlgraphics/image/codec/tiff/TIFFFaxDecoder.java
- src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRaw.java
- src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java
- src/main/java/org/apache/xmlgraphics/image/loader/impl/imageio/PreloaderImageIO.java
- src/main/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
- src/main/java/org/apache/xmlgraphics/image/loader/spi/ImageImplRegistry.java
- src/main/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
- src/main/java/org/apache/xmlgraphics/ps/FormGenerator.java
- src/main/java/org/apache/xmlgraphics/ps/PSImageUtils.java
- src/main/java/org/apache/xmlgraphics/xmp/XMPHandler.java
- src/test/java/org/apache/xmlgraphics/image/loader/CorruptImagesTestCase.java
- src/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNGTestCase.java
- src/test/java/org/apache/xmlgraphics/io/URIResolverAdapterTestCase.java
- src/test/java/org/apache/xmlgraphics/io/XmlSourceUtilTestCase.java
- src/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java
- src/test/java/org/apache/xmlgraphics/xmp/XMPParserTestCase.java
- + src/test/java/org/apache/xmlgraphics/xmp/test-subproperty.xmp
- xmlgraphics-commons-pom-template.pom


Changes:

=====================================
README
=====================================
@@ -1,4 +1,4 @@
-$Id: README 1896948 2022-01-12 10:37:20Z ssteiner $
+$Id: README 1905001 2022-11-02 11:49:58Z ssteiner $
 
 ==============================================================================
   APACHE XML GRAPHICS COMMONS  -  README
@@ -82,6 +82,11 @@ License labeling (according to http://www.apache.org/legal/3party.html):
 For more detailed info about the changes, please see:
 http://xmlgraphics.apache.org/commons/changes.html
 
+Version 2.8
+--------------
+
+Minor release to be used with FOP 2.8
+
 Version 2.7
 --------------
 


=====================================
build.properties
=====================================
@@ -34,7 +34,7 @@
 ## ===================================================================
 ## 3. Project specific properties
 
-version = 2.7
+version = 2.8
 
 ## Allows you to switch off the compilation of the internal image
 ## codecs which depend on Sun-private classes. Setting this to true


=====================================
build.xml
=====================================
@@ -30,8 +30,8 @@
   <property name="javac.debug" value="on"/>
   <property name="javac.optimize" value="off"/>
   <property name="javac.deprecation" value="on"/>
-  <property name="javac.source" value="1.7"/>
-  <property name="javac.target" value="1.7"/>
+  <property name="javac.source" value="1.8"/>
+  <property name="javac.target" value="1.8"/>
   <property name="javac.fork" value="no"/>
 
   <property name="junit.fork" value="on"/>
@@ -232,6 +232,7 @@
       <src path="${src.java.dir}"/>
       <patternset refid="compile-pattern"/>
       <classpath refid="libs-build-classpath"/>
+      <compilerarg value="-Xlint:cast"/>
     </javac>
   </target>
 
@@ -321,6 +322,7 @@
           <include name="${name}-${version}.jar"/>
         </fileset>
       </classpath>
+      <compilerarg value="-Xlint:cast"/>
     </javac>
     <copy todir="${build.dir}/test-classes" includeEmptyDirs="false">
       <fileset dir="${test.res.dir}"/>


=====================================
lib/commons-io-1.3.1.jar deleted
=====================================
Binary files a/lib/commons-io-1.3.1.jar and /dev/null differ


=====================================
lib/commons-io-2.11.0.jar
=====================================
Binary files /dev/null and b/lib/commons-io-2.11.0.jar differ


=====================================
pom.xml
=====================================
@@ -4,7 +4,7 @@
 
   <groupId>org.apache.xmlgraphics</groupId>
   <artifactId>xmlgraphics-commons</artifactId>
-  <version>2.7</version>
+  <version>2.8</version>
   <name>${project.groupId}:${project.artifactId}</name>
   <description>XML Graphics Commons</description>
   <url>http://xmlgraphics.apache.org/commons/</url>
@@ -13,7 +13,7 @@
     <checkstyle.version>2.15</checkstyle.version>
     <exec.version>1.4.0</exec.version>
     <findbugs.version>3.0.4</findbugs.version>
-    <java.version>1.7</java.version>
+    <java.version>1.8</java.version>
     <junit.version>4.11</junit.version>
     <project.info.reports.version>2.8</project.info.reports.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -52,7 +52,7 @@
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
-      <version>1.3.2</version>
+      <version>2.11.0</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>


=====================================
src/main/java/org/apache/xmlgraphics/image/codec/png/PNGEncodeParam.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PNGEncodeParam.java 1732018 2016-02-24 04:51:06Z gadams $ */
+/* $Id: PNGEncodeParam.java 1902007 2022-06-17 09:51:56Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.codec.png;
 
@@ -174,7 +174,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
                    IllegalArgumentException(PropertyUtil.getString("PNGEncodeParam1"));
             }
 
-            palette = (int[])(rgb.clone());
+            palette = rgb.clone();
             paletteSet = true;
         }
 
@@ -192,7 +192,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
             if (!paletteSet) {
                 throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam3"));
             }
-            return (int[])(palette.clone());
+            return palette.clone();
         }
 
         /**
@@ -530,7 +530,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
          * <p> The 'tRNS' chunk will encode this information.
          */
         public void setTransparentRGB(int[] transparentRGB) {
-            transparency = (int[])(transparentRGB.clone());
+            transparency = transparentRGB.clone();
             transparencySet = true;
         }
 
@@ -547,7 +547,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
             if (!transparencySet) {
                 throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam10"));
             }
-            return (int[])(transparency.clone());
+            return transparency.clone();
         }
     }
 
@@ -653,7 +653,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
         if (chromaticity.length != 8) {
             throw new IllegalArgumentException(PropertyUtil.getString("PNGEncodeParam28"));
         }
-        this.chromaticity = (float[])(chromaticity.clone());
+        this.chromaticity = chromaticity.clone();
         chromaticitySet = true;
     }
 
@@ -692,7 +692,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
         if (!chromaticitySet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam12"));
         }
-        return (float[])(chromaticity.clone());
+        return chromaticity.clone();
     }
 
     /**
@@ -767,7 +767,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
      * <p> The 'hIST' chunk will encode this information.
      */
     public void setPaletteHistogram(int[] paletteHistogram) {
-        this.paletteHistogram = (int[])(paletteHistogram.clone());
+        this.paletteHistogram = paletteHistogram.clone();
         paletteHistogramSet = true;
     }
 
@@ -813,7 +813,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
      * <p> The 'iCCP' chunk will encode this information.
      */
     public void setICCProfileData(byte[] iccProfileData) {
-        this.iccProfileData = (byte[])(iccProfileData.clone());
+        this.iccProfileData = iccProfileData.clone();
         iccProfileDataSet = true;
     }
 
@@ -829,7 +829,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
         if (!iccProfileDataSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam15"));
         }
-        return (byte[])(iccProfileData.clone());
+        return iccProfileData.clone();
     }
 
     /**
@@ -862,7 +862,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
      * <p> The 'pHYS' chunk will encode this information.
      */
     public void setPhysicalDimension(int[] physicalDimension) {
-        this.physicalDimension = (int[])(physicalDimension.clone());
+        this.physicalDimension = physicalDimension.clone();
         physicalDimensionSet = true;
     }
 
@@ -895,7 +895,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
         if (!physicalDimensionSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam16"));
         }
-        return (int[])(physicalDimension.clone());
+        return physicalDimension.clone();
     }
 
     /**
@@ -926,7 +926,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
      * <p> The 'sPLT' chunk will encode this information.
      */
     public void setSuggestedPalette(PNGSuggestedPaletteEntry[] palette) {
-        suggestedPalette = (PNGSuggestedPaletteEntry[])(palette.clone());
+        suggestedPalette = palette.clone();
         suggestedPaletteSet = true;
     }
 
@@ -945,7 +945,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
         if (!suggestedPaletteSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam17"));
         }
-        return (PNGSuggestedPaletteEntry[])(suggestedPalette.clone());
+        return suggestedPalette.clone();
     }
 
     /**
@@ -979,7 +979,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
      * <p> The 'sBIT' chunk will encode this information.
      */
     public void setSignificantBits(int[] significantBits) {
-        this.significantBits = (int[])(significantBits.clone());
+        this.significantBits = significantBits.clone();
         significantBitsSet = true;
     }
 
@@ -997,7 +997,7 @@ public abstract class PNGEncodeParam implements ImageEncodeParam {
         if (!significantBitsSet) {
             throw new IllegalStateException(PropertyUtil.getString("PNGEncodeParam18"));
         }
-        return (int[])significantBits.clone();
+        return significantBits.clone();
     }
 
     /**


=====================================
src/main/java/org/apache/xmlgraphics/image/codec/tiff/TIFFFaxDecoder.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: TIFFFaxDecoder.java 1732018 2016-02-24 04:51:06Z gadams $ */
+/* $Id: TIFFFaxDecoder.java 1902007 2022-06-17 09:51:56Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.codec.tiff;
 
@@ -813,7 +813,7 @@ class TIFFFaxDecoder {
                     entry = nextLesserThan8Bits(7);
 
                     // Run these through the 2DCodes table
-                    entry = (int)(twoDCodes[entry] & 0xff);
+                    entry = twoDCodes[entry] & 0xff;
 
                     // Get the code and the number of bits used up
                     code = (entry & 0x78) >>> 3;
@@ -963,7 +963,7 @@ class TIFFFaxDecoder {
                 // Get the next seven bits
                 entry = nextLesserThan8Bits(7);
                 // Run these through the 2DCodes table
-                entry = (int)(twoDCodes[entry] & 0xff);
+                entry = twoDCodes[entry] & 0xff;
 
                 // Get the code and the number of bits used up
                 code = (entry & 0x78) >>> 3;


=====================================
src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRaw.java
=====================================
@@ -15,12 +15,22 @@
  * limitations under the License.
  */
 
-/* $Id: ImageLoaderFactoryRaw.java 1681137 2015-05-22 14:54:05Z ssteiner $ */
+/* $Id: ImageLoaderFactoryRaw.java 1904425 2022-10-06 12:37:37Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.loader.impl;
 
+import java.util.Map;
+
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataNode;
+
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
 import org.apache.xmlgraphics.image.loader.spi.ImageLoader;
+import org.apache.xmlgraphics.image.loader.util.Penalty;
 import org.apache.xmlgraphics.util.MimeConstants;
 
 /**
@@ -93,4 +103,34 @@ public class ImageLoaderFactoryRaw extends AbstractImageLoaderFactory {
         return true;
     }
 
+    @Override
+    public boolean isSupported(ImageInfo imageInfo) {
+        if ("image/png".equals(imageInfo.getMimeType())) {
+            Map additionalPenalties = (Map) imageInfo.getCustomObjects().get("additionalPenalties");
+            int penalty = 0;
+            Penalty penaltyObj = ((Penalty)additionalPenalties.get(ImageLoaderRawPNG.class.getName()));
+            if (penaltyObj != null) {
+                penalty = penaltyObj.getValue();
+            }
+            IIOMetadata metadata = (IIOMetadata) imageInfo.getCustomObjects().get(IIOMetadata.class);
+            if (metadata != null) {
+                IIOMetadataNode children = (IIOMetadataNode)metadata.getAsTree("javax_imageio_png_1.0").getChildNodes();
+                NamedNodeMap attr = children.getElementsByTagName("IHDR").item(0).getAttributes();
+                String bitDepth = attr.getNamedItem("bitDepth").getNodeValue();
+                String interlaceMethod = attr.getNamedItem("interlaceMethod").getNodeValue();
+                String colorType = attr.getNamedItem("colorType").getNodeValue();
+                if (!bitDepth.equals("8") || !interlaceMethod.equals("none")
+                        || ((colorType.equals("RGBAlpha") || colorType.equals("GrayAlpha")) && penalty >= 0)) {
+                    return false;
+                }
+                children = (IIOMetadataNode)metadata.getAsTree("javax_imageio_1.0").getChildNodes();
+                Node numChannels = children.getElementsByTagName("NumChannels").item(0);
+                String numChannelsStr = numChannels.getAttributes().getNamedItem("value").getNodeValue();
+                if ("4".equals(numChannelsStr) && "Palette".equals(colorType) && penalty >= 0) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
 }


=====================================
src/main/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: ImageLoaderRawPNG.java 1843559 2018-10-11 14:59:17Z ssteiner $ */
+/* $Id: ImageLoaderRawPNG.java 1904425 2022-10-06 12:37:37Z ssteiner $ */
 
 // Original author: Matthias Reichenbacher
 
@@ -74,13 +74,4 @@ public class ImageLoaderRawPNG extends AbstractImageLoader {
         ImageRawPNG irpng = im.getImageRawPNG(info);
         return irpng;
     }
-
-    /** {@inheritDoc} */
-    public int getUsagePenalty() {
-        // since this image loader does not handle all kinds of PNG images then we add some penalty to it
-        // so that it is not chosen by default; instead, users need to give it a negative penalty in
-        // fop.xconf so that it is used
-        return 1000;
-    }
-
 }


=====================================
src/main/java/org/apache/xmlgraphics/image/loader/impl/imageio/PreloaderImageIO.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PreloaderImageIO.java 1452610 2013-03-05 01:00:35Z lbernardo $ */
+/* $Id: PreloaderImageIO.java 1904425 2022-10-06 12:37:37Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.loader.impl.imageio;
 
@@ -52,6 +52,7 @@ public class PreloaderImageIO extends AbstractImagePreloader {
             return null;
         }
         ImageInputStream in = ImageUtil.needImageInputStream(src);
+        long startPos = in.getStreamPosition();
         Iterator iter = ImageIO.getImageReaders(in);
         if (!iter.hasNext()) {
             return null;
@@ -85,15 +86,8 @@ public class PreloaderImageIO extends AbstractImagePreloader {
         }
 
         if (iiometa == null) {
-            if (firstIOException == null) {
-                throw new ImageException("Could not extract image metadata");
-            } else {
-                throw new ImageException("I/O error while extracting image metadata"
-                        + (firstIOException.getMessage() != null
-                            ? ": " + firstIOException.getMessage()
-                            : ""),
-                        firstIOException);
-            }
+            in.seek(startPos);
+            return null;
         }
 
         //Resolution (first a default, then try to read the metadata)


=====================================
src/main/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PipelineFactory.java 1804124 2017-08-04 14:13:54Z ssteiner $ */
+/* $Id: PipelineFactory.java 1902007 2022-06-17 09:51:56Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.loader.pipeline;
 
@@ -117,7 +117,7 @@ public class PipelineFactory {
         //Choose best pipeline
         if (candidates.length > 0) {
             Arrays.sort(candidates, new PipelineComparator());
-            ImageProviderPipeline pipeline = (ImageProviderPipeline)candidates[0];
+            ImageProviderPipeline pipeline = candidates[0];
             if (pipeline != null && log.isDebugEnabled()) {
                 log.debug("Pipeline: " + pipeline
                         + " with penalty " + pipeline.getConversionPenalty());


=====================================
src/main/java/org/apache/xmlgraphics/image/loader/spi/ImageImplRegistry.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: ImageImplRegistry.java 1804124 2017-08-04 14:13:54Z ssteiner $ */
+/* $Id: ImageImplRegistry.java 1904425 2022-10-06 12:37:37Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.loader.spi;
 
@@ -322,6 +322,7 @@ public class ImageImplRegistry {
     public ImageLoaderFactory[] getImageLoaderFactories(ImageInfo imageInfo, ImageFlavor flavor) {
         String mime = imageInfo.getMimeType();
         Collection matches = new java.util.TreeSet(new ImageLoaderFactoryComparator(flavor));
+        imageInfo.getCustomObjects().put("additionalPenalties", additionalPenalties);
         Map flavorMap = (Map) loaders.get(mime);
         if (flavorMap != null) {
             for (Object i : flavorMap.entrySet()) {


=====================================
src/main/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PSGraphics2D.java 1845492 2018-11-01 15:54:06Z ssteiner $ */
+/* $Id: PSGraphics2D.java 1903802 2022-09-01 09:35:58Z ssteiner $ */
 
 package org.apache.xmlgraphics.java2d.ps;
 
@@ -61,7 +61,7 @@ import org.apache.xmlgraphics.ps.PSImageUtils;
  * therefore of <tt>Graphics2D</tt>) which is able to generate PostScript
  * code.
  *
- * @version $Id: PSGraphics2D.java 1845492 2018-11-01 15:54:06Z ssteiner $
+ * @version $Id: PSGraphics2D.java 1903802 2022-09-01 09:35:58Z ssteiner $
  * @see org.apache.xmlgraphics.java2d.AbstractGraphics2D
  *
  * Originally authored by Keiron Liddle.
@@ -254,6 +254,10 @@ public class PSGraphics2D extends AbstractGraphics2D {
     }
 
     public boolean drawImage(Image img, int x, int y, ImageObserver observer, Color mask) {
+        return drawImage(img, x, y, observer, mask, null);
+    }
+
+    public boolean drawImage(Image img, int x, int y, ImageObserver observer, Color mask, RenderedImage imageMask) {
         preparePainting();
         if (DEBUG) {
             System.out.println("drawImage: " + x + ", " + y + " " + img.getClass().getName());
@@ -285,7 +289,11 @@ public class PSGraphics2D extends AbstractGraphics2D {
             gen.concatMatrix(at);
             Shape imclip = getClip();
             writeClip(imclip);
-            PSImageUtils.renderBitmapImage(buf, x, y, width, height, gen, mask);
+            if (imageMask == null) {
+                PSImageUtils.renderBitmapImage(buf, x, y, width, height, gen, mask, false);
+            } else {
+                PSImageUtils.renderBitmapImage(imageMask, x, y, width, height, gen, mask, true);
+            }
             gen.restoreGraphicsState();
         } catch (IOException ioe) {
             handleIOException(ioe);
@@ -685,7 +693,7 @@ public class PSGraphics2D extends AbstractGraphics2D {
             Shape imclip = getClip();
             writeClip(imclip);
             PSImageUtils.renderBitmapImage(img,
-                0, 0, img.getWidth(), img.getHeight(), gen, null);
+                0, 0, img.getWidth(), img.getHeight(), gen, null, false);
             gen.restoreGraphicsState();
         } catch (IOException ioe) {
             handleIOException(ioe);


=====================================
src/main/java/org/apache/xmlgraphics/ps/FormGenerator.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: FormGenerator.java 750418 2009-03-05 11:03:54Z vhennebert $ */
+/* $Id: FormGenerator.java 1898073 2022-02-14 14:54:16Z ssteiner $ */
 
 package org.apache.xmlgraphics.ps;
 
@@ -129,10 +129,13 @@ public abstract class FormGenerator {
         gen.writeln("    grestore");
         gen.writeln("  } bind");
         gen.writeln(">> def");
-        generateAdditionalDataStream(gen);
-        gen.writeDSCComment(DSCConstants.END_RESOURCE);
         PSResource res = new PSResource(PSResource.TYPE_FORM, formName);
-        gen.getResourceTracker().registerSuppliedResource(res);
+        try {
+            generateAdditionalDataStream(gen);
+        } finally {
+            gen.writeDSCComment(DSCConstants.END_RESOURCE);
+            gen.getResourceTracker().registerSuppliedResource(res);
+        }
         return res;
     }
 }


=====================================
src/main/java/org/apache/xmlgraphics/ps/PSImageUtils.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PSImageUtils.java 1792872 2017-04-27 12:30:09Z ssteiner $ */
+/* $Id: PSImageUtils.java 1903802 2022-09-01 09:35:58Z ssteiner $ */
 
 package org.apache.xmlgraphics.ps;
 
@@ -146,7 +146,7 @@ public class PSImageUtils {
 
     public static void writeImage(ImageEncoder encoder, Dimension imgDim, String imgDescription,
                                   Rectangle2D targetRect, ColorModel colorModel, PSGenerator gen) throws IOException {
-        writeImage(encoder, imgDim, imgDescription, targetRect, colorModel, gen, null);
+        writeImage(encoder, imgDim, imgDescription, targetRect, colorModel, gen, null, false);
     }
 
     /**
@@ -160,7 +160,7 @@ public class PSImageUtils {
      * @throws IOException In case of an I/O exception
      */
     public static void writeImage(ImageEncoder encoder, Dimension imgDim, String imgDescription,
-            Rectangle2D targetRect, ColorModel colorModel, PSGenerator gen, RenderedImage ri)
+            Rectangle2D targetRect, ColorModel colorModel, PSGenerator gen, RenderedImage ri, boolean maskBitmap)
             throws IOException {
 
         gen.saveGraphicsState();
@@ -193,7 +193,7 @@ public class PSImageUtils {
                 imageDict.put("/BitsPerComponent", 8);
             }
         }
-        writeImageCommand(imageDict, colorModel, gen);
+        writeImageCommand(imageDict, colorModel, gen, maskBitmap);
 
         /*
          * the following two lines could be enabled if something still goes wrong
@@ -256,7 +256,7 @@ public class PSImageUtils {
                 imageDict.put("/BitsPerComponent", 8);
             }
         }
-        writeImageCommand(imageDict, colorModel, gen);
+        writeImageCommand(imageDict, colorModel, gen, false);
 
         /*
          * the following two lines could be enabled if something still goes wrong
@@ -411,14 +411,20 @@ public class PSImageUtils {
         Dimension imgDim = new Dimension(img.getWidth(), img.getHeight());
 
         populateImageDictionary(imgDim, cm, imageDict);
-        writeImageCommand(imageDict, cm, gen);
+        writeImageCommand(imageDict, cm, gen, false);
     }
 
-    static void writeImageCommand(PSDictionary imageDict, ColorModel cm, PSGenerator gen)
+    static void writeImageCommand(PSDictionary imageDict, ColorModel cm, PSGenerator gen, boolean maskBitmap)
                 throws IOException {
-        prepareColorSpace(gen, cm);
+        if (!maskBitmap) {
+            prepareColorSpace(gen, cm);
+        }
         gen.write(imageDict.toString());
-        gen.writeln(" image");
+        if (maskBitmap) {
+            gen.writeln(" imagemask");
+        } else {
+            gen.writeln(" image");
+        }
     }
 
     static void writeImageCommand(PSDictionary imageDict,
@@ -463,7 +469,7 @@ public class PSImageUtils {
      * @throws IOException In case of an I/O problem while rendering the image
      */
     public static void renderBitmapImage(RenderedImage img,
-                float x, float y, float w, float h, PSGenerator gen, Color mask)
+                float x, float y, float w, float h, PSGenerator gen, Color mask, boolean maskBitmap)
                     throws IOException {
         Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
         ImageEncoder encoder = ImageEncodingHelper.createRenderedImageEncoder(img);
@@ -473,7 +479,7 @@ public class PSImageUtils {
         ColorModel cm = helper.getEncodedColorModel();
 
         if (mask == null) {
-            writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen, img);
+            writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen, img, maskBitmap);
         } else {
             writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen, img, mask);
         }


=====================================
src/main/java/org/apache/xmlgraphics/xmp/XMPHandler.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: XMPHandler.java 1681108 2015-05-22 13:26:12Z ssteiner $ */
+/* $Id: XMPHandler.java 1902231 2022-06-24 12:44:08Z ssteiner $ */
 
 package org.apache.xmlgraphics.xmp;
 
@@ -287,7 +287,9 @@ public class XMPHandler extends DefaultHandler {
             if (prop.getName() == null) {
                 throw new IllegalStateException("No content in XMP property");
             }
-            assert getCurrentProperties() != null : "no current property";
+            if (getCurrentProperties() == null) {
+                startStructure();
+            }
             getCurrentProperties().setProperty(prop);
         }
 


=====================================
src/test/java/org/apache/xmlgraphics/image/loader/CorruptImagesTestCase.java
=====================================
@@ -15,14 +15,13 @@
  * limitations under the License.
  */
 
-/* $Id: CorruptImagesTestCase.java 1830541 2018-04-30 09:30:55Z ssteiner $ */
+/* $Id: CorruptImagesTestCase.java 1904425 2022-10-06 12:37:37Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.loader;
 
 import org.junit.Test;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
 
 /**
  * Tests for error behaviour with corrupt images.
@@ -38,13 +37,8 @@ public class CorruptImagesTestCase {
         ImageSessionContext sessionContext = imageContext.newSessionContext();
         ImageManager manager = imageContext.getImageManager();
 
-        try {
-            manager.preloadImage(uri, sessionContext);
-            fail("Expected an ImageException!");
-        } catch (Exception ie) {
-            //Expected exception
-            assertNotNull(ie.getMessage());
-        }
+        ImageInfo imageInfo = manager.preloadImage(uri, sessionContext);
+        assertEquals(imageInfo.getMimeType(), "image/png");
     }
 
 }


=====================================
src/test/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNGTestCase.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: ImageLoaderRawPNGTestCase.java 1732019 2016-02-24 05:01:10Z gadams $ */
+/* $Id: ImageLoaderRawPNGTestCase.java 1904425 2022-10-06 12:37:37Z ssteiner $ */
 
 package org.apache.xmlgraphics.image.loader.impl;
 
@@ -48,7 +48,7 @@ public class ImageLoaderRawPNGTestCase {
 
     @Test
     public void testGetUsagePenalty() {
-        assertEquals(1000, ilrpng.getUsagePenalty());
+        assertEquals(0, ilrpng.getUsagePenalty());
     }
 
     @Test


=====================================
src/test/java/org/apache/xmlgraphics/io/URIResolverAdapterTestCase.java
=====================================
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.io.StringWriter;
 import java.net.URI;
 import java.net.URL;
+import java.nio.charset.Charset;
 
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
@@ -66,7 +67,7 @@ public class URIResolverAdapterTestCase {
 
     private void testInputStream(InputStream stream) throws IOException {
         StringWriter writer = new StringWriter();
-        IOUtils.copy(stream, writer);
+        IOUtils.copy(stream, writer, Charset.defaultCharset());
         assertEquals("This is a text file used to test the CatalogResolver\n", writer.toString());
     }
 


=====================================
src/test/java/org/apache/xmlgraphics/io/XmlSourceUtilTestCase.java
=====================================
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringWriter;
+import java.nio.charset.Charset;
 
 import javax.imageio.stream.ImageInputStream;
 import javax.xml.parsers.DocumentBuilder;
@@ -91,7 +92,7 @@ public class XmlSourceUtilTestCase {
         domSource = new DOMSource(db.newDocument().createElement("test"));
         InputStream inStream = XmlSourceUtil.getInputStream(domSource);
         writer = new StringWriter();
-        IOUtils.copy(inStream, writer);
+        IOUtils.copy(inStream, writer, Charset.defaultCharset());
     }
 
     @Test
@@ -145,7 +146,7 @@ public class XmlSourceUtilTestCase {
     public void testNeedInputStreamFailureCaseDOMSource() throws IOException {
         InputStream inStream = needInputStream(new DOMSource());
         StringWriter writer = new StringWriter();
-        IOUtils.copy(inStream, writer);
+        IOUtils.copy(inStream, writer, Charset.defaultCharset());
         assertEquals("", writer.toString());
     }
 


=====================================
src/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PSGraphics2DTestCase.java 1845492 2018-11-01 15:54:06Z ssteiner $ */
+/* $Id: PSGraphics2DTestCase.java 1903802 2022-09-01 09:35:58Z ssteiner $ */
 
 package org.apache.xmlgraphics.java2d.ps;
 
@@ -176,4 +176,15 @@ public class PSGraphics2DTestCase {
         p.fill(new Rectangle());
         assertTrue(out.toString().contains("\nN\n"));
     }
+
+    @Test
+    public void testMask() {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        PSGenerator generator = new PSGenerator(out);
+        PSGraphics2D graphics = new PSGraphics2D(false, generator);
+        graphics.setGraphicContext(new GraphicContext());
+        BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
+        graphics.drawImage(image, 0, 0, null, null, image);
+        assertTrue(out.toString().contains("imagemask"));
+    }
 }


=====================================
src/test/java/org/apache/xmlgraphics/xmp/XMPParserTestCase.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: XMPParserTestCase.java 1878394 2020-06-02 13:18:41Z ssteiner $ */
+/* $Id: XMPParserTestCase.java 1902231 2022-06-24 12:44:08Z ssteiner $ */
 
 package org.apache.xmlgraphics.xmp;
 
@@ -30,6 +30,9 @@ import javax.xml.transform.stream.StreamSource;
 
 import org.junit.Test;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -194,6 +197,30 @@ public class XMPParserTestCase {
         assertNull(title); //Empty value treated same as not existant
     }
 
+    @Test
+    public void testSubproperty() throws Exception {
+        URL url = getClass().getResource("test-subproperty.xmp");
+        Metadata meta = XMPParser.parseXMP(url);
+        final StringBuilder sb = new StringBuilder();
+        meta.toSAX(new DefaultHandler() {
+            public void startElement(String uri, String localName, String qName, Attributes attributes) {
+                sb.append(qName).append("\n");
+            }
+        });
+        assertEquals("x:xmpmeta\n"
+                + "rdf:RDF\n"
+                + "rdf:Description\n"
+                + "pdfaExtension:schemas\n"
+                + "rdf:Bag\n"
+                + "rdf:li\n"
+                + "rdf:Description\n"
+                + "pdfaSchema:property\n"
+                + "rdf:Seq\n"
+                + "rdf:li\n"
+                + "rdf:Description\n"
+                + "pdfaProperty:name\n", sb.toString());
+    }
+
     @Test
     public void testExternalDTD() {
         String payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -206,6 +233,6 @@ public class XMPParserTestCase {
         } catch (TransformerException e) {
             msg = e.getMessage();
         }
-        assertTrue(msg, msg.contains("access is not allowed"));
+        assertTrue(msg, msg.contains("accessExternalDTD"));
     }
 }


=====================================
src/test/java/org/apache/xmlgraphics/xmp/test-subproperty.xmp
=====================================
@@ -0,0 +1,21 @@
+<x:xmpmeta xmlns:x="adobe:ns:meta/">
+    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+        <rdf:Description xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"
+                         xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#"
+                         xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#" rdf:about="">
+            <pdfaExtension:schemas>
+                <rdf:Bag>
+                    <rdf:li rdf:parseType="Resource">
+                        <pdfaSchema:property>
+                            <rdf:Seq>
+                                <rdf:li rdf:parseType="Resource">
+                                    <pdfaProperty:name>DocumentFileName</pdfaProperty:name>
+                                </rdf:li>
+                            </rdf:Seq>
+                        </pdfaSchema:property>
+                    </rdf:li>
+                </rdf:Bag>
+            </pdfaExtension:schemas>
+        </rdf:Description>
+    </rdf:RDF>
+</x:xmpmeta>
\ No newline at end of file


=====================================
xmlgraphics-commons-pom-template.pom
=====================================
@@ -70,7 +70,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
-      <version>1.3.1</version>
+      <version>2.11.0</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>



View it on GitLab: https://salsa.debian.org/java-team/xmlgraphics-commons/-/commit/c4487dc7f624357631dfb05148344cc1c3928dbc

-- 
View it on GitLab: https://salsa.debian.org/java-team/xmlgraphics-commons/-/commit/c4487dc7f624357631dfb05148344cc1c3928dbc
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20230104/e634f384/attachment.htm>


More information about the pkg-java-commits mailing list