use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSSFTextRun method getPitchAndFamily.
public byte getPitchAndFamily() {
CTTextCharacterProperties rPr = getRPr();
CTTextFont font = rPr.getLatin();
if (font != null) {
return font.getPitchFamily();
}
return 0;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class TestXSLFAutoShape method testTextRun.
@Test
public void testTextRun() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
XSLFAutoShape shape = slide.createAutoShape();
assertEquals(0, shape.getTextParagraphs().size());
XSLFTextParagraph p = shape.addNewTextParagraph();
assertEquals(1, shape.getTextParagraphs().size());
assertEquals(0, p.getTextRuns().size());
XSLFTextRun r = p.addNewTextRun();
CTTextCharacterProperties rPr = r.getRPr(false);
assertNotNull(rPr);
assertEquals(1, p.getTextRuns().size());
assertSame(r, p.getTextRuns().get(0));
// default font size for text boxes
assertEquals(18.0, r.getFontSize(), 0);
assertFalse(rPr.isSetSz());
r.setFontSize(10.0);
assertEquals(1000, rPr.getSz());
r.setFontSize(12.5);
assertEquals(1250, rPr.getSz());
r.setFontSize(null);
assertFalse(rPr.isSetSz());
assertFalse(rPr.isSetLatin());
// comes from the slide master
assertEquals("Calibri", r.getFontFamily());
r.setFontFamily(null);
// comes from the slide master
assertEquals("Calibri", r.getFontFamily());
r.setFontFamily("Arial");
assertEquals("Arial", r.getFontFamily());
assertEquals("Arial", rPr.getLatin().getTypeface());
r.setFontFamily("Symbol");
assertEquals("Symbol", r.getFontFamily());
assertEquals("Symbol", rPr.getLatin().getTypeface());
r.setFontFamily(null);
// comes from the slide master
assertEquals("Calibri", r.getFontFamily());
assertFalse(rPr.isSetLatin());
assertFalse(r.isStrikethrough());
assertFalse(rPr.isSetStrike());
r.setStrikethrough(true);
assertTrue(r.isStrikethrough());
assertEquals(STTextStrikeType.SNG_STRIKE, rPr.getStrike());
assertFalse(r.isBold());
assertFalse(rPr.isSetB());
r.setBold(true);
assertTrue(r.isBold());
assertEquals(true, rPr.getB());
assertFalse(r.isItalic());
assertFalse(rPr.isSetI());
r.setItalic(true);
assertTrue(r.isItalic());
assertEquals(true, rPr.getI());
assertFalse(r.isUnderlined());
assertFalse(rPr.isSetU());
r.setUnderlined(true);
assertTrue(r.isUnderlined());
assertEquals(STTextUnderlineType.SNG, rPr.getU());
r.setText("Apache");
assertEquals("Apache", r.getRawText());
r.setText("POI");
assertEquals("POI", r.getRawText());
r.setText(null);
assertNull(r.getRawText());
ppt.close();
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class TestXSSFDrawing method testRichTextFontAndColor.
/**
* ensure that font and color rich text attributes defined in a XSSFRichTextString
* are passed to XSSFSimpleShape.
*
* See Bugzilla 54969.
*/
@Test
public void testRichTextFontAndColor() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFDrawing drawing = sheet.createDrawingPatriarch();
XSSFTextBox shape = drawing.createTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4));
XSSFRichTextString rt = new XSSFRichTextString("Test String");
XSSFFont font = wb.createFont();
font.setColor(new XSSFColor(new Color(0, 128, 128)));
font.setFontName("Arial");
rt.applyFont(font);
shape.setText(rt);
CTTextParagraph pr = shape.getCTShape().getTxBody().getPArray(0);
assertEquals(1, pr.sizeOfRArray());
CTTextCharacterProperties rPr = pr.getRArray(0).getRPr();
assertEquals("Arial", rPr.getLatin().getTypeface());
assertArrayEquals(new byte[] { 0, (byte) 128, (byte) 128 }, rPr.getSolidFill().getSrgbClr().getVal());
checkRewrite(wb);
wb.close();
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties 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.CTTextCharacterProperties 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;
}
Aggregations