poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r677995 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml java/org/apache/poi/hssf/model/Sheet.java testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Date Fri, 18 Jul 2008 18:40:11 GMT
Author: nick
Date: Fri Jul 18 11:40:11 2008
New Revision: 677995

URL: http://svn.apache.org/viewvc?rev=677995&view=rev
Log:
Patch from bug #45414 - Don't add too many UncalcedRecords to sheets with charts in them

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/model/Sheet.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=677995&r1=677994&r2=677995&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Jul 18 11:40:11 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45414 - Don't add too many UncalcedRecords
to sheets with charts in them</action>
            <action dev="POI-DEVELOPERS" type="fix">45398 - Support detecting date formats
containing "am/pm" as date times</action>
            <action dev="POI-DEVELOPERS" type="fix">45410 - Removed dependency from
contrib on commons beanutils,collections and lang</action>
            <action dev="POI-DEVELOPERS" type="add">New helper, HSSFOptimiser, which
handles removing duplicated font and style records, to avoid going over the limits in Excel</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=677995&r1=677994&r2=677995&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Jul 18 11:40:11 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45414 - Don't add too many UncalcedRecords
to sheets with charts in them</action>
            <action dev="POI-DEVELOPERS" type="fix">45398 - Support detecting date formats
containing "am/pm" as date times</action>
            <action dev="POI-DEVELOPERS" type="fix">45410 - Removed dependency from
contrib on commons beanutils,collections and lang</action>
            <action dev="POI-DEVELOPERS" type="add">New helper, HSSFOptimiser, which
handles removing duplicated font and style records, to avoid going over the limits in Excel</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/Sheet.java?rev=677995&r1=677994&r2=677995&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/Sheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/Sheet.java Fri Jul 18 11:40:11 2008
@@ -827,16 +827,21 @@
 
             // If the BOF record was just serialized then add the IndexRecord
             if (record.getSid() == BOFRecord.sid) {
-              // Add an optional UncalcedRecord
-              if (_isUncalced) {
-                  UncalcedRecord rec = new UncalcedRecord();
-                  pos += rec.serialize(pos, data);
-              }
-              //Can there be more than one BOF for a sheet? If not then we can
-              //remove this guard. So be safe it is left here.
-              if (rows != null && !haveSerializedIndex) {
+              if (!haveSerializedIndex) {
                 haveSerializedIndex = true;
-                pos += serializeIndexRecord(k, pos, data);
+                // Add an optional UncalcedRecord. However, we should add
+                //  it in only the once, after the sheet's own BOFRecord.
+                // If there are diagrams, they have their own BOFRecords,
+                //  and one shouldn't go in after that!
+                if (_isUncalced) {
+                    UncalcedRecord rec = new UncalcedRecord();
+                    pos += rec.serialize(pos, data);
+                }
+                //Can there be more than one BOF for a sheet? If not then we can
+                //remove this guard. So be safe it is left here.
+                if (rows != null) {
+                  pos += serializeIndexRecord(k, pos, data);
+                }
               }
             }
         }

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=677995&r1=677994&r2=677995&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 Fri Jul 18 11:40:11
2008
@@ -1362,4 +1362,24 @@
         HSSFSheet sh = wb.getSheetAt(0);
         for(short i=0; i < 30; i++) sh.autoSizeColumn(i);
      }
+    
+    /**
+     * We used to add too many UncalcRecords to sheets
+     *  with diagrams on. Don't any more
+     */
+    public void test45414() throws Exception {
+    	HSSFWorkbook wb = openSample("WithThreeCharts.xls");
+    	wb.getSheetAt(0).setForceFormulaRecalculation(true);
+    	wb.getSheetAt(1).setForceFormulaRecalculation(false);
+    	wb.getSheetAt(2).setForceFormulaRecalculation(true);
+    	
+    	// Write out and back in again
+    	// This used to break
+    	HSSFWorkbook nwb = writeOutAndReadBack(wb);
+    	
+    	// Check now set as it should be
+    	assertTrue(nwb.getSheetAt(0).getForceFormulaRecalculation());
+    	assertFalse(nwb.getSheetAt(1).getForceFormulaRecalculation());
+    	assertTrue(nwb.getSheetAt(2).getForceFormulaRecalculation());
+    }
 }



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


Mime
View raw message