sc/source/core/tool/interpr1.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 276037edb6f98ec1fa64e8740958668a1b30cef2
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Aug 26 16:10:38 2022 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Fri Sep 9 15:37:11 2022 +0200

    fix undoing range reducing to apply only to COUNTIFS (tdf#150618)
    
    Before 7674399aac661eb503d7badc53b9a4d68bd9839d the code tried
    to range-reduce all operations except for COUNTIFS, the commit added
    handling also COUNTIFS and then later undo the rare cases when it
    shouldn't be done, but the undo wasn't specific to COUNTIFS even
    though it should have.
    
    Change-Id: Ibdb6516a1ac7bc7d34f16f8a99781859e9fc7b60
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138880
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>
    (cherry picked from commit 5367616819e232e7ef2405c614bbfa3ca0d2aecf)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138974
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit e20d52afe5a33ae9490e238e7b5833d3df68f004)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139416
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index cc485e383038..0fd78f8b1a99 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6092,9 +6092,10 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
                     rParam.eSearchType = 
DetectSearchType(rItem.maString.getString(), mrDoc);
             }
 
-            // Undo bRangeReduce if asked to match empty cells (which should 
be rare).
+            // Undo bRangeReduce if asked to match empty cells for COUNTIFS 
(which should be rare).
             assert(rEntry.GetQueryItems().size() == 1);
-            if((rEntry.IsQueryByEmpty() || rItem.mbMatchEmpty) && bRangeReduce)
+            const bool isCountIfs = (nParamCount % 2) == 0;
+            if(isCountIfs && (rEntry.IsQueryByEmpty() || rItem.mbMatchEmpty) 
&& bRangeReduce)
             {
                 bRangeReduce = false;
                 // All criteria ranges are svDoubleRef's, so only vConditions 
needs adjusting.

Reply via email to