* 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
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) {
// 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
assertEquals(Picture.JPEG, pict.getType());\r
}\r
\r
+ /**\r
+ * Bug 44770: java.lang.RuntimeException: Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing\r
+ */\r
+ public void test44770() throws Exception {\r
+ FileInputStream is = new FileInputStream(new File(cwd, "44770.ppt"));\r
+ SlideShow ppt = new SlideShow(is);\r
+ is.close();\r
+\r
+ assertTrue("No Exceptions while reading file", true);\r
+ }\r
}\r