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