From: Andreas Beeker Date: Sun, 29 Nov 2015 16:17:29 +0000 (+0000) Subject: XSLF: tables can now be removed from sheets/groups X-Git-Tag: REL_3_14_BETA1~47 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7d4b30cd72fefcc29709aa93b7c5c48c2d6b396a;p=poi.git XSLF: tables can now be removed from sheets/groups git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1717087 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java index 93ca5ed0e6..3652b89b17 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java @@ -41,6 +41,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D; import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector; +import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame; import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape; import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual; import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture; @@ -174,6 +175,8 @@ implements XSLFShapeContainer, GroupShape { grpSp.getGrpSpList().remove(obj); } else if (obj instanceof CTConnector){ grpSp.getCxnSpList().remove(obj); + } else if (obj instanceof CTGraphicalObjectFrame) { + grpSp.getGraphicFrameList().remove(obj); } else if (obj instanceof CTPicture) { XSLFPictureShape ps = (XSLFPictureShape)xShape; XSLFSheet sh = getSheet(); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java index d8d9cd3b60..5dac2181e9 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java @@ -278,10 +278,12 @@ implements XSLFShapeContainer, Sheet { 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); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java index cf535b5650..a58fb603a4 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java @@ -17,6 +17,7 @@ package org.apache.poi.xslf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -146,4 +147,22 @@ public class TestXSLFTable { ppt.close(); } + + @Test + public void removeTable() throws IOException { + XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("shapes.pptx"); + XSLFSlide sl = ss.getSlides().get(0); + XSLFTable tab = (XSLFTable)sl.getShapes().get(4); + sl.removeShape(tab); + + XMLSlideShow ss2 = XSLFTestDataSamples.writeOutAndReadBack(ss); + ss.close(); + + sl = ss2.getSlides().get(0); + for (XSLFShape s : sl.getShapes()) { + assertFalse(s instanceof XSLFTable); + } + + ss2.close(); + } } \ No newline at end of file