use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing 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.CTTextSpacing 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);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing 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.CTTextSpacing 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;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing in project poi by apache.
the class XSLFTextParagraph method getSpaceBefore.
@Override
public Double getSpaceBefore() {
ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()) {
public boolean fetch(CTTextParagraphProperties props) {
if (props.isSetSpcBef()) {
CTTextSpacing spc = props.getSpcBef();
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();
}
Aggregations