use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.
the class XSSFDrawing method createConnector.
/**
* Creates a simple shape. This includes such shapes as lines, rectangles,
* and ovals.
*
* @param anchor the client anchor describes how this group is attached
* to the sheet.
* @return the newly created shape.
*/
public XSSFConnector createConnector(XSSFClientAnchor anchor) {
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
CTConnector ctShape = ctAnchor.addNewCxnSp();
ctShape.set(XSSFConnector.prototype());
XSSFConnector shape = new XSSFConnector(this, ctShape);
shape.anchor = anchor;
return shape;
}
use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.
the class XSSFObjectData method prototype.
/**
* Prototype with the default structure of a new auto-shape.
*/
/**
* Prototype with the default structure of a new auto-shape.
*/
protected static CTShape prototype() {
final String drawNS = "http://schemas.microsoft.com/office/drawing/2010/main";
if (prototype == null) {
CTShape shape = CTShape.Factory.newInstance();
CTShapeNonVisual nv = shape.addNewNvSpPr();
CTNonVisualDrawingProps nvp = nv.addNewCNvPr();
nvp.setId(1);
nvp.setName("Shape 1");
// nvp.setHidden(true);
CTOfficeArtExtensionList extLst = nvp.addNewExtLst();
// https://msdn.microsoft.com/en-us/library/dd911027(v=office.12).aspx
CTOfficeArtExtension ext = extLst.addNewExt();
ext.setUri("{63B3BB69-23CF-44E3-9099-C40C66FF867C}");
XmlCursor cur = ext.newCursor();
cur.toEndToken();
cur.beginElement(new QName(drawNS, "compatExt", "a14"));
cur.insertNamespace("a14", drawNS);
cur.insertAttributeWithValue("spid", "_x0000_s1");
cur.dispose();
nv.addNewCNvSpPr();
CTShapeProperties sp = shape.addNewSpPr();
CTTransform2D t2d = sp.addNewXfrm();
CTPositiveSize2D p1 = t2d.addNewExt();
p1.setCx(0);
p1.setCy(0);
CTPoint2D p2 = t2d.addNewOff();
p2.setX(0);
p2.setY(0);
CTPresetGeometry2D geom = sp.addNewPrstGeom();
geom.setPrst(STShapeType.RECT);
geom.addNewAvLst();
prototype = shape;
}
return prototype;
}
use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.
the class XSSFDrawing method createPicture.
/**
* Creates a picture.
*
* @param anchor the client anchor describes how this picture is attached to the sheet.
* @param pictureIndex the index of the picture in the workbook collection of pictures,
* {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
*
* @return the newly created picture shape.
*/
public XSSFPicture createPicture(XSSFClientAnchor anchor, int pictureIndex) {
PackageRelationship rel = addPictureReference(pictureIndex);
long shapeId = newShapeId();
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
CTPicture ctShape = ctAnchor.addNewPic();
ctShape.set(XSSFPicture.prototype());
ctShape.getNvPicPr().getCNvPr().setId(shapeId);
XSSFPicture shape = new XSSFPicture(this, ctShape);
shape.anchor = anchor;
shape.setPictureReference(rel);
ctShape.getSpPr().setXfrm(createXfrm(anchor));
return shape;
}
use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.
the class XSSFShapeGroup method createConnector.
/**
* Creates a simple shape. This includes such shapes as lines, rectangles,
* and ovals.
*
* @param anchor the child anchor describes how this shape is attached
* to the group.
* @return the newly created shape.
*/
public XSSFConnector createConnector(XSSFChildAnchor anchor) {
CTConnector ctShape = ctGroup.addNewCxnSp();
ctShape.set(XSSFConnector.prototype());
XSSFConnector shape = new XSSFConnector(getDrawing(), ctShape);
shape.parent = this;
shape.anchor = anchor;
shape.getCTConnector().getSpPr().setXfrm(anchor.getCTTransform2D());
return shape;
}
use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.
the class XSSFShapeGroup method createGroup.
/**
* Creates a group shape.
*
* @param anchor the client anchor describes how this group is attached to the group.
* @return the newly created group shape.
*/
public XSSFShapeGroup createGroup(XSSFChildAnchor anchor) {
CTGroupShape ctShape = ctGroup.addNewGrpSp();
ctShape.set(prototype());
XSSFShapeGroup shape = new XSSFShapeGroup(getDrawing(), ctShape);
shape.parent = this;
shape.anchor = anchor;
// TODO: calculate bounding rectangle on anchor and set off/ext correctly
CTGroupTransform2D xfrm = shape.getCTGroupShape().getGrpSpPr().getXfrm();
CTTransform2D t2 = anchor.getCTTransform2D();
xfrm.setOff(t2.getOff());
xfrm.setExt(t2.getExt());
// child offset is left to 0,0
xfrm.setChExt(t2.getExt());
xfrm.setFlipH(t2.getFlipH());
xfrm.setFlipV(t2.getFlipV());
return shape;
}
Aggregations