use of org.apache.poi.xslf.usermodel.XSLFCommentAuthors in project poi by apache.
the class XSLFPowerPointExtractor method getText.
/**
* Gets the requested text from the slide
*
* @param slide the slide to retrieve the text from
* @param slideText Should we retrieve text from slides?
* @param notesText Should we retrieve text from notes?
* @param masterText Should we retrieve text from master slides?
*
* @return the extracted text
*/
public static String getText(XSLFSlide slide, boolean slideText, boolean notesText, boolean masterText) {
StringBuilder text = new StringBuilder();
XSLFCommentAuthors commentAuthors = slide.getSlideShow().getCommentAuthors();
XSLFNotes notes = slide.getNotes();
XSLFComments comments = slide.getComments();
XSLFSlideLayout layout = slide.getSlideLayout();
XSLFSlideMaster master = layout.getSlideMaster();
// Do the slide's text if requested
if (slideText) {
extractText(slide, false, text);
// If requested, get text from the master and it's layout
if (masterText) {
assert (layout != null);
extractText(layout, true, text);
assert (master != null);
extractText(master, true, text);
}
// If the slide has comments, do those too
if (comments != null) {
for (CTComment comment : comments.getCTCommentsList().getCmArray()) {
// Do the author if we can
if (commentAuthors != null) {
CTCommentAuthor author = commentAuthors.getAuthorById(comment.getAuthorId());
if (author != null) {
text.append(author.getName() + ": ");
}
}
// Then the comment text, with a new line afterwards
text.append(comment.getText());
text.append("\n");
}
}
}
// Do the notes if requested
if (notesText && notes != null) {
extractText(notes, false, text);
}
return text.toString();
}
Aggregations