Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-646236 via svnmerge from

https://svn.apache.org:443/repos/asf/poi/trunk

........
  r645952 | yegor | 2008-04-08 15:49:59 +0100 (Tue, 08 Apr 2008) | 1 line
  
  fix bug #44770: RuntimeException: Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing
........
  r646194 | josh | 2008-04-09 06:56:50 +0100 (Wed, 09 Apr 2008) | 1 line
  
  some more tweaks for bug 30311. Set some (unused) bits in  FontFormatting to match Excel.
........


git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@646237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2008-04-09 09:17:58 +00:00
parent 13bbdb732e
commit 033bb682a2
7 changed files with 502 additions and 534 deletions

File diff suppressed because it is too large Load Diff

View File

@ -88,7 +88,7 @@ public final class HSSFFontFormatting
*
* @return fontheight (in points/20); or -1 if not modified
*/
public short getFontHeight()
public int getFontHeight()
{
return fontFormatting.getFontHeight();
}
@ -308,7 +308,7 @@ public final class HSSFFontFormatting
* @param height
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontHeight(short)
*/
public void setFontHeight(short height)
public void setFontHeight(int height)
{
fontFormatting.setFontHeight(height);
}

View File

@ -119,6 +119,9 @@ public class PPDrawing extends RecordAtom
* 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 @@ public class PPDrawing extends RecordAtom
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) {

View File

@ -185,13 +185,13 @@ public abstract class Record
// 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

Binary file not shown.

View File

@ -350,4 +350,14 @@ public class TestBugs extends TestCase {
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);
}
}

View File

@ -230,7 +230,7 @@ public final class TestCFRuleRecord extends TestCase
fontFormatting.setFontColorIndex((short)10);
assertEquals(10,fontFormatting.getFontColorIndex());
fontFormatting.setFontHeight((short)100);
fontFormatting.setFontHeight(100);
assertEquals(100,fontFormatting.getFontHeight());
fontFormatting.setFontOutlineModified(false);