Search in sources :

Example 1 with NumId

use of org.docx4j.wml.PPrBase.NumPr.NumId in project mdw-designer by CenturyLinkCloud.

the class DocxBuilder method createBulletListNumPr.

public NumPr createBulletListNumPr() {
    ObjectFactory factory = Context.getWmlObjectFactory();
    NumPr numPr = factory.createPPrBaseNumPr();
    Ilvl ilvlElement = factory.createPPrBaseNumPrIlvl();
    numPr.setIlvl(ilvlElement);
    ilvlElement.setVal(BigInteger.valueOf(0));
    NumId numIdElement = factory.createPPrBaseNumPrNumId();
    numPr.setNumId(numIdElement);
    numIdElement.setVal(bulletNumId);
    return numPr;
}
Also used : NumId(org.docx4j.wml.PPrBase.NumPr.NumId) ObjectFactory(org.docx4j.wml.ObjectFactory) NumPr(org.docx4j.wml.PPrBase.NumPr) Ilvl(org.docx4j.wml.PPrBase.NumPr.Ilvl)

Example 2 with NumId

use of org.docx4j.wml.PPrBase.NumPr.NumId in project mdw-designer by CenturyLinkCloud.

the class DocxBuilder method addNumberedList.

public void addNumberedList(List<String> list) throws Exception {
    if (numberingNum == null) {
        numberingNum = getNdp().addAbstractListNumberingDefinition((Numbering.AbstractNum) XmlUtils.unmarshalString(getFragment("numbering")));
        numberingNumId = numberingNum.getNumId();
    } else {
        numberingNumId = BigInteger.valueOf(ndp.restart(numberingNumId.longValue(), 0, 1));
    }
    for (String item : list) {
        ObjectFactory factory = Context.getWmlObjectFactory();
        P listP = factory.createP();
        Text t = factory.createText();
        t.setValue(item);
        R listRun = factory.createR();
        listRun.getContent().add(t);
        listP.getContent().add(listRun);
        PPr listPpr = factory.createPPr();
        listP.setPPr(listPpr);
        // create and add <w:numPr>
        NumPr numPr = factory.createPPrBaseNumPr();
        listPpr.setNumPr(numPr);
        // the <w:ilvl> element
        Ilvl ilvlElement = factory.createPPrBaseNumPrIlvl();
        numPr.setIlvl(ilvlElement);
        ilvlElement.setVal(BigInteger.valueOf(0));
        // The <w:numId> element
        NumId numIdElement = factory.createPPrBaseNumPrNumId();
        numPr.setNumId(numIdElement);
        numIdElement.setVal(numberingNumId);
        getMdp().addObject(listP);
    }
}
Also used : P(org.docx4j.wml.P) NumId(org.docx4j.wml.PPrBase.NumPr.NumId) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) ObjectFactory(org.docx4j.wml.ObjectFactory) NumPr(org.docx4j.wml.PPrBase.NumPr) Text(org.docx4j.wml.Text) Ilvl(org.docx4j.wml.PPrBase.NumPr.Ilvl)

Aggregations

ObjectFactory (org.docx4j.wml.ObjectFactory)2 NumPr (org.docx4j.wml.PPrBase.NumPr)2 Ilvl (org.docx4j.wml.PPrBase.NumPr.Ilvl)2 NumId (org.docx4j.wml.PPrBase.NumPr.NumId)2 P (org.docx4j.wml.P)1 PPr (org.docx4j.wml.PPr)1 R (org.docx4j.wml.R)1 Text (org.docx4j.wml.Text)1