summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-03-02 20:44:56 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-03-02 20:44:56 -0500
commit3ac33327631408ddc0025ac87f339e23a5746564 (patch)
tree78d734c39b6b28eb4782d0bdb5f22af42be8e607
parent11ab18f7a10cbd5acc45282f31f881ac4723635a (diff)
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.
-rw-r--r--sc/source/core/inc/interpre.hxx8
-rw-r--r--sc/source/core/tool/interpr4.cxx2
-rw-r--r--sc/source/core/tool/interpr7.cxx49
-rw-r--r--sc/source/core/tool/makefile.mk1
4 files changed, 59 insertions, 1 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index d32302749..68aefe905 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 72cc4f7c7..e36328853 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 000000000..c7674d6ff
--- /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@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@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 15ec28399..904f0d14d 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 \