]> source.dussan.org Git - poi.git/commitdiff
Update XSLFPowerPointExtractor to include Comment Authors along with comment text
authorNick Burch <nick@apache.org>
Sun, 4 Sep 2011 21:16:32 +0000 (21:16 +0000)
committerNick Burch <nick@apache.org>
Sun, 4 Sep 2011 21:16:32 +0000 (21:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1165112 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java
src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java

index 71e14e0053c768e83af7873d0a43291d2a5b0151..f7149a972be901801aef38952c2c30d3f56b8ed2 100644 (file)
@@ -34,6 +34,9 @@
 
     <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>
index 4614591a2d197f6a15fb2e4ab75aa14dbc71fb3d..536a34bfbe393290ece88a7f88fc4a8cd32245b1 100644 (file)
@@ -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");
                   }
                }
             }
index 12db5140999d9107cec7ca466f809ed786d90449..8cf2afbe6dd111d03e1bdde2d00e5ffb502d30bf 100644 (file)
@@ -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 {