Search in sources :

Example 11 with CTTransform2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D in project poi by apache.

the class XSSFDrawing method createGroup.

/**
     * 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 XSSFShapeGroup createGroup(XSSFClientAnchor anchor) {
    CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
    CTGroupShape ctGroup = ctAnchor.addNewGrpSp();
    ctGroup.set(XSSFShapeGroup.prototype());
    CTTransform2D xfrm = createXfrm(anchor);
    CTGroupTransform2D grpXfrm = ctGroup.getGrpSpPr().getXfrm();
    grpXfrm.setOff(xfrm.getOff());
    grpXfrm.setExt(xfrm.getExt());
    grpXfrm.setChExt(xfrm.getExt());
    XSSFShapeGroup shape = new XSSFShapeGroup(this, ctGroup);
    shape.anchor = anchor;
    return shape;
}
Also used : CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTGroupTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D) CTTwoCellAnchor(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor) CTGroupShape(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape)

Example 12 with CTTransform2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D 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;
}
Also used : CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) QName(javax.xml.namespace.QName) CTShape(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape) XmlCursor(org.apache.xmlbeans.XmlCursor) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTShapeNonVisual(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTOfficeArtExtension(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D) CTOfficeArtExtensionList(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList)

Example 13 with CTTransform2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D 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;
}
Also used : CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTGroupTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D) CTGroupShape(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape)

Example 14 with CTTransform2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D in project poi by apache.

the class XSLFSimpleShape method getAnchor.

@Override
public Rectangle2D getAnchor() {
    CTTransform2D xfrm = getXfrm(false);
    if (xfrm == null) {
        return null;
    }
    CTPoint2D off = xfrm.getOff();
    double x = Units.toPoints(off.getX());
    double y = Units.toPoints(off.getY());
    CTPositiveSize2D ext = xfrm.getExt();
    double cx = Units.toPoints(ext.getCx());
    double cy = Units.toPoints(ext.getCy());
    return new Rectangle2D.Double(x, y, cx, cy);
}
Also used : CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)

Example 15 with CTTransform2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D in project poi by apache.

the class XSLFGraphicFrame method setAnchor.

@Override
public void setAnchor(Rectangle2D anchor) {
    CTTransform2D xfrm = ((CTGraphicalObjectFrame) getXmlObject()).getXfrm();
    CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();
    long x = Units.toEMU(anchor.getX());
    long y = Units.toEMU(anchor.getY());
    off.setX(x);
    off.setY(y);
    CTPositiveSize2D ext = xfrm.isSetExt() ? xfrm.getExt() : xfrm.addNewExt();
    long cx = Units.toEMU(anchor.getWidth());
    long cy = Units.toEMU(anchor.getHeight());
    ext.setCx(cx);
    ext.setCy(cy);
}
Also used : CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTGraphicalObjectFrame(org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)

Aggregations

CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)14 CTPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D)11 CTPositiveSize2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)11 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)5 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)5 CTPresetGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D)4 CTBlipFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties)2 CTGroupTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D)2 CTNonVisualPictureProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties)2 CTGroupShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape)2 CTShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape)2 CTShapeNonVisual (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual)2 CTGraphicalObjectFrame (org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame)2 Rectangle2D (java.awt.geom.Rectangle2D)1 StringReader (java.io.StringReader)1 QName (javax.xml.namespace.QName)1 PropertyFetcher (org.apache.poi.xslf.model.PropertyFetcher)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1