Search in sources :

Example 1 with CTPresetGeometry2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D in project poi by apache.

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

Example 2 with CTPresetGeometry2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D in project poi by apache.

the class XSLFConnectorShape method prototype.

/**
     * @param shapeId 1-based shapeId
     */
static CTConnector prototype(int shapeId) {
    CTConnector ct = CTConnector.Factory.newInstance();
    CTConnectorNonVisual nvSpPr = ct.addNewNvCxnSpPr();
    CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr();
    cnv.setName("Connector " + shapeId);
    cnv.setId(shapeId + 1);
    nvSpPr.addNewCNvCxnSpPr();
    nvSpPr.addNewNvPr();
    CTShapeProperties spPr = ct.addNewSpPr();
    CTPresetGeometry2D prst = spPr.addNewPrstGeom();
    prst.setPrst(STShapeType.LINE);
    prst.addNewAvLst();
    /* CTLineProperties ln = */
    spPr.addNewLn();
    return ct;
}
Also used : CTConnector(org.openxmlformats.schemas.presentationml.x2006.main.CTConnector) CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTConnectorNonVisual(org.openxmlformats.schemas.presentationml.x2006.main.CTConnectorNonVisual)

Example 3 with CTPresetGeometry2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D in project poi by apache.

the class XSSFPicture method prototype.

/**
     * Returns a prototype that is used to construct new shapes
     *
     * @return a prototype that is used to construct new shapes
     */
protected static CTPicture prototype() {
    if (prototype == null) {
        CTPicture pic = CTPicture.Factory.newInstance();
        CTPictureNonVisual nvpr = pic.addNewNvPicPr();
        CTNonVisualDrawingProps nvProps = nvpr.addNewCNvPr();
        nvProps.setId(1);
        nvProps.setName("Picture 1");
        nvProps.setDescr("Picture");
        CTNonVisualPictureProperties nvPicProps = nvpr.addNewCNvPicPr();
        nvPicProps.addNewPicLocks().setNoChangeAspect(true);
        CTBlipFillProperties blip = pic.addNewBlipFill();
        blip.addNewBlip().setEmbed("");
        blip.addNewStretch().addNewFillRect();
        CTShapeProperties sppr = pic.addNewSpPr();
        CTTransform2D t2d = sppr.addNewXfrm();
        CTPositiveSize2D ext = t2d.addNewExt();
        //should be original picture width and height expressed in EMUs
        ext.setCx(0);
        ext.setCy(0);
        CTPoint2D off = t2d.addNewOff();
        off.setX(0);
        off.setY(0);
        CTPresetGeometry2D prstGeom = sppr.addNewPrstGeom();
        prstGeom.setPrst(STShapeType.RECT);
        prstGeom.addNewAvLst();
        prototype = pic;
    }
    return prototype;
}
Also used : CTNonVisualPictureProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties) CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTBlipFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties) CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTPicture(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture) CTPictureNonVisual(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPictureNonVisual) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)

Example 4 with CTPresetGeometry2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D in project poi by apache.

the class TestXSLFSimpleShape method testInvalidGeometry.

@Test
public void testInvalidGeometry() throws Exception {
    XMLSlideShow ppt = new XMLSlideShow();
    XSLFSlide slide = ppt.createSlide();
    XSLFSimpleShape shape = slide.createAutoShape();
    CTShapeProperties spPr = getSpPr(shape);
    CTPresetGeometry2D prstGeom = CTPresetGeometry2D.Factory.newInstance();
    prstGeom.setPrst(STShapeType.Enum.forInt(1));
    assertNotNull(prstGeom.getPrst());
    assertNotNull(prstGeom.getPrst().toString());
    assertNotNull(spPr.getPrstGeom());
    spPr.setPrstGeom(prstGeom);
    assertNotNull(spPr.getPrstGeom().getPrst());
    assertNotNull(spPr.getPrstGeom().getPrst().toString());
    try {
        // cause the geometries to be not found
        TestPresetGeometries.clearPreset();
        try {
            shape.getGeometry();
            fail("Should fail without the geometry");
        } catch (IllegalStateException e) {
            assertTrue(e.getMessage(), e.getMessage().contains("line"));
        }
    } finally {
        // reset to not affect other tests
        TestPresetGeometries.resetPreset();
    }
    ppt.close();
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) Test(org.junit.Test)

Example 5 with CTPresetGeometry2D

use of org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D in project poi by apache.

the class TestXSLFSimpleShape method testValidGeometry.

@Test
public void testValidGeometry() throws Exception {
    XMLSlideShow ppt = new XMLSlideShow();
    XSLFSlide slide = ppt.createSlide();
    XSLFSimpleShape shape = slide.createAutoShape();
    CTShapeProperties spPr = getSpPr(shape);
    CTPresetGeometry2D prstGeom = CTPresetGeometry2D.Factory.newInstance();
    prstGeom.setPrst(STShapeType.Enum.forInt(1));
    assertNotNull(prstGeom.getPrst());
    assertNotNull(prstGeom.getPrst().toString());
    assertNotNull(spPr.getPrstGeom());
    spPr.setPrstGeom(prstGeom);
    assertNotNull(spPr.getPrstGeom().getPrst());
    assertNotNull(spPr.getPrstGeom().getPrst().toString());
    assertNotNull(shape.getGeometry());
    ppt.close();
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) Test(org.junit.Test)

Aggregations

CTPresetGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D)10 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)9 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)7 CTPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D)4 CTPositiveSize2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)4 CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)4 CTBlipFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties)3 Test (org.junit.Test)2 CTBlip (org.openxmlformats.schemas.drawingml.x2006.main.CTBlip)2 CTNonVisualPictureProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties)2 CTShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape)2 CTShapeNonVisual (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual)2 StringReader (java.io.StringReader)1 QName (javax.xml.namespace.QName)1 XSLFGeometryProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFGeometryProperties)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlString (org.apache.xmlbeans.XmlString)1 CTFontReference (org.openxmlformats.schemas.drawingml.x2006.main.CTFontReference)1 CTGraphicalObject (org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject)1