]> source.dussan.org Git - poi.git/commitdiff
Apply patch for bug 64791 to use proper position for the WriteAccessRecord
authorDominik Stadler <centic@apache.org>
Sun, 25 Oct 2020 07:21:56 +0000 (07:21 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 25 Oct 2020 07:21:56 +0000 (07:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1882829 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/model/InternalWorkbook.java
src/testcases/org/apache/poi/hssf/model/TestWorkbook.java

index eb232c6ecfcaa3d93d32c4ec0f545ccb9340bae6..8ddb368e0a9d16654be189f254da45908e70c2dc 100644 (file)
@@ -336,7 +336,8 @@ public final class InternalWorkbook {
         records.add(new InterfaceHdrRecord(CODEPAGE));
         records.add(createMMS());
         records.add(InterfaceEndRecord.instance);
-        records.add(createWriteAccess());
+        // store the write-access record at the proper position
+        retval.getWriteAccess();
         records.add(createCodepage());
         records.add(createDSF());
         records.add(createTabId());
index 996f450922ecab3c307f2c717f844f6170886c3b..bc8db67c85d3d2f718a418c66a4abe363e5368c3 100644 (file)
@@ -154,4 +154,22 @@ public final class TestWorkbook {
 
         wb.close();
     }
+
+    @Test
+    public void testWriteAccess() {
+        HSSFWorkbook wb = new HSSFWorkbook();
+        InternalWorkbook iwb = TestHSSFWorkbook.getInternalWorkbook(wb);
+
+        int oldRecordsCount = iwb.getNumRecords();
+        //System.out.println("records count = " + oldRecordsCount);
+        assertEquals("records count", 68, oldRecordsCount);
+
+        WriteAccessRecord writeAccess = iwb.getWriteAccess();
+        assertNotNull(writeAccess);
+        assertEquals(WriteAccessRecord.sid, writeAccess.getSid());
+
+        int newRecordsCount = iwb.getNumRecords();
+        //System.out.println("records count after 'getWriteAccess' = " + newRecordsCount);
+        assertEquals("records count after getWriteAccess", oldRecordsCount, newRecordsCount);
+    }
 }