Search in sources :

Example 1 with CTGraphicalObjectFrame

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

the class XSLFDrawing method createTable.

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

Example 2 with CTGraphicalObjectFrame

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

Example 3 with CTGraphicalObjectFrame

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

the class XSLFSheet method removeShape.

/**
     * Removes the specified shape from this sheet, if it is present
     * (optional operation).  If this sheet does not contain the element,
     * it is unchanged.
     *
     * @param xShape shape to be removed from this sheet, if present
     * @return <tt>true</tt> if this sheet contained the specified element
     * @throws IllegalArgumentException if the type of the specified shape
     *         is incompatible with this sheet (optional)
     */
public boolean removeShape(XSLFShape xShape) {
    XmlObject obj = xShape.getXmlObject();
    CTGroupShape spTree = getSpTree();
    if (obj instanceof CTShape) {
        spTree.getSpList().remove(obj);
    } else if (obj instanceof CTGroupShape) {
        spTree.getGrpSpList().remove(obj);
    } else if (obj instanceof CTConnector) {
        spTree.getCxnSpList().remove(obj);
    } else if (obj instanceof CTGraphicalObjectFrame) {
        spTree.getGraphicFrameList().remove(obj);
    } else if (obj instanceof CTPicture) {
        XSLFPictureShape ps = (XSLFPictureShape) xShape;
        removePictureRelation(ps);
        spTree.getPicList().remove(obj);
    } else {
        throw new IllegalArgumentException("Unsupported shape: " + xShape);
    }
    return getShapes().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)

Example 4 with CTGraphicalObjectFrame

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

the class XSLFSheet method buildShapes.

protected static List<XSLFShape> buildShapes(CTGroupShape spTree, XSLFSheet sheet) {
    List<XSLFShape> shapes = new ArrayList<XSLFShape>();
    for (XmlObject ch : spTree.selectPath("*")) {
        if (ch instanceof CTShape) {
            // simple shape
            XSLFAutoShape shape = XSLFAutoShape.create((CTShape) ch, sheet);
            shapes.add(shape);
        } else if (ch instanceof CTGroupShape) {
            shapes.add(new XSLFGroupShape((CTGroupShape) ch, sheet));
        } else if (ch instanceof CTConnector) {
            shapes.add(new XSLFConnectorShape((CTConnector) ch, sheet));
        } else if (ch instanceof CTPicture) {
            shapes.add(new XSLFPictureShape((CTPicture) ch, sheet));
        } else if (ch instanceof CTGraphicalObjectFrame) {
            XSLFGraphicFrame shape = XSLFGraphicFrame.create((CTGraphicalObjectFrame) ch, sheet);
            shapes.add(shape);
        }
    }
    return shapes;
}
Also used : CTConnector(org.openxmlformats.schemas.presentationml.x2006.main.CTConnector) CTGraphicalObjectFrame(org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame) ArrayList(java.util.ArrayList) CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape) CTPicture(org.openxmlformats.schemas.presentationml.x2006.main.CTPicture) XmlObject(org.apache.xmlbeans.XmlObject)

Example 5 with CTGraphicalObjectFrame

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

the class XSLFTable method prototype.

static CTGraphicalObjectFrame prototype(int shapeId) {
    CTGraphicalObjectFrame frame = CTGraphicalObjectFrame.Factory.newInstance();
    CTGraphicalObjectFrameNonVisual nvGr = frame.addNewNvGraphicFramePr();
    CTNonVisualDrawingProps cnv = nvGr.addNewCNvPr();
    cnv.setName("Table " + shapeId);
    cnv.setId(shapeId + 1);
    nvGr.addNewCNvGraphicFramePr().addNewGraphicFrameLocks().setNoGrp(true);
    nvGr.addNewNvPr();
    frame.addNewXfrm();
    CTGraphicalObjectData gr = frame.addNewGraphic().addNewGraphicData();
    XmlCursor grCur = gr.newCursor();
    grCur.toNextToken();
    grCur.beginElement(new QName(DRAWINGML_URI, "tbl"));
    CTTable tbl = CTTable.Factory.newInstance();
    tbl.addNewTblPr();
    tbl.addNewTblGrid();
    XmlCursor tblCur = tbl.newCursor();
    tblCur.moveXmlContents(grCur);
    tblCur.dispose();
    grCur.dispose();
    gr.setUri(TABLE_URI);
    return frame;
}
Also used : CTGraphicalObjectData(org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData) CTGraphicalObjectFrame(org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame) QName(javax.xml.namespace.QName) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTTable(org.openxmlformats.schemas.drawingml.x2006.main.CTTable) CTGraphicalObjectFrameNonVisual(org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrameNonVisual) XmlCursor(org.apache.xmlbeans.XmlCursor)

Aggregations

CTGraphicalObjectFrame (org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame)10 XmlObject (org.apache.xmlbeans.XmlObject)5 CTGroupShape (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)5 CTConnector (org.openxmlformats.schemas.presentationml.x2006.main.CTConnector)4 CTPicture (org.openxmlformats.schemas.presentationml.x2006.main.CTPicture)4 CTShape (org.openxmlformats.schemas.presentationml.x2006.main.CTShape)4 ArrayList (java.util.ArrayList)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 CTGraphicalObjectData (org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData)2 CTPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D)2 CTPositiveSize2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)2 CTTable (org.openxmlformats.schemas.drawingml.x2006.main.CTTable)2 CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)2 Rectangle2D (java.awt.geom.Rectangle2D)1 QName (javax.xml.namespace.QName)1 POIXMLException (org.apache.poi.POIXMLException)1 BorderEdge (org.apache.poi.sl.usermodel.TableCell.BorderEdge)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlAnyTypeImpl (org.apache.xmlbeans.impl.values.XmlAnyTypeImpl)1 Test (org.junit.Test)1