poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1203295 - in /poi/trunk: src/documentation/content/xdocs/ src/scratchpad/src/org/apache/poi/hslf/extractor/ src/scratchpad/src/org/apache/poi/hslf/model/ src/scratchpad/testcases/org/apache/poi/hslf/extractor/ test-data/slideshow/
Date Thu, 17 Nov 2011 17:35:42 GMT
Author: yegor
Date: Thu Nov 17 17:35:42 2011
New Revision: 1203295

URL: http://svn.apache.org/viewvc?rev=1203295&view=rev
Log:
Bugzilla 51803: fixed HSLF TextExtractor to extract content from master slide 

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
    poi/trunk/test-data/slideshow/master_text.ppt

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1203295&r1=1203294&r2=1203295&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Nov 17 17:35:42 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51803 - fixed HSLF TextExtractor
to extract content from master slide </action>
            <action dev="poi-developers" type="fix">52190 - null check on XWPF setFontFamily</action>
            <action dev="poi-developers" type="fix">52062 - ensure that temporary files
in SXSSF are deleted</action>
            <action dev="poi-developers" type="fix">50936 - Exception parsing MS Word
8.0 file (as duplicate of 47958)</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java?rev=1203295&r1=1203294&r2=1203295&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java Thu
Nov 17 17:35:42 2011
@@ -221,7 +221,22 @@ public final class PowerPointExtractor e
 		if (getSlideText) {
             if (getMasterText) {
                 for (SlideMaster master : _show.getSlidesMasters()) {
-                    textRunsToText(ret, master.getTextRuns());
+                    for(Shape sh : master.getShapes()){
+                        if(sh instanceof TextShape){
+                            if(MasterSheet.isPlaceholder(sh)) {
+                                // don't bother about boiler
+                                // plate text on master
+                                // sheets
+                                continue;
+                            }
+                            TextShape tsh = (TextShape)sh;
+                            String text = tsh.getText();
+                            ret.append(text);
+                            if (!text.endsWith("\n")) {
+                                ret.append("\n");
+                            }
+                        }
+                    }
                 }
             }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java?rev=1203295&r1=1203294&r2=1203295&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java Thu Nov 17 17:35:42
2011
@@ -24,7 +24,6 @@ import org.apache.poi.hslf.usermodel.Sli
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Vector;
 import java.awt.*;
 
 /**
@@ -122,7 +121,7 @@ public abstract class Sheet {
      * For a given PPDrawing, grab all the TextRuns
      */
     public static TextRun[] findTextRuns(PPDrawing ppdrawing) {
-        Vector runsV = new Vector();
+        final List<TextRun> runsV = new ArrayList<TextRun>();
         EscherTextboxWrapper[] wrappers = ppdrawing.getTextboxWrappers();
         for (int i = 0; i < wrappers.length; i++) {
             int s1 = runsV.size();
@@ -132,15 +131,11 @@ public abstract class Sheet {
             findTextRuns(wrappers[i].getChildRecords(), runsV);
             int s2 = runsV.size();
             if (s2 != s1){
-                TextRun t = (TextRun) runsV.get(runsV.size()-1);
+                TextRun t = runsV.get(runsV.size()-1);
                 t.setShapeId(wrappers[i].getShapeId());
             }
         }
-        TextRun[] runs = new TextRun[runsV.size()];
-        for (int i = 0; i < runs.length; i++) {
-            runs[i] = (TextRun) runsV.get(i);
-        }
-        return runs;
+        return runsV.toArray(new TextRun[runsV.size()]);
     }
 
     /**
@@ -151,7 +146,7 @@ public abstract class Sheet {
      * @param records the records to build from
      * @param found   vector to add any found to
      */
-    protected static void findTextRuns(Record[] records, Vector found) {
+    protected static void findTextRuns(Record[] records, List<TextRun> found) {
         // Look for a TextHeaderAtom
         for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) {
             if (records[i] instanceof TextHeaderAtom) {

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java?rev=1203295&r1=1203294&r2=1203295&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java Thu
Nov 17 17:35:42 2011
@@ -292,13 +292,15 @@ public final class TestExtractor extends
        
        // Initially not there
        String text = ppe.getText();
-       assertFalse(text.contains("Master Header Text"));
+       assertFalse(text.contains("Text that I added to the master slide"));
        
        // Enable, shows up
        ppe.setMasterByDefault(true);
        text = ppe.getText();
-       assertTrue(text.contains("Master Header Text"));
-       
+       assertTrue(text.contains("Text that I added to the master slide"));
+
+       // Make sure placeholder text does not come out
+       assertFalse(text.contains("Click to edit Master"));
        
        // Now with another file only containing master text
        // Will always show up

Modified: poi/trunk/test-data/slideshow/master_text.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/master_text.ppt?rev=1203295&r1=1203294&r2=1203295&view=diff
==============================================================================
Binary files - no diff available.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message