mirror of https://github.com/apache/poi.git
Fix bug #50939 - ChartEndObjectRecord is supposed to have 6 bytes at the end, but handle it not
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1082936 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d82c5b6336
commit
0055c90bc4
|
@ -34,6 +34,7 @@
|
|||
|
||||
<changes>
|
||||
<release version="3.8-beta2" date="2011-??-??">
|
||||
<action dev="poi-developers" type="fix">50939 - ChartEndObjectRecord is supposed to have 6 bytes at the end, but handle it not</action>
|
||||
<action dev="poi-developers" type="add">HMEF - New component which supports TNEF (Transport Neutral Encoding Format), aka winmail.dat</action>
|
||||
<action dev="poi-developers" type="fix">50313 - support for getting HWPFDocument fields</action>
|
||||
<action dev="poi-developers" type="fix">50912 - fixed setting named styles to HSSFCells</action>
|
||||
|
|
|
@ -33,15 +33,23 @@ public final class ChartEndObjectRecord extends StandardRecord {
|
|||
private short rt;
|
||||
private short grbitFrt;
|
||||
private short iObjectKind;
|
||||
private byte[] unused;
|
||||
private byte[] reserved;
|
||||
|
||||
public ChartEndObjectRecord(RecordInputStream in) {
|
||||
rt = in.readShort();
|
||||
grbitFrt = in.readShort();
|
||||
iObjectKind = in.readShort();
|
||||
|
||||
unused = new byte[6];
|
||||
in.readFully(unused);
|
||||
// The spec says that there should be 6 bytes at the
|
||||
// end, which must be there and must be zero
|
||||
// However, sometimes Excel forgets them...
|
||||
reserved = new byte[6];
|
||||
if(in.available() == 0) {
|
||||
// They've gone missing...
|
||||
} else {
|
||||
// Read the reserved bytes
|
||||
in.readFully(reserved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +68,7 @@ public final class ChartEndObjectRecord extends StandardRecord {
|
|||
out.writeShort(grbitFrt);
|
||||
out.writeShort(iObjectKind);
|
||||
// 6 bytes unused
|
||||
out.write(unused);
|
||||
out.write(reserved);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +79,7 @@ public final class ChartEndObjectRecord extends StandardRecord {
|
|||
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
|
||||
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
|
||||
buffer.append(" .iObjectKind=").append(HexDump.shortToHex(iObjectKind)).append('\n');
|
||||
buffer.append(" .unused =").append(HexDump.toHex(unused)).append('\n');
|
||||
buffer.append(" .reserved =").append(HexDump.toHex(reserved)).append('\n');
|
||||
buffer.append("[/ENDOBJECT]\n");
|
||||
return buffer.toString();
|
||||
}
|
||||
|
|
|
@ -2028,4 +2028,12 @@ if(1==2) {
|
|||
writeOutAndReadBack(wb2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The spec says that ChartEndObjectRecord has 6 reserved
|
||||
* bytes on the end, but we sometimes find files without...
|
||||
*/
|
||||
public void test50939() throws Exception {
|
||||
HSSFWorkbook wb = openSample("50939.xls");
|
||||
assertEquals(2, wb.getNumberOfSheets());
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue