I have a document (attached) including the following XML (simplified here for clarity):
<w:del w:id="1">
<w:r>
<w:rPr>
<w:sz w:val="40"/>
<w:szCs w:val="40"/>
<w:rPrChange w:id="1">
<w:rPr/>
</w:rPrChange>
</w:rPr>
<w:delText>This is another sentence.</w:delText>
</w:r>
<w:r>
<w:delText xml:space="preserve"> </w:delText>
</w:r>
</w:del>
I want to accept the rPrChange
but not any other changes. That is, I would like to end up with
<w:del w:id="1">
<w:r>
<w:rPr/> <!-- or this rPr can be removed entirely, it doesn't matter -->
<w:delText>This is another sentence.</w:delText>
</w:r>
<w:r>
<w:delText xml:space="preserve"> </w:delText>
</w:r>
</w:del>
I attempted to do this with the following snippet:
for (Revision revision : document.getRevisions()) {
if (revision.getRevisionType() == RevisionType.FORMAT_CHANGE) {
formatRevisions.add(revision);
}
}
for (Revision revision : formatRevisions) {
revision.accept();
}
This does not work. Instead, it also accepts the entire next delText
, resulting in:
<w:del w:id="0">
<w:r>
<w:delText xml:space="preserve"> </w:delText>
</w:r>
</w:del>
This is unexpected, especially since Aspose reports that this document has 3 revisions, only one of which is a FORMAT_CHANGE, yet accepting that one revision brings the total to 1. Java, version 21.12.
convert.docx (12.1 KB)
(Filed internally as #4626.)