新增段落时的标签问题

你好,我的输入文档:
项目进度计划.docx (21.0 KB)

代码:

Document document = new Document("D:\\xxx\\项目进度计划.docx");
        NodeCollection<Paragraph> childNodes = document.getChildNodes(NodeType.PARAGRAPH, true);
        document.startTrackRevisions("DF ");
        for (Paragraph childNode : childNodes) {
            if (childNode.getParagraphFormat().isHeading()) {
                Paragraph paragraph = new Paragraph(document);
                paragraph.getParagraphFormat().setStyleName("Heading 1");
                paragraph.appendChild(new Run(document, "新增章节"));
                childNode.getParentNode().insertBefore(paragraph, childNode);
                break;
            }
        }
        document.updateListLabels();
        NodeCollection<Paragraph> paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true);
        for (Paragraph paragraph : paragraphs) {
            String text = paragraph.getText();
            if (text.contains("新增章节")) {
                String labelString = paragraph.getListLabel().getLabelString();
                System.out.println(labelString);
            }
        }

labelString 值为空,按理说值应该为 1 才对,请问是为什么呢?

@ouchli 问题在于修订中的段落。感谢您报告此问题。 我们已经在我们的内部问题跟踪系统中打开了以下新工单,并将根据 免费支持政策 中提到的条款提供它们的修复:

Issue ID(s): WORDSNET-27049

如果您需要优先支持以及直接联系我们的付费支持管理团队,您可以获得 付费支持服务

@ouchli 您需要使用 document.setRevisionsView(RevisionsView.FINAL);

document.updateListLabels();
NodeCollection<Paragraph> paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph paragraph : paragraphs) {
    String text = paragraph.getText();
    if (text.contains("新增章节")) {
        document.setRevisionsView(RevisionsView.FINAL);
        String labelString = paragraph.getListLabel().getLabelString();
        System.out.println(labelString);
    }
}

The issues you have found earlier (filed as WORDSNET-27049) have been fixed in this Aspose.Words for Java 24.7 update.