Search in sources :

Example 6 with CTGroupShape

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

use of org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape in project poi by apache.

the class XSLFDrawing method createGroup.

public XSLFGroupShape createGroup() {
    CTGroupShape obj = _spTree.addNewGrpSp();
    obj.set(XSLFGroupShape.prototype(_shapeId++));
    XSLFGroupShape shape = new XSLFGroupShape(obj, _sheet);
    shape.setAnchor(new Rectangle2D.Double());
    return shape;
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)

Example 8 with CTGroupShape

use of org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape in project poi by apache.

the class XSLFGraphicFrame method getFallbackPicture.

@Override
public XSLFPictureShape getFallbackPicture() {
    String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main'; " + "declare namespace mc='http://schemas.openxmlformats.org/markup-compatibility/2006' " + ".//mc:Fallback/*/p:pic";
    XmlObject xo = selectProperty(XmlObject.class, xquery);
    if (xo == null) {
        return null;
    }
    CTGroupShape gs;
    try {
        gs = CTGroupShape.Factory.parse(xo.newDomNode());
    } catch (XmlException e) {
        LOG.log(POILogger.WARN, "Can't parse fallback picture stream of graphical frame", e);
        return null;
    }
    if (gs.sizeOfPicArray() == 0) {
        return null;
    }
    return new XSLFPictureShape(gs.getPicArray(0), getSheet());
}
Also used : XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)

Example 9 with CTGroupShape

use of org.openxmlformats.schemas.presentationml.x2006.main.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)

Example 10 with CTGroupShape

use of org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape in project poi by apache.

the class XSLFGroupShape method removeShape.

/**
     * Remove the specified shape from this group
     */
@Override
public boolean removeShape(XSLFShape xShape) {
    XmlObject obj = xShape.getXmlObject();
    CTGroupShape grpSp = (CTGroupShape) getXmlObject();
    if (obj instanceof CTShape) {
        grpSp.getSpList().remove(obj);
    } else if (obj instanceof CTGroupShape) {
        grpSp.getGrpSpList().remove(obj);
    } else if (obj instanceof CTConnector) {
        grpSp.getCxnSpList().remove(obj);
    } else if (obj instanceof CTGraphicalObjectFrame) {
        grpSp.getGraphicFrameList().remove(obj);
    } else if (obj instanceof CTPicture) {
        XSLFPictureShape ps = (XSLFPictureShape) xShape;
        XSLFSheet sh = getSheet();
        if (sh != null) {
            sh.removePictureRelation(ps);
        }
        grpSp.getPicList().remove(obj);
    } else {
        throw new IllegalArgumentException("Unsupported shape: " + xShape);
    }
    return _shapes.remove(xShape);
}
Also used : CTConnector(org.openxmlformats.schemas.presentationml.x2006.main.CTConnector) CTGraphicalObjectFrame(org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame) CTPicture(org.openxmlformats.schemas.presentationml.x2006.main.CTPicture) XmlObject(org.apache.xmlbeans.XmlObject) CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)

Aggregations

CTGroupShape (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)10 XmlObject (org.apache.xmlbeans.XmlObject)6 CTGraphicalObjectFrame (org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame)5 CTShape (org.openxmlformats.schemas.presentationml.x2006.main.CTShape)5 CTConnector (org.openxmlformats.schemas.presentationml.x2006.main.CTConnector)4 CTPicture (org.openxmlformats.schemas.presentationml.x2006.main.CTPicture)4 ArrayList (java.util.ArrayList)2 XmlException (org.apache.xmlbeans.XmlException)2 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)2 CTGroupShapeNonVisual (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual)2 Rectangle2D (java.awt.geom.Rectangle2D)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 POIXMLException (org.apache.poi.POIXMLException)1 OPCPackage (org.apache.poi.openxml4j.opc.OPCPackage)1 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)1 PackagePartName (org.apache.poi.openxml4j.opc.PackagePartName)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlAnyTypeImpl (org.apache.xmlbeans.impl.values.XmlAnyTypeImpl)1 CTGraphicalObjectData (org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData)1 CTGroupShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties)1