use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextParagraph method addLineBreak.
/**
* Insert a line break
*
* @return text run representing this line break ('\n')
*/
public XSLFTextRun addLineBreak() {
XSLFLineBreak run = new XSLFLineBreak(_p.addNewBr(), this);
CTTextCharacterProperties brProps = run.getRPr(true);
if (_runs.size() > 0) {
// by default line break has the font size of the last text run
CTTextCharacterProperties prevRun = _runs.get(_runs.size() - 1).getRPr(true);
brProps.set(prevRun);
}
_runs.add(run);
return run;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextParagraph method addNewTextRun.
/**
* Add a new run of text
*
* @return a new run of text
*/
public XSLFTextRun addNewTextRun() {
CTRegularTextRun r = _p.addNewR();
CTTextCharacterProperties rPr = r.addNewRPr();
rPr.setLang("en-US");
XSLFTextRun run = newTextRun(r);
_runs.add(run);
return run;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextRun method setFontFamily.
public void setFontFamily(String typeface, byte charset, byte pictAndFamily, boolean isSymbol) {
CTTextCharacterProperties rPr = getRPr(true);
if (typeface == null) {
if (rPr.isSetLatin())
rPr.unsetLatin();
if (rPr.isSetCs())
rPr.unsetCs();
if (rPr.isSetSym())
rPr.unsetSym();
} else {
if (isSymbol) {
CTTextFont font = rPr.isSetSym() ? rPr.getSym() : rPr.addNewSym();
font.setTypeface(typeface);
} else {
CTTextFont latin = rPr.isSetLatin() ? rPr.getLatin() : rPr.addNewLatin();
latin.setTypeface(typeface);
if (charset != -1)
latin.setCharset(charset);
if (pictAndFamily != -1)
latin.setPitchFamily(pictAndFamily);
}
}
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSSFTextRun method getFontColor.
public Color getFontColor() {
CTTextCharacterProperties rPr = getRPr();
if (rPr.isSetSolidFill()) {
CTSolidColorFillProperties fill = rPr.getSolidFill();
if (fill.isSetSrgbClr()) {
CTSRgbColor clr = fill.getSrgbClr();
byte[] rgb = clr.getVal();
return new Color(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2]);
}
}
return new Color(0, 0, 0);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSSFTextRun method setFontColor.
public void setFontColor(Color color) {
CTTextCharacterProperties rPr = getRPr();
CTSolidColorFillProperties fill = rPr.isSetSolidFill() ? rPr.getSolidFill() : rPr.addNewSolidFill();
CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr();
clr.setVal(new byte[] { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() });
if (fill.isSetHslClr())
fill.unsetHslClr();
if (fill.isSetPrstClr())
fill.unsetPrstClr();
if (fill.isSetSchemeClr())
fill.unsetSchemeClr();
if (fill.isSetScrgbClr())
fill.unsetScrgbClr();
if (fill.isSetSysClr())
fill.unsetSysClr();
}
Aggregations