public String getText() {
StringBuffer out = new StringBuffer();
for (IRunElement run : iruns) {
- if (run instanceof XWPFSDT) {
+ 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()) {
+ out.append(xRun.toString());
+ }
+ } else if (run instanceof XWPFSDT) {
out.append(((XWPFSDT) run).getContent().getText());
} else {
out.append(run.toString());
assertNull(p.getRun(null));
doc.close();
}
+
+ @Test
+ public void test58067() throws IOException {
+ XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("58067.docx");
+
+ StringBuilder str = new StringBuilder();
+ for(XWPFParagraph par : doc.getParagraphs()) {
+ str.append(par.getText()).append("\n");
+ }
+ 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());
+ }
}