use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextParagraph method clearButKeepProperties.
/**
* Helper method for appending text and keeping paragraph and character properties.
* The character properties are moved to the end paragraph marker
*/
/* package */
void clearButKeepProperties() {
CTTextParagraph thisP = getXmlObject();
for (int i = thisP.sizeOfBrArray(); i > 0; i--) {
thisP.removeBr(i - 1);
}
for (int i = thisP.sizeOfFldArray(); i > 0; i--) {
thisP.removeFld(i - 1);
}
if (!_runs.isEmpty()) {
int size = _runs.size();
XSLFTextRun lastRun = _runs.get(size - 1);
CTTextCharacterProperties cpOther = lastRun.getRPr(false);
if (cpOther != null) {
if (thisP.isSetEndParaRPr()) {
thisP.unsetEndParaRPr();
}
CTTextCharacterProperties cp = thisP.addNewEndParaRPr();
cp.set(cpOther);
}
for (int i = size; i > 0; i--) {
thisP.removeR(i - 1);
}
_runs.clear();
}
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextRun method setFontColor.
@Override
public void setFontColor(PaintStyle color) {
if (!(color instanceof SolidPaint)) {
throw new IllegalArgumentException("Currently only SolidPaint is supported!");
}
SolidPaint sp = (SolidPaint) color;
Color c = DrawPaint.applyColorTransform(sp.getSolidColor());
CTTextCharacterProperties rPr = getRPr(true);
CTSolidColorFillProperties fill = rPr.isSetSolidFill() ? rPr.getSolidFill() : rPr.addNewSolidFill();
XSLFColor col = new XSLFColor(fill, getParentParagraph().getParentShape().getSheet().getTheme(), fill.getSchemeClr());
col.setColor(c);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextRun method getFontSize.
@Override
public Double getFontSize() {
double scale = 1;
CTTextNormalAutofit afit = getParentParagraph().getParentShape().getTextBodyPr().getNormAutofit();
if (afit != null)
scale = (double) afit.getFontScale() / 100000;
CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()) {
public boolean fetch(CTTextCharacterProperties props) {
if (props != null && props.isSetSz()) {
setValue(props.getSz() * 0.01);
return true;
}
return false;
}
};
fetchCharacterProperty(fetcher);
return fetcher.getValue() == null ? null : fetcher.getValue() * scale;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextRun method getFontFamily.
@Override
public String getFontFamily() {
final XSLFTheme theme = _p.getParentShape().getSheet().getTheme();
CharacterPropertyFetcher<String> visitor = new CharacterPropertyFetcher<String>(_p.getIndentLevel()) {
public boolean fetch(CTTextCharacterProperties props) {
if (props != null) {
CTTextFont font = props.getLatin();
if (font != null) {
String typeface = font.getTypeface();
if ("+mj-lt".equals(typeface)) {
typeface = theme.getMajorFont();
} else if ("+mn-lt".equals(typeface)) {
typeface = theme.getMinorFont();
}
setValue(typeface);
return true;
}
}
return false;
}
};
fetchCharacterProperty(visitor);
return visitor.getValue();
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties in project poi by apache.
the class XSLFTextRun method getHyperlink.
@Override
public XSLFHyperlink getHyperlink() {
CTTextCharacterProperties rPr = getRPr(false);
if (rPr == null) {
return null;
}
CTHyperlink hl = rPr.getHlinkClick();
if (hl == null) {
return null;
}
return new XSLFHyperlink(hl, _p.getParentShape().getSheet());
}
Aggregations