Search in sources :

Example 1 with CTShape

use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.

the class XSLFAutoShape 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("AutoShape " + shapeId);
    cnv.setId(shapeId + 1);
    nvSpPr.addNewCNvSpPr();
    nvSpPr.addNewNvPr();
    CTShapeProperties spPr = ct.addNewSpPr();
    CTPresetGeometry2D prst = spPr.addNewPrstGeom();
    prst.setPrst(STShapeType.RECT);
    prst.addNewAvLst();
    return ct;
}
Also used : CTShapeNonVisual(org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual) CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape)

Example 2 with CTShape

use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.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);
    }
}
Also used : CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape) CTApplicationNonVisualDrawingProps(org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps) CTTextBody(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)

Example 3 with CTShape

use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.

the class XSSFShapeGroup 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 XSSFWorkbook#getAllPictures()} .
     * @return the newly created picture shape.
     */
public XSSFPicture createPicture(XSSFClientAnchor anchor, int pictureIndex) {
    PackageRelationship rel = getDrawing().addPictureReference(pictureIndex);
    CTPicture ctShape = ctGroup.addNewPic();
    ctShape.set(XSSFPicture.prototype());
    XSSFPicture shape = new XSSFPicture(getDrawing(), ctShape);
    shape.parent = this;
    shape.anchor = anchor;
    shape.setPictureReference(rel);
    return shape;
}
Also used : PackageRelationship(org.apache.poi.openxml4j.opc.PackageRelationship) CTPicture(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture)

Example 4 with CTShape

use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.

the class XSSFShapeGroup method createTextbox.

/**
     * Constructs a textbox.
     *
     * @param anchor the child anchor describes how this shape is attached
     *               to the group.
     * @return      the newly created textbox.
     */
public XSSFTextBox createTextbox(XSSFChildAnchor anchor) {
    CTShape ctShape = ctGroup.addNewSp();
    ctShape.set(XSSFSimpleShape.prototype());
    XSSFTextBox shape = new XSSFTextBox(getDrawing(), ctShape);
    shape.parent = this;
    shape.anchor = anchor;
    shape.getCTShape().getSpPr().setXfrm(anchor.getCTTransform2D());
    return shape;
}
Also used : CTShape(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape)

Example 5 with CTShape

use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape in project poi by apache.

the class XSSFShapeGroup method createSimpleShape.

/**
     * 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 XSSFSimpleShape createSimpleShape(XSSFChildAnchor anchor) {
    CTShape ctShape = ctGroup.addNewSp();
    ctShape.set(XSSFSimpleShape.prototype());
    XSSFSimpleShape shape = new XSSFSimpleShape(getDrawing(), ctShape);
    shape.parent = this;
    shape.anchor = anchor;
    shape.getCTShape().getSpPr().setXfrm(anchor.getCTTransform2D());
    return shape;
}
Also used : CTShape(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape)

Aggregations

CTShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape)8 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)6 CTTwoCellAnchor (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor)5 CTShape (org.openxmlformats.schemas.presentationml.x2006.main.CTShape)5 CTShapeNonVisual (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual)4 PackageRelationship (org.apache.poi.openxml4j.opc.PackageRelationship)3 XmlCursor (org.apache.xmlbeans.XmlCursor)3 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)3 CTConnector (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTConnector)3 CTPicture (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture)3 QName (javax.xml.namespace.QName)2 CTHyperlink (org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink)2 CTPresetGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D)2 CTTextBody (org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)2 CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)2 CTGroupShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape)2 CTShapeNonVisual (org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual)2 Rectangle2D (java.awt.geom.Rectangle2D)1 POIXMLException (org.apache.poi.POIXMLException)1 InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)1