Search in sources :

Example 6 with CTShape

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

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

the class TestXSLFBugs method bug60662.

@Test
public void bug60662() throws IOException {
    XMLSlideShow src = new XMLSlideShow();
    XSLFSlide sl = src.createSlide();
    XSLFGroupShape gs = sl.createGroup();
    gs.setAnchor(new Rectangle2D.Double(100, 100, 100, 100));
    gs.setInteriorAnchor(new Rectangle2D.Double(0, 0, 100, 100));
    XSLFAutoShape as = gs.createAutoShape();
    as.setAnchor(new Rectangle2D.Double(0, 0, 100, 100));
    as.setShapeType(ShapeType.STAR_24);
    as.setFillColor(Color.YELLOW);
    CTShape csh = (CTShape) as.getXmlObject();
    CTOuterShadowEffect shadow = csh.getSpPr().addNewEffectLst().addNewOuterShdw();
    shadow.setDir(270000);
    shadow.setDist(100000);
    shadow.addNewSrgbClr().setVal(new byte[] { 0x00, (byte) 0xFF, 0x00 });
    XMLSlideShow dst = new XMLSlideShow();
    XSLFSlide sl2 = dst.createSlide();
    sl2.importContent(sl);
    XSLFGroupShape gs2 = (XSLFGroupShape) sl2.getShapes().get(0);
    XSLFAutoShape as2 = (XSLFAutoShape) gs2.getShapes().get(0);
    CTShape csh2 = (CTShape) as2.getXmlObject();
    assertTrue(csh2.getSpPr().isSetEffectLst());
    dst.close();
    src.close();
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape) CTOuterShadowEffect(org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect) Test(org.junit.Test)

Example 8 with CTShape

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

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

Example 9 with CTShape

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

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

the class XSLFDrawing method createAutoShape.

public XSLFAutoShape createAutoShape() {
    CTShape sp = _spTree.addNewSp();
    sp.set(XSLFAutoShape.prototype(_shapeId++));
    XSLFAutoShape shape = new XSLFAutoShape(sp, _sheet);
    shape.setAnchor(new Rectangle2D.Double());
    return shape;
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape)

Aggregations

CTShape (org.openxmlformats.schemas.presentationml.x2006.main.CTShape)13 Rectangle2D (java.awt.geom.Rectangle2D)4 XmlObject (org.apache.xmlbeans.XmlObject)4 CTConnector (org.openxmlformats.schemas.presentationml.x2006.main.CTConnector)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 CTShapeNonVisual (org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual)3 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)2 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)2 CTTextBody (org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 CTCustomGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTCustomGeometry2D)1 CTGeomRect (org.openxmlformats.schemas.drawingml.x2006.main.CTGeomRect)1 CTOuterShadowEffect (org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect)1 CTPresetGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D)1 CTApplicationNonVisualDrawingProps (org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps)1