accept all revisions in a .docx files programmatically in java

Viewed 240

My aim is to accept all revisions for a .docx files using Java. I've already used the apache-poi project to highlight sentences in docx, so I'm not entirely new to that project.

Here is what I've found till now:

public static String getBasicTextFromParagraphWithoutDeletions(XWPFParagraph par) {
  StringBuffer out = new StringBuffer();
  for (IRunElement run : par.getIRuns()) {
      if (run instanceof XWPFRun) {
          XWPFRun xRun = (XWPFRun) run;
          if (xRun.getCTR().getRsidDel() == null) {
              out.append(xRun.toString());
          }
      } else if (run instanceof XWPFSDT) {
          out.append(((XWPFSDT) run).getContent().getText());
      } else {
          out.append(run.toString());
      }
  }

  return out.toString();
}

Does anyone knows if there is a way to accept the revisions in java too?

Thanks.

0 Answers
Related