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