Search in sources :

Example 6 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setSmallCaps.

public void setSmallCaps(boolean value) {
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTOnOff caps = pr.isSetSmallCaps() ? pr.getSmallCaps() : pr.addNewSmallCaps();
    caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTOnOff(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff)

Example 7 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setBold.

/**
     * Whether the bold property shall be applied to all non-complex script
     * characters in the contents of this run when displayed in a document.
     * <p>
     * This formatting property is a toggle property, which specifies that its
     * behavior differs between its use within a style definition and its use as
     * direct formatting. When used as part of a style definition, setting this
     * property shall toggle the current state of that property as specified up
     * to this point in the hierarchy (i.e. applied to not applied, and vice
     * versa). Setting it to <code>false</code> (or an equivalent) shall
     * result in the current setting remaining unchanged. However, when used as
     * direct formatting, setting this property to true or false shall set the
     * absolute state of the resulting property.
     * </p>
     * <p>
     * If this element is not present, the default value is to leave the
     * formatting applied at previous level in the style hierarchy. If this
     * element is never applied in the style hierarchy, then bold shall not be
     * applied to non-complex script characters.
     * </p>
     *
     * @param value <code>true</code> if the bold property is applied to
     *              this run
     */
public void setBold(boolean value) {
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTOnOff bold = pr.isSetB() ? pr.getB() : pr.addNewB();
    bold.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTOnOff(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff)

Example 8 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setSubscript.

/**
     * Specifies the alignment which shall be applied to the contents of this
     * run in relation to the default appearance of the run's text. This allows
     * the text to be repositioned as subscript or superscript without altering
     * the font size of the run properties.
     * <p/>
     * If this element is not present, the default value is to leave the
     * formatting applied at previous level in the style hierarchy. If this
     * element is never applied in the style hierarchy, then the text shall not
     * be subscript or superscript relative to the default baseline location for
     * the contents of this run.
     * </p>
     *
     * @param valign
     * @see VerticalAlign
     */
public void setSubscript(VerticalAlign valign) {
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTVerticalAlignRun ctValign = pr.isSetVertAlign() ? pr.getVertAlign() : pr.addNewVertAlign();
    ctValign.setVal(STVerticalAlignRun.Enum.forInt(valign.getValue()));
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTVerticalAlignRun(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalAlignRun)

Example 9 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method getFontFamily.

/**
     * Gets the font family for the specified font char range.
     * If fcr is null, the font char range "ascii" is used
     *
     * @param fcr the font char range, defaults to "ansi"
     * @return a string representing the font famil
     */
public String getFontFamily(FontCharRange fcr) {
    CTRPr pr = run.getRPr();
    if (pr == null || !pr.isSetRFonts())
        return null;
    CTFonts fonts = pr.getRFonts();
    switch(fcr == null ? FontCharRange.ascii : fcr) {
        default:
        case ascii:
            return fonts.getAscii();
        case cs:
            return fonts.getCs();
        case eastAsia:
            return fonts.getEastAsia();
        case hAnsi:
            return fonts.getHAnsi();
    }
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTFonts(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts)

Example 10 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setFontSize.

/**
     * Specifies the font size which shall be applied to all non complex script
     * characters in the contents of this run when displayed.
     * <p/>
     * If this element is not present, the default value is to leave the value
     * applied at previous level in the style hierarchy. If this element is
     * never applied in the style hierarchy, then any appropriate font size may
     * be used for non complex script characters.
     * </p>
     *
     * @param size
     */
public void setFontSize(int size) {
    BigInteger bint = new BigInteger("" + size);
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz();
    ctSize.setVal(bint.multiply(new BigInteger("2")));
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) BigInteger(java.math.BigInteger) CTHpsMeasure(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure)

Aggregations

CTRPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr)31 CTOnOff (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff)10 Test (org.junit.Test)9 BigInteger (java.math.BigInteger)4 CTFonts (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts)3 CTColor (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor)2 CTHpsMeasure (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure)2 CTR (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR)2 CTLock (com.microsoft.schemas.office.office.CTLock)1 CTFormulas (com.microsoft.schemas.vml.CTFormulas)1 CTGroup (com.microsoft.schemas.vml.CTGroup)1 CTH (com.microsoft.schemas.vml.CTH)1 CTHandles (com.microsoft.schemas.vml.CTHandles)1 CTPath (com.microsoft.schemas.vml.CTPath)1 CTShape (com.microsoft.schemas.vml.CTShape)1 CTShapetype (com.microsoft.schemas.vml.CTShapetype)1 CTTextPath (com.microsoft.schemas.vml.CTTextPath)1 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)1 XmlString (org.apache.xmlbeans.XmlString)1 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)1