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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations