瀏覽代碼

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
tags/REL_3_8_BETA2
Nick Burch 13 年之前
父節點
當前提交
0055c90bc4

+ 1
- 0
src/documentation/content/xdocs/status.xml 查看文件



<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>

+ 13
- 5
src/java/org/apache/poi/hssf/record/chart/ChartEndObjectRecord.java 查看文件

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];
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 @Override
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
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();
} }

+ 8
- 0
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java 查看文件

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());
}
} }

二進制
test-data/spreadsheet/50939.xls 查看文件


Loading…
取消
儲存