]> source.dussan.org Git - poi.git/commitdiff
Patch from bug #45414 - Don't add too many UncalcedRecords to sheets with charts...
authorNick Burch <nick@apache.org>
Fri, 18 Jul 2008 18:40:11 +0000 (18:40 +0000)
committerNick Burch <nick@apache.org>
Fri, 18 Jul 2008 18:40:11 +0000 (18:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@677995 13f79535-47bb-0310-9956-ffa450edef68

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

index caa238df5949453bc7f08c7c715aeacae76b3d61..9933efbf1f4a0898f5d31e3aaf88341c6cd4ae8d 100644 (file)
@@ -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>
index 798d358294227505e2346f002a84a991c23c1307..09949e470b9a126b99cc642aa1c58d553bd4af52 100644 (file)
@@ -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>
index b95ad6bba38ea9139e22ff22f7f8fd0f0f24a460..cbbe663b1dfa386c3917392a7f581367df485a68 100644 (file)
@@ -827,16 +827,21 @@ public final class Sheet implements Model {
 
             // 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);
+                }
               }
             }
         }
index 6e92f6e3deff0ca90f54a80c0d1c07befb2564c5..fe201068de489cc6ff41398853cd862386a4ead8 100644 (file)
@@ -1362,4 +1362,24 @@ public final class TestBugs extends TestCase {
         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());
+    }
 }