poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r541632 - in /jakarta/poi/trunk/src/scratchpad: src/org/apache/poi/hslf/record/ExHyperlink.java testcases/org/apache/poi/hslf/data/42486.ppt testcases/org/apache/poi/hslf/usermodel/TestBugs.java
Date Fri, 25 May 2007 13:03:27 GMT
Author: yegor
Date: Fri May 25 06:03:26 2007
New Revision: 541632

URL: http://svn.apache.org/viewvc?view=rev&rev=541632
Log:
fixed bug 42486:  Failure parsing a seemingly valid PPT. Some of the assertions in ExHyperlink
were too strong. Write to log instead of throwing exception

Added:
    jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/42486.ppt   (with
props)
Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
    jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.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=541632&r1=541631&r2=541632
==============================================================================
--- 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 Fri May
25 06:03:26 2007
@@ -20,6 +20,7 @@
 import java.io.OutputStream;
 
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogger;
 
 /**
  * This class represents the data of a link in the document. 
@@ -93,37 +94,25 @@
 	 *  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];
 		} else {
-			throw new IllegalStateException("First child record wasn't a ExHyperlinkAtom, was of type
" + _children[0].getRecordType());
-		}
-		
-		// Second child should be the first link details
-		if(_children[1] instanceof CString) {
-			linkDetailsA = (CString)_children[1];
-		} else {
-			throw new IllegalStateException("Second child record wasn't a CString, was of type " +
_children[1].getRecordType());
+			logger.log(POILogger.ERROR, "First child record wasn't a ExHyperlinkAtom, was of type
" + _children[0].getRecordType());
 		}
 
-		// 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 {
-			// Should be fine to not have one
-		}
+        for (int i = 1; i < _children.length; i++) {
+            if (_children[i] instanceof CString){
+                if ( linkDetailsA == null) linkDetailsA = (CString)_children[i];
+                else linkDetailsB = (CString)_children[i];
+            } else {
+                logger.log(POILogger.ERROR, "Record after ExHyperlinkAtom wasn't a CString,
was of type " + _children[1].getRecordType());
+            }
+
+        }
 	}
-	
+
 	/**
 	 * Create a new ExHyperlink, with blank fields
 	 */

Added: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/42486.ppt
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/42486.ppt?view=auto&rev=541632
==============================================================================
Binary file - no diff available.

Propchange: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/42486.ppt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?view=diff&rev=541632&r1=541631&r2=541632
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
(original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
Fri May 25 06:03:26 2007
@@ -184,4 +184,21 @@
         }
     }
 
+    /**
+     * Bug 42486:  Failure parsing a seemingly valid PPT
+     */
+    public void test42486 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42486.ppt"));
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            Shape[] shape = slide[i].getShapes();
+        }
+        assertTrue("No Exceptions while reading file", true);
+
+    }
+
 }



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