diff options
author | Marius Volkhart <mariusvolkhart@apache.org> | 2021-02-27 00:43:56 +0000 |
---|---|---|
committer | Marius Volkhart <mariusvolkhart@apache.org> | 2021-02-27 00:43:56 +0000 |
commit | 50757bca8e22c532e9f924c6efa3af9e942a313e (patch) | |
tree | b9731e4ad771b709a906b5688f555ae6c10532b1 /src/testcases/org | |
parent | 451684aa9168aed515ea9f33b8d30f4e99227390 (diff) | |
download | poi-50757bca8e22c532e9f924c6efa3af9e942a313e.tar.gz poi-50757bca8e22c532e9f924c6efa3af9e942a313e.zip |
Fix bug with record indexes for HSSF Workbooks
We have encountered workbooks that do not have a TabIdRecord (see 55982.xls). However, the WorkbookRecordList#updateRecordPos() method would still increment the position of the TabIdRecord for such workbooks. Changing the default position of the record from 0 to -1 indicates that the record position has now been set.
This bug was discovered while adding support for editing pictures in HSSF documents.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886963 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/model/TestWorkbookRecordList.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/model/TestWorkbookRecordList.java b/src/testcases/org/apache/poi/hssf/model/TestWorkbookRecordList.java new file mode 100644 index 0000000000..53fd549842 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/model/TestWorkbookRecordList.java @@ -0,0 +1,26 @@ +package org.apache.poi.hssf.model; + +import org.apache.poi.hssf.record.chart.ChartRecord; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.apache.poi.hssf.HSSFTestDataSamples.openSampleWorkbook; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class TestWorkbookRecordList { + + @Test + public void tabposIsOnlyUpdatedIfWorkbookHasTabIdRecord() throws IOException { + try (HSSFWorkbook wb = openSampleWorkbook("55982.xls")) { + WorkbookRecordList records = wb.getInternalWorkbook().getWorkbookRecordList(); + assertEquals(-1, records.getTabpos()); + + // Add an arbitrary record to the front of the list + records.add(0, new ChartRecord()); + + assertEquals(-1, records.getTabpos()); + } + } +} |