poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r497090 - in /jakarta/poi/trunk/src/scratchpad: src/org/apache/poi/hslf/record/RecordTypes.java testcases/org/apache/poi/hslf/record/TestExHyperlink.java
Date Wed, 17 Jan 2007 17:12:27 GMT
Author: nick
Date: Wed Jan 17 09:12:26 2007
New Revision: 497090

URL: http://svn.apache.org/viewvc?view=rev&rev=497090
Log:
Add ExHyperlink tests against a real file

Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
    jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java

Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?view=diff&rev=497090&r1=497089&r2=497090
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Wed Jan
17 09:12:26 2007
@@ -59,7 +59,7 @@
     public static final Type DocRoutingSlip = new Type(1030,null);
     public static final Type OutlineViewInfo = new Type(1031,null);
     public static final Type SorterViewInfo = new Type(1032,null);
-    public static final Type ExObjList = new Type(1033,null);
+    public static final Type ExObjList = new Type(1033,DummyRecordWithChildren.class);
     public static final Type ExObjListAtom = new Type(1034,null);
     public static final Type PPDrawingGroup = new Type(1035,PPDrawingGroup.class);
     public static final Type PPDrawing = new Type(1036,PPDrawing.class);

Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java?view=diff&rev=497090&r1=497089&r2=497090
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
(original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
Wed Jan 17 09:12:26 2007
@@ -24,8 +24,12 @@
 import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
 /**
  * Tests that ExHyperlink works properly.
  *
@@ -95,6 +99,46 @@
 	}
 	
 	public void testRealFile() throws Exception {
-		// TODO
+		String dirname = System.getProperty("HSLF.testdata.path");
+		HSLFSlideShow hss = new HSLFSlideShow(dirname + "WithLinks.ppt");
+		SlideShow ss = new SlideShow(hss);
+		
+		// Get the document
+		Document doc = ss.getDocumentRecord();
+		// Get the ExObjList
+		RecordContainer exObjList = null;
+		for(int i=0; i<doc._children.length; i++) {
+			if(doc._children[i].getRecordType() == RecordTypes.ExObjList.typeID) {
+				exObjList = (RecordContainer)doc._children[i];
+			}
+		}
+		assertNotNull(exObjList);
+		
+		// Within that, grab out the Hyperlink atoms
+		ArrayList linksA = new ArrayList();
+		for(int i=0; i<exObjList._children.length; i++) {
+			if(exObjList._children[i] instanceof ExHyperlink) {
+				linksA.add(exObjList._children[i]);
+			}
+		}
+		
+		// Should be 4 of them
+		assertEquals(4, linksA.size());
+		ExHyperlink[] links = new ExHyperlink[linksA.size()];
+		linksA.toArray(links);
+		
+		// Check they have what we expect in them
+		assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
+		assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
+		
+		assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
+		assertEquals("http://slashdot.org/", links[1].getLinkURL());
+		
+		assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
+		assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
+		
+		assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
+		assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
+		
 	}
 }



---------------------------------------------------------------------
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/


Mime
View raw message