]> source.dussan.org Git - poi.git/commitdiff
Bug #54016 - Avoid exception when parsing workbooks with DConRefRecord in row aggregate
authorYegor Kozlov <yegor@apache.org>
Fri, 26 Oct 2012 12:21:33 +0000 (12:21 +0000)
committerYegor Kozlov <yegor@apache.org>
Fri, 26 Oct 2012 12:21:33 +0000 (12:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1402482 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
test-data/spreadsheet/54016.xls [new file with mode: 0644]

index 839684de4f42d5ab31e0efd788c56cb00aa8a8d9..27ec8027fb7d18c88795fed615a0a06188b0a63d 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.9-beta1" date="2012-??-??">
+          <action dev="poi-developers" type="fix">54016 - Avoid exception when parsing workbooks with DConRefRecord in row aggregate</action>
           <action dev="poi-developers" type="fix">54008 - Fixed Ant build to support build directories with blanks</action>
           <action dev="poi-developers" type="fix">53374 - Avoid exceptions when parsing hyperlinks of type "javascript://"</action>
           <action dev="poi-developers" type="fix">53404 - Fixed compatibility bug with modifying xls files created by POI-3.6 and earlier</action>
index e4e92cf70958ca3856a402785ac754d3d06120b2..535e7781f2dad4aaca82142a8d8dbab0e45883e9 100644 (file)
@@ -24,20 +24,7 @@ import java.util.Map;
 import java.util.TreeMap;
 
 import org.apache.poi.hssf.model.RecordStream;
-import org.apache.poi.hssf.record.ArrayRecord;
-import org.apache.poi.hssf.record.CellValueRecordInterface;
-import org.apache.poi.hssf.record.ContinueRecord;
-import org.apache.poi.hssf.record.DBCellRecord;
-import org.apache.poi.hssf.record.DimensionsRecord;
-import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.IndexRecord;
-import org.apache.poi.hssf.record.MergeCellsRecord;
-import org.apache.poi.hssf.record.MulBlankRecord;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.RowRecord;
-import org.apache.poi.hssf.record.SharedFormulaRecord;
-import org.apache.poi.hssf.record.TableRecord;
-import org.apache.poi.hssf.record.UnknownRecord;
+import org.apache.poi.hssf.record.*;
 import org.apache.poi.ss.formula.FormulaShifter;
 import org.apache.poi.ss.SpreadsheetVersion;
 
@@ -86,7 +73,10 @@ public final class RowRecordsAggregate extends RecordAggregate {
                                case RowRecord.sid:
                                        insertRow((RowRecord) rec);
                                        continue;
-                               case DBCellRecord.sid:
+                case DConRefRecord.sid:
+                    addUnknownRecord(rec);
+                    continue;
+                case DBCellRecord.sid:
                                        // end of 'Row Block'.  Should only occur after cell records
                                        // ignore DBCELL records because POI generates them upon re-serialization
                                        continue;
index 7dd8591b8488109f3b5d2d4cd0d08db6c90bb18e..f392a4da20626e5fc544bd738daf29a92751428f 100644 (file)
@@ -2313,4 +2313,10 @@ if(1==2) {
 
         wb = writeOutAndReadBack((HSSFWorkbook) wb);
     }
+
+    public void test54016() {
+        // This used to break
+        HSSFWorkbook wb = openSample("54016.xls");
+        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
+    }
 }
diff --git a/test-data/spreadsheet/54016.xls b/test-data/spreadsheet/54016.xls
new file mode 100644 (file)
index 0000000..4148ca7
Binary files /dev/null and b/test-data/spreadsheet/54016.xls differ