diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index 989c93db5..2e7e8238d 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -148,6 +148,12 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para // This implementation does not preserve the tagging information buildRunsInOrderFromXml(o); } + if (o instanceof CTRunTrackChange) { + // add all the insertions as text + for (CTRunTrackChange change : ((CTRunTrackChange) o).getInsArray()) { + buildRunsInOrderFromXml(change); + } + } } c.dispose(); } @@ -189,7 +195,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para if (run instanceof XWPFRun) { XWPFRun xRun = (XWPFRun) run; // don't include the text if reviewing is enabled and this is a deleted run - if (!xRun.getCTR().isSetRsidDel()) { + if (xRun.getCTR().getDelTextArray().length == 0) { out.append(xRun); } } else if (run instanceof XWPFSDT) { diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java index 718c73e70..30d9d7ef2 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java @@ -414,7 +414,9 @@ public final class TestXWPFParagraph { //CTMoveBookmarkImpl into ooxml-lite. XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Tika-792.docx"); XWPFParagraph paragraph = doc.getParagraphs().get(0); - assertEquals("s", paragraph.getText()); + assertEquals("", paragraph.getText()); + paragraph = doc.getParagraphs().get(1); + assertEquals("b", paragraph.getText()); doc.close(); } @@ -612,7 +614,19 @@ public final class TestXWPFParagraph { } assertEquals("This is a test.\n\n\n\n3\n4\n5\n\n\n\nThis is a whole paragraph where one word is deleted.\n", str.toString()); } - + + @Test + public void test61787() throws IOException { + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("61787.docx"); + + StringBuilder str = new StringBuilder(); + for(XWPFParagraph par : doc.getParagraphs()) { + str.append(par.getText()).append("\n"); + } + String s = str.toString(); + assertTrue("Having text: \n" + s + "\nTrimmed lenght: " + s.trim().length(), s.trim().length() > 0); + } + /** * Tests for numbered lists * diff --git a/test-data/document/61787.docx b/test-data/document/61787.docx new file mode 100644 index 000000000..0c4c9353c Binary files /dev/null and b/test-data/document/61787.docx differ