summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2012-10-26 12:21:33 +0000
committerYegor Kozlov <yegor@apache.org>2012-10-26 12:21:33 +0000
commit4575104984e6d74fe8756b709a79c0e86c3c0bef (patch)
treeb1fa8e46edcd2ab086bf1153d60b74abc2a87846
parent59b4c3e08dd36618345b6906d17437e3e3842f60 (diff)
downloadpoi-4575104984e6d74fe8756b709a79c0e86c3c0bef.tar.gz
poi-4575104984e6d74fe8756b709a79c0e86c3c0bef.zip
Bug #54016 - Avoid exception when parsing workbooks with DConRefRecord in row aggregate
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1402482 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/documentation/content/xdocs/status.xml1
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java20
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java6
-rw-r--r--test-data/spreadsheet/54016.xlsbin0 -> 984576 bytes
4 files changed, 12 insertions, 15 deletions
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml
index 839684de4f..27ec8027fb 100644
--- a/src/documentation/content/xdocs/status.xml
+++ b/src/documentation/content/xdocs/status.xml
@@ -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>
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
index e4e92cf709..535e7781f2 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
@@ -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;
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
index 7dd8591b84..f392a4da20 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
@@ -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
index 0000000000..4148ca7904
--- /dev/null
+++ b/test-data/spreadsheet/54016.xls
Binary files differ