Browse Source

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
tags/REL_3_14_BETA1
Andreas Beeker 8 years ago
parent
commit
7d4b30cd72

+ 3
- 0
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java 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();

+ 4
- 2
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java View 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);

+ 19
- 0
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java 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();
}
}

Loading…
Cancel
Save