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 93ca5ed0e..3652b89b1 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 d8d9cd3b6..5dac2181e 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 cf535b565..a58fb603a 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