Search in sources :

Example 6 with CTGroupShape

use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape 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 7 with CTGroupShape

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

the class XSLFCommonSlideData method getDrawingText.

public List<DrawingTextBody> getDrawingText() {
    CTGroupShape gs = data.getSpTree();
    List<DrawingTextBody> out = new ArrayList<DrawingTextBody>();
    processShape(gs, out);
    for (CTGroupShape shape : gs.getGrpSpArray()) {
        processShape(shape, out);
    }
    for (CTGraphicalObjectFrame frame : gs.getGraphicFrameArray()) {
        CTGraphicalObjectData data = frame.getGraphic().getGraphicData();
        XmlCursor c = data.newCursor();
        c.selectPath("declare namespace pic='" + CTTable.type.getName().getNamespaceURI() + "' .//pic:tbl");
        while (c.toNextSelection()) {
            XmlObject o = c.getObject();
            if (o instanceof XmlAnyTypeImpl) {
                // Pesky XmlBeans bug - see Bugzilla #49934
                try {
                    o = CTTable.Factory.parse(o.toString(), DEFAULT_XML_OPTIONS);
                } catch (XmlException e) {
                    throw new POIXMLException(e);
                }
            }
            if (o instanceof CTTable) {
                DrawingTable table = new DrawingTable((CTTable) o);
                for (DrawingTableRow row : table.getRows()) {
                    for (DrawingTableCell cell : row.getCells()) {
                        DrawingTextBody textBody = cell.getTextBody();
                        out.add(textBody);
                    }
                }
            }
        }
        c.dispose();
    }
    return out;
}
Also used : CTGraphicalObjectFrame(org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame) ArrayList(java.util.ArrayList) POIXMLException(org.apache.poi.POIXMLException) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape) XmlCursor(org.apache.xmlbeans.XmlCursor) CTGraphicalObjectData(org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData) XmlException(org.apache.xmlbeans.XmlException) CTTable(org.openxmlformats.schemas.drawingml.x2006.main.CTTable) XmlAnyTypeImpl(org.apache.xmlbeans.impl.values.XmlAnyTypeImpl) XmlObject(org.apache.xmlbeans.XmlObject)

Example 8 with CTGroupShape

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

the class XSLFGroupShape method prototype.

/**
     * @param shapeId 1-based shapeId
     */
static CTGroupShape prototype(int shapeId) {
    CTGroupShape ct = CTGroupShape.Factory.newInstance();
    CTGroupShapeNonVisual nvSpPr = ct.addNewNvGrpSpPr();
    CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr();
    cnv.setName("Group " + shapeId);
    cnv.setId(shapeId + 1);
    nvSpPr.addNewCNvGrpSpPr();
    nvSpPr.addNewNvPr();
    ct.addNewGrpSpPr();
    return ct;
}
Also used : CTGroupShapeNonVisual(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)

Aggregations

CTGroupTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D)4 CTGroupShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape)4 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)3 CTGroupShape (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)3 XmlCursor (org.apache.xmlbeans.XmlCursor)2 XmlException (org.apache.xmlbeans.XmlException)2 XmlObject (org.apache.xmlbeans.XmlObject)2 XmlAnyTypeImpl (org.apache.xmlbeans.impl.values.XmlAnyTypeImpl)2 CTGroupShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties)2 CTPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D)2 CTPositiveSize2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)2 CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)2 CTGroupShapeNonVisual (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual)2 ArrayList (java.util.ArrayList)1 POIXMLException (org.apache.poi.POIXMLException)1 CTGraphicalObjectData (org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData)1 CTTable (org.openxmlformats.schemas.drawingml.x2006.main.CTTable)1 CTTextBody (org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)1 CTConnector (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTConnector)1 CTDrawing (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing)1