use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method setSpaceBefore.
@Override
public void setSpaceBefore(Double spaceBefore) {
if (spaceBefore == null && !_p.isSetPPr()) {
return;
}
// unset the space before on null input
if (spaceBefore == null) {
if (_p.getPPr().isSetSpcBef()) {
_p.getPPr().unsetSpcBef();
}
return;
}
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
CTTextSpacing spc = CTTextSpacing.Factory.newInstance();
if (spaceBefore >= 0) {
spc.addNewSpcPct().setVal((int) (spaceBefore * 1000));
} else {
spc.addNewSpcPts().setVal((int) (-spaceBefore * 100));
}
pr.setSpcBef(spc);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method fetchParagraphProperty.
private <T> boolean fetchParagraphProperty(ParagraphPropertyFetcher<T> visitor) {
boolean ok = false;
XSLFTextShape shape = getParentShape();
XSLFSheet sheet = shape.getSheet();
if (_p.isSetPPr())
ok = visitor.fetch(_p.getPPr());
if (ok)
return true;
ok = shape.fetchShapeProperty(visitor);
if (ok)
return true;
CTPlaceholder ph = shape.getCTPlaceholder();
if (ph == null) {
// if it is a plain text box then take defaults from presentation.xml
@SuppressWarnings("resource") XMLSlideShow ppt = sheet.getSlideShow();
CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(getIndentLevel());
if (themeProps != null)
ok = visitor.fetch(themeProps);
}
if (ok)
return true;
// defaults for placeholders are defined in the slide master
CTTextParagraphProperties defaultProps = getDefaultMasterStyle();
// TODO: determine master shape
if (defaultProps != null)
ok = visitor.fetch(defaultProps);
if (ok)
return true;
return false;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method getTabStop.
public double getTabStop(final int idx) {
ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()) {
public boolean fetch(CTTextParagraphProperties props) {
if (props.isSetTabLst()) {
CTTextTabStopList tabStops = props.getTabLst();
if (idx < tabStops.sizeOfTabArray()) {
CTTextTabStop ts = tabStops.getTabArray(idx);
double val = Units.toPoints(ts.getPos());
setValue(val);
return true;
}
}
return false;
}
};
fetchParagraphProperty(fetcher);
return fetcher.getValue() == null ? 0. : fetcher.getValue();
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method setBullet.
/**
*
* @param flag whether text in this paragraph has bullets
*/
public void setBullet(boolean flag) {
if (isBullet() == flag)
return;
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
if (flag) {
pr.addNewBuFont().setTypeface("Arial");
pr.addNewBuChar().setChar("•");
} else {
if (pr.isSetBuFont())
pr.unsetBuFont();
if (pr.isSetBuChar())
pr.unsetBuChar();
if (pr.isSetBuAutoNum())
pr.unsetBuAutoNum();
if (pr.isSetBuBlip())
pr.unsetBuBlip();
if (pr.isSetBuClr())
pr.unsetBuClr();
if (pr.isSetBuClrTx())
pr.unsetBuClrTx();
if (pr.isSetBuFont())
pr.unsetBuFont();
if (pr.isSetBuFontTx())
pr.unsetBuFontTx();
if (pr.isSetBuSzPct())
pr.unsetBuSzPct();
if (pr.isSetBuSzPts())
pr.unsetBuSzPts();
if (pr.isSetBuSzTx())
pr.unsetBuSzTx();
pr.addNewBuNone();
}
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.
the class XSLFTextParagraph method getLineSpacing.
@Override
public Double getLineSpacing() {
ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()) {
public boolean fetch(CTTextParagraphProperties props) {
if (props.isSetLnSpc()) {
CTTextSpacing spc = props.getLnSpc();
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);
Double lnSpc = fetcher.getValue();
if (lnSpc != null && lnSpc > 0) {
// check if the percentage value is scaled
CTTextNormalAutofit normAutofit = getParentShape().getTextBodyPr().getNormAutofit();
if (normAutofit != null) {
double scale = 1 - (double) normAutofit.getLnSpcReduction() / 100000;
lnSpc *= scale;
}
}
return lnSpc;
}
Aggregations