sc/source/core/data/table2.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 0b59601e415d186565278289e4d3613f727ef75c
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Wed Feb 9 20:17:53 2022 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Wed Feb 16 21:21:44 2022 +0100

    tdf#113785 sc: IsDataFiltered must be normalized
    
    I can't believe this hasn't caused major issues
    and has survived as a bug for so long.
    
    Due to the way IsDataFiltered is coded,
    it is required that the range is normalized
    in order to get any kind of meaningful result,
    so lets ensure that.
    
    Change-Id: I2ede77f738fbaeb05a0f1425a2e88e59fca08e9e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129735
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit bda200a5e9c4592bd61b7924fa171ec3265bfd24)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129761
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130049
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 95bef419c9a8..7ed03187b4b4 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3665,6 +3665,8 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool 
bShow)
 
 bool ScTable::IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, 
SCROW nRowEnd) const
 {
+    assert(nColStart <= nColEnd && nRowStart <= nRowEnd
+           && "range must be normalized to obtain a valid result");
     for (SCROW i = nRowStart; i <= nRowEnd; ++i)
     {
         if (RowHidden(i))
@@ -3680,8 +3682,9 @@ bool ScTable::IsDataFiltered(SCCOL nColStart, SCROW 
nRowStart, SCCOL nColEnd, SC
 
 bool ScTable::IsDataFiltered(const ScRange& rRange) const
 {
-    return IsDataFiltered(rRange.aStart.Col(), rRange.aStart.Row(),
-                rRange.aEnd.Col(), rRange.aEnd.Row());
+    ScRange aNormalized(rRange.aStart, rRange.aEnd);
+    return IsDataFiltered(aNormalized.aStart.Col(), aNormalized.aStart.Row(),
+                          aNormalized.aEnd.Col(), aNormalized.aEnd.Row());
 }
 
 void ScTable::SetRowFlags( SCROW nRow, CRFlags nNewFlags )

Reply via email to