You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ni...@apache.org on 2006/07/03 22:53:09 UTC

svn commit: r418847 - in /jakarta/poi/trunk/src/scratchpad: src/org/apache/poi/hslf/model/Slide.java testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java

Author: nick
Date: Mon Jul  3 13:53:08 2006
New Revision: 418847

URL: http://svn.apache.org/viewvc?rev=418847&view=rev
Log:
Yegor's Slide Title patch from bug 39948

Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
    jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java

Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java?rev=418847&r1=418846&r2=418847&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java Mon Jul  3 13:53:08 2006
@@ -143,7 +143,33 @@
   }
 
 
-  // Accesser methods follow
+	// Complex Accesser methods follow
+
+	/**
+	 * Return title of this slide or <code>null</code> if the slide does not have title.
+	 * <p>
+	 * The title is a run of text of type <code>TextHeaderAtom.CENTER_TITLE_TYPE</code> or
+	 * <code>TextHeaderAtom.TITLE_TYPE</code>
+	 * </p>
+	 *
+	 * @see TextHeaderAtom
+	 *
+	 * @return title of this slide
+	 */
+	public String getTitle(){
+		TextRun[] txt = getTextRuns();
+		for (int i = 0; i < txt.length; i++) {
+			int type = txt[i].getRunType();
+			if (type == TextHeaderAtom.CENTER_TITLE_TYPE ||
+			type == TextHeaderAtom.TITLE_TYPE ){
+				String title = txt[i].getText();
+				return title;
+			}
+		}
+		return null;
+	}
+  
+	// Simple Accesser methods follow
 
   /**
    * Returns an array of all the TextRuns found

Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java?rev=418847&r1=418846&r2=418847&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java (original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java Mon Jul  3 13:53:08 2006
@@ -85,4 +85,74 @@
     	assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
     	assertEquals(firstTRs[2], s3.getTextRuns()[0].getText());
     }
+
+    /**
+     * Assert that the order of slides is correct.
+     *
+     * @param filename  file name of the slide show to assert
+     * @param titles    array of reference slide titles
+     */
+    protected void assertSlideOrdering(String filename, String[] titles) throws Exception {
+        SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));
+        Slide[] slide = ppt.getSlides();
+
+        assertEquals(titles.length, slide.length);
+        for (int i = 0; i < slide.length; i++) {
+            String title = slide[i].getTitle();
+            assertEquals("Wrong slide title in " + filename, titles[i], title);
+        }
+    }
+
+    public void testTitles() throws Exception{
+        String dirname = System.getProperty("HSLF.testdata.path");
+
+        assertSlideOrdering(dirname + "/basic_test_ppt_file.ppt",
+                new String[]{
+                    "This is a test title",
+                    "This is the title on page 2"
+                });
+
+        assertSlideOrdering(dirname + "/incorrect_slide_order.ppt",
+                new String[]{
+                    "Slide 1",
+                    "Slide 2",
+                    "Slide 3"
+                });
+
+        assertSlideOrdering(dirname + "/next_test_ppt_file.ppt",
+                new String[]{
+                    "This is a test title",
+                    "This is the title on page 2"
+                });
+String a = "’";
+System.err.println((int)(a.toCharArray()[0]));
+
+        assertSlideOrdering(dirname + "/Single_Coloured_Page.ppt",
+                new String[]{
+                    "This is a title, it" + (char)0x2019 +"s in black"
+                });
+
+        assertSlideOrdering(dirname + "/Single_Coloured_Page_With_Fonts_and_Alignments.ppt",
+                new String[]{
+                    "This is a title, it"+ (char)0x2019 +"s in black"
+                });
+
+        assertSlideOrdering(dirname + "/ParagraphStylesShorterThanCharStyles.ppt",
+                new String[]{
+                    "ROMANCE: AN ANALYSIS",
+                    "AGENDA",
+                    "You are an important supplier of various items that I need",
+                    (char)0x0B + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
+                    "Since the time that we seriously go out together, you rank highly among existing relationships",
+                    "Although our personal interests are mostly compatible, the greatest gap exists in Sex and Shopping",
+                    "Your physical characteristics are strong when compared with your competition",
+                    "The combination of your high physical appearance and personality rank you highly, although your sister is also a top prospect",
+                    "When people found out that we were going out, their responses have been mixed",
+                    "The benchmark of relationship lifecycles, suggests that we are on schedule",
+                    "In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ",
+                    "THE ANSWER",
+                    "Unfortunately a huge disconnect exists between my needs and your existing service",
+                    "SUMMARY",
+                });
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/