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;
}
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);
}
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);
}
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));
}
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();
}
Aggregations