Fix bug #48180 - short chart records skipping some unused fields
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@884065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
83504367e3
commit
4bcde19ada
@ -34,6 +34,7 @@
|
||||
|
||||
<changes>
|
||||
<release version="3.6-beta1" date="2009-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">48180 - be more forgiving of short chart records, which skip some unused fields</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">48274 - fix erronious wrapping of byte colours in HSSFPalette.findSimilarColor</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">48269 - fix fetching of error codes from XSSF formula cells</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">48229 - fixed javadoc for HSSFSheet.setColumnWidth and XSSFSheet setColumnWidth </action>
|
||||
|
@ -35,7 +35,7 @@ public final class CatLabRecord extends StandardRecord {
|
||||
private short wOffset;
|
||||
private short at;
|
||||
private short grbit;
|
||||
private short unused;
|
||||
private Short unused;
|
||||
|
||||
public CatLabRecord(RecordInputStream in) {
|
||||
rt = in.readShort();
|
||||
@ -43,12 +43,18 @@ public final class CatLabRecord extends StandardRecord {
|
||||
wOffset = in.readShort();
|
||||
at = in.readShort();
|
||||
grbit = in.readShort();
|
||||
|
||||
// Often, but not always has an unused short at the end
|
||||
if(in.available() == 0) {
|
||||
unused = null;
|
||||
} else {
|
||||
unused = in.readShort();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDataSize() {
|
||||
return 2 + 2 + 2 + 2 + 2 + 2;
|
||||
return 2 + 2 + 2 + 2 + 2 + (unused==null? 0:2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,12 +64,12 @@ public final class CatLabRecord extends StandardRecord {
|
||||
|
||||
@Override
|
||||
public void serialize(LittleEndianOutput out) {
|
||||
|
||||
out.writeShort(rt);
|
||||
out.writeShort(grbitFrt);
|
||||
out.writeShort(wOffset);
|
||||
out.writeShort(at);
|
||||
out.writeShort(grbit);
|
||||
if(unused != null)
|
||||
out.writeShort(unused);
|
||||
}
|
||||
|
||||
|
@ -40,13 +40,18 @@ public final class ChartEndBlockRecord extends StandardRecord {
|
||||
grbitFrt = in.readShort();
|
||||
iObjectKind = in.readShort();
|
||||
|
||||
// Often, but not always has 6 unused bytes at the end
|
||||
if(in.available() == 0) {
|
||||
unused = new byte[0];
|
||||
} else {
|
||||
unused = new byte[6];
|
||||
in.readFully(unused);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDataSize() {
|
||||
return 2 + 2 + 2 + 6;
|
||||
return 2 + 2 + 2 + unused.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1509,4 +1509,17 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(32766, cell2.getStringCellValue().length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Short records on certain sheets with charts in them
|
||||
*/
|
||||
public void test48180() {
|
||||
HSSFWorkbook wb = openSample("48180.xls");
|
||||
|
||||
HSSFSheet s = wb.getSheetAt(0);
|
||||
HSSFCell cell1 = s.getRow(0).getCell(0);
|
||||
assertEquals("test ", cell1.getStringCellValue().toString());
|
||||
|
||||
HSSFCell cell2 = s.getRow(0).getCell(1);
|
||||
assertEquals(1.0, cell2.getNumericCellValue());
|
||||
}
|
||||
}
|
||||
|
BIN
test-data/spreadsheet/48180.xls
Normal file
BIN
test-data/spreadsheet/48180.xls
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user