]> source.dussan.org Git - poi.git/commitdiff
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-63924...
authorNick Burch <nick@apache.org>
Tue, 5 Aug 2008 17:06:49 +0000 (17:06 +0000)
committerNick Burch <nick@apache.org>
Tue, 5 Aug 2008 17:06:49 +0000 (17:06 +0000)
https://svn.apache.org/repos/asf/poi/trunk

........
  r682778 | nick | 2008-08-05 17:33:07 +0100 (Tue, 05 Aug 2008) | 1 line

  Start on bug #45537 - headers and footers from ppt
........

git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@682793 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Footer.ppt [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Header.ppt [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hslf/extractor/TextExtractor.java

index 9dddb700bd467f00562aea6d1a23ea2a1e6ebda4..95900a45efa4b495c58bb39f4ee7942dc44cd62b 100644 (file)
@@ -175,6 +175,12 @@ public class PowerPointExtractor extends POIOLE2TextExtractor
        if(getSlideText) {
                for(int i=0; i<_slides.length; i++) {
                        Slide slide = _slides[i];
+                       
+                       HeadersFooters hf = slide.getHeadersFooters();
+                       if(hf != null && hf.getHeaderText() != null) {
+                               ret.append(hf.getHeaderText() + "\n");
+                       }
+                       
                        TextRun[] runs = slide.getTextRuns();
                        for(int j=0; j<runs.length; j++) {
                                TextRun run = runs[j];
@@ -187,6 +193,10 @@ public class PowerPointExtractor extends POIOLE2TextExtractor
                                }
                        }
                        
+                       if(hf != null && hf.getFooterText() != null) {
+                               ret.append(hf.getFooterText() + "\n");
+                       }
+                       
                        if(getCommentText) {
                                Comment[] comments = slide.getComments();
                                for(int j=0; j<comments.length; j++) {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Footer.ppt b/src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Footer.ppt
new file mode 100644 (file)
index 0000000..f358b14
Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Footer.ppt differ
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Header.ppt b/src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Header.ppt
new file mode 100644 (file)
index 0000000..e09d775
Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hslf/data/45537_Header.ppt differ
index 35113866f22a192eab38e16d477b4d1551f60958..2fbdb6af9217feb69318bc4b93e2caab8bb539a6 100644 (file)
@@ -24,6 +24,7 @@ package org.apache.poi.hslf.extractor;
 import java.io.FileInputStream;
 
 import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
@@ -248,4 +249,38 @@ public class TextExtractor extends TestCase {
                text = ppe.getText();
                assertTrue("Unable to find expected word in text\n" + text, text.contains("testdoc"));
     }
+    
+    /**
+     * From bug #45537
+     */
+    public void DISABLEDtestHeaderFooter() throws Exception {
+               String filename, text;
+               
+               // With a header
+               filename = dirname + "/45537_Header.ppt";
+               HSLFSlideShow hslf = new HSLFSlideShow(new FileInputStream(filename));
+               SlideShow ss = new SlideShow(hslf);
+               assertNotNull(ss.getSlides()[0].getHeadersFooters());
+               assertEquals("testdoc test phrase", ss.getSlides()[0].getHeadersFooters().getHeaderText());
+               
+               ppe = new PowerPointExtractor(hslf);
+
+               text = ppe.getText();
+               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"));
+
+        
+               // And with a footer
+               filename = dirname + "/45537_Footer.ppt";
+               hslf = new HSLFSlideShow(new FileInputStream(filename));
+               ss = new SlideShow(hslf);
+               assertNotNull(ss.getSlides()[0].getHeadersFooters());
+               assertEquals("testdoc test phrase", ss.getSlides()[0].getHeadersFooters().getFooterText());
+               
+               ppe = new PowerPointExtractor(filename);
+
+               text = ppe.getText();
+               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"));
+    }
 }