Search in sources :

Example 1 with CTTextNormalAutofit

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit 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;
}
Also used : CharacterPropertyFetcher(org.apache.poi.xslf.model.CharacterPropertyFetcher) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) CTTextNormalAutofit(org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit)

Example 2 with CTTextNormalAutofit

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit 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;
}
Also used : ParagraphPropertyFetcher(org.apache.poi.xslf.model.ParagraphPropertyFetcher) CTTextSpacing(org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing) CTTextNormalAutofit(org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)

Example 3 with CTTextNormalAutofit

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit in project poi by apache.

the class XSSFTextRun method getFontSize.

/**
     * @return font size in points or -1 if font size is not set.
     */
public double getFontSize() {
    double scale = 1;
    // default font size
    double size = XSSFFont.DEFAULT_FONT_SIZE;
    CTTextNormalAutofit afit = getParentParagraph().getParentShape().getTxBody().getBodyPr().getNormAutofit();
    if (afit != null)
        scale = (double) afit.getFontScale() / 100000;
    CTTextCharacterProperties rPr = getRPr();
    if (rPr.isSetSz()) {
        size = rPr.getSz() * 0.01;
    }
    return size * scale;
}
Also used : CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) CTTextNormalAutofit(org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit)

Aggregations

CTTextNormalAutofit (org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit)3 CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)2 CharacterPropertyFetcher (org.apache.poi.xslf.model.CharacterPropertyFetcher)1 ParagraphPropertyFetcher (org.apache.poi.xslf.model.ParagraphPropertyFetcher)1 CTTextParagraphProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)1 CTTextSpacing (org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing)1