mirror of https://github.com/apache/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
This commit is contained in:
parent
d729c3208a
commit
7d4b30cd72
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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…
Reference in New Issue