sc/qa/unit/uicalc/uicalc.cxx | 77 +++++++++++++++++++++++++++++++++++++ sc/source/ui/docshell/dbdocfun.cxx | 2 2 files changed, 79 insertions(+)
New commits: commit 472011276be24ef28708d23a85665ad8ca1a56bd Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Wed Feb 10 16:46:12 2021 +0100 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Thu Apr 22 13:25:37 2021 +0200 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 <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110940 Tested-by: Jenkins (cherry picked from commit e51f4419645305037af92d051b7ca40d77da4678) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114431 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index b68c5e6cd941..20be4ea98e28 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -29,6 +29,9 @@ public: ScModelObj* createDoc(const char* pName); void checkCurrentCell(SCCOL nCol, SCROW nRow); + void goToCell(const OUString& rCell); + void insertStringToCell(ScModelObj& rModelObj, const OUString& rCell, const std::string& rStr, + bool bIsArray = false); protected: uno::Reference<lang::XComponent> mxComponent; @@ -55,6 +58,39 @@ void ScUiCalcTest::checkCurrentCell(SCCOL nCol, SCROW nRow) CPPUNIT_ASSERT_EQUAL(sal_Int32(nRow), ScDocShell::GetViewData()->GetCurY()); } +void ScUiCalcTest::goToCell(const OUString& rCell) +{ + uno::Sequence<beans::PropertyValue> aArgs + = comphelper::InitPropertySequence({ { "ToPoint", uno::makeAny(rCell) } }); + dispatchCommand(mxComponent, ".uno:GoToCell", aArgs); +} + +void ScUiCalcTest::insertStringToCell(ScModelObj& rModelObj, const OUString& rCell, + const std::string& rStr, bool bIsArray) +{ + goToCell(rCell); + + for (const char c : rStr) + { + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0); + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0); + Scheduler::ProcessEventsToIdle(); + } + + if (bIsArray) + { + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD1 | KEY_SHIFT | awt::Key::RETURN); + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_MOD1 | KEY_SHIFT | awt::Key::RETURN); + Scheduler::ProcessEventsToIdle(); + } + else + { + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); + Scheduler::ProcessEventsToIdle(); + } +} + char const DATA_DIRECTORY[] = "/sc/qa/unit/uicalc/data/"; ScModelObj* ScUiCalcTest::createDoc(const char* pName) @@ -178,6 +214,47 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf83901) CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(0, 1, 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 352c77f619e9..36197edf8ee4 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); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits