poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1173756 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/xslf/extractor/ ooxml/testcases/org/apache/poi/xslf/extractor/ scratchpad/src/org/apache/poi/hslf/extractor/
Date Wed, 21 Sep 2011 16:54:23 GMT
Author: nick
Date: Wed Sep 21 16:54:22 2011
New Revision: 1173756

URL: http://svn.apache.org/viewvc?rev=1173756&view=rev
Log:
Update the XSLF slide master text extraction to be optional, as HSLF already is, plus fix
some indents

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1173756&r1=1173755&r2=1173756&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Sep 21 16:54:22 2011
@@ -34,7 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
-           <action dev="poi-developers" type="add">51804 - include Master Slide text
in XSLF text extraction</action>
+           <action dev="poi-developers" type="add">51804 - optionally include Master
Slide text in XSLF text extraction, as HSLF already offers</action>
            <action dev="poi-developers" type="add">New PackagePart method getRelatedPart(PackageRelationship)
to simplify navigation of relations between OPC Parts</action>
            <action dev="poi-developers" type="fix">51832 - handle XLS files where the
WRITEPROTECT record preceeds the FILEPASS one, rather than following as normal</action>
            <action dev="poi-developers" type="fix">51809 - correct GTE handling in
COUNTIF</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java?rev=1173756&r1=1173755&r2=1173756&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java Wed
Sep 21 16:54:22 2011
@@ -45,6 +45,7 @@ public class XSLFPowerPointExtractor ext
 	private XMLSlideShow slideshow;
 	private boolean slidesByDefault = true;
 	private boolean notesByDefault = false;
+   private boolean masterByDefault = false;
 	
 	public XSLFPowerPointExtractor(XMLSlideShow slideshow) {
 		super(slideshow);
@@ -84,6 +85,13 @@ public class XSLFPowerPointExtractor ext
 		this.notesByDefault = notesByDefault;
 	}
 	
+   /**
+    * Should a call to getText() return text from master? Default is no
+    */
+   public void setMasterByDefault(boolean masterByDefault) {
+       this.masterByDefault = masterByDefault;
+   }
+	
 	/**
 	 * Gets the slide text, but not the notes text
 	 */
@@ -97,6 +105,16 @@ public class XSLFPowerPointExtractor ext
     * @param notesText Should we retrieve text from notes?
     */
    public String getText(boolean slideText, boolean notesText) {
+      return getText(slideText, notesText, masterByDefault);
+   }
+   
+   /**
+    * Gets the requested text from the file
+    * @param slideText Should we retrieve text from slides?
+    * @param notesText Should we retrieve text from notes?
+    * @param masterText Should we retrieve text from master slides?
+    */
+   public String getText(boolean slideText, boolean notesText, boolean masterText) {
       StringBuffer text = new StringBuffer();
 
       XSLFSlide[] slides = slideshow.getSlides();
@@ -115,8 +133,8 @@ public class XSLFPowerPointExtractor ext
             if (slideText) {
                extractText(slide.getCommonSlideData(), text);
                
-               // If there's a master sheet, grab text from there
-               if(master != null) {
+               // If there's a master sheet and it's requested, grab text from there
+               if(masterText && master != null) {
                   extractText(master.getCommonSlideData(), text);
                }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java?rev=1173756&r1=1173755&r2=1173756&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java
Wed Sep 21 16:54:22 2011
@@ -68,22 +68,18 @@ public class TestXSLFPowerPointExtractor
          "Fifth level\n";
 		
 		// Just slides, no notes
-		text = extractor.getText(true, false);
+		text = extractor.getText(true, false, false);
 		assertEquals(
 				"Lorem ipsum dolor sit amet\n" +
 				"Nunc at risus vel erat tempus posuere. Aenean non ante.\n" +
 				"\n" +
-				masterText +
-            "\n\n\n" +
 				"Lorem ipsum dolor sit amet\n" +
 				"Lorem\n" +
 				"ipsum\n" +
 				"dolor\n" +
 				"sit\n" +
 				"amet\n" +
-				"\n" +
-            masterText +
-				"\n\n\n"
+				"\n"
 				, text
 		);
 		
@@ -94,25 +90,61 @@ public class TestXSLFPowerPointExtractor
 		);
 		
 		// Both
-		text = extractor.getText(true, true);
+		text = extractor.getText(true, true, false);
 		assertEquals(
 				"Lorem ipsum dolor sit amet\n" +
 				"Nunc at risus vel erat tempus posuere. Aenean non ante.\n" +
-            "\n" +
-            masterText +
-				"\n\n\n\n\n" +
+            "\n\n\n" +
 				"Lorem ipsum dolor sit amet\n" +
 				"Lorem\n" +
 				"ipsum\n" +
 				"dolor\n" +
 				"sit\n" +
 				"amet\n" +
-				"\n" +
-            masterText +
-            "\n\n\n\n\n"
+				"\n\n\n"
 				, text
 		);
 		
+		// With Slides and Master Text
+      text = extractor.getText(true, false, true);
+      assertEquals(
+            "Lorem ipsum dolor sit amet\n" +
+            "Nunc at risus vel erat tempus posuere. Aenean non ante.\n" +
+            "\n" +
+            masterText +
+            "\n\n\n" +
+            "Lorem ipsum dolor sit amet\n" +
+            "Lorem\n" +
+            "ipsum\n" +
+            "dolor\n" +
+            "sit\n" +
+            "amet\n" +
+            "\n" +
+            masterText +
+            "\n\n\n"
+            , text
+      );
+		
+		// With Slides, Notes and Master Text
+      text = extractor.getText(true, true, true);
+      assertEquals(
+            "Lorem ipsum dolor sit amet\n" +
+            "Nunc at risus vel erat tempus posuere. Aenean non ante.\n" +
+            "\n" +
+            masterText +
+            "\n\n\n\n\n" +
+            "Lorem ipsum dolor sit amet\n" +
+            "Lorem\n" +
+            "ipsum\n" +
+            "dolor\n" +
+            "sit\n" +
+            "amet\n" +
+            "\n" +
+            masterText +
+            "\n\n\n\n\n"
+            , text
+      );
+		
 		// Via set defaults
 		extractor.setSlidesByDefault(false);
 		extractor.setNotesByDefault(true);

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=1173756&r1=1173755&r2=1173756&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 Wed
Sep 21 16:54:22 2011
@@ -39,14 +39,14 @@ import org.apache.poi.poifs.filesystem.P
  * @author Nick Burch
  */
 public final class PowerPointExtractor extends POIOLE2TextExtractor {
-	private HSLFSlideShow _hslfshow;
-	private SlideShow _show;
-	private Slide[] _slides;
-
-	private boolean _slidesByDefault = true;
-	private boolean _notesByDefault = false;
-	private boolean _commentsByDefault = false;
-    private boolean _masterByDefault = false;
+   private HSLFSlideShow _hslfshow;
+   private SlideShow _show;
+   private Slide[] _slides;
+
+   private boolean _slidesByDefault = true;
+   private boolean _notesByDefault = false;
+   private boolean _commentsByDefault = false;
+   private boolean _masterByDefault = false;
 
 	/**
 	 * Basic extractor. Returns all the text, and optionally all the notes



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


Mime
View raw message