use of org.apache.poi.xslf.model.CharacterPropertyFetcher 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.apache.poi.xslf.model.CharacterPropertyFetcher 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.apache.poi.xslf.model.CharacterPropertyFetcher in project poi by apache.
the class XSLFTextRun method getFontColor.
@Override
public PaintStyle getFontColor() {
final boolean hasPlaceholder = getParentParagraph().getParentShape().getPlaceholder() != null;
CharacterPropertyFetcher<PaintStyle> fetcher = new CharacterPropertyFetcher<PaintStyle>(_p.getIndentLevel()) {
public boolean fetch(CTTextCharacterProperties props) {
if (props == null) {
return false;
}
XSLFShape shape = _p.getParentShape();
CTShapeStyle style = shape.getSpStyle();
CTSchemeColor phClr = null;
if (style != null && style.getFontRef() != null) {
phClr = style.getFontRef().getSchemeClr();
}
XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);
XSLFSheet sheet = shape.getSheet();
PackagePart pp = sheet.getPackagePart();
XSLFTheme theme = sheet.getTheme();
PaintStyle ps = XSLFShape.selectPaint(fp, phClr, pp, theme, hasPlaceholder);
if (ps != null) {
setValue(ps);
return true;
}
return false;
}
};
fetchCharacterProperty(fetcher);
return fetcher.getValue();
}
use of org.apache.poi.xslf.model.CharacterPropertyFetcher in project poi by apache.
the class XSLFTextRun method getTextCap.
/**
* @return whether a run of text will be formatted as a superscript text. Default is false.
*/
public TextCap getTextCap() {
CharacterPropertyFetcher<TextCap> fetcher = new CharacterPropertyFetcher<TextCap>(_p.getIndentLevel()) {
public boolean fetch(CTTextCharacterProperties props) {
if (props != null && props.isSetCap()) {
int idx = props.getCap().intValue() - 1;
setValue(TextCap.values()[idx]);
return true;
}
return false;
}
};
fetchCharacterProperty(fetcher);
return fetcher.getValue() == null ? TextCap.NONE : fetcher.getValue();
}
use of org.apache.poi.xslf.model.CharacterPropertyFetcher in project poi by apache.
the class XSLFTextRun method getPitchAndFamily.
public byte getPitchAndFamily() {
// final XSLFTheme theme = _p.getParentShape().getSheet().getTheme();
CharacterPropertyFetcher<Byte> visitor = new CharacterPropertyFetcher<Byte>(_p.getIndentLevel()) {
public boolean fetch(CTTextCharacterProperties props) {
if (props != null) {
CTTextFont font = props.getLatin();
if (font != null) {
setValue(font.getPitchFamily());
return true;
}
}
return false;
}
};
fetchCharacterProperty(visitor);
return visitor.getValue() == null ? 0 : visitor.getValue();
}
Aggregations