You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/11/29 01:51:05 UTC
svn commit: r1717018 - in /poi: site/src/documentation/content/xdocs/
trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/
trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/
Author: kiwiwings
Date: Sun Nov 29 00:51:04 2015
New Revision: 1717018
URL: http://svn.apache.org/viewvc?rev=1717018&view=rev
Log:
#58663 - Pictures cannot be removed from a slide
Modified:
poi/site/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java
Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1717018&r1=1717017&r2=1717018&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Sun Nov 29 00:51:04 2015
@@ -40,6 +40,7 @@
</devs>
<release version="3.14-beta1" date="2015-11-??">
+ <action dev="PD" type="fix" fixes-bug="58663">Pictures cannot be removed from a slide</action>
<action dev="PD" type="add" fixes-bug="58636">Replace ClientAnchor anchor type constants with AnchorType enum</action>
<action dev="PD" type="add" fixes-bug="58644">Replace Sheet.setZoom(num, den) with Sheet.setZoom(scale)</action>
<action dev="PD" type="add" fixes-bug="58642">Remove deprecated functions</action>
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java?rev=1717018&r1=1717017&r2=1717018&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java Sun Nov 29 00:51:04 2015
@@ -43,6 +43,7 @@ import org.openxmlformats.schemas.drawin
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
/**
@@ -173,6 +174,13 @@ implements XSLFShapeContainer, GroupShap
grpSp.getGrpSpList().remove(obj);
} else if (obj instanceof CTConnector){
grpSp.getCxnSpList().remove(obj);
+ } else if (obj instanceof CTPicture) {
+ XSLFPictureShape ps = (XSLFPictureShape)xShape;
+ XSLFSheet sh = getSheet();
+ if (sh != null) {
+ sh.removePictureRelation(ps);
+ }
+ grpSp.getPicList().remove(obj);
} else {
throw new IllegalArgumentException("Unsupported shape: " + xShape);
}
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=1717018&r1=1717017&r2=1717018&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 Sun Nov 29 00:51:04 2015
@@ -144,16 +144,18 @@ public class XSLFPictureShape extends XS
return null;
}
- private CTBlip getBlip(){
+ protected CTBlip getBlip(){
CTPicture ct = (CTPicture)getXmlObject();
return ct.getBlipFill().getBlip();
}
- private String getBlipLink(){
+
+ protected String getBlipLink(){
String link = getBlip().getLink();
if (link.isEmpty()) return null;
return link;
}
- private String getBlipId(){
+
+ protected String getBlipId(){
String id = getBlip().getEmbed();
if (id.isEmpty()) return null;
return id;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1717018&r1=1717017&r2=1717018&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Sun Nov 29 00:51:04 2015
@@ -49,7 +49,6 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
@@ -283,6 +282,10 @@ implements XSLFShapeContainer, Sheet<XSL
spTree.getGrpSpList().remove(obj);
} else if (obj instanceof CTConnector){
spTree.getCxnSpList().remove(obj);
+ } else if (obj instanceof CTPicture) {
+ XSLFPictureShape ps = (XSLFPictureShape)xShape;
+ removePictureRelation(ps);
+ spTree.getPicList().remove(obj);
} else {
throw new IllegalArgumentException("Unsupported shape: " + xShape);
}
@@ -586,4 +589,14 @@ implements XSLFShapeContainer, Sheet<XSL
}
return part;
}
+
+ /**
+ * Helper method for sheet and group shapes
+ *
+ * @param pictureShape the picture shapes whose relation is to be removed
+ */
+ void removePictureRelation(XSLFPictureShape pictureShape) {
+ POIXMLDocumentPart pd = getRelationById(pictureShape.getBlipId());
+ removeRelation(pd);
+ }
}
\ No newline at end of file
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java?rev=1717018&r1=1717017&r2=1717018&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java Sun Nov 29 00:51:04 2015
@@ -20,20 +20,24 @@ import static org.junit.Assert.assertArr
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.poi.xslf.XSLFTestDataSamples;
+import org.apache.poi.POIDataSamples;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
+import org.apache.poi.xslf.XSLFTestDataSamples;
import org.junit.Test;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
-/**
- * @author Yegor Kozlov
- */
public class TestXSLFPictureShape {
+ private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
@Test
public void testCreate() throws Exception {
@@ -170,4 +174,23 @@ public class TestXSLFPictureShape {
ppt1.close();
ppt2.close();
}
+
+ @Test
+ public void bug58663() throws IOException {
+ InputStream is = _slTests.openResourceAsStream("shapes.pptx");
+ XMLSlideShow ppt = new XMLSlideShow(is);
+ is.close();
+
+ XSLFSlide slide = ppt.getSlides().get(0);
+ XSLFPictureShape ps = (XSLFPictureShape)slide.getShapes().get(3);
+ slide.removeShape(ps);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ppt.write(bos);
+ ppt.close();
+
+ XMLSlideShow ppt2 = new XMLSlideShow(new ByteArrayInputStream(bos.toByteArray()));
+ assertTrue(ppt2.getPictureData().isEmpty());
+ ppt2.close();
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org