use of org.openxmlformats.schemas.presentationml.x2006.main.CTShape in project poi by apache.
the class XSLFCommonSlideData method processShape.
private void processShape(CTGroupShape gs, List<DrawingTextBody> out) {
for (CTShape shape : gs.getSpArray()) {
CTTextBody ctTextBody = shape.getTxBody();
if (ctTextBody == null) {
continue;
}
DrawingTextBody textBody;
CTApplicationNonVisualDrawingProps nvpr = shape.getNvSpPr().getNvPr();
if (nvpr.isSetPh()) {
textBody = new DrawingTextPlaceholder(ctTextBody, nvpr.getPh());
} else {
textBody = new DrawingTextBody(ctTextBody);
}
out.add(textBody);
}
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTShape in project poi by apache.
the class XSLFSheet method removeShape.
/**
* Removes the specified shape from this sheet, if it is present
* (optional operation). If this sheet does not contain the element,
* it is unchanged.
*
* @param xShape shape to be removed from this sheet, if present
* @return <tt>true</tt> if this sheet contained the specified element
* @throws IllegalArgumentException if the type of the specified shape
* is incompatible with this sheet (optional)
*/
public boolean removeShape(XSLFShape xShape) {
XmlObject obj = xShape.getXmlObject();
CTGroupShape spTree = getSpTree();
if (obj instanceof CTShape) {
spTree.getSpList().remove(obj);
} else if (obj instanceof CTGroupShape) {
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);
spTree.getPicList().remove(obj);
} else {
throw new IllegalArgumentException("Unsupported shape: " + xShape);
}
return getShapes().remove(xShape);
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTShape in project poi by apache.
the class XSLFSheet method buildShapes.
protected static List<XSLFShape> buildShapes(CTGroupShape spTree, XSLFSheet sheet) {
List<XSLFShape> shapes = new ArrayList<XSLFShape>();
for (XmlObject ch : spTree.selectPath("*")) {
if (ch instanceof CTShape) {
// simple shape
XSLFAutoShape shape = XSLFAutoShape.create((CTShape) ch, sheet);
shapes.add(shape);
} else if (ch instanceof CTGroupShape) {
shapes.add(new XSLFGroupShape((CTGroupShape) ch, sheet));
} else if (ch instanceof CTConnector) {
shapes.add(new XSLFConnectorShape((CTConnector) ch, sheet));
} else if (ch instanceof CTPicture) {
shapes.add(new XSLFPictureShape((CTPicture) ch, sheet));
} else if (ch instanceof CTGraphicalObjectFrame) {
XSLFGraphicFrame shape = XSLFGraphicFrame.create((CTGraphicalObjectFrame) ch, sheet);
shapes.add(shape);
}
}
return shapes;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTShape in project poi by apache.
the class TestXSLFBugs method bug60662.
@Test
public void bug60662() throws IOException {
XMLSlideShow src = new XMLSlideShow();
XSLFSlide sl = src.createSlide();
XSLFGroupShape gs = sl.createGroup();
gs.setAnchor(new Rectangle2D.Double(100, 100, 100, 100));
gs.setInteriorAnchor(new Rectangle2D.Double(0, 0, 100, 100));
XSLFAutoShape as = gs.createAutoShape();
as.setAnchor(new Rectangle2D.Double(0, 0, 100, 100));
as.setShapeType(ShapeType.STAR_24);
as.setFillColor(Color.YELLOW);
CTShape csh = (CTShape) as.getXmlObject();
CTOuterShadowEffect shadow = csh.getSpPr().addNewEffectLst().addNewOuterShdw();
shadow.setDir(270000);
shadow.setDist(100000);
shadow.addNewSrgbClr().setVal(new byte[] { 0x00, (byte) 0xFF, 0x00 });
XMLSlideShow dst = new XMLSlideShow();
XSLFSlide sl2 = dst.createSlide();
sl2.importContent(sl);
XSLFGroupShape gs2 = (XSLFGroupShape) sl2.getShapes().get(0);
XSLFAutoShape as2 = (XSLFAutoShape) gs2.getShapes().get(0);
CTShape csh2 = (CTShape) as2.getXmlObject();
assertTrue(csh2.getSpPr().isSetEffectLst());
dst.close();
src.close();
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTShape in project poi by apache.
the class XSLFDrawing method createFreeform.
public XSLFFreeformShape createFreeform() {
CTShape sp = _spTree.addNewSp();
sp.set(XSLFFreeformShape.prototype(_shapeId++));
XSLFFreeformShape shape = new XSLFFreeformShape(sp, _sheet);
shape.setAnchor(new Rectangle2D.Double());
return shape;
}
Aggregations