Search in sources :

Example 1 with CTTransform2D

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

the class XSLFSimpleShape method setAnchor.

@Override
public void setAnchor(Rectangle2D anchor) {
    CTTransform2D xfrm = getXfrm(true);
    if (xfrm == null) {
        return;
    }
    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) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)

Example 2 with CTTransform2D

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

the class XSSFDrawing method createXfrm.

private CTTransform2D createXfrm(XSSFClientAnchor anchor) {
    CTTransform2D xfrm = CTTransform2D.Factory.newInstance();
    CTPoint2D off = xfrm.addNewOff();
    off.setX(anchor.getDx1());
    off.setY(anchor.getDy1());
    XSSFSheet sheet = getSheet();
    double widthPx = 0;
    for (int col = anchor.getCol1(); col < anchor.getCol2(); col++) {
        widthPx += sheet.getColumnWidthInPixels(col);
    }
    double heightPx = 0;
    for (int row = anchor.getRow1(); row < anchor.getRow2(); row++) {
        heightPx += ImageUtils.getRowHeightInPixels(sheet, row);
    }
    long width = Units.pixelToEMU((int) widthPx);
    long height = Units.pixelToEMU((int) heightPx);
    CTPositiveSize2D ext = xfrm.addNewExt();
    ext.setCx(width - anchor.getDx1() + anchor.getDx2());
    ext.setCy(height - anchor.getDy1() + anchor.getDy2());
    // TODO: handle vflip/hflip
    return xfrm;
}
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 3 with CTTransform2D

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

the class XSSFPicture method prototype.

/**
     * Returns a prototype that is used to construct new shapes
     *
     * @return a prototype that is used to construct new shapes
     */
protected static CTPicture prototype() {
    if (prototype == null) {
        CTPicture pic = CTPicture.Factory.newInstance();
        CTPictureNonVisual nvpr = pic.addNewNvPicPr();
        CTNonVisualDrawingProps nvProps = nvpr.addNewCNvPr();
        nvProps.setId(1);
        nvProps.setName("Picture 1");
        nvProps.setDescr("Picture");
        CTNonVisualPictureProperties nvPicProps = nvpr.addNewCNvPicPr();
        nvPicProps.addNewPicLocks().setNoChangeAspect(true);
        CTBlipFillProperties blip = pic.addNewBlipFill();
        blip.addNewBlip().setEmbed("");
        blip.addNewStretch().addNewFillRect();
        CTShapeProperties sppr = pic.addNewSpPr();
        CTTransform2D t2d = sppr.addNewXfrm();
        CTPositiveSize2D ext = t2d.addNewExt();
        //should be original picture width and height expressed in EMUs
        ext.setCx(0);
        ext.setCy(0);
        CTPoint2D off = t2d.addNewOff();
        off.setX(0);
        off.setY(0);
        CTPresetGeometry2D prstGeom = sppr.addNewPrstGeom();
        prstGeom.setPrst(STShapeType.RECT);
        prstGeom.addNewAvLst();
        prototype = pic;
    }
    return prototype;
}
Also used : CTNonVisualPictureProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties) CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTBlipFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties) CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTPicture(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture) CTPictureNonVisual(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPictureNonVisual) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)

Example 4 with CTTransform2D

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

the class XSSFGraphicFrame method prototype.

/**
	 * Initialize default structure of a new graphic frame
	 */
protected static CTGraphicalObjectFrame prototype() {
    if (prototype == null) {
        CTGraphicalObjectFrame graphicFrame = CTGraphicalObjectFrame.Factory.newInstance();
        CTGraphicalObjectFrameNonVisual nvGraphic = graphicFrame.addNewNvGraphicFramePr();
        CTNonVisualDrawingProps props = nvGraphic.addNewCNvPr();
        props.setId(0);
        props.setName("Diagramm 1");
        nvGraphic.addNewCNvGraphicFramePr();
        CTTransform2D transform = graphicFrame.addNewXfrm();
        CTPositiveSize2D extPoint = transform.addNewExt();
        CTPoint2D offPoint = transform.addNewOff();
        extPoint.setCx(0);
        extPoint.setCy(0);
        offPoint.setX(0);
        offPoint.setY(0);
        /* CTGraphicalObject graphic = */
        graphicFrame.addNewGraphic();
        prototype = graphicFrame;
    }
    return prototype;
}
Also used : CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTGraphicalObjectFrame(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGraphicalObjectFrame) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTGraphicalObjectFrameNonVisual(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGraphicalObjectFrameNonVisual) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)

Example 5 with CTTransform2D

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

the class XSLFGraphicFrame method getAnchor.

@Override
public Rectangle2D getAnchor() {
    CTTransform2D xfrm = ((CTGraphicalObjectFrame) getXmlObject()).getXfrm();
    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) 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