[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Mar 2 17:50:33 PST 2011


 sc/source/core/inc/interpre.hxx  |    8 +++++-
 sc/source/core/tool/interpr4.cxx |    2 +
 sc/source/core/tool/interpr7.cxx |   49 +++++++++++++++++++++++++++++++++++++++
 sc/source/core/tool/makefile.mk  |    1 
 4 files changed, 59 insertions(+), 1 deletion(-)

New commits:
commit 3ac33327631408ddc0025ac87f339e23a5746564
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Mar 2 20:44:56 2011 -0500

    Go through all tokens to look for a volatile one. (fdo#31939)
    
    When a volatile token is inside a conditional function (such as IF),
    *and* the evaluation of that conditional skips the volatile token
    it would incorrectly mark the cell non-volatile.  The solution is
    to scan through all tokens in the token array in the beginning of
    the calculation and mark the cell volatile if one is found.

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index d323027..68aefe9 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -804,7 +804,13 @@ double GetGammaDistPDF(double fX, double fAlpha, double fLambda);
 // cumulative distribution function; fLambda is "scale" parameter
 double GetGammaDist(double fX, double fAlpha, double fLambda);
 
-//----------------------------------------------------------------------------
+/**
+ * Go through all tokens to see if the array contains a volatile token.  We
+ * need to do this since a conditional token such as IF function may skip
+ * some tokens and it may incorrectly mark the token array non-volatile.
+ */
+void CheckForVolatileToken();
+
 public:
     ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
                     const ScAddress&, ScTokenArray& );
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 72cc4f7..e363288 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3648,6 +3648,8 @@ StackVar ScInterpreter::Interpret()
     // so reassure exceptions are really off.
     SAL_MATH_FPEXCEPTIONS_OFF();
 
+    CheckForVolatileToken();
+
     aCode.Reset();
     while( ( pCur = aCode.Next() ) != NULL
             && (!nGlobalError || nErrorFunction <= nErrorFunctionCount) )
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
new file mode 100644
index 0000000..c7674d6
--- /dev/null
+++ b/sc/source/core/tool/interpr7.cxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Kohei Yoshida <kyoshida at novell.com> (Novell, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):  Kohei Yoshida <kyoshida at novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "interpre.hxx"
+#include "formula/FormulaCompiler.hxx"
+
+void ScInterpreter::CheckForVolatileToken()
+{
+    for (const formula::FormulaToken* p = aCode.First(); p; p = aCode.Next())
+    {
+        if (formula::FormulaCompiler::IsOpCodeVolatile(p->GetOpCode()))
+        {
+            meVolaileType = VOLATILE;
+            return;
+        }
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/makefile.mk b/sc/source/core/tool/makefile.mk
index 15ec283..904f0d1 100644
--- a/sc/source/core/tool/makefile.mk
+++ b/sc/source/core/tool/makefile.mk
@@ -90,6 +90,7 @@ EXCEPTIONSFILES= \
         $(SLO)$/interpr4.obj \
         $(SLO)$/interpr5.obj \
         $(SLO)$/interpr6.obj \
+        $(SLO)$/interpr7.obj \
         $(SLO)$/lookupcache.obj \
         $(SLO)$/odffmap.obj \
         $(SLO)$/optutil.obj \


More information about the Libreoffice-commits mailing list