Search in sources :

Example 26 with CTRPr

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

the class TestXWPFRun method testSetGetFontSize.

@Test
public void testSetGetFontSize() {
    CTRPr rpr = ctRun.addNewRPr();
    rpr.addNewSz().setVal(new BigInteger("14"));
    XWPFRun run = new XWPFRun(ctRun, irb);
    assertEquals(7, run.getFontSize());
    run.setFontSize(24);
    assertEquals(48, rpr.getSz().getVal().longValue());
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 27 with CTRPr

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

the class TestXWPFRun method testSetGetItalic.

@Test
public void testSetGetItalic() {
    CTRPr rpr = ctRun.addNewRPr();
    rpr.addNewI().setVal(STOnOff.TRUE);
    XWPFRun run = new XWPFRun(ctRun, irb);
    assertEquals(true, run.isItalic());
    run.setItalic(false);
    assertEquals(STOnOff.FALSE, rpr.getI().getVal());
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) Test(org.junit.Test)

Example 28 with CTRPr

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

the class TestXWPFRun method testSetGetBold.

@Test
public void testSetGetBold() {
    CTRPr rpr = ctRun.addNewRPr();
    rpr.addNewB().setVal(STOnOff.TRUE);
    XWPFRun run = new XWPFRun(ctRun, irb);
    assertEquals(true, run.isBold());
    run.setBold(false);
    // Implementation detail: POI natively prefers <w:b w:val="false"/>,
    // but should correctly read val="0" and val="off"
    assertEquals(STOnOff.FALSE, rpr.getB().getVal());
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) Test(org.junit.Test)

Example 29 with CTRPr

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

the class TestXWPFRun method testSetGetTextForegroundBackground.

@Test
public void testSetGetTextForegroundBackground() {
    CTRPr rpr = ctRun.addNewRPr();
    rpr.addNewPosition().setVal(new BigInteger("4000"));
    XWPFRun run = new XWPFRun(ctRun, irb);
    assertEquals(4000, run.getTextPosition());
    run.setTextPosition(2400);
    assertEquals(2400, rpr.getPosition().getVal().longValue());
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 30 with CTRPr

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

the class XWPFRun method setTextPosition.

/**
     * This element specifies the amount by which text shall be raised or
     * lowered for this run in relation to the default baseline of the
     * surrounding non-positioned text. This allows the text to be repositioned
     * without altering the font size of the contents.
     * <p/>
     * If the val attribute is positive, then the parent run shall be raised
     * above the baseline of the surrounding text by the specified number of
     * half-points. If the val attribute is negative, then the parent run shall
     * be lowered below the baseline of the surrounding text by the specified
     * number of half-points.
     * </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 the text shall not
     * be raised or lowered relative to the default baseline location for the
     * contents of this run.
     * </p>
     *
     * @param val
     */
public void setTextPosition(int val) {
    BigInteger bint = new BigInteger("" + val);
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTSignedHpsMeasure position = pr.isSetPosition() ? pr.getPosition() : pr.addNewPosition();
    position.setVal(bint);
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) BigInteger(java.math.BigInteger) CTSignedHpsMeasure(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedHpsMeasure)

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