Search in sources :

Example 6 with CTTextCharacterProperties

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

the class XSLFTextParagraph method addLineBreak.

/**
     * Insert a line break
     *
     * @return text run representing this line break ('\n')
     */
public XSLFTextRun addLineBreak() {
    XSLFLineBreak run = new XSLFLineBreak(_p.addNewBr(), this);
    CTTextCharacterProperties brProps = run.getRPr(true);
    if (_runs.size() > 0) {
        // by default line break has the font size of the last text run
        CTTextCharacterProperties prevRun = _runs.get(_runs.size() - 1).getRPr(true);
        brProps.set(prevRun);
    }
    _runs.add(run);
    return run;
}
Also used : CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)

Example 7 with CTTextCharacterProperties

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

the class XSLFTextParagraph method addNewTextRun.

/**
     * Add a new run of text
     *
     * @return a new run of text
     */
public XSLFTextRun addNewTextRun() {
    CTRegularTextRun r = _p.addNewR();
    CTTextCharacterProperties rPr = r.addNewRPr();
    rPr.setLang("en-US");
    XSLFTextRun run = newTextRun(r);
    _runs.add(run);
    return run;
}
Also used : CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) CTRegularTextRun(org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun)

Example 8 with CTTextCharacterProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties 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 9 with CTTextCharacterProperties

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

the class XSSFTextRun method getFontColor.

public Color getFontColor() {
    CTTextCharacterProperties rPr = getRPr();
    if (rPr.isSetSolidFill()) {
        CTSolidColorFillProperties fill = rPr.getSolidFill();
        if (fill.isSetSrgbClr()) {
            CTSRgbColor clr = fill.getSrgbClr();
            byte[] rgb = clr.getVal();
            return new Color(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2]);
        }
    }
    return new Color(0, 0, 0);
}
Also used : CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) Color(java.awt.Color) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Example 10 with CTTextCharacterProperties

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

the class XSSFTextRun method setFontColor.

public void setFontColor(Color color) {
    CTTextCharacterProperties rPr = getRPr();
    CTSolidColorFillProperties fill = rPr.isSetSolidFill() ? rPr.getSolidFill() : rPr.addNewSolidFill();
    CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr();
    clr.setVal(new byte[] { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() });
    if (fill.isSetHslClr())
        fill.unsetHslClr();
    if (fill.isSetPrstClr())
        fill.unsetPrstClr();
    if (fill.isSetSchemeClr())
        fill.unsetSchemeClr();
    if (fill.isSetScrgbClr())
        fill.unsetScrgbClr();
    if (fill.isSetSysClr())
        fill.unsetSysClr();
}
Also used : CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Aggregations

CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)28 Test (org.junit.Test)6 CTTextFont (org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont)6 CharacterPropertyFetcher (org.apache.poi.xslf.model.CharacterPropertyFetcher)5 CTTextParagraph (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph)5 CTSolidColorFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties)4 CTTextParagraphProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)4 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)3 Color (java.awt.Color)2 DrawPaint (org.apache.poi.sl.draw.DrawPaint)2 CTSRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)2 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)2 CTTextNormalAutofit (org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit)2 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)1 PaintStyle (org.apache.poi.sl.usermodel.PaintStyle)1 XSLFFillProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CTBlipFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties)1 CTFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTFillProperties)1 CTGradientFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties)1