diff options
author | Dennis Francis <dennis.francis@collabora.co.uk> | 2018-02-07 12:00:47 +0530 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-04-28 13:33:55 +0200 |
commit | 67b1c26c27590678ece7bcef763433aedd0b164d (patch) | |
tree | efed6b3c2c2a6db724d0aa60dcde735d5d10ac4a /formula | |
parent | 212807f77b78c69263f8aae51dcdc73e8017c53a (diff) |
tdf#114479: compute implicit sum ranges for ocSumIf,ocAverageIf...
and update the sum-range token in RPN array while creation of
the RPN array itself.
+ Adds unit tests.
+ In ScParallelismTest unit test, enable threading in its setUp()
method and restore the original setting in tearDown().
Change-Id: Iee9b7759210a82950181a418eb92766a6cf891fc
Reviewed-on: https://gerrit.libreoffice.org/49465
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index d16e08068b94..96c2e166fe00 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include <sal/macros.h> +#include <sal/alloca.h> #include <formula/FormulaCompiler.hxx> #include <formula/errorcodes.hxx> #include <formula/token.hxx> @@ -1596,7 +1597,21 @@ void FormulaCompiler::Factor() sal_uInt32 nSepCount = 0; if( !bNoParam ) { + bool bDoIICompute = IsIIOpCode(eMyLastOp); + // Array of FormulaToken double pointers to collect the parameters of II opcodes. + FormulaToken*** pArgArray = nullptr; + if (bDoIICompute) + { + pArgArray = static_cast<FormulaToken***>(alloca(sizeof(FormulaToken**)*FORMULA_MAXPARAMSII)); + if (!pArgArray) + bDoIICompute = false; + } + nSepCount++; + + if (bDoIICompute) + pArgArray[nSepCount-1] = pCode - 1; // Add first argument + while ((eOp == ocSep) && (pArr->GetCodeError() == FormulaError::NONE || !mbStopOnError)) { NextToken(); @@ -1605,7 +1620,12 @@ void FormulaCompiler::Factor() if (nSepCount > FORMULA_MAXPARAMS) SetError( FormulaError::CodeOverflow); eOp = Expression(); + if (bDoIICompute && nSepCount <= FORMULA_MAXPARAMSII) + pArgArray[nSepCount - 1] = pCode - 1; // Add rest of the arguments } + if (bDoIICompute) + HandleIIOpCode(eMyLastOp, pArgArray, + std::min(nSepCount, static_cast<sal_uInt32>(FORMULA_MAXPARAMSII))); } if (bBadName) ; // nothing, keep current token for return |