1
リスト段落(aで始まる)を見つけて、このリストに別のリスト項目を追加したい(最初のリスト要素のテキストに依存する)。 新しい段落を作成する方法はたくさんありましたが、達成したことは新しいリスト要素を作成することですが、新しい段落が追加された段落には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); }...}