use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties in project poi by apache.
the class XSLFTextShape method getTextBodyPr.
protected CTTextBodyProperties getTextBodyPr(boolean create) {
CTTextBody textBody = getTextBody(create);
if (textBody == null) {
return null;
}
CTTextBodyProperties textBodyPr = textBody.getBodyPr();
if (textBodyPr == null && create) {
textBodyPr = textBody.addNewBodyPr();
}
return textBodyPr;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties in project poi by apache.
the class XSLFAutoShape method initTextBody.
protected static void initTextBody(CTTextBody txBody) {
CTTextBodyProperties bodypr = txBody.addNewBodyPr();
bodypr.setAnchor(STTextAnchoringType.T);
bodypr.setRtlCol(false);
CTTextParagraph p = txBody.addNewP();
p.addNewPPr().setAlgn(STTextAlignType.L);
CTTextCharacterProperties endPr = p.addNewEndParaRPr();
endPr.setLang("en-US");
endPr.setSz(1100);
p.addNewR().setT("");
txBody.addNewLstStyle();
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties in project poi by apache.
the class XSSFSimpleShape method prototype.
/**
* Prototype with the default structure of a new auto-shape.
*/
protected static CTShape prototype() {
if (prototype == null) {
CTShape shape = CTShape.Factory.newInstance();
CTShapeNonVisual nv = shape.addNewNvSpPr();
CTNonVisualDrawingProps nvp = nv.addNewCNvPr();
nvp.setId(1);
nvp.setName("Shape 1");
nv.addNewCNvSpPr();
CTShapeProperties sp = shape.addNewSpPr();
CTTransform2D t2d = sp.addNewXfrm();
CTPositiveSize2D p1 = t2d.addNewExt();
p1.setCx(0);
p1.setCy(0);
CTPoint2D p2 = t2d.addNewOff();
p2.setX(0);
p2.setY(0);
CTPresetGeometry2D geom = sp.addNewPrstGeom();
geom.setPrst(STShapeType.RECT);
geom.addNewAvLst();
CTTextBody body = shape.addNewTxBody();
CTTextBodyProperties bodypr = body.addNewBodyPr();
bodypr.setAnchor(STTextAnchoringType.T);
bodypr.setRtlCol(false);
CTTextParagraph p = body.addNewP();
p.addNewPPr().setAlgn(STTextAlignType.L);
CTTextCharacterProperties endPr = p.addNewEndParaRPr();
endPr.setLang("en-US");
endPr.setSz(1100);
CTSolidColorFillProperties scfpr = endPr.addNewSolidFill();
scfpr.addNewSrgbClr().setVal(new byte[] { 0, 0, 0 });
body.addNewLstStyle();
prototype = shape;
}
return prototype;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties in project poi by apache.
the class TestXSLFTextShape method verifySlide4.
void verifySlide4(XSLFSlide slide) {
XSLFSlideLayout layout = slide.getSlideLayout();
List<XSLFShape> shapes = slide.getShapes();
assertEquals("Two Content", layout.getName());
XSLFTextShape shape1 = (XSLFTextShape) shapes.get(0);
CTPlaceholder ph1 = shape1.getCTPlaceholder();
assertEquals(STPlaceholderType.TITLE, ph1.getType());
// anchor is not defined in the shape
assertNull(getSpPr(shape1).getXfrm());
XSLFTextShape masterShape1 = (XSLFTextShape) layout.getPlaceholder(ph1);
// layout does not have anchor info either, it is in the slide master
assertNull(getSpPr(masterShape1).getXfrm());
masterShape1 = (XSLFTextShape) layout.getSlideMaster().getPlaceholder(ph1);
assertNotNull(getSpPr(masterShape1).getXfrm());
assertEquals(masterShape1.getAnchor(), shape1.getAnchor());
CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();
// none of the following properties are set in the shapes and fetched from the master shape
assertTrue(!bodyPr1.isSetLIns() && !bodyPr1.isSetRIns() && !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor());
// 0.1"
assertEquals(7.2, shape1.getLeftInset(), 0);
// 0.1"
assertEquals(7.2, shape1.getRightInset(), 0);
// 0.05"
assertEquals(3.6, shape1.getTopInset(), 0);
// 0.05"
assertEquals(3.6, shape1.getBottomInset(), 0);
assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment());
// now check text properties
assertEquals("Title", shape1.getText());
XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0);
assertEquals(TextAlign.CENTER, r1.getParentParagraph().getTextAlign());
assertEquals("Calibri", r1.getFontFamily());
assertEquals(44.0, r1.getFontSize(), 0);
assertTrue(sameColor(Color.black, r1.getFontColor()));
XSLFTextShape shape2 = (XSLFTextShape) shapes.get(1);
CTPlaceholder ph2 = shape2.getCTPlaceholder();
assertFalse(ph2.isSetType());
assertTrue(ph2.isSetIdx());
//<p:ph sz="half" idx="1"/>
assertEquals(1, ph2.getIdx());
// anchor is not defined in the shape
assertNull(getSpPr(shape2).getXfrm());
XSLFTextShape masterShape2 = (XSLFTextShape) layout.getPlaceholder(ph2);
assertNotNull(getSpPr(masterShape2).getXfrm());
assertEquals(masterShape2.getAnchor(), shape2.getAnchor());
CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr();
// none of the following properties are set in the shapes and fetched from the master shape
assertTrue(!bodyPr2.isSetLIns() && !bodyPr2.isSetRIns() && !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor());
// 0.1"
assertEquals(7.2, shape2.getLeftInset(), 0);
// 0.1"
assertEquals(7.2, shape2.getRightInset(), 0);
// 0.05"
assertEquals(3.6, shape2.getTopInset(), 0);
// 0.05"
assertEquals(3.6, shape2.getBottomInset(), 0);
assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment());
XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0);
assertEquals(0, pr1.getParentParagraph().getIndentLevel());
assertEquals("Left", pr1.getRawText());
assertEquals("Calibri", pr1.getFontFamily());
assertEquals(28.0, pr1.getFontSize(), 0);
assertEquals(27.0, pr1.getParentParagraph().getLeftMargin(), 0);
assertEquals("•", pr1.getParentParagraph().getBulletCharacter());
assertEquals("Arial", pr1.getParentParagraph().getBulletFont());
XSLFTextRun pr2 = shape2.getTextParagraphs().get(1).getTextRuns().get(0);
assertEquals(1, pr2.getParentParagraph().getIndentLevel());
assertEquals("Level 2", pr2.getParentParagraph().getText());
assertEquals("Calibri", pr2.getFontFamily());
assertEquals(24.0, pr2.getFontSize(), 0);
assertEquals(58.5, pr2.getParentParagraph().getLeftMargin(), 0);
assertEquals("–", pr2.getParentParagraph().getBulletCharacter());
assertEquals("Arial", pr2.getParentParagraph().getBulletFont());
XSLFTextRun pr3 = shape2.getTextParagraphs().get(2).getTextRuns().get(0);
assertEquals(2, pr3.getParentParagraph().getIndentLevel());
assertEquals("Level 3", pr3.getParentParagraph().getText());
assertEquals("Calibri", pr3.getFontFamily());
assertEquals(20.0, pr3.getFontSize(), 0);
assertEquals(90.0, pr3.getParentParagraph().getLeftMargin(), 0);
assertEquals("•", pr3.getParentParagraph().getBulletCharacter());
assertEquals("Arial", pr3.getParentParagraph().getBulletFont());
XSLFTextRun pr4 = shape2.getTextParagraphs().get(3).getTextRuns().get(0);
assertEquals(3, pr4.getParentParagraph().getIndentLevel());
assertEquals("Level 4", pr4.getParentParagraph().getText());
assertEquals("Calibri", pr4.getFontFamily());
assertEquals(18.0, pr4.getFontSize(), 0);
assertEquals(126.0, pr4.getParentParagraph().getLeftMargin(), 0);
assertEquals("–", pr4.getParentParagraph().getBulletCharacter());
assertEquals("Arial", pr4.getParentParagraph().getBulletFont());
XSLFTextShape shape3 = (XSLFTextShape) shapes.get(2);
XSLFTextRun pr5 = shape3.getTextParagraphs().get(0).getTextRuns().get(0);
assertEquals(0, pr5.getParentParagraph().getIndentLevel());
assertEquals("Right", pr5.getRawText());
assertEquals("Calibri", pr5.getFontFamily());
assertTrue(sameColor(Color.black, pr5.getFontColor()));
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties in project poi by apache.
the class TestXSLFTextShape method verifySlide7.
void verifySlide7(XSLFSlide slide) {
XSLFSlideLayout layout = slide.getSlideLayout();
List<XSLFShape> shapes = slide.getShapes();
assertEquals("Blank", layout.getName());
XSLFTextShape shape1 = (XSLFTextShape) shapes.get(0);
CTPlaceholder ph1 = shape1.getCTPlaceholder();
assertEquals(STPlaceholderType.TITLE, ph1.getType());
// anchor is not defined in the shape
assertNull(getSpPr(shape1).getXfrm());
CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();
// none of the following properties are set in the shapes and fetched from the master shape
assertTrue(!bodyPr1.isSetLIns() && !bodyPr1.isSetRIns() && !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor());
// 0.1"
assertEquals(7.2, shape1.getLeftInset(), 0);
// 0.1"
assertEquals(7.2, shape1.getRightInset(), 0);
// 0.05"
assertEquals(3.6, shape1.getTopInset(), 0);
// 0.05"
assertEquals(3.6, shape1.getBottomInset(), 0);
assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment());
// now check text properties
assertEquals("Blank with Default Title", shape1.getText());
XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0);
assertEquals(TextAlign.CENTER, r1.getParentParagraph().getTextAlign());
assertEquals("Calibri", r1.getFontFamily());
assertEquals(44.0, r1.getFontSize(), 0);
assertTrue(sameColor(Color.black, r1.getFontColor()));
assertFalse(r1.isBold());
XSLFTextShape shape2 = (XSLFTextShape) shapes.get(1);
CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr();
// none of the following properties are set in the shapes and fetched from the master shape
assertTrue(!bodyPr2.isSetLIns() && !bodyPr2.isSetRIns() && !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor());
// 0.1"
assertEquals(7.2, shape2.getLeftInset(), 0);
// 0.1"
assertEquals(7.2, shape2.getRightInset(), 0);
// 0.05"
assertEquals(3.6, shape2.getTopInset(), 0);
// 0.05"
assertEquals(3.6, shape2.getBottomInset(), 0);
assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment());
XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0);
assertEquals(0, pr1.getParentParagraph().getIndentLevel());
assertEquals("Default Text", pr1.getRawText());
assertEquals("Calibri", pr1.getFontFamily());
assertEquals(18.0, pr1.getFontSize(), 0);
XSLFTextShape shape3 = (XSLFTextShape) shapes.get(2);
assertEquals("Default", shape3.getTextParagraphs().get(0).getText());
assertEquals("Text with levels", shape3.getTextParagraphs().get(1).getText());
assertEquals("Level 1", shape3.getTextParagraphs().get(2).getText());
assertEquals("Level 2", shape3.getTextParagraphs().get(3).getText());
assertEquals("Level 3", shape3.getTextParagraphs().get(4).getText());
for (int p = 0; p < 5; p++) {
XSLFTextParagraph pr = shape3.getTextParagraphs().get(p);
assertEquals("Calibri", pr.getTextRuns().get(0).getFontFamily());
assertEquals(18.0, pr.getTextRuns().get(0).getFontSize(), 0);
}
}
Aggregations