Search in sources :

Example 6 with Ind

use of org.docx4j.wml.PPrBase.Ind in project Java-Tutorial by gpcodervn.

the class NumberingTest method testUnorderedCssOnUlToIndent.

/**
 * We go to some effort to honour an 'inherited' value.
 */
@Test
public void testUnorderedCssOnUlToIndent() throws Docx4JException {
    this.addNumberingPart(wordMLPackage.getMainDocumentPart());
    this.addStylesPart(wordMLPackage.getMainDocumentPart());
    String xhtml = "<div>" + "<ul style=\"margin-left: 0.5in;\">" + "<li>List item one</li>" + "</ul>" + "</div>";
    // 40px default = 600
    List<Object> results = convert(xhtml, FormattingOption.IGNORE_CLASS);
    wordMLPackage.getMainDocumentPart().getContent().addAll(results);
    System.out.println(XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true));
    System.out.println(XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getNumberingDefinitionsPart().getJaxbElement(), true, true));
    P p = (P) results.get(0);
    // Should be numbered, but not using our predefined list
    assertTrue(p.getPPr().getNumPr() != null);
    assertTrue(p.getPPr().getNumPr().getNumId() != null);
    assertTrue(p.getPPr().getNumPr().getNumId().getVal().intValue() != PREDEFINED_OL_NUMID);
    // TODO this shouldn't be necessary
    wordMLPackage.getMainDocumentPart().getNumberingDefinitionsPart().initialiseMaps();
    Ind ind = wordMLPackage.getMainDocumentPart().getNumberingDefinitionsPart().getInd(p.getPPr().getNumPr());
    // System.out.println(XmlUtils.marshaltoString(ind));
    assertTrue(ind.getLeft().intValue() == 1680);
}
Also used : P(org.docx4j.wml.P) Ind(org.docx4j.wml.PPrBase.Ind) Test(org.junit.Test)

Aggregations

Ind (org.docx4j.wml.PPrBase.Ind)6 P (org.docx4j.wml.P)3 PPr (org.docx4j.wml.PPr)3 BigInteger (java.math.BigInteger)2 Jc (org.docx4j.wml.Jc)2 Test (org.junit.Test)2 CTLongHexNumber (org.docx4j.wml.CTLongHexNumber)1 CTVerticalJc (org.docx4j.wml.CTVerticalJc)1 Lvl (org.docx4j.wml.Lvl)1 NumFmt (org.docx4j.wml.NumFmt)1 Numbering (org.docx4j.wml.Numbering)1 PPrBase (org.docx4j.wml.PPrBase)1 RFonts (org.docx4j.wml.RFonts)1 RPr (org.docx4j.wml.RPr)1 STVerticalJc (org.docx4j.wml.STVerticalJc)1 Ignore (org.junit.Ignore)1