<changes>
<release version="3.8-beta5" date="2011-??-??">
+ <action dev="poi-developers" type="add">XSLFPowerPointExtractor support for including comment authors with comment text</action>
+ <action dev="poi-developers" type="fix">Converted XSLFPowerPointExtractor to use UserModel for all text extraction</action>
+ <action dev="poi-developers" type="add">XSLF initial UserModel support for Notes and Comments for Slides</action>
</release>
<release version="3.8-beta4" date="2011-08-26">
<action dev="poi-developers" type="fix">51678 - Extracting text from Bug51524.zip is slow</action>
import org.apache.poi.xslf.XSLFSlideShow;
import org.apache.poi.xslf.usermodel.DrawingParagraph;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
+import org.apache.poi.xslf.usermodel.XSLFCommentAuthors;
import org.apache.poi.xslf.usermodel.XSLFComments;
import org.apache.poi.xslf.usermodel.XSLFCommonSlideData;
import org.apache.poi.xslf.usermodel.XSLFNotes;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.presentationml.x2006.main.CTComment;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthor;
public class XSLFPowerPointExtractor extends POIXMLTextExtractor {
public static final XSLFRelation[] SUPPORTED_TYPES = new XSLFRelation[] {
StringBuffer text = new StringBuffer();
XSLFSlide[] slides = slideshow.getSlides();
+ XSLFCommentAuthors commentAuthors = slideshow.getCommentAuthors();
for (XSLFSlide slide : slides) {
try {
// If the slide has comments, do those too
if (comments != null) {
for (CTComment comment : comments.getCTCommentsList().getCmList()) {
- // TODO - comment authors too
- // (They're in another stream)
- text.append(
- comment.getText() + "\n"
- );
+ // 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");
}
}
}
// Check comments are there
assertTrue("Unable to find expected word in text\n" + text, text.contains("testdoc"));
+ assertTrue("Unable to find expected word in text\n" + text, text.contains("test phrase"));
+
+ // Check the authors came through too
+ assertTrue("Unable to find expected word in text\n" + text, text.contains("XPVMWARE01"));
}
public void testTable() throws Exception {