You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2008/04/08 16:50:02 UTC
svn commit: r645952 - in /poi/trunk/src/scratchpad:
src/org/apache/poi/hslf/record/PPDrawing.java
src/org/apache/poi/hslf/record/Record.java
testcases/org/apache/poi/hslf/data/44770.ppt
testcases/org/apache/poi/hslf/usermodel/TestBugs.java
Author: yegor
Date: Tue Apr 8 07:49:59 2008
New Revision: 645952
URL: http://svn.apache.org/viewvc?rev=645952&view=rev
Log:
fix bug #44770: RuntimeException: Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing
Added:
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44770.ppt (with props)
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java?rev=645952&r1=645951&r2=645952&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java Tue Apr 8 07:49:59 2008
@@ -119,6 +119,9 @@
* Tree walking way of finding Escher Child Records
*/
private void findEscherChildren(DefaultEscherRecordFactory erf, byte[] source, int startPos, int lenToGo, Vector found) {
+
+ int escherBytes = LittleEndian.getInt( source, startPos + 4 ) + 8;
+
// Find the record
EscherRecord r = erf.createRecord(source,startPos);
// Fill it in
@@ -131,6 +134,17 @@
if(size < 8) {
logger.log(POILogger.WARN, "Hit short DDF record at " + startPos + " - " + size);
}
+
+ /**
+ * Sanity check. Always advance the cursor by the correct value.
+ *
+ * getRecordSize() must return exatcly the same number of bytes that was written in fillFields.
+ * Sometimes it is not so, see an example in bug #44770. Most likely reason is that one of ddf records calculates wrong size.
+ */
+ if(size != escherBytes){
+ logger.log(POILogger.WARN, "Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass());
+ size = escherBytes;
+ }
startPos += size;
lenToGo -= size;
if(lenToGo >= 8) {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=645952&r1=645951&r2=645952&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Tue Apr 8 07:49:59 2008
@@ -185,13 +185,13 @@
// Instantiate
toReturn = (Record)(con.newInstance(new Object[] { b, new Integer(start), new Integer(len) }));
} catch(InstantiationException ie) {
- throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie);
+ throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie, ie);
} catch(java.lang.reflect.InvocationTargetException ite) {
- throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ite + "\nCause was : " + ite.getCause());
+ throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ite + "\nCause was : " + ite.getCause(), ite);
} catch(IllegalAccessException iae) {
- throw new RuntimeException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + iae);
+ throw new RuntimeException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + iae, iae);
} catch(NoSuchMethodException nsme) {
- throw new RuntimeException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + nsme);
+ throw new RuntimeException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + nsme, nsme);
}
// Handling for special kinds of records follow
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44770.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44770.ppt?rev=645952&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44770.ppt
------------------------------------------------------------------------------
svn:executable = *
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44770.ppt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=645952&r1=645951&r2=645952&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Tue Apr 8 07:49:59 2008
@@ -350,4 +350,14 @@
assertEquals(Picture.JPEG, pict.getType());
}
+ /**
+ * Bug 44770: java.lang.RuntimeException: Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing
+ */
+ public void test44770() throws Exception {
+ FileInputStream is = new FileInputStream(new File(cwd, "44770.ppt"));
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ assertTrue("No Exceptions while reading file", true);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org