You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/21 20:15:01 UTC
svn commit: r777204 [16/21] - in /poi/trunk/src/scratchpad:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hwpf/ src/org/apache/poi/hdf/event/
src/org/apache/poi/hdf/extractor/ src/org/apache/poi/hdf/extractor/data/
src/org/apac...
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java Thu May 21 18:12:22 2009
@@ -1,224 +1,221 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-
-
-package org.apache.poi.hslf.model;
-
-import java.io.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
-
-import junit.framework.TestCase;
-
-/**
- * Test {@link org.apache.poi.hslf.model.HeadersFooters} object
- */
-public class TestHeadersFooters extends TestCase
-{
-
- public static final String cwd = System.getProperty("HSLF.testdata.path");
-
- public void testRead() throws Exception
- {
- File file = new File(cwd, "headers_footers.ppt");
- FileInputStream is = new FileInputStream(file);
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
- assertTrue(slideHdd.isFooterVisible());
- assertEquals("Global Slide Footer", slideHdd.getFooterText());
- assertTrue(slideHdd.isSlideNumberVisible());
- assertFalse(slideHdd.isHeaderVisible());
- assertNull(slideHdd.getHeaderText());
- assertFalse(slideHdd.isUserDateVisible());
- assertNull(slideHdd.getDateTimeText());
-
-
- HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
- assertTrue(notesHdd.isFooterVisible());
- assertEquals("Notes Footer", notesHdd.getFooterText());
- assertTrue(notesHdd.isHeaderVisible());
- assertEquals("Notes Header", notesHdd.getHeaderText());
- assertTrue(notesHdd.isUserDateVisible());
- assertNull(notesHdd.getDateTimeText());
-
- Slide[] slide = ppt.getSlides();
- //the first slide uses presentation-scope headers / footers
- HeadersFooters hd1 = slide[0].getHeadersFooters();
- assertEquals(slideHdd.isFooterVisible(), hd1.isFooterVisible());
- assertEquals(slideHdd.getFooterText(), hd1.getFooterText());
- assertEquals(slideHdd.isSlideNumberVisible(), hd1.isSlideNumberVisible());
- assertEquals(slideHdd.isHeaderVisible(), hd1.isHeaderVisible());
- assertEquals(slideHdd.getHeaderText(), hd1.getHeaderText());
- assertEquals(slideHdd.isUserDateVisible(), hd1.isUserDateVisible());
- assertEquals(slideHdd.getDateTimeText(), hd1.getDateTimeText());
-
- //the first slide uses per-slide headers / footers
- HeadersFooters hd2 = slide[1].getHeadersFooters();
- assertEquals(true, hd2.isFooterVisible());
- assertEquals("per-slide footer", hd2.getFooterText());
- assertEquals(true, hd2.isUserDateVisible());
- assertEquals("custom date format", hd2.getDateTimeText());
- }
-
- /**
- * If Headers / Footers are not set, all the getters should return <code>false</code> or <code>null</code>
- */
- public void testReadNoHeadersFooters() throws Exception
- {
- File file = new File(cwd, "basic_test_ppt_file.ppt");
- FileInputStream is = new FileInputStream(file);
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
- assertFalse(slideHdd.isFooterVisible());
- assertNull(slideHdd.getFooterText());
- assertFalse(slideHdd.isSlideNumberVisible());
- assertFalse(slideHdd.isHeaderVisible());
- assertNull(slideHdd.getHeaderText());
- assertFalse(slideHdd.isUserDateVisible());
- assertNull(slideHdd.getDateTimeText());
-
-
- HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
- assertFalse(notesHdd.isFooterVisible());
- assertNull(notesHdd.getFooterText());
- assertFalse(notesHdd.isHeaderVisible());
- assertNull(notesHdd.getHeaderText());
- assertFalse(notesHdd.isUserDateVisible());
- assertNull(notesHdd.getDateTimeText());
-
- Slide[] slide = ppt.getSlides();
- for(int i=0 ; i < slide.length; i++){
- HeadersFooters hd1 = slide[i].getHeadersFooters();
- assertFalse(hd1.isFooterVisible());
- assertNull(hd1.getFooterText());
- assertFalse(hd1.isHeaderVisible());
- assertNull(hd1.getHeaderText());
- assertFalse(hd1.isUserDateVisible());
- assertNull(hd1.getDateTimeText());
- }
- }
-
- /**
- * Test extraction of headers / footers from PPTs saved in Office 2007
- */
- public void testRead2007() throws Exception
- {
- File file = new File(cwd, "headers_footers_2007.ppt");
- FileInputStream is = new FileInputStream(file);
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
- assertTrue(slideHdd.isFooterVisible());
- assertEquals("THE FOOTER TEXT", slideHdd.getFooterText());
- assertTrue(slideHdd.isSlideNumberVisible());
- assertFalse(slideHdd.isHeaderVisible());
- assertNull(slideHdd.getHeaderText());
- assertTrue(slideHdd.isUserDateVisible());
- assertEquals("Wednesday, August 06, 2008", slideHdd.getDateTimeText());
-
-
- HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
- assertTrue(notesHdd.isFooterVisible());
- assertEquals("THE NOTES FOOTER TEXT", notesHdd.getFooterText());
- assertTrue(notesHdd.isHeaderVisible());
- assertEquals("THE NOTES HEADER TEXT", notesHdd.getHeaderText());
- assertTrue(notesHdd.isUserDateVisible());
- assertTrue(notesHdd.isDateTimeVisible());
- //TODO: depending on the formatId getDateTimeText() should return formatted date
- //assertEquals("08/12/08", notesHdd.getDateTimeText());
-
- //per-slide headers / footers
- Slide[] slide = ppt.getSlides();
- //the first slide uses presentation-scope headers / footers
- HeadersFooters hd1 = slide[0].getHeadersFooters();
- assertTrue(hd1.isFooterVisible());
- assertEquals("THE FOOTER TEXT", hd1.getFooterText());
- assertTrue(hd1.isSlideNumberVisible());
- assertFalse(hd1.isHeaderVisible());
- assertNull(hd1.getHeaderText());
- assertTrue(hd1.isUserDateVisible());
- assertTrue(hd1.isDateTimeVisible());
- assertEquals("Wednesday, August 06, 2008", hd1.getDateTimeText());
-
- //the second slide uses custom per-slide headers / footers
- HeadersFooters hd2 = slide[1].getHeadersFooters();
- assertTrue(hd2.isFooterVisible());
- assertEquals("THE FOOTER TEXT FOR SLIDE 2", hd2.getFooterText());
- assertTrue(hd2.isSlideNumberVisible());
- assertFalse(hd2.isHeaderVisible());
- assertNull(hd2.getHeaderText());
- assertTrue(hd2.isUserDateVisible());
- assertTrue(hd2.isDateTimeVisible());
- assertEquals("August 06, 2008", hd2.getDateTimeText());
-
- //the third slide uses per-slide headers / footers
- HeadersFooters hd3 = slide[2].getHeadersFooters();
- assertTrue(hd3.isFooterVisible());
- assertEquals("THE FOOTER TEXT", hd3.getFooterText());
- assertTrue(hd3.isSlideNumberVisible());
- assertFalse(hd3.isHeaderVisible());
- assertNull(hd3.getHeaderText());
- assertTrue(hd3.isUserDateVisible());
- assertTrue(hd3.isDateTimeVisible());
- assertEquals("Wednesday, August 06, 2008", hd3.getDateTimeText());
- }
-
- public void testCreateSlideFooters() throws Exception
- {
- SlideShow ppt = new SlideShow();
- HeadersFooters hdd = ppt.getSlideHeadersFooters();
- hdd.setFootersText("My slide footer");
- hdd.setSlideNumberVisible(true);
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ppt.write(out);
- byte[] b = out.toByteArray();
-
- SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
- HeadersFooters hdd2 = ppt2.getSlideHeadersFooters();
- assertTrue(hdd2.isSlideNumberVisible());
- assertTrue(hdd2.isFooterVisible());
- assertEquals("My slide footer", hdd2.getFooterText());
- }
-
- public void testCreateNotesFooters() throws Exception
- {
- SlideShow ppt = new SlideShow();
- HeadersFooters hdd = ppt.getNotesHeadersFooters();
- hdd.setFootersText("My notes footer");
- hdd.setHeaderText("My notes header");
- hdd.setSlideNumberVisible(true);
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ppt.write(out);
- byte[] b = out.toByteArray();
-
- SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
- HeadersFooters hdd2 = ppt2.getNotesHeadersFooters();
- assertTrue(hdd2.isSlideNumberVisible());
- assertTrue(hdd2.isFooterVisible());
- assertEquals("My notes footer", hdd2.getFooterText());
- assertTrue(hdd2.isHeaderVisible());
- assertEquals("My notes header", hdd2.getHeaderText());
- }
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import java.io.*;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+import junit.framework.TestCase;
+
+/**
+ * Test {@link org.apache.poi.hslf.model.HeadersFooters} object
+ */
+public final class TestHeadersFooters extends TestCase
+{
+
+ public static final String cwd = System.getProperty("HSLF.testdata.path");
+
+ public void testRead() throws Exception
+ {
+ File file = new File(cwd, "headers_footers.ppt");
+ FileInputStream is = new FileInputStream(file);
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
+ assertTrue(slideHdd.isFooterVisible());
+ assertEquals("Global Slide Footer", slideHdd.getFooterText());
+ assertTrue(slideHdd.isSlideNumberVisible());
+ assertFalse(slideHdd.isHeaderVisible());
+ assertNull(slideHdd.getHeaderText());
+ assertFalse(slideHdd.isUserDateVisible());
+ assertNull(slideHdd.getDateTimeText());
+
+
+ HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
+ assertTrue(notesHdd.isFooterVisible());
+ assertEquals("Notes Footer", notesHdd.getFooterText());
+ assertTrue(notesHdd.isHeaderVisible());
+ assertEquals("Notes Header", notesHdd.getHeaderText());
+ assertTrue(notesHdd.isUserDateVisible());
+ assertNull(notesHdd.getDateTimeText());
+
+ Slide[] slide = ppt.getSlides();
+ //the first slide uses presentation-scope headers / footers
+ HeadersFooters hd1 = slide[0].getHeadersFooters();
+ assertEquals(slideHdd.isFooterVisible(), hd1.isFooterVisible());
+ assertEquals(slideHdd.getFooterText(), hd1.getFooterText());
+ assertEquals(slideHdd.isSlideNumberVisible(), hd1.isSlideNumberVisible());
+ assertEquals(slideHdd.isHeaderVisible(), hd1.isHeaderVisible());
+ assertEquals(slideHdd.getHeaderText(), hd1.getHeaderText());
+ assertEquals(slideHdd.isUserDateVisible(), hd1.isUserDateVisible());
+ assertEquals(slideHdd.getDateTimeText(), hd1.getDateTimeText());
+
+ //the first slide uses per-slide headers / footers
+ HeadersFooters hd2 = slide[1].getHeadersFooters();
+ assertEquals(true, hd2.isFooterVisible());
+ assertEquals("per-slide footer", hd2.getFooterText());
+ assertEquals(true, hd2.isUserDateVisible());
+ assertEquals("custom date format", hd2.getDateTimeText());
+ }
+
+ /**
+ * If Headers / Footers are not set, all the getters should return <code>false</code> or <code>null</code>
+ */
+ public void testReadNoHeadersFooters() throws Exception
+ {
+ File file = new File(cwd, "basic_test_ppt_file.ppt");
+ FileInputStream is = new FileInputStream(file);
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
+ assertFalse(slideHdd.isFooterVisible());
+ assertNull(slideHdd.getFooterText());
+ assertFalse(slideHdd.isSlideNumberVisible());
+ assertFalse(slideHdd.isHeaderVisible());
+ assertNull(slideHdd.getHeaderText());
+ assertFalse(slideHdd.isUserDateVisible());
+ assertNull(slideHdd.getDateTimeText());
+
+
+ HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
+ assertFalse(notesHdd.isFooterVisible());
+ assertNull(notesHdd.getFooterText());
+ assertFalse(notesHdd.isHeaderVisible());
+ assertNull(notesHdd.getHeaderText());
+ assertFalse(notesHdd.isUserDateVisible());
+ assertNull(notesHdd.getDateTimeText());
+
+ Slide[] slide = ppt.getSlides();
+ for(int i=0 ; i < slide.length; i++){
+ HeadersFooters hd1 = slide[i].getHeadersFooters();
+ assertFalse(hd1.isFooterVisible());
+ assertNull(hd1.getFooterText());
+ assertFalse(hd1.isHeaderVisible());
+ assertNull(hd1.getHeaderText());
+ assertFalse(hd1.isUserDateVisible());
+ assertNull(hd1.getDateTimeText());
+ }
+ }
+
+ /**
+ * Test extraction of headers / footers from PPTs saved in Office 2007
+ */
+ public void testRead2007() throws Exception
+ {
+ File file = new File(cwd, "headers_footers_2007.ppt");
+ FileInputStream is = new FileInputStream(file);
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
+ assertTrue(slideHdd.isFooterVisible());
+ assertEquals("THE FOOTER TEXT", slideHdd.getFooterText());
+ assertTrue(slideHdd.isSlideNumberVisible());
+ assertFalse(slideHdd.isHeaderVisible());
+ assertNull(slideHdd.getHeaderText());
+ assertTrue(slideHdd.isUserDateVisible());
+ assertEquals("Wednesday, August 06, 2008", slideHdd.getDateTimeText());
+
+
+ HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
+ assertTrue(notesHdd.isFooterVisible());
+ assertEquals("THE NOTES FOOTER TEXT", notesHdd.getFooterText());
+ assertTrue(notesHdd.isHeaderVisible());
+ assertEquals("THE NOTES HEADER TEXT", notesHdd.getHeaderText());
+ assertTrue(notesHdd.isUserDateVisible());
+ assertTrue(notesHdd.isDateTimeVisible());
+ //TODO: depending on the formatId getDateTimeText() should return formatted date
+ //assertEquals("08/12/08", notesHdd.getDateTimeText());
+
+ //per-slide headers / footers
+ Slide[] slide = ppt.getSlides();
+ //the first slide uses presentation-scope headers / footers
+ HeadersFooters hd1 = slide[0].getHeadersFooters();
+ assertTrue(hd1.isFooterVisible());
+ assertEquals("THE FOOTER TEXT", hd1.getFooterText());
+ assertTrue(hd1.isSlideNumberVisible());
+ assertFalse(hd1.isHeaderVisible());
+ assertNull(hd1.getHeaderText());
+ assertTrue(hd1.isUserDateVisible());
+ assertTrue(hd1.isDateTimeVisible());
+ assertEquals("Wednesday, August 06, 2008", hd1.getDateTimeText());
+
+ //the second slide uses custom per-slide headers / footers
+ HeadersFooters hd2 = slide[1].getHeadersFooters();
+ assertTrue(hd2.isFooterVisible());
+ assertEquals("THE FOOTER TEXT FOR SLIDE 2", hd2.getFooterText());
+ assertTrue(hd2.isSlideNumberVisible());
+ assertFalse(hd2.isHeaderVisible());
+ assertNull(hd2.getHeaderText());
+ assertTrue(hd2.isUserDateVisible());
+ assertTrue(hd2.isDateTimeVisible());
+ assertEquals("August 06, 2008", hd2.getDateTimeText());
+
+ //the third slide uses per-slide headers / footers
+ HeadersFooters hd3 = slide[2].getHeadersFooters();
+ assertTrue(hd3.isFooterVisible());
+ assertEquals("THE FOOTER TEXT", hd3.getFooterText());
+ assertTrue(hd3.isSlideNumberVisible());
+ assertFalse(hd3.isHeaderVisible());
+ assertNull(hd3.getHeaderText());
+ assertTrue(hd3.isUserDateVisible());
+ assertTrue(hd3.isDateTimeVisible());
+ assertEquals("Wednesday, August 06, 2008", hd3.getDateTimeText());
+ }
+
+ public void testCreateSlideFooters() throws Exception
+ {
+ SlideShow ppt = new SlideShow();
+ HeadersFooters hdd = ppt.getSlideHeadersFooters();
+ hdd.setFootersText("My slide footer");
+ hdd.setSlideNumberVisible(true);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ppt.write(out);
+ byte[] b = out.toByteArray();
+
+ SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
+ HeadersFooters hdd2 = ppt2.getSlideHeadersFooters();
+ assertTrue(hdd2.isSlideNumberVisible());
+ assertTrue(hdd2.isFooterVisible());
+ assertEquals("My slide footer", hdd2.getFooterText());
+ }
+
+ public void testCreateNotesFooters() throws Exception
+ {
+ SlideShow ppt = new SlideShow();
+ HeadersFooters hdd = ppt.getNotesHeadersFooters();
+ hdd.setFootersText("My notes footer");
+ hdd.setHeaderText("My notes header");
+ hdd.setSlideNumberVisible(true);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ppt.write(out);
+ byte[] b = out.toByteArray();
+
+ SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
+ HeadersFooters hdd2 = ppt2.getNotesHeadersFooters();
+ assertTrue(hdd2.isSlideNumberVisible());
+ assertTrue(hdd2.isFooterVisible());
+ assertEquals("My notes footer", hdd2.getFooterText());
+ assertTrue(hdd2.isHeaderVisible());
+ assertEquals("My notes header", hdd2.getHeaderText());
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java Thu May 21 18:12:22 2009
@@ -1,89 +1,90 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import junit.framework.TestCase;
-
-import java.io.FileInputStream;
-import java.io.File;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-
-/**
- * Test Hyperlink.
- *
- * @author Yegor Kozlov
- */
-public class TestHyperlink extends TestCase {
- protected String cwd = System.getProperty("HSLF.testdata.path");
-
- public void testTextRunHyperlinks() throws Exception {
- FileInputStream is = new FileInputStream(new File(cwd, "WithLinks.ppt"));
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- TextRun[] run;
- Slide slide;
- slide = ppt.getSlides()[0];
- run = slide.getTextRuns();
- for (int i = 0; i < run.length; i++) {
- String text = run[i].getText();
- if (text.equals(
- "This page has two links:\n" +
- "http://jakarta.apache.org/poi/\n" +
- "\n" +
- "http://slashdot.org/\n" +
- "\n" +
- "In addition, its notes has one link")){
-
- Hyperlink[] links = run[i].getHyperlinks();
- assertNotNull(links);
- assertEquals(2, links.length);
-
- assertEquals("http://jakarta.apache.org/poi/", links[0].getTitle());
- assertEquals("http://jakarta.apache.org/poi/", links[0].getAddress());
- assertEquals("http://jakarta.apache.org/poi/", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
-
- assertEquals("http://slashdot.org/", links[1].getTitle());
- assertEquals("http://slashdot.org/", links[1].getAddress());
- assertEquals("http://slashdot.org/", text.substring(links[1].getStartIndex(), links[1].getEndIndex()-1));
-
- }
- }
-
- slide = ppt.getSlides()[1];
- run = slide.getTextRuns();
- for (int i = 0; i < run.length; i++) {
- String text = run[i].getText();
- if (text.equals(
- "I have the one link:\n" +
- "Jakarta HSSF")){
-
- Hyperlink[] links = run[i].getHyperlinks();
- assertNotNull(links);
- assertEquals(1, links.length);
-
- assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getTitle());
- assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getAddress());
- assertEquals("Jakarta HSSF", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
-
- }
- }
-
- }
-
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.FileInputStream;
+import java.io.File;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+/**
+ * Test Hyperlink.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestHyperlink extends TestCase {
+ protected String cwd = System.getProperty("HSLF.testdata.path");
+
+ public void testTextRunHyperlinks() throws Exception {
+ FileInputStream is = new FileInputStream(new File(cwd, "WithLinks.ppt"));
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ TextRun[] run;
+ Slide slide;
+ slide = ppt.getSlides()[0];
+ run = slide.getTextRuns();
+ for (int i = 0; i < run.length; i++) {
+ String text = run[i].getText();
+ if (text.equals(
+ "This page has two links:\n" +
+ "http://jakarta.apache.org/poi/\n" +
+ "\n" +
+ "http://slashdot.org/\n" +
+ "\n" +
+ "In addition, its notes has one link")){
+
+ Hyperlink[] links = run[i].getHyperlinks();
+ assertNotNull(links);
+ assertEquals(2, links.length);
+
+ assertEquals("http://jakarta.apache.org/poi/", links[0].getTitle());
+ assertEquals("http://jakarta.apache.org/poi/", links[0].getAddress());
+ assertEquals("http://jakarta.apache.org/poi/", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
+
+ assertEquals("http://slashdot.org/", links[1].getTitle());
+ assertEquals("http://slashdot.org/", links[1].getAddress());
+ assertEquals("http://slashdot.org/", text.substring(links[1].getStartIndex(), links[1].getEndIndex()-1));
+
+ }
+ }
+
+ slide = ppt.getSlides()[1];
+ run = slide.getTextRuns();
+ for (int i = 0; i < run.length; i++) {
+ String text = run[i].getText();
+ if (text.equals(
+ "I have the one link:\n" +
+ "Jakarta HSSF")){
+
+ Hyperlink[] links = run[i].getHyperlinks();
+ assertNotNull(links);
+ assertEquals(1, links.length);
+
+ assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getTitle());
+ assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getAddress());
+ assertEquals("Jakarta HSSF", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
+
+ }
+ }
+
+ }
+
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java Thu May 21 18:12:22 2009
@@ -1,57 +1,58 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import junit.framework.*;
-
-import java.io.FileOutputStream;
-import java.io.File;
-import java.awt.*;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.blip.ImagePainter;
-import org.apache.poi.hslf.blip.BitmapPainter;
-import org.apache.poi.ddf.EscherBSERecord;
-
-/**
- * Test Picture shape.
- *
- * @author Yegor Kozlov
- */
-public class TestImagePainter extends TestCase {
-
- private static class CustomImagePainer implements ImagePainter{
- public void paint(Graphics2D graphics, PictureData pict, Picture parent){
- //do noting
- }
-
- }
-
- public void testImagePainter() throws Exception {
-
- ImagePainter pntr = PictureData.getImagePainter(Picture.PNG);
- assertTrue(PictureData.getImagePainter(Picture.PNG) instanceof BitmapPainter);
- assertTrue(PictureData.getImagePainter(Picture.JPEG) instanceof BitmapPainter);
- assertTrue(PictureData.getImagePainter(Picture.DIB) instanceof BitmapPainter);
-
- PictureData.setImagePainter(Picture.WMF, new CustomImagePainer());
- assertTrue(PictureData.getImagePainter(Picture.WMF) instanceof CustomImagePainer);
- }
-
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import junit.framework.*;
+
+import java.io.FileOutputStream;
+import java.io.File;
+import java.awt.*;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.blip.ImagePainter;
+import org.apache.poi.hslf.blip.BitmapPainter;
+import org.apache.poi.ddf.EscherBSERecord;
+
+/**
+ * Test Picture shape.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestImagePainter extends TestCase {
+
+ private static class CustomImagePainer implements ImagePainter{
+ public void paint(Graphics2D graphics, PictureData pict, Picture parent){
+ //do noting
+ }
+
+ }
+
+ public void testImagePainter() throws Exception {
+
+ ImagePainter pntr = PictureData.getImagePainter(Picture.PNG);
+ assertTrue(PictureData.getImagePainter(Picture.PNG) instanceof BitmapPainter);
+ assertTrue(PictureData.getImagePainter(Picture.JPEG) instanceof BitmapPainter);
+ assertTrue(PictureData.getImagePainter(Picture.DIB) instanceof BitmapPainter);
+
+ PictureData.setImagePainter(Picture.WMF, new CustomImagePainer());
+ assertTrue(PictureData.getImagePainter(Picture.WMF) instanceof CustomImagePainer);
+ }
+
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.model;
import junit.framework.*;
@@ -26,10 +27,10 @@
/**
* Test Line shape.
- *
+ *
* @author Yegor Kozlov
*/
-public class TestLine extends TestCase {
+public final class TestLine extends TestCase {
public void setUp() throws Exception {
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java Thu May 21 18:12:22 2009
@@ -1,66 +1,67 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import junit.framework.TestCase;
-
-import java.io.*;
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.HSLFSlideShow;
-
-/**
- * Test <code>MovieShape</code> object.
- *
- * @author Yegor Kozlov
- */
-public class TestMovieShape extends TestCase {
-
- protected String cwd = System.getProperty("HSLF.testdata.path");
-
- public void testCreate() throws Exception {
- SlideShow ppt = new SlideShow();
-
- Slide slide = ppt.createSlide();
-
- String path = cwd + "/test-movie.mpg";
- int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG);
- int thumbnailIdx = ppt.addPicture(new File(cwd, "tomcat.png"), Picture.PNG);
-
- MovieShape shape = new MovieShape(movieIdx, thumbnailIdx);
- shape.setAnchor(new Rectangle2D.Float(300,225,120,90));
- slide.addShape(shape);
-
- assertEquals(path, shape.getPath());
- assertTrue(shape.isAutoPlay());
- shape.setAutoPlay(false);
- assertFalse(shape.isAutoPlay());
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ppt.write(out);
-
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
- slide = ppt.getSlides()[0];
- shape = (MovieShape)slide.getShapes()[0];
- assertEquals(path, shape.getPath());
- assertFalse(shape.isAutoPlay());
-
- }
-
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.*;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.HSLFSlideShow;
+
+/**
+ * Test <code>MovieShape</code> object.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestMovieShape extends TestCase {
+
+ protected String cwd = System.getProperty("HSLF.testdata.path");
+
+ public void testCreate() throws Exception {
+ SlideShow ppt = new SlideShow();
+
+ Slide slide = ppt.createSlide();
+
+ String path = cwd + "/test-movie.mpg";
+ int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG);
+ int thumbnailIdx = ppt.addPicture(new File(cwd, "tomcat.png"), Picture.PNG);
+
+ MovieShape shape = new MovieShape(movieIdx, thumbnailIdx);
+ shape.setAnchor(new Rectangle2D.Float(300,225,120,90));
+ slide.addShape(shape);
+
+ assertEquals(path, shape.getPath());
+ assertTrue(shape.isAutoPlay());
+ shape.setAutoPlay(false);
+ assertFalse(shape.isAutoPlay());
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ppt.write(out);
+
+ ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ slide = ppt.getSlides()[0];
+ shape = (MovieShape)slide.getShapes()[0];
+ assertEquals(path, shape.getPath());
+ assertFalse(shape.isAutoPlay());
+
+ }
+
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java Thu May 21 18:12:22 2009
@@ -1,92 +1,92 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.ObjectData;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hwpf.HWPFDocument;
-
-public final class TestOleEmbedding extends TestCase {
- /**
- * Tests support for OLE objects.
- *
- * @throws Exception if an error occurs.
- */
- public void testOleEmbedding2003() throws Exception {
- String dirname = System.getProperty("HSLF.testdata.path");
- File file = new File(dirname, "ole2-embedding-2003.ppt");
- HSLFSlideShow slideShow = new HSLFSlideShow(new FileInputStream(file));
- // Placeholder EMFs for clients that don't support the OLE components.
- PictureData[] pictures = slideShow.getPictures();
- assertEquals("Should be two pictures", 2, pictures.length);
- //assertDigestEquals("Wrong data for picture 1", "8d1fbadf4814f321bb1ccdd056e3c788", pictures[0].getData());
- //assertDigestEquals("Wrong data for picture 2", "987a698e83559cf3d38a0deeba1cc63b", pictures[1].getData());
-
- // Actual embedded objects.
- ObjectData[] objects = slideShow.getEmbeddedObjects();
- assertEquals("Should be two objects", 2, objects.length);
- //assertDigestEquals("Wrong data for objecs 1", "0d1fcc61a83de5c4894dc0c88e9a019d", objects[0].getData());
- //assertDigestEquals("Wrong data for object 2", "b323604b2003a7299c77c2693b641495", objects[1].getData());
- }
-
- public void testOLEShape() throws Exception {
- String dirname = System.getProperty("HSLF.testdata.path");
- File file = new File(dirname, "ole2-embedding-2003.ppt");
- FileInputStream is = new FileInputStream(file);
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- Slide slide = ppt.getSlides()[0];
- Shape[] sh = slide.getShapes();
- int cnt = 0;
- for (int i = 0; i < sh.length; i++) {
- if(sh[i] instanceof OLEShape){
- cnt++;
- OLEShape ole = (OLEShape)sh[i];
- ObjectData data = ole.getObjectData();
- if("Worksheet".equals(ole.getInstanceName())){
- //Voila! we created a workbook from the embedded OLE data
- HSSFWorkbook wb = new HSSFWorkbook(data.getData());
- HSSFSheet sheet = wb.getSheetAt(0);
- //verify we can access the xls data
- assertEquals(1, sheet.getRow(0).getCell(0).getNumericCellValue(), 0);
- assertEquals(1, sheet.getRow(1).getCell(0).getNumericCellValue(), 0);
- assertEquals(2, sheet.getRow(2).getCell(0).getNumericCellValue(), 0);
- assertEquals(3, sheet.getRow(3).getCell(0).getNumericCellValue(), 0);
- assertEquals(8, sheet.getRow(5).getCell(0).getNumericCellValue(), 0);
- } else if ("Document".equals(ole.getInstanceName())){
- //creating a HWPF document
- HWPFDocument doc = new HWPFDocument(data.getData());
- String txt = doc.getRange().getParagraph(0).text();
- assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
- }
- }
-
- }
- assertEquals("Expected 2 OLE shapes", 2, cnt);
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.ObjectData;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.hwpf.HWPFDocument;
+
+public final class TestOleEmbedding extends TestCase {
+ /**
+ * Tests support for OLE objects.
+ *
+ * @throws Exception if an error occurs.
+ */
+ public void testOleEmbedding2003() throws Exception {
+ String dirname = System.getProperty("HSLF.testdata.path");
+ File file = new File(dirname, "ole2-embedding-2003.ppt");
+ HSLFSlideShow slideShow = new HSLFSlideShow(new FileInputStream(file));
+ // Placeholder EMFs for clients that don't support the OLE components.
+ PictureData[] pictures = slideShow.getPictures();
+ assertEquals("Should be two pictures", 2, pictures.length);
+ //assertDigestEquals("Wrong data for picture 1", "8d1fbadf4814f321bb1ccdd056e3c788", pictures[0].getData());
+ //assertDigestEquals("Wrong data for picture 2", "987a698e83559cf3d38a0deeba1cc63b", pictures[1].getData());
+
+ // Actual embedded objects.
+ ObjectData[] objects = slideShow.getEmbeddedObjects();
+ assertEquals("Should be two objects", 2, objects.length);
+ //assertDigestEquals("Wrong data for objecs 1", "0d1fcc61a83de5c4894dc0c88e9a019d", objects[0].getData());
+ //assertDigestEquals("Wrong data for object 2", "b323604b2003a7299c77c2693b641495", objects[1].getData());
+ }
+
+ public void testOLEShape() throws Exception {
+ String dirname = System.getProperty("HSLF.testdata.path");
+ File file = new File(dirname, "ole2-embedding-2003.ppt");
+ FileInputStream is = new FileInputStream(file);
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ Slide slide = ppt.getSlides()[0];
+ Shape[] sh = slide.getShapes();
+ int cnt = 0;
+ for (int i = 0; i < sh.length; i++) {
+ if(sh[i] instanceof OLEShape){
+ cnt++;
+ OLEShape ole = (OLEShape)sh[i];
+ ObjectData data = ole.getObjectData();
+ if("Worksheet".equals(ole.getInstanceName())){
+ //Voila! we created a workbook from the embedded OLE data
+ HSSFWorkbook wb = new HSSFWorkbook(data.getData());
+ HSSFSheet sheet = wb.getSheetAt(0);
+ //verify we can access the xls data
+ assertEquals(1, sheet.getRow(0).getCell(0).getNumericCellValue(), 0);
+ assertEquals(1, sheet.getRow(1).getCell(0).getNumericCellValue(), 0);
+ assertEquals(2, sheet.getRow(2).getCell(0).getNumericCellValue(), 0);
+ assertEquals(3, sheet.getRow(3).getCell(0).getNumericCellValue(), 0);
+ assertEquals(8, sheet.getRow(5).getCell(0).getNumericCellValue(), 0);
+ } else if ("Document".equals(ole.getInstanceName())){
+ //creating a HWPF document
+ HWPFDocument doc = new HWPFDocument(data.getData());
+ String txt = doc.getRange().getParagraph(0).text();
+ assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
+ }
+ }
+
+ }
+ assertEquals("Expected 2 OLE shapes", 2, cnt);
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java Thu May 21 18:12:22 2009
@@ -1,56 +1,55 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
-
-import java.io.IOException;
-
-/**
- * Test adding fonts to the presenataion resources
- *
- * @author Yegor Kozlov
- */
-public class TestPPFont extends TestCase{
-
- public void testCreate() throws IOException {
- SlideShow ppt = new SlideShow();
- assertEquals(1, ppt.getNumberOfFonts());
- assertEquals("Arial", ppt.getFont(0).getFontName());
-
- //adding the same font twice
- assertEquals(0, ppt.addFont(PPFont.ARIAL));
- assertEquals(1, ppt.getNumberOfFonts());
-
- assertEquals(1, ppt.addFont(PPFont.TIMES_NEW_ROMAN));
- assertEquals(2, ppt.addFont(PPFont.COURIER_NEW));
- assertEquals(3, ppt.addFont(PPFont.WINGDINGS));
-
- assertEquals(4, ppt.getNumberOfFonts());
-
- assertEquals(PPFont.TIMES_NEW_ROMAN.getFontName(), ppt.getFont(1).getFontName());
- assertEquals(PPFont.COURIER_NEW.getFontName(), ppt.getFont(2).getFontName());
-
- PPFont font3 = ppt.getFont(3);
- assertEquals(PPFont.WINGDINGS.getFontName(), font3.getFontName());
- assertEquals(PPFont.SYMBOL_CHARSET, font3.getCharSet());
- assertEquals(PPFont.VARIABLE_PITCH, font3.getPitchAndFamily());
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import junit.framework.TestCase;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+import java.io.IOException;
+
+/**
+ * Test adding fonts to the presenataion resources
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestPPFont extends TestCase{
+
+ public void testCreate() throws IOException {
+ SlideShow ppt = new SlideShow();
+ assertEquals(1, ppt.getNumberOfFonts());
+ assertEquals("Arial", ppt.getFont(0).getFontName());
+
+ //adding the same font twice
+ assertEquals(0, ppt.addFont(PPFont.ARIAL));
+ assertEquals(1, ppt.getNumberOfFonts());
+
+ assertEquals(1, ppt.addFont(PPFont.TIMES_NEW_ROMAN));
+ assertEquals(2, ppt.addFont(PPFont.COURIER_NEW));
+ assertEquals(3, ppt.addFont(PPFont.WINGDINGS));
+
+ assertEquals(4, ppt.getNumberOfFonts());
+
+ assertEquals(PPFont.TIMES_NEW_ROMAN.getFontName(), ppt.getFont(1).getFontName());
+ assertEquals(PPFont.COURIER_NEW.getFontName(), ppt.getFont(2).getFontName());
+
+ PPFont font3 = ppt.getFont(3);
+ assertEquals(PPFont.WINGDINGS.getFontName(), font3.getFontName());
+ assertEquals(PPFont.SYMBOL_CHARSET, font3.getCharSet());
+ assertEquals(PPFont.VARIABLE_PITCH, font3.getPitchAndFamily());
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.model;
import junit.framework.TestCase;
@@ -30,7 +31,7 @@
*
* @author Yegor Kozlov
*/
-public class TestPPGraphics2D extends TestCase {
+public final class TestPPGraphics2D extends TestCase {
private SlideShow ppt;
protected void setUp() throws Exception {
@@ -42,7 +43,7 @@
public void testGraphics() throws Exception {
// Starts off empty
assertEquals(0, ppt.getSlides().length);
-
+
// Add a slide
Slide slide = ppt.createSlide();
assertEquals(1, ppt.getSlides().length);
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java Thu May 21 18:12:22 2009
@@ -1,96 +1,97 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import junit.framework.*;
-
-import java.io.FileOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.ddf.EscherBSERecord;
-
-/**
- * Test Picture shape.
- *
- * @author Yegor Kozlov
- */
-public class TestPicture extends TestCase {
-
- /**
- * Test that the reference count of a blip is incremented every time the picture is inserted.
- * This is important when the same image appears multiple times in a slide show.
- *
- */
- public void testMultiplePictures() throws Exception {
- String cwd = System.getProperty("HSLF.testdata.path");
- SlideShow ppt = new SlideShow();
-
- Slide s = ppt.createSlide();
- Slide s2 = ppt.createSlide();
- Slide s3 = ppt.createSlide();
-
- int idx = ppt.addPicture(new File(cwd, "clock.jpg"), Picture.JPEG);
- Picture pict = new Picture(idx);
- Picture pict2 = new Picture(idx);
- Picture pict3 = new Picture(idx);
-
- pict.setAnchor(new Rectangle(10,10,100,100));
- s.addShape(pict);
- EscherBSERecord bse1 = pict.getEscherBSERecord();
- assertEquals(1, bse1.getRef());
-
- pict2.setAnchor(new Rectangle(10,10,100,100));
- s2.addShape(pict2);
- EscherBSERecord bse2 = pict.getEscherBSERecord();
- assertSame(bse1, bse2);
- assertEquals(2, bse1.getRef());
-
- pict3.setAnchor(new Rectangle(10,10,100,100));
- s3.addShape(pict3);
- EscherBSERecord bse3 = pict.getEscherBSERecord();
- assertSame(bse2, bse3);
- assertEquals(3, bse1.getRef());
-
- }
-
- /**
- * Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER
- * was not found. The correct behaviour is to return null.
- */
- public void test46122() throws IOException {
- SlideShow ppt = new SlideShow();
- Slide slide = ppt.createSlide();
-
- Picture pict = new Picture(-1); //index to non-existing picture data
- pict.setSheet(slide);
- PictureData data = pict.getPictureData();
- assertNull(data);
-
- BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics = img.createGraphics();
- pict.draw(graphics);
-
- assertTrue("no errors rendering Picture with null data", true);
- }
-
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import junit.framework.*;
+
+import java.io.FileOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.ddf.EscherBSERecord;
+
+/**
+ * Test Picture shape.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestPicture extends TestCase {
+
+ /**
+ * Test that the reference count of a blip is incremented every time the picture is inserted.
+ * This is important when the same image appears multiple times in a slide show.
+ *
+ */
+ public void testMultiplePictures() throws Exception {
+ String cwd = System.getProperty("HSLF.testdata.path");
+ SlideShow ppt = new SlideShow();
+
+ Slide s = ppt.createSlide();
+ Slide s2 = ppt.createSlide();
+ Slide s3 = ppt.createSlide();
+
+ int idx = ppt.addPicture(new File(cwd, "clock.jpg"), Picture.JPEG);
+ Picture pict = new Picture(idx);
+ Picture pict2 = new Picture(idx);
+ Picture pict3 = new Picture(idx);
+
+ pict.setAnchor(new Rectangle(10,10,100,100));
+ s.addShape(pict);
+ EscherBSERecord bse1 = pict.getEscherBSERecord();
+ assertEquals(1, bse1.getRef());
+
+ pict2.setAnchor(new Rectangle(10,10,100,100));
+ s2.addShape(pict2);
+ EscherBSERecord bse2 = pict.getEscherBSERecord();
+ assertSame(bse1, bse2);
+ assertEquals(2, bse1.getRef());
+
+ pict3.setAnchor(new Rectangle(10,10,100,100));
+ s3.addShape(pict3);
+ EscherBSERecord bse3 = pict.getEscherBSERecord();
+ assertSame(bse2, bse3);
+ assertEquals(3, bse1.getRef());
+
+ }
+
+ /**
+ * Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER
+ * was not found. The correct behaviour is to return null.
+ */
+ public void test46122() throws IOException {
+ SlideShow ppt = new SlideShow();
+ Slide slide = ppt.createSlide();
+
+ Picture pict = new Picture(-1); //index to non-existing picture data
+ pict.setSheet(slide);
+ PictureData data = pict.getPictureData();
+ assertNull(data);
+
+ BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
+ Graphics2D graphics = img.createGraphics();
+ pict.draw(graphics);
+
+ assertTrue("no errors rendering Picture with null data", true);
+ }
+
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.model;
import junit.framework.TestCase;
@@ -29,7 +30,7 @@
*
* @author Yegor Kozlov
*/
-public class TestSetBoldItalic extends TestCase {
+public final class TestSetBoldItalic extends TestCase {
/**
* Verify that we can add TextBox shapes to a slide
* and set some of the style attributes
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.model;
import junit.framework.TestCase;
@@ -36,7 +37,7 @@
*
* @author Yegor Kozlov
*/
-public class TestShapes extends TestCase {
+public final class TestShapes extends TestCase {
private SlideShow ppt;
private SlideShow pptB;
@@ -44,7 +45,7 @@
String dirname = System.getProperty("HSLF.testdata.path");
String filename = dirname + "/empty.ppt";
ppt = new SlideShow(new HSLFSlideShow(filename));
-
+
String filenameB = dirname + "/empty_textbox.ppt";
pptB = new SlideShow(new HSLFSlideShow(filenameB));
}
@@ -166,7 +167,7 @@
ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
sl = ppt.getSlides()[0];
-
+
txtbox = (TextBox)sl.getShapes()[0];
rt = txtbox.getTextRun().getRichTextRuns()[0];
@@ -179,7 +180,7 @@
assertEquals("Arial", rt.getFontName());
assertEquals(Color.red, rt.getFontColor());
}
-
+
/**
* Test with an empty text box
*/
@@ -187,7 +188,7 @@
assertEquals(2, pptB.getSlides().length);
Slide s1 = pptB.getSlides()[0];
Slide s2 = pptB.getSlides()[1];
-
+
// Check we can get the shapes count
assertEquals(2, s1.getShapes().length);
assertEquals(2, s2.getShapes().length);
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java Thu May 21 18:12:22 2009
@@ -1,106 +1,107 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import junit.framework.TestCase;
-
-import java.io.FileInputStream;
-import java.io.File;
-
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
-import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.hslf.record.PPDrawing;
-import org.apache.poi.hslf.usermodel.SlideShow;
-
-/**
- * Test common functionality of the <code>Sheet</code> object.
- * For each ppt in the test directory check that all sheets are properly initialized
- *
- * @author Yegor Kozlov
- */
-public class TestSheet extends TestCase{
-
- /**
- * For each ppt in the test directory check that all sheets are properly initialized
- */
- public void testSheet() throws Exception {
- File home = new File(System.getProperty("HSLF.testdata.path"));
- File[] files = home.listFiles();
- for (int i = 0; i < files.length; i++) {
- if(!files[i].getName().endsWith(".ppt")) continue;
- if(files[i].getName().endsWith("PPT95.ppt")) continue;
-
- try {
- FileInputStream is = new FileInputStream(files[i]);
- HSLFSlideShow hslf = new HSLFSlideShow(is);
- is.close();
-
- SlideShow ppt = new SlideShow(hslf);
- doSlideShow(ppt);
- } catch (EncryptedPowerPointFileException e){
- ; //skip encrypted ppt
- }
- }
- }
-
- private void doSlideShow(SlideShow ppt) throws Exception {
- Slide[] slide = ppt.getSlides();
- for (int i = 0; i < slide.length; i++) {
- verify(slide[i]);
-
- Notes notes = slide[i].getNotesSheet();
- if(notes != null) verify(notes);
-
- MasterSheet master = slide[i].getMasterSheet();
- assertNotNull(master);
- verify(master);
- }
- }
-
- private void verify(Sheet sheet){
- assertNotNull(sheet.getSlideShow());
-
- ColorSchemeAtom colorscheme = sheet.getColorScheme();
- assertNotNull(colorscheme);
-
- PPDrawing ppdrawing = sheet.getPPDrawing();
- assertNotNull(ppdrawing);
-
- Background background = sheet.getBackground();
- assertNotNull(background);
-
- assertTrue(sheet._getSheetNumber() != 0);
- assertTrue(sheet._getSheetRefId() != 0);
-
- TextRun[] txt = sheet.getTextRuns();
- assertTrue(txt != null);
- for (int i = 0; i < txt.length; i++) {
- assertNotNull(txt[i].getSheet());
- }
-
- Shape[] shape = sheet.getShapes();
- assertTrue(shape != null);
- for (int i = 0; i < shape.length; i++) {
- assertNotNull(shape[i].getSpContainer());
- assertNotNull(shape[i].getSheet());
- assertNotNull(shape[i].getShapeName());
- assertNotNull(shape[i].getAnchor());
- }
-
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.FileInputStream;
+import java.io.File;
+
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
+import org.apache.poi.hslf.record.ColorSchemeAtom;
+import org.apache.poi.hslf.record.PPDrawing;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+/**
+ * Test common functionality of the <code>Sheet</code> object.
+ * For each ppt in the test directory check that all sheets are properly initialized
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestSheet extends TestCase{
+
+ /**
+ * For each ppt in the test directory check that all sheets are properly initialized
+ */
+ public void testSheet() throws Exception {
+ File home = new File(System.getProperty("HSLF.testdata.path"));
+ File[] files = home.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if(!files[i].getName().endsWith(".ppt")) continue;
+ if(files[i].getName().endsWith("PPT95.ppt")) continue;
+
+ try {
+ FileInputStream is = new FileInputStream(files[i]);
+ HSLFSlideShow hslf = new HSLFSlideShow(is);
+ is.close();
+
+ SlideShow ppt = new SlideShow(hslf);
+ doSlideShow(ppt);
+ } catch (EncryptedPowerPointFileException e){
+ ; //skip encrypted ppt
+ }
+ }
+ }
+
+ private void doSlideShow(SlideShow ppt) throws Exception {
+ Slide[] slide = ppt.getSlides();
+ for (int i = 0; i < slide.length; i++) {
+ verify(slide[i]);
+
+ Notes notes = slide[i].getNotesSheet();
+ if(notes != null) verify(notes);
+
+ MasterSheet master = slide[i].getMasterSheet();
+ assertNotNull(master);
+ verify(master);
+ }
+ }
+
+ private void verify(Sheet sheet){
+ assertNotNull(sheet.getSlideShow());
+
+ ColorSchemeAtom colorscheme = sheet.getColorScheme();
+ assertNotNull(colorscheme);
+
+ PPDrawing ppdrawing = sheet.getPPDrawing();
+ assertNotNull(ppdrawing);
+
+ Background background = sheet.getBackground();
+ assertNotNull(background);
+
+ assertTrue(sheet._getSheetNumber() != 0);
+ assertTrue(sheet._getSheetRefId() != 0);
+
+ TextRun[] txt = sheet.getTextRuns();
+ assertTrue(txt != null);
+ for (int i = 0; i < txt.length; i++) {
+ assertNotNull(txt[i].getSheet());
+ }
+
+ Shape[] shape = sheet.getShapes();
+ assertTrue(shape != null);
+ for (int i = 0; i < shape.length; i++) {
+ assertNotNull(shape[i].getSpContainer());
+ assertNotNull(shape[i].getSheet());
+ assertNotNull(shape[i].getShapeName());
+ assertNotNull(shape[i].getAnchor());
+ }
+
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.model;
@@ -32,7 +29,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestSlideChangeNotes extends TestCase {
+public final class TestSlideChangeNotes extends TestCase {
// SlideShow primed on the test data
private SlideShow ss;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java Thu May 21 18:12:22 2009
@@ -31,10 +31,10 @@
/**
* Tests for SlideMaster
- *
+ *
* @author Yegor Kozlov
*/
-public class TestSlideMaster extends TestCase{
+public final class TestSlideMaster extends TestCase{
String home;
public void setUp() throws Exception {
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java Thu May 21 18:12:22 2009
@@ -26,12 +26,12 @@
/**
* Test adding new slides to a ppt.
- *
- * Note - uses the same empty PPT file as the core "new Slideshow"
+ *
+ * Note - uses the same empty PPT file as the core "new Slideshow"
* stuff does
* @author Yegor Kozlov
*/
-public class TestSlides extends TestCase {
+public final class TestSlides extends TestCase {
/**
* Add 1 slide to an empty ppt.
@@ -40,7 +40,7 @@
public void testAddSlides1() throws Exception {
SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
assertTrue(ppt.getSlides().length == 0);
-
+
Slide s1 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 1);
assertEquals(3, s1._getSheetRefId());
@@ -63,13 +63,13 @@
public void testAddSlides2() throws Exception {
SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
assertTrue(ppt.getSlides().length == 0);
-
+
Slide s1 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 1);
assertEquals(3, s1._getSheetRefId());
assertEquals(256, s1._getSheetNumber());
assertEquals(1, s1.getSlideNumber());
-
+
Slide s2 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 2);
assertEquals(4, s2._getSheetRefId());
@@ -92,13 +92,13 @@
public void testAddSlides3() throws Exception {
SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
assertTrue(ppt.getSlides().length == 0);
-
+
Slide s1 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 1);
assertEquals(3, s1._getSheetRefId());
assertEquals(256, s1._getSheetNumber());
assertEquals(1, s1.getSlideNumber());
-
+
Slide s2 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 2);
assertEquals(4, s2._getSheetRefId());
@@ -111,7 +111,7 @@
assertEquals(258, s3._getSheetNumber());
assertEquals(3, s3.getSlideNumber());
-
+
//serialize and read again
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
@@ -119,7 +119,7 @@
ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
assertTrue(ppt.getSlides().length == 3);
-
+
// Check IDs are still right
s1 = ppt.getSlides()[0];
assertEquals(256, s1._getSheetNumber());
@@ -139,26 +139,26 @@
public void testAddSlides2to3() throws Exception {
String dirname = System.getProperty("HSLF.testdata.path");
SlideShow ppt = new SlideShow(new HSLFSlideShow(dirname + "/basic_test_ppt_file.ppt"));
-
+
assertTrue(ppt.getSlides().length == 2);
-
+
// First slide is 256 / 4
Slide s1 = ppt.getSlides()[0];
assertEquals(256, s1._getSheetNumber());
assertEquals(4, s1._getSheetRefId());
-
+
// Last slide is 257 / 6
Slide s2 = ppt.getSlides()[1];
assertEquals(257, s2._getSheetNumber());
assertEquals(6, s2._getSheetRefId());
-
+
// Add another slide, goes in at the end
Slide s3 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 3);
assertEquals(258, s3._getSheetNumber());
assertEquals(8, s3._getSheetRefId());
-
+
// Serialize and read again
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
@@ -166,8 +166,8 @@
ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
assertTrue(ppt.getSlides().length == 3);
-
-
+
+
// Check IDs are still right
s1 = ppt.getSlides()[0];
assertEquals(256, s1._getSheetNumber());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org