]> source.dussan.org Git - poi.git/commitdiff
fixed importing pictures having associated custom tags, see Bugzilla 52687
authorYegor Kozlov <yegor@apache.org>
Tue, 21 Feb 2012 12:13:39 +0000 (12:13 +0000)
committerYegor Kozlov <yegor@apache.org>
Tue, 21 Feb 2012 12:13:39 +0000 (12:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1291730 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java

index edfd430e92e211bd0495d7fe3fba4dda41a4fd4b..85064486b635424e31bb5efdc161f80f8480b016 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta6" date="2012-??-??">
+           <action dev="poi-developers" type="fix">52687 - fixed merging slides with pictures with associated custom tags</action>
            <action dev="poi-developers" type="add"> allow runtime registration of functions in FormulaEvaluator</action>
            <action dev="poi-developers" type="fix">52665 - When reading from a ZipFileZipEntrySource that has already been closed, give IllegalArgumentException rather than NPE</action>
            <action dev="poi-developers" type="fix">52664 - MAPIMessage may not always have name chunks when checking for 7 bit encodings</action>
index 8ad48364ce2b4dc936957b8c401026e7bb261ff8..035e15e438546d1823113b7b2a60730f1a345e6d 100644 (file)
@@ -29,6 +29,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 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.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
@@ -147,5 +148,11 @@ public class XSLFPictureShape extends XSLFSimpleShape {
         CTBlip blip = ct.getBlipFill().getBlip();\r
         blip.setEmbed(relId);\r
 \r
+        CTApplicationNonVisualDrawingProps nvPr = ct.getNvPicPr().getNvPr();\r
+        if(nvPr.isSetCustDataLst()) {\r
+            // discard any custom tags associated with the picture being copied\r
+            nvPr.unsetCustDataLst();\r
+        }\r
+\r
     }\r
 }\r
index bf56481f5984db374824e7455ad2ed1341d0ba28..efdccb65a3d89baa1cf58d33e01cbcfc2d238a66 100644 (file)
@@ -18,6 +18,7 @@ package org.apache.poi.xslf.usermodel;
 \r
 import junit.framework.TestCase;\r
 import org.apache.poi.xslf.XSLFTestDataSamples;\r
+import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;\r
 \r
 import java.io.IOException;\r
 import java.util.Arrays;\r
@@ -130,4 +131,26 @@ public class TestXSLFPictureShape extends TestCase {
         XSLFSlide slide2 = ppt.createSlide();\r
 \r
     }\r
+\r
+    public void testMerge() {\r
+        XMLSlideShow ppt1 = new XMLSlideShow();\r
+        byte[] data1 = new byte[100];\r
+        int idx1 = ppt1.addPicture(data1, XSLFPictureData.PICTURE_TYPE_JPEG);\r
+\r
+        XSLFSlide slide1 = ppt1.createSlide();\r
+        XSLFPictureShape shape1 = slide1.createPicture(idx1);\r
+        CTPicture ctPic1 = (CTPicture)shape1.getXmlObject();\r
+        ctPic1.getNvPicPr().getNvPr().addNewCustDataLst().addNewTags().setId("rId99");\r
+\r
+        XMLSlideShow ppt2 = new XMLSlideShow();\r
+\r
+        XSLFSlide slide2 = ppt2.createSlide().importContent(slide1);\r
+        XSLFPictureShape shape2 = (XSLFPictureShape)slide2.getShapes()[0];\r
+\r
+        assertTrue(Arrays.equals(data1, shape2.getPictureData().getData()));\r
+\r
+        CTPicture ctPic2 = (CTPicture)shape2.getXmlObject();\r
+        assertFalse(ctPic2.getNvPicPr().getNvPr().isSetCustDataLst());\r
+\r
+    }\r
 }
\ No newline at end of file