[Libreoffice-commits] core.git: sc/qa sc/source

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 15 14:12:28 UTC 2021


 sc/qa/unit/uicalc/uicalc.cxx       |   41 +++++++++++++++++++++++++++++++++++++
 sc/source/ui/docshell/dbdocfun.cxx |    2 +
 2 files changed, 43 insertions(+)

New commits:
commit 8f4dda644d1ed08ef846b5d09ead365236c57952
Author:     Tünde Tóth <toth.tunde at nisz.hu>
AuthorDate: Wed Feb 10 16:46:12 2021 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Feb 15 15:11:47 2021 +0100

    tdf#123202 calc: fix sorting of autofiltered rows
    
    by keeping the query, when the data range contains
    hidden rows.
    
    Change-Id: Ib3de0c36d53b6fd4541a9cb5e53e018c29bd38c1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110715
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 7335fa01dc22..af82c872a183 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1196,6 +1196,47 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf81351)
     CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 4, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf123202)
+{
+    mxComponent = loadFromDesktop("private:factory/scalc");
+    ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+    CPPUNIT_ASSERT(pModelObj);
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    insertStringToCell(*pModelObj, "A1", "1");
+    insertStringToCell(*pModelObj, "A2", "2");
+    insertStringToCell(*pModelObj, "A3", "3");
+    insertStringToCell(*pModelObj, "A4", "4");
+
+    goToCell("A3");
+
+    dispatchCommand(mxComponent, ".uno:HideRow", {});
+
+    goToCell("A1:A4");
+
+    dispatchCommand(mxComponent, ".uno:SortDescending", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString("4"), pDoc->GetString(ScAddress(0, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("3"), pDoc->GetString(ScAddress(0, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("2"), pDoc->GetString(ScAddress(0, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(ScAddress(0, 3, 0)));
+
+    // This failed, if the "3" is visible.
+    CPPUNIT_ASSERT(pDoc->RowHidden(1, 0));
+    CPPUNIT_ASSERT(!pDoc->RowHidden(2, 0));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(ScAddress(0, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("2"), pDoc->GetString(ScAddress(0, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("3"), pDoc->GetString(ScAddress(0, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("4"), pDoc->GetString(ScAddress(0, 3, 0)));
+
+    CPPUNIT_ASSERT(!pDoc->RowHidden(1, 0));
+    CPPUNIT_ASSERT(pDoc->RowHidden(2, 0));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 6b10b53beb8f..53492205dbd2 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -574,6 +574,8 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
         ScInputOptions aInputOption = SC_MOD()->GetInputOptions();
         bool bUpdateRefs = aInputOption.GetSortRefUpdate();
         ScProgress aProgress(&rDocShell, ScResId(STR_PROGRESS_SORTING), 0, true);
+        if (!bRepeatQuery)
+            bRepeatQuery = rDoc.HasHiddenRows(aLocalParam.nRow1, aLocalParam.nRow2, nTab);
         rDoc.Sort(nTab, aLocalParam, bRepeatQuery, bUpdateRefs, &aProgress, &aUndoParam);
     }
 


More information about the Libreoffice-commits mailing list