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
ac0e87072e
commit
9e5f795b54
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.8-beta2" date="2011-??-??">
|
<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="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">50313 - support for getting HWPFDocument fields</action>
|
||||||
<action dev="poi-developers" type="fix">50912 - fixed setting named styles to HSSFCells</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 rt;
|
||||||
private short grbitFrt;
|
private short grbitFrt;
|
||||||
private short iObjectKind;
|
private short iObjectKind;
|
||||||
private byte[] unused;
|
private byte[] reserved;
|
||||||
|
|
||||||
public ChartEndObjectRecord(RecordInputStream in) {
|
public ChartEndObjectRecord(RecordInputStream in) {
|
||||||
rt = in.readShort();
|
rt = in.readShort();
|
||||||
grbitFrt = in.readShort();
|
grbitFrt = in.readShort();
|
||||||
iObjectKind = in.readShort();
|
iObjectKind = in.readShort();
|
||||||
|
|
||||||
unused = new byte[6];
|
// The spec says that there should be 6 bytes at the
|
||||||
in.readFully(unused);
|
// 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
|
@Override
|
||||||
@ -60,7 +68,7 @@ public final class ChartEndObjectRecord extends StandardRecord {
|
|||||||
out.writeShort(grbitFrt);
|
out.writeShort(grbitFrt);
|
||||||
out.writeShort(iObjectKind);
|
out.writeShort(iObjectKind);
|
||||||
// 6 bytes unused
|
// 6 bytes unused
|
||||||
out.write(unused);
|
out.write(reserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +79,7 @@ public final class ChartEndObjectRecord extends StandardRecord {
|
|||||||
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
|
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
|
||||||
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
|
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
|
||||||
buffer.append(" .iObjectKind=").append(HexDump.shortToHex(iObjectKind)).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");
|
buffer.append("[/ENDOBJECT]\n");
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -2028,4 +2028,12 @@ if(1==2) {
|
|||||||
writeOutAndReadBack(wb2);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test-data/spreadsheet/50939.xls
Normal file
BIN
test-data/spreadsheet/50939.xls
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user