Search in sources :

Example 6 with CTShapeProperties

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

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

the class XSSFShape method setFillColor.

@Override
public void setFillColor(int red, int green, int blue) {
    CTShapeProperties props = getShapeProperties();
    CTSolidColorFillProperties fill = props.isSetSolidFill() ? props.getSolidFill() : props.addNewSolidFill();
    CTSRgbColor rgb = CTSRgbColor.Factory.newInstance();
    rgb.setVal(new byte[] { (byte) red, (byte) green, (byte) blue });
    fill.setSrgbClr(rgb);
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Example 8 with CTShapeProperties

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

the class XSSFShape method setLineStyleColor.

@Override
public void setLineStyleColor(int red, int green, int blue) {
    CTShapeProperties props = getShapeProperties();
    CTLineProperties ln = props.isSetLn() ? props.getLn() : props.addNewLn();
    CTSolidColorFillProperties fill = ln.isSetSolidFill() ? ln.getSolidFill() : ln.addNewSolidFill();
    CTSRgbColor rgb = CTSRgbColor.Factory.newInstance();
    rgb.setVal(new byte[] { (byte) red, (byte) green, (byte) blue });
    fill.setSrgbClr(rgb);
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Example 9 with CTShapeProperties

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

the class XSSFShape method setLineWidth.

/**
     * Specifies the width to be used for the underline stroke.
     *
     * @param lineWidth width in points
     */
public void setLineWidth(double lineWidth) {
    CTShapeProperties props = getShapeProperties();
    CTLineProperties ln = props.isSetLn() ? props.getLn() : props.addNewLn();
    ln.setW((int) (lineWidth * EMU_PER_POINT));
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)

Example 10 with CTShapeProperties

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

Aggregations

CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)21 CTPresetGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D)9 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)8 XmlObject (org.apache.xmlbeans.XmlObject)6 CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)5 CTBlipFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties)4 CTLineProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)4 CTPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D)4 CTPositiveSize2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)4 AffineTransform (java.awt.geom.AffineTransform)2 Rectangle2D (java.awt.geom.Rectangle2D)2 Test (org.junit.Test)2 CTAdjPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTAdjPoint2D)2 CTBlip (org.openxmlformats.schemas.drawingml.x2006.main.CTBlip)2 CTCustomGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTCustomGeometry2D)2 CTNonVisualPictureProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties)2 CTPath2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPath2D)2 CTPath2DCubicBezierTo (org.openxmlformats.schemas.drawingml.x2006.main.CTPath2DCubicBezierTo)2 CTPath2DQuadBezierTo (org.openxmlformats.schemas.drawingml.x2006.main.CTPath2DQuadBezierTo)2 CTSRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)2