diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 71e14e005..f7149a972 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,9 @@ + XSLFPowerPointExtractor support for including comment authors with comment text + Converted XSLFPowerPointExtractor to use UserModel for all text extraction + XSLF initial UserModel support for Notes and Comments for Slides 51678 - Extracting text from Bug51524.zip is slow diff --git a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java b/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java index 4614591a2..536a34bfb 100644 --- a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java +++ b/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java @@ -24,6 +24,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage; 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; @@ -31,6 +32,7 @@ import org.apache.poi.xslf.usermodel.XSLFRelation; 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[] { @@ -97,6 +99,7 @@ public class XSLFPowerPointExtractor extends POIXMLTextExtractor { StringBuffer text = new StringBuffer(); XSLFSlide[] slides = slideshow.getSlides(); + XSLFCommentAuthors commentAuthors = slideshow.getCommentAuthors(); for (XSLFSlide slide : slides) { try { @@ -112,11 +115,17 @@ public class XSLFPowerPointExtractor extends POIXMLTextExtractor { // 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"); } } } diff --git a/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java b/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java index 12db51409..8cf2afbe6 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java @@ -112,6 +112,10 @@ public class TestXSLFPowerPointExtractor extends TestCase { // 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 {