use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method setBulletFontColor.
/**
* Set the color to be used on bullet characters within a given paragraph.
*
* @param color the bullet color
*/
public void setBulletFontColor(PaintStyle color) {
if (!(color instanceof SolidPaint)) {
throw new IllegalArgumentException("Currently XSLF only supports SolidPaint");
}
// TODO: implement setting bullet color to null
SolidPaint sp = (SolidPaint) color;
Color col = DrawPaint.applyColorTransform(sp.getSolidColor());
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
CTColor c = pr.isSetBuClr() ? pr.getBuClr() : pr.addNewBuClr();
CTSRgbColor clr = c.isSetSrgbClr() ? c.getSrgbClr() : c.addNewSrgbClr();
clr.setVal(new byte[] { (byte) col.getRed(), (byte) col.getGreen(), (byte) col.getBlue() });
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method getBulletFontColor.
/**
*
* @return the color of bullet characters within a given paragraph.
* A <code>null</code> value means to use the text font color.
*/
public PaintStyle getBulletFontColor() {
final XSLFTheme theme = getParentShape().getSheet().getTheme();
ParagraphPropertyFetcher<Color> fetcher = new ParagraphPropertyFetcher<Color>(getIndentLevel()) {
public boolean fetch(CTTextParagraphProperties props) {
if (props.isSetBuClr()) {
XSLFColor c = new XSLFColor(props.getBuClr(), theme, null);
setValue(c.getColor());
return true;
}
return false;
}
};
fetchParagraphProperty(fetcher);
Color col = fetcher.getValue();
return (col == null) ? null : DrawPaint.createSolidPaint(col);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method getSpaceAfter.
@Override
public Double getSpaceAfter() {
ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()) {
public boolean fetch(CTTextParagraphProperties props) {
if (props.isSetSpcAft()) {
CTTextSpacing spc = props.getSpcAft();
if (spc.isSetSpcPct())
setValue(spc.getSpcPct().getVal() * 0.001);
else if (spc.isSetSpcPts())
setValue(-spc.getSpcPts().getVal() * 0.01);
return true;
}
return false;
}
};
fetchParagraphProperty(fetcher);
return fetcher.getValue();
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method getDefaultMasterStyle.
/**
* @return master style text paragraph properties, or <code>null</code> if
* there are no master slides or the master slides do not contain a text paragraph
*/
/* package */
CTTextParagraphProperties getDefaultMasterStyle() {
CTPlaceholder ph = _shape.getCTPlaceholder();
String defaultStyleSelector;
switch(ph == null ? -1 : ph.getType().intValue()) {
case STPlaceholderType.INT_TITLE:
case STPlaceholderType.INT_CTR_TITLE:
defaultStyleSelector = "titleStyle";
break;
// no placeholder means plain text box
case -1:
case STPlaceholderType.INT_FTR:
case STPlaceholderType.INT_SLD_NUM:
case STPlaceholderType.INT_DT:
defaultStyleSelector = "otherStyle";
break;
default:
defaultStyleSelector = "bodyStyle";
break;
}
int level = getIndentLevel();
// wind up and find the root master sheet which must be slide master
final String nsPML = "http://schemas.openxmlformats.org/presentationml/2006/main";
final String nsDML = "http://schemas.openxmlformats.org/drawingml/2006/main";
XSLFSheet masterSheet = _shape.getSheet();
for (XSLFSheet m = masterSheet; m != null; m = (XSLFSheet) m.getMasterSheet()) {
masterSheet = m;
XmlObject xo = masterSheet.getXmlObject();
XmlCursor cur = xo.newCursor();
try {
cur.push();
if ((cur.toChild(nsPML, "txStyles") && cur.toChild(nsPML, defaultStyleSelector)) || (cur.pop() && cur.toChild(nsPML, "notesStyle"))) {
while (level >= 0) {
cur.push();
if (cur.toChild(nsDML, "lvl" + (level + 1) + "pPr")) {
return (CTTextParagraphProperties) cur.getObject();
}
cur.pop();
level--;
}
}
} finally {
cur.dispose();
}
}
return null;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method setSpaceAfter.
@Override
public void setSpaceAfter(Double spaceAfter) {
if (spaceAfter == null && !_p.isSetPPr()) {
return;
}
// unset the space before on null input
if (spaceAfter == null) {
if (_p.getPPr().isSetSpcAft()) {
_p.getPPr().unsetSpcAft();
}
return;
}
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
CTTextSpacing spc = CTTextSpacing.Factory.newInstance();
if (spaceAfter >= 0) {
spc.addNewSpcPct().setVal((int) (spaceAfter * 1000));
} else {
spc.addNewSpcPts().setVal((int) (-spaceAfter * 100));
}
pr.setSpcAft(spc);
}
Aggregations