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
This commit is contained in:
Andreas Beeker 2015-11-29 16:17:29 +00:00
parent d729c3208a
commit 7d4b30cd72
3 changed files with 26 additions and 2 deletions

View File

@ -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<XSLFShape,XSLFTextParagraph> {
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();

View File

@ -282,6 +282,8 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
spTree.getGrpSpList().remove(obj);
} 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);

View File

@ -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();
}
}