]> source.dussan.org Git - poi.git/commitdiff
XSLF: tables can now be removed from sheets/groups
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 29 Nov 2015 16:17:29 +0000 (16:17 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 29 Nov 2015 16:17:29 +0000 (16:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1717087 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java

index 93ca5ed0e6775aeda8b2892853f716b587f4fa12..3652b89b175aa974e9f60f9fc2dc89a401b9a2aa 100644 (file)
@@ -41,6 +41,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;\r
+import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;\r
@@ -174,6 +175,8 @@ implements XSLFShapeContainer, GroupShape<XSLFShape,XSLFTextParagraph> {
             grpSp.getGrpSpList().remove(obj);\r
         } else if (obj instanceof CTConnector){\r
             grpSp.getCxnSpList().remove(obj);\r
+        } else if (obj instanceof CTGraphicalObjectFrame) {\r
+            grpSp.getGraphicFrameList().remove(obj);\r
         } else if (obj instanceof CTPicture) {\r
             XSLFPictureShape ps = (XSLFPictureShape)xShape;\r
             XSLFSheet sh = getSheet();\r
index d8d9cd3b601999ae442525f9ba6561d5edb11b3a..5dac2181e97af784bbabffb6cd1e205fb533f497 100644 (file)
@@ -278,10 +278,12 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
         CTGroupShape spTree = getSpTree();
         if(obj instanceof CTShape){
             spTree.getSpList().remove(obj);
-        } else if (obj instanceof CTGroupShape){
+        } else if (obj instanceof CTGroupShape) {
             spTree.getGrpSpList().remove(obj);
-        } else if (obj instanceof CTConnector){
+        } else if (obj instanceof CTConnector) {
             spTree.getCxnSpList().remove(obj);
+        } else if (obj instanceof CTGraphicalObjectFrame) {
+            spTree.getGraphicFrameList().remove(obj);
         } else if (obj instanceof CTPicture) {
             XSLFPictureShape ps = (XSLFPictureShape)xShape;
             removePictureRelation(ps);
index cf535b5650f417412d011a0fb52c543e7d6946a2..a58fb603a4db666656d897af29d3238ca91fca0a 100644 (file)
@@ -17,6 +17,7 @@
 package org.apache.poi.xslf.usermodel;\r
 \r
 import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
 import static org.junit.Assert.assertNotNull;\r
 import static org.junit.Assert.assertNull;\r
 import static org.junit.Assert.assertSame;\r
@@ -146,4 +147,22 @@ public class TestXSLFTable {
         \r
         ppt.close();\r
     }\r
+    \r
+    @Test\r
+    public void removeTable() throws IOException {\r
+        XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("shapes.pptx");\r
+        XSLFSlide sl = ss.getSlides().get(0);\r
+        XSLFTable tab = (XSLFTable)sl.getShapes().get(4);\r
+        sl.removeShape(tab);\r
+        \r
+        XMLSlideShow ss2 = XSLFTestDataSamples.writeOutAndReadBack(ss);\r
+        ss.close();\r
+        \r
+        sl = ss2.getSlides().get(0);\r
+        for (XSLFShape s : sl.getShapes()) {\r
+            assertFalse(s instanceof XSLFTable);\r
+        }\r
+        \r
+        ss2.close();\r
+    }\r
 }
\ No newline at end of file