poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwool...@apache.org
Subject svn commit: r1856652 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
Date Sun, 31 Mar 2019 01:00:06 GMT
Author: gwoolsey
Date: Sun Mar 31 01:00:05 2019
New Revision: 1856652

URL: http://svn.apache.org/viewvc?rev=1856652&view=rev
Log:
#61700 getForceFormulaRecalculation() returns wrong value

changed to use the proper OOXML attribute instead of a hack about calculation engine version
ID.  Reporter was right, the behavior was wrong in some cases, but it turns out the fix was
a bit more.  See issue for details.

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1856652&r1=1856651&r2=1856652&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Sun Mar 31 01:00:05
2019
@@ -2221,9 +2221,9 @@ public class XSSFWorkbook extends POIXML
     public void setForceFormulaRecalculation(boolean value){
         CTWorkbook ctWorkbook = getCTWorkbook();
         CTCalcPr calcPr = ctWorkbook.isSetCalcPr() ? ctWorkbook.getCalcPr() : ctWorkbook.addNewCalcPr();
-        // when set to 0, will tell Excel that it needs to recalculate all formulas
+        // when set to true, will tell Excel that it needs to recalculate all formulas
         // in the workbook the next time the file is opened.
-        calcPr.setCalcId(0);
+        calcPr.setFullCalcOnLoad(value);
 
         if(value && calcPr.getCalcMode() == STCalcMode.MANUAL) {
             calcPr.setCalcMode(STCalcMode.AUTO);
@@ -2239,7 +2239,7 @@ public class XSSFWorkbook extends POIXML
     public boolean getForceFormulaRecalculation(){
         CTWorkbook ctWorkbook = getCTWorkbook();
         CTCalcPr calcPr = ctWorkbook.getCalcPr();
-        return calcPr != null && calcPr.getCalcId() != 1;
+        return calcPr != null && calcPr.isSetFullCalcOnLoad() && calcPr.getFullCalcOnLoad();
     }
 
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java?rev=1856652&r1=1856651&r2=1856652&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java Sun
Mar 31 01:00:05 2019
@@ -489,7 +489,7 @@ public final class TestXSSFWorkbook exte
             CTWorkbook ctWorkbook = wb.getCTWorkbook();
             assertFalse(ctWorkbook.isSetCalcPr());
 
-            wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
+            wb.setForceFormulaRecalculation(true);
 
             CTCalcPr calcPr = ctWorkbook.getCalcPr();
             assertNotNull(calcPr);
@@ -498,8 +498,7 @@ public final class TestXSSFWorkbook exte
             calcPr.setCalcId(100);
             assertTrue(wb.getForceFormulaRecalculation());
 
-            wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
-            assertEquals(0, (int) calcPr.getCalcId());
+            wb.setForceFormulaRecalculation(false);
             assertTrue(wb.getForceFormulaRecalculation());
 
             // calcMode="manual" is unset when forceFormulaRecalculation=true
@@ -1145,8 +1144,7 @@ public final class TestXSSFWorkbook exte
     }
     
     /**
-     * See bug #61700 test data tables
-     *
+     * See bug #61700
      * @throws Exception
      */
     @Test
@@ -1154,14 +1152,14 @@ public final class TestXSSFWorkbook exte
         Workbook workbook = _testDataProvider.createWorkbook();
         workbook.createSheet().createRow(0).createCell(0).setCellFormula("B1+C1");
         workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
-
+    
         assertFalse(workbook.getForceFormulaRecalculation());
         workbook.setForceFormulaRecalculation(true);
         assertTrue(workbook.getForceFormulaRecalculation());
-
+    
         Workbook wbBack = _testDataProvider.writeOutAndReadBack(workbook);
         assertTrue(wbBack.getForceFormulaRecalculation());
-
+    
         workbook.close();
         wbBack.close();
     }



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


Mime
View raw message