poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1737602 - in /poi/trunk: src/java/org/apache/poi/hssf/model/InternalWorkbook.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/55982.xls
Date Sun, 03 Apr 2016 18:32:22 GMT
Author: centic
Date: Sun Apr  3 18:32:22 2016
New Revision: 1737602

URL: http://svn.apache.org/viewvc?rev=1737602&view=rev
Log:
Bug 55982: Don't fail to open the spreadsheet if no TabIdRecord is found

Added:
    poi/trunk/test-data/spreadsheet/55982.xls
Modified:
    poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java?rev=1737602&r1=1737601&r2=1737602&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java Sun Apr  3 18:32:22
2016
@@ -801,20 +801,24 @@ public final class InternalWorkbook {
 
     /**
      * make the tabid record look like the current situation.
-     *
-     * @return number of bytes written in the TabIdRecord
      */
-    private int fixTabIdRecord() {
-        TabIdRecord tir = ( TabIdRecord ) records.get(records.getTabpos());
-        int sz = tir.getRecordSize();
+    private void fixTabIdRecord() {
+        Record rec = records.get(records.getTabpos());
+
+        // 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() ];
 
         for (short k = 0; k < tia.length; k++) {
             tia[ k ] = k;
         }
         tir.setTabIdArray(tia);
-        return tir.getRecordSize() - sz;
-
     }
 
     /**

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1737602&r1=1737601&r2=1737602&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sun Apr  3 18:32:22
2016
@@ -3001,4 +3001,12 @@ public final class TestBugs extends Base
 
         wb.close();
     }
+
+    @Test
+    public void test55982() throws IOException {
+        Workbook wb = HSSFTestDataSamples.openSampleWorkbook("55982.xls");
+        Sheet newSheet = wb.cloneSheet(1);
+        assertNotNull(newSheet);
+        wb.close();
+    }
 }

Added: poi/trunk/test-data/spreadsheet/55982.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/55982.xls?rev=1737602&view=auto
==============================================================================
Binary files poi/trunk/test-data/spreadsheet/55982.xls (added) and poi/trunk/test-data/spreadsheet/55982.xls
Sun Apr  3 18:32:22 2016 differ



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message