summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sc/qa/unit/ucalc_formula.cxx2
-rw-r--r--sc/source/core/tool/compiler.cxx9
2 files changed, 8 insertions, 3 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 153096d6a434..feb0e8fef22a 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1464,7 +1464,7 @@ CPPUNIT_TEST_FIXTURE(TestFormula, testFormulaAnnotateTrimOnDoubleRefs)
{
"=SUMPRODUCT(A:A=$C$1; 1-(A:A=$C$1))",
- ScRange(0, 0, 0, 0, 1048575, 0),
+ ScRange(-1, -1, -1, -1, -1, -1), // Has no trimmable double-ref.
0.0,
false // Not in matrix mode.
},
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 451956922c29..7e1fa777bfec 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -6477,6 +6477,8 @@ void ScCompiler::AnnotateTrimOnDoubleRefs()
// OpCode of the "root" operator (which is already in RPN array).
OpCode eOpCode = (*(pCode - 1))->GetOpCode();
+ // Param number of the "root" operator (which is already in RPN array).
+ sal_uInt8 nRootParam = (*(pCode - 1))->GetByte();
// eOpCode can be some operator which does not change with operands with or contains zero values.
if (eOpCode == ocSum)
{
@@ -6569,7 +6571,8 @@ void ScCompiler::AnnotateTrimOnDoubleRefs()
// such that one of the operands of ocEqual is a double-ref.
// Examples of formula that matches this are:
// SUMPRODUCT(IF($A:$A=$L12;$D:$D*G:G))
- // Also in case of DoubleRef arguments around other Binary operators can be trimmable:
+ // Also in case of DoubleRef arguments around other Binary operators can be trimmable inside one parameter
+ // of the root operator:
// SUMPRODUCT(($D:$D>M47:M47)*($D:$D<M48:M48)*($I:$I=N$41))
bool bTillClose = true;
bool bCloseTillIf = false;
@@ -6621,7 +6624,9 @@ void ScCompiler::AnnotateTrimOnDoubleRefs()
case ocUnion:
case ocRange:
{
- if (!pTok->IsInForceArray())
+ // tdf#160616: Double refs with these operators only
+ // trimmable in case of one paramater
+ if (!pTok->IsInForceArray() || nRootParam > 1)
break;
FormulaToken* pLHS = *(ppTok - 1);
FormulaToken* pRHS = *(ppTok - 2);