Search in sources :

Example 1 with CTJc

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

the class TestXWPFParagraph method testSetGetAlignment.

@Test
public void testSetGetAlignment() throws IOException {
    //new clean instance of paragraph
    XWPFDocument doc = new XWPFDocument();
    XWPFParagraph p = doc.createParagraph();
    assertEquals(STJc.LEFT.intValue(), p.getAlignment().getValue());
    CTP ctp = p.getCTP();
    CTPPr ppr = ctp.getPPr() == null ? ctp.addNewPPr() : ctp.getPPr();
    CTJc align = ppr.addNewJc();
    align.setVal(STJc.CENTER);
    assertEquals(ParagraphAlignment.CENTER, p.getAlignment());
    p.setAlignment(ParagraphAlignment.BOTH);
    assertEquals(STJc.BOTH, ppr.getJc().getVal());
    doc.close();
}
Also used : CTJc(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc) CTPPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr) CTP(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CTJc (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc)1 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)1 CTPPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr)1