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 XSLFTextBox method prototype.
/**
*
* @param shapeId 1-based shapeId
*/
static CTShape prototype(int shapeId) {
CTShape ct = CTShape.Factory.newInstance();
CTShapeNonVisual nvSpPr = ct.addNewNvSpPr();
CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr();
cnv.setName("TextBox " + shapeId);
cnv.setId(shapeId + 1);
nvSpPr.addNewCNvSpPr().setTxBox(true);
nvSpPr.addNewNvPr();
CTShapeProperties spPr = ct.addNewSpPr();
CTPresetGeometry2D prst = spPr.addNewPrstGeom();
prst.setPrst(STShapeType.RECT);
prst.addNewAvLst();
CTTextBody txBody = ct.addNewTxBody();
XSLFAutoShape.initTextBody(txBody);
return ct;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTShape in project poi by apache.
the class XSLFSheet method appendContent.
/**
* Append content to this sheet.
*
* @param src the source sheet
* @return modified <code>this</code>.
*/
public XSLFSheet appendContent(XSLFSheet src) {
CTGroupShape spTree = getSpTree();
int numShapes = getShapes().size();
CTGroupShape srcTree = src.getSpTree();
for (XmlObject ch : srcTree.selectPath("*")) {
if (ch instanceof CTShape) {
// simple shape
spTree.addNewSp().set(ch);
} else if (ch instanceof CTGroupShape) {
spTree.addNewGrpSp().set(ch);
} else if (ch instanceof CTConnector) {
spTree.addNewCxnSp().set(ch);
} else if (ch instanceof CTPicture) {
spTree.addNewPic().set(ch);
} else if (ch instanceof CTGraphicalObjectFrame) {
spTree.addNewGraphicFrame().set(ch);
}
}
_shapes = null;
_spTree = null;
_drawing = null;
_spTree = null;
_placeholders = null;
// recursively update each shape
List<XSLFShape> tgtShapes = getShapes();
List<XSLFShape> srcShapes = src.getShapes();
for (int i = 0; i < srcShapes.size(); i++) {
XSLFShape s1 = srcShapes.get(i);
XSLFShape s2 = tgtShapes.get(numShapes + i);
s2.copy(s1);
}
return this;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTShape in project poi by apache.
the class XSLFDrawing method createAutoShape.
public XSLFAutoShape createAutoShape() {
CTShape sp = _spTree.addNewSp();
sp.set(XSLFAutoShape.prototype(_shapeId++));
XSLFAutoShape shape = new XSLFAutoShape(sp, _sheet);
shape.setAnchor(new Rectangle2D.Double());
return shape;
}
Aggregations