Search in sources :

Example 1 with CTTextFont

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

the class XSLFTextParagraph method setBulletFont.

public void setBulletFont(String typeface) {
    CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
    CTTextFont font = pr.isSetBuFont() ? pr.getBuFont() : pr.addNewBuFont();
    font.setTypeface(typeface);
}
Also used : CTTextFont(org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)

Example 2 with CTTextFont

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

Example 3 with CTTextFont

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

the class XSLFTextRun method setFontFamily.

public void setFontFamily(String typeface, byte charset, byte pictAndFamily, boolean isSymbol) {
    CTTextCharacterProperties rPr = getRPr(true);
    if (typeface == null) {
        if (rPr.isSetLatin())
            rPr.unsetLatin();
        if (rPr.isSetCs())
            rPr.unsetCs();
        if (rPr.isSetSym())
            rPr.unsetSym();
    } else {
        if (isSymbol) {
            CTTextFont font = rPr.isSetSym() ? rPr.getSym() : rPr.addNewSym();
            font.setTypeface(typeface);
        } else {
            CTTextFont latin = rPr.isSetLatin() ? rPr.getLatin() : rPr.addNewLatin();
            latin.setTypeface(typeface);
            if (charset != -1)
                latin.setCharset(charset);
            if (pictAndFamily != -1)
                latin.setPitchFamily(pictAndFamily);
        }
    }
}
Also used : CTTextFont(org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)

Example 4 with CTTextFont

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

the class XSSFTextRun method getPitchAndFamily.

public byte getPitchAndFamily() {
    CTTextCharacterProperties rPr = getRPr();
    CTTextFont font = rPr.getLatin();
    if (font != null) {
        return font.getPitchFamily();
    }
    return 0;
}
Also used : CTTextFont(org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)

Example 5 with CTTextFont

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

Aggregations

CTTextFont (org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont)7 CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)6 CharacterPropertyFetcher (org.apache.poi.xslf.model.CharacterPropertyFetcher)2 CTTextParagraphProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)1