poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1436608 - in /poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel: XSLFPictureData.java XSLFPictureShape.java XSLFRelation.java
Date Mon, 21 Jan 2013 20:46:32 GMT
Author: yegor
Date: Mon Jan 21 20:46:32 2013
New Revision: 1436608

URL: http://svn.apache.org/viewvc?rev=1436608&view=rev
Log:
fix exception when calling importContent, see Bugzilla 54407

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

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java?rev=1436608&r1=1436607&r2=1436608&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java Mon Jan 21
20:46:32 2013
@@ -93,12 +93,17 @@ public final class XSLFPictureData exten
     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 exten
         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;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java?rev=1436608&r1=1436607&r2=1436608&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java Mon Jan 21
20:46:32 2013
@@ -23,17 +23,15 @@ import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
 
 import javax.imageio.ImageIO;
+import javax.xml.namespace.QName;
 import java.awt.Graphics2D;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
@@ -153,6 +151,21 @@ public class XSLFPictureShape extends XS
             // discard any custom tags associated with the picture being copied
             nvPr.unsetCustDataLst();
         }
+        if(blip.isSetExtLst()) {
+
+            CTOfficeArtExtensionList extLst = blip.getExtLst();
+            for(CTOfficeArtExtension ext : extLst.getExtList()){
+                String xpath = "declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main'
$this//a14:imgProps/a14:imgLayer";
+                XmlObject[] obj = ext.selectPath(xpath);
+                if(obj != null && obj.length == 1){
+                    XmlCursor c = obj[0].newCursor();
+                    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]");
+                    String newId = getSheet().importBlip(id, p.getSheet().getPackagePart());
+                    c.setAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships",
"embed"), newId);
+                    c.dispose();
+                }
+            }
+        }
 
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java?rev=1436608&r1=1436607&r2=1436608&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java Mon Jan 21 20:46:32
2013
@@ -213,6 +213,12 @@ public class XSLFRelation extends POIXML
             "/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,



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message