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 2007/04/03 12:13:22 UTC

svn commit: r525127 - /jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java

Author: nick
Date: Tue Apr  3 03:13:20 2007
New Revision: 525127

URL: http://svn.apache.org/viewvc?view=rev&rev=525127
Log:
It seems that some PPT files only have linkAtom + linkDetailsA for their ExHyperlink, and miss the linkDetailsB. For those files, do the right thing

Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java

Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java?view=diff&rev=525127&r1=525126&r2=525127
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java Tue Apr  3 03:13:20 2007
@@ -33,7 +33,6 @@
 	private ExHyperlinkAtom linkAtom;
 	private CString linkDetailsA;
 	private CString linkDetailsB;
-	private Comment2000Atom commentAtom; 
 	
 	/** 
 	 * Returns the ExHyperlinkAtom of this link
@@ -55,7 +54,11 @@
 	 */
 	public void setLinkURL(String url) {
 		linkDetailsA.setText(url);
-		linkDetailsB.setText(url);
+
+		// linkDetailsB isn't present in all PPT versions
+		if(linkDetailsB != null) {
+			linkDetailsB.setText(url);
+		}
 	}
 	
 	/**
@@ -90,6 +93,11 @@
 	 *  methods.
 	 */	
 	private void findInterestingChildren() {
+		// We need to have 2 children, ideally 3, and sometimes have more
+		if(_children.length < 2) {
+			throw new IllegalStateException("We need at least two child records, but we only had " + _children.length);
+		}
+
 		// First child should be the ExHyperlinkAtom
 		if(_children[0] instanceof ExHyperlinkAtom) {
 			linkAtom = (ExHyperlinkAtom)_children[0];
@@ -103,11 +111,16 @@
 		} else {
 			throw new IllegalStateException("Second child record wasn't a CString, was of type " + _children[1].getRecordType());
 		}
-		// Third child should be the second link details
-		if(_children[2] instanceof CString) {
-			linkDetailsB = (CString)_children[2];
+
+		// Third child, if it exists, should be the second link details
+		if(_children.length >= 3) {
+			if(_children[2] instanceof CString) {
+				linkDetailsB = (CString)_children[2];
+			} else {
+				throw new IllegalStateException("Third child record wasn't a CString, was of type " + _children[2].getRecordType());
+			}
 		} else {
-			throw new IllegalStateException("Third child record wasn't a CString, was of type " + _children[2].getRecordType());
+			// Should be fine to not have one
 		}
 	}
 	



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