]> source.dussan.org Git - poi.git/commitdiff
[bug-65650] use image/x-pict mime type
authorPJ Fanning <fanningpj@apache.org>
Sat, 23 Oct 2021 10:49:18 +0000 (10:49 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 23 Oct 2021 10:49:18 +0000 (10:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894507 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ContentTypes.java
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
poi-ooxml/src/test/java/org/apache/poi/openxml4j/opc/TestRelationships.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/PictureType.java
poi/src/main/java/org/apache/poi/common/usermodel/PictureType.java
poi/src/main/java/org/apache/poi/sl/usermodel/PictureData.java

index 1b90361d8ca41e4ef661a9e741879833aafe48d7..bda08f64454f353bd354fe94b0a6179b77ad218d 100644 (file)
@@ -97,7 +97,7 @@ public final class ContentTypes {
      * @see <a href="http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html">
      * http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html</a>
      */
-    public static final String IMAGE_PICT = "image/pict";
+    public static final String IMAGE_PICT = "image/x-pict";
 
     public static final String EXTENSION_PICT = "pict";
 
index a3989aa7e2d0b7b171d5415e3f4b4280cc621a4a..7c08964bd245c8a87fb92ed439e76cd5a6f6336a 100644 (file)
@@ -23,8 +23,11 @@ import java.util.Map;
 import org.apache.poi.ooxml.POIXMLDocument;
 import org.apache.poi.ooxml.POIXMLRelation;
 import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
+import org.apache.poi.sl.usermodel.PictureData;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
+import static org.apache.poi.openxml4j.opc.PackageRelationshipTypes.IMAGE_PART;
+
 public final class XWPFRelation extends POIXMLRelation {
 
     /**
@@ -155,76 +158,76 @@ public final class XWPFRelation extends POIXMLRelation {
      * Supported image formats
      */
     public static final XWPFRelation IMAGE_EMF = new XWPFRelation(
-        "image/x-emf",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.emf",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.EMF.contentType,
+            IMAGE_PART,
+            "/word/media/image#.emf",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_WMF = new XWPFRelation(
-        "image/x-wmf",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.wmf",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.WMF.contentType,
+            IMAGE_PART,
+            "/word/media/image#.wmf",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_PICT = new XWPFRelation(
-        "image/pict",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.pict",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.PICT.contentType,
+            IMAGE_PART,
+            "/word/media/image#.pict",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_JPEG = new XWPFRelation(
-        "image/jpeg",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.jpeg",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.JPEG.contentType,
+            IMAGE_PART,
+            "/word/media/image#.jpeg",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_PNG = new XWPFRelation(
-        "image/png",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.png",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.PNG.contentType,
+            IMAGE_PART,
+            "/word/media/image#.png",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_DIB = new XWPFRelation(
-        "image/dib",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.dib",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.DIB.contentType,
+            IMAGE_PART,
+            "/word/media/image#.dib",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_GIF = new XWPFRelation(
-        "image/gif",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.gif",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.GIF.contentType,
+            IMAGE_PART,
+            "/word/media/image#.gif",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_TIFF = new XWPFRelation(
-        "image/tiff",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.tiff",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.TIFF.contentType,
+            IMAGE_PART,
+            "/word/media/image#.tiff",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_EPS = new XWPFRelation(
-        "image/x-eps",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.eps",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.EPS.contentType,
+            IMAGE_PART,
+            "/word/media/image#.eps",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_BMP = new XWPFRelation(
-        "image/x-ms-bmp",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.bmp",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.BMP.contentType,
+            IMAGE_PART,
+            "/word/media/image#.bmp",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGE_WPG = new XWPFRelation(
-        "image/x-wpg",
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        "/word/media/image#.wpg",
-        XWPFPictureData::new, XWPFPictureData::new
+            PictureData.PictureType.WPG.contentType,
+            IMAGE_PART,
+            "/word/media/image#.wpg",
+            XWPFPictureData::new, XWPFPictureData::new
     );
     public static final XWPFRelation IMAGES = new XWPFRelation(
-        null,
-        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-        null,
-        XWPFPictureData::new, XWPFPictureData::new
+            null,
+            IMAGE_PART,
+            null,
+            XWPFPictureData::new, XWPFPictureData::new
     );
 
     private XWPFRelation(String type, String rel, String defaultName) {
index ec82a36dd4702e008d60617e609a681f34e3b0f0..7fd655d4a1bd39db21896b27a6582ce683ab0fee 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.openxml4j.opc;
 
 import static org.apache.poi.openxml4j.OpenXML4JTestDataSamples.openSampleStream;
+import static org.apache.poi.openxml4j.opc.PackageRelationshipTypes.IMAGE_PART;
 import static org.apache.poi.openxml4j.opc.TestContentType.isOldXercesActive;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -316,7 +317,7 @@ class TestRelationships {
         assertEquals(6, drawingRels.size());
 
         // expected one image
-        assertEquals(1, drawingPart.getRelationshipsByType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image").size());
+        assertEquals(1, drawingPart.getRelationshipsByType(IMAGE_PART).size());
         // and three hyperlinks
         assertEquals(5, drawingPart.getRelationshipsByType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink").size());
 
index e1d5753f7db75f723a95cd1d5953d25c06c8cd30..88e7088bf04ab535acd1841279684792271f0448 100644 (file)
@@ -29,7 +29,7 @@ public enum PictureType
 
     JPEG( "image/jpeg", "jpg", new byte[][] { { (byte) 0xFF, (byte) 0xD8 } } ),
 
-    PICT( "image/pict", ".pict", new byte[0][] ),
+    PICT( "image/x-pict", ".pict", new byte[0][] ),
 
     PNG( "image/png", "png", new byte[][] { { (byte) 0x89, 0x50, 0x4E, 0x47,
             0x0D, 0x0A, 0x1A, 0x0A } } ),
index d3ed67fc2e47d2e91e2672591d5b136e60709379..2a5c6625fb64e1c29c8f426fb5f4446ff9717e32 100644 (file)
@@ -30,7 +30,7 @@ public enum PictureType {
     /** Windows Meta File */
     WMF("image/x-wmf",".wmf"),
     /** Mac PICT format */
-    PICT("image/pict",".pict"), // or image/x-pict (for HSLF) ???
+    PICT("image/x-pict",".pict"),
     /** JPEG format */
     JPEG("image/jpeg",".jpg"),
     /** PNG format */
index 5ade4d33f17dd73e06cf95c6647e5adb981692de..c6afb2ec4bbc4cf87a0b25ba1b00b3777c8068f7 100644 (file)
@@ -28,7 +28,7 @@ public interface PictureData {
         /** Windows Meta File */
         WMF(3,3,"image/x-wmf",".wmf"),
         /** Mac PICT format */
-        PICT(4,4,"image/pict",".pict"), // or image/x-pict (for HSLF) ???
+        PICT(4,4,"image/x-pict",".pict"),
         /** JPEG format */
         JPEG(5,5,"image/jpeg",".jpg"),
         /** PNG format */
@@ -60,7 +60,7 @@ public interface PictureData {
         ;
         
         public final int nativeId, ooxmlId;
-        public final String contentType,extension;
+        public final String contentType, extension;
 
         PictureType(int nativeId, int ooxmlId,String contentType,String extension) {
             this.nativeId = nativeId;