Author: yegor
Date: Thu Mar 29 10:35:41 2012
New Revision: 1306781
URL: http://svn.apache.org/viewvc?rev=1306781&view=rev
Log:
Bugzilla 49529 - avoid exception when cloning sheets with no drawing records
and initialized drawing patriarch
Added:
poi/trunk/test-data/spreadsheet/49529.xls (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL:
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1306781&r1=1306780&r2=1306781&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Mar 29 10:35:41
2012
@@ -34,7 +34,7 @@
<changes>
<release version="3.9-beta1" date="2012-??-??">
-
+ <action dev="poi-developers" type="fix">49529 - avoid exception when
cloning sheets with no drawing records and initialized drawing
patriarch</action>
</release>
<release version="3.8-FINAL" date="2012-03-26">
<action dev="poi-developers" type="add">52928 -
DateFormatConverter: an utility to convert instances of java.text.DateFormat to
Excel format patterns</action>
Modified: poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java?rev=1306781&r1=1306780&r2=1306781&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java Thu Mar 29
10:35:41 2012
@@ -386,6 +386,14 @@ public final class InternalSheet {
((RecordAggregate) rb).visitContainedRecords(new
RecordCloner(clonedRecords));
continue;
}
+ if (rb instanceof EscherAggregate){
+ // EscherAggregate is used only as a container for SODRAWING
and OBJ record combinations
+ // So, if the container is empty, there is no reason to clone
this record
+ // See https://issues.apache.org/bugzilla/show_bug.cgi?id=49529
+ if (0 == rb.getRecordSize()){
+ continue;
+ }
+ }
Record rec = (Record) ((Record) rb).clone();
clonedRecords.add(rec);
}
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=1306781&r1=1306780&r2=1306781&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 Thu Mar
29 10:35:41 2012
@@ -2227,4 +2227,15 @@ if(1==2) {
cell.getCellFormula());
}
+ public void test49529() throws Exception {
+ // user code reported in Bugzilla #49529
+ HSSFWorkbook workbook = openSample("49529.xls");
+ workbook.getSheetAt(0).createDrawingPatriarch();
+ // prior to the fix the line below failed with
+ // java.lang.IllegalStateException: EOF - next record not available
+ workbook.cloneSheet(0);
+
+ // make sure we are still readable
+ writeOutAndReadBack(workbook);
+ }
}
Added: poi/trunk/test-data/spreadsheet/49529.xls
URL:
http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/49529.xls?rev=1306781&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/49529.xls
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]