]> source.dussan.org Git - poi.git/commitdiff
fix exception when calling importContent, see Bugzilla 54407
authorYegor Kozlov <yegor@apache.org>
Mon, 21 Jan 2013 20:46:32 +0000 (20:46 +0000)
committerYegor Kozlov <yegor@apache.org>
Mon, 21 Jan 2013 20:46:32 +0000 (20:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1436608 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java

index d51e1c0d26cced5156cbbec1083bc458225b703b..2122e62d2677c762fbd0a1e8dc66fa9aa84ab149 100644 (file)
@@ -92,13 +92,18 @@ public final class XSLFPictureData extends POIXMLDocumentPart {
      */
     public static final int PICTURE_TYPE_WPG = 12;
 
+    /**
+     * Microsoft Windows Media Photo image (.wdp)
+     */
+    public static final int PICTURE_TYPE_WDP = 13;
+
     /**
      * Relationships for each known picture type
      */
     protected static final POIXMLRelation[] RELATIONS;
 
     static {
-        RELATIONS = new POIXMLRelation[13];
+        RELATIONS = new POIXMLRelation[14];
         RELATIONS[PICTURE_TYPE_EMF] = XSLFRelation.IMAGE_EMF;
         RELATIONS[PICTURE_TYPE_WMF] = XSLFRelation.IMAGE_WMF;
         RELATIONS[PICTURE_TYPE_PICT] = XSLFRelation.IMAGE_PICT;
@@ -110,6 +115,7 @@ public final class XSLFPictureData extends POIXMLDocumentPart {
         RELATIONS[PICTURE_TYPE_EPS] = XSLFRelation.IMAGE_EPS;
         RELATIONS[PICTURE_TYPE_BMP] = XSLFRelation.IMAGE_BMP;
         RELATIONS[PICTURE_TYPE_WPG] = XSLFRelation.IMAGE_WPG;
+        RELATIONS[PICTURE_TYPE_WDP] = XSLFRelation.IMAGE_WDP;
     }
 
     private Long checksum = null;
index 035e15e438546d1823113b7b2a60730f1a345e6d..872f82f83f3178b17baa1e3bf6cac3fd22d40445 100644 (file)
@@ -23,17 +23,15 @@ import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;\r
 import org.apache.poi.openxml4j.opc.PackageRelationship;\r
 import org.apache.poi.util.Beta;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;\r
+import org.apache.xmlbeans.XmlCursor;\r
+import org.apache.xmlbeans.XmlObject;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;\r
 \r
 import javax.imageio.ImageIO;\r
+import javax.xml.namespace.QName;\r
 import java.awt.Graphics2D;\r
 import java.awt.geom.Rectangle2D;\r
 import java.awt.image.BufferedImage;\r
@@ -153,6 +151,21 @@ public class XSLFPictureShape extends XSLFSimpleShape {
             // discard any custom tags associated with the picture being copied\r
             nvPr.unsetCustDataLst();\r
         }\r
+        if(blip.isSetExtLst()) {\r
+\r
+            CTOfficeArtExtensionList extLst = blip.getExtLst();\r
+            for(CTOfficeArtExtension ext : extLst.getExtList()){\r
+                String xpath = "declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' $this//a14:imgProps/a14:imgLayer";\r
+                XmlObject[] obj = ext.selectPath(xpath);\r
+                if(obj != null && obj.length == 1){\r
+                    XmlCursor c = obj[0].newCursor();\r
+                    String id = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"));//selectPath("declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' $this//[@embed]");\r
+                    String newId = getSheet().importBlip(id, p.getSheet().getPackagePart());\r
+                    c.setAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"), newId);\r
+                    c.dispose();\r
+                }\r
+            }\r
+        }\r
 \r
     }\r
 }\r
index 1ec3ac2d8a3f8ad2e171c71760f0943922333e64..046e71e6a57a46b127ff37dcf499c036d1c81caf 100644 (file)
@@ -213,6 +213,12 @@ public class XSLFRelation extends POIXMLRelation {
             "/ppt/media/image#.wpg",
             XSLFPictureData.class
     );
+    public static final XSLFRelation IMAGE_WDP = new XSLFRelation(
+            "image/vnd.ms-photo",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/ppt/media/image#.wdp",
+            XSLFPictureData.class
+    );
 
     public static final XSLFRelation IMAGES = new XSLFRelation(
             null,