Bug 55982: Don't fail to open the spreadsheet if no TabIdRecord is found
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1737602 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8263f9d8f
commit
b46a57926c
@ -801,20 +801,24 @@ public final class InternalWorkbook {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* make the tabid record look like the current situation.
|
* make the tabid record look like the current situation.
|
||||||
*
|
|
||||||
* @return number of bytes written in the TabIdRecord
|
|
||||||
*/
|
*/
|
||||||
private int fixTabIdRecord() {
|
private void fixTabIdRecord() {
|
||||||
TabIdRecord tir = ( TabIdRecord ) records.get(records.getTabpos());
|
Record rec = records.get(records.getTabpos());
|
||||||
int sz = tir.getRecordSize();
|
|
||||||
|
// see bug 55982, quite a number of documents do not have a TabIdRecord and
|
||||||
|
// thus there is no way to do the fixup here,
|
||||||
|
// we use the same check on Tabpos as done in other places
|
||||||
|
if(records.getTabpos() <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TabIdRecord tir = ( TabIdRecord ) rec;
|
||||||
short[] tia = new short[ boundsheets.size() ];
|
short[] tia = new short[ boundsheets.size() ];
|
||||||
|
|
||||||
for (short k = 0; k < tia.length; k++) {
|
for (short k = 0; k < tia.length; k++) {
|
||||||
tia[ k ] = k;
|
tia[ k ] = k;
|
||||||
}
|
}
|
||||||
tir.setTabIdArray(tia);
|
tir.setTabIdArray(tia);
|
||||||
return tir.getRecordSize() - sz;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3001,4 +3001,12 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test55982() throws IOException {
|
||||||
|
Workbook wb = HSSFTestDataSamples.openSampleWorkbook("55982.xls");
|
||||||
|
Sheet newSheet = wb.cloneSheet(1);
|
||||||
|
assertNotNull(newSheet);
|
||||||
|
wb.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test-data/spreadsheet/55982.xls
Normal file
BIN
test-data/spreadsheet/55982.xls
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user