Search in sources :

Example 6 with CTConnector

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

the class XSLFSheet method appendContent.

/**
     * Append content to this sheet.
     *
     * @param src the source sheet
     * @return modified <code>this</code>.
     */
public XSLFSheet appendContent(XSLFSheet src) {
    CTGroupShape spTree = getSpTree();
    int numShapes = getShapes().size();
    CTGroupShape srcTree = src.getSpTree();
    for (XmlObject ch : srcTree.selectPath("*")) {
        if (ch instanceof CTShape) {
            // simple shape
            spTree.addNewSp().set(ch);
        } else if (ch instanceof CTGroupShape) {
            spTree.addNewGrpSp().set(ch);
        } else if (ch instanceof CTConnector) {
            spTree.addNewCxnSp().set(ch);
        } else if (ch instanceof CTPicture) {
            spTree.addNewPic().set(ch);
        } else if (ch instanceof CTGraphicalObjectFrame) {
            spTree.addNewGraphicFrame().set(ch);
        }
    }
    _shapes = null;
    _spTree = null;
    _drawing = null;
    _spTree = null;
    _placeholders = null;
    // recursively update each shape
    List<XSLFShape> tgtShapes = getShapes();
    List<XSLFShape> srcShapes = src.getShapes();
    for (int i = 0; i < srcShapes.size(); i++) {
        XSLFShape s1 = srcShapes.get(i);
        XSLFShape s2 = tgtShapes.get(numShapes + i);
        s2.copy(s1);
    }
    return this;
}
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 7 with CTConnector

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

CTConnector (org.openxmlformats.schemas.presentationml.x2006.main.CTConnector)7 XmlObject (org.apache.xmlbeans.XmlObject)4 CTGraphicalObjectFrame (org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame)4 CTGroupShape (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)4 CTPicture (org.openxmlformats.schemas.presentationml.x2006.main.CTPicture)4 CTShape (org.openxmlformats.schemas.presentationml.x2006.main.CTShape)4 Rectangle2D (java.awt.geom.Rectangle2D)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 CTConnection (org.openxmlformats.schemas.drawingml.x2006.main.CTConnection)1 CTNonVisualConnectorProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualConnectorProperties)1 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)1 CTPresetGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D)1 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)1 CTConnectorNonVisual (org.openxmlformats.schemas.presentationml.x2006.main.CTConnectorNonVisual)1