Search in sources :

Example 1 with CTShape

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

the class XSLFCommonSlideData method processShape.

private void processShape(CTGroupShape gs, List<DrawingTextBody> out) {
    for (CTShape shape : gs.getSpArray()) {
        CTTextBody ctTextBody = shape.getTxBody();
        if (ctTextBody == null) {
            continue;
        }
        DrawingTextBody textBody;
        CTApplicationNonVisualDrawingProps nvpr = shape.getNvSpPr().getNvPr();
        if (nvpr.isSetPh()) {
            textBody = new DrawingTextPlaceholder(ctTextBody, nvpr.getPh());
        } else {
            textBody = new DrawingTextBody(ctTextBody);
        }
        out.add(textBody);
    }
}
Also used : CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape) CTApplicationNonVisualDrawingProps(org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps) CTTextBody(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)

Example 2 with CTShape

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

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

the class XSLFDrawing method createFreeform.

public XSLFFreeformShape createFreeform() {
    CTShape sp = _spTree.addNewSp();
    sp.set(XSLFFreeformShape.prototype(_shapeId++));
    XSLFFreeformShape shape = new XSLFFreeformShape(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