1
我想查找列表段落(以。开头),并将另一个列表项添加到此列表(取决于第一个列表元素的文本)。 我已经尝试过很多创建新段落的方法,但是我所取得的所有成果都是创建了新的列表元素,但org.docx4j.wml.Text
对象被追加到段落的后面,新段落被追加。新的段落文本是空的。如何可以创建新的列表元素并将其添加到正确的元素?如何将新列表项添加到列表中
- a。列表元素1 | test | // |考试|应附加到b。
- b。 //创建新项目,但没有文字
- c。
//traverse through a document public List<Object> apply(Object obj) { if (obj instanceof org.docx4j.wml.P) { if (p.getPPr() != null) { if (p.getPPr().getPStyle() != null) { if ((p.getPPr().getPStyle().getVal().equals("Akapitzlist"))) { //there is a list paragraph ObjectFactory factory = Context.getWmlObjectFactory(); Object deepCopy = XmlUtils.deepCopy(obj); //Create the paragraph org.docx4j.wml.P para = factory.createP(); // Create the text element org.docx4j.wml.Text t = factory.createText(); t.setValue("|test|"); // Create the run org.docx4j.wml.R run = factory.createR(); run.getContent().add(t); para.getContent().add(run); //add new paragraph to the document ((org.docx4j.wml.P) obj).getContent().add(para); }...}