sc/qa/unit/uicalc/uicalc.cxx | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
New commits: commit 77ae9bbff7ce7118d711f7110ec15dab908f398e Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Jan 21 10:31:20 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jan 21 18:33:12 2021 +0100 CppunitTest_sc_uicalc: Add local function to select range Change-Id: If3d7102ef10935e85e263eb4d2dc56d8a29b4e57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109731 Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 884ed31488df..efdcd7c7af6d 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -21,6 +21,7 @@ #include <docuno.hxx> #include <docsh.hxx> #include <inputopt.hxx> +#include <rangeutl.hxx> #include <scmod.hxx> #include <viewdata.hxx> @@ -60,6 +61,16 @@ static void lcl_AssertCurrentCursorPosition(SCCOL nCol, SCROW nRow) CPPUNIT_ASSERT_EQUAL(sal_Int32(nRow), ScDocShell::GetViewData()->GetCurY()); } +static void lcl_SelectRangeFromString(const ScDocument& rDoc, const OUString& rStr) +{ + ScRange aRange; + sal_Int32 nOffset = 0; + ScRangeStringConverter::GetRangeFromString(aRange, rStr, rDoc, + formula::FormulaGrammar::CONV_OOO, nOffset); + + ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aRange); +} + constexpr OUStringLiteral DATA_DIRECTORY = u"/sc/qa/unit/uicalc/data/"; ScModelObj* ScUiCalcTest::createDoc(const char* pName) @@ -107,17 +118,13 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf120660) aInputOption.SetReplaceCellsWarn(false); pMod->SetInputOptions(aInputOption); - // Select A8:E8 - ScRange aMatRange(0, 7, 0, 4, 7, 0); - ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange); + lcl_SelectRangeFromString(*pDoc, "A8:E8"); ScDocument aClipDoc(SCDOCMODE_CLIP); ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false); Scheduler::ProcessEventsToIdle(); - // Select A4:E4 - aMatRange = ScRange(0, 3, 0, 4, 3, 0); - ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange); + lcl_SelectRangeFromString(*pDoc, "A4:E4"); ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc); Scheduler::ProcessEventsToIdle(); @@ -130,16 +137,12 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf120660) CPPUNIT_ASSERT_EQUAL(2200.0, pDoc->GetValue(ScAddress(4, 3, 0))); CPPUNIT_ASSERT_EQUAL(900.0, pDoc->GetValue(ScAddress(4, 7, 0))); - // Select A8:D8 - aMatRange = ScRange(0, 7, 0, 3, 7, 0); - ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange); + lcl_SelectRangeFromString(*pDoc, "A8:D8"); ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false); Scheduler::ProcessEventsToIdle(); - // Select A4:D4 - aMatRange = ScRange(0, 3, 0, 3, 3, 0); - ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange); + lcl_SelectRangeFromString(*pDoc, "A4:D4"); ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc); Scheduler::ProcessEventsToIdle(); @@ -536,9 +539,8 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf71339) pDoc->SetString(ScAddress(0, 1, 0), "1"); pDoc->SetString(ScAddress(0, 2, 0), "1"); - // A1:A3 - ScRange aMatRange(0, 0, 0, 0, 2, 0); - ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange); + lcl_SelectRangeFromString(*pDoc, "A1:A3"); + dispatchCommand(mxComponent, ".uno:AutoSum", {}); CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(ScAddress(0, 3, 0))); @@ -569,8 +571,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf81351) ScDocShell::GetViewData()->SetCurY(0); lcl_AssertCurrentCursorPosition(0, 0); - ScRange aMatRange(0, 0, 0, 5, 4, 0); - ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange); + lcl_SelectRangeFromString(*pDoc, "A1:F5"); dispatchCommand(mxComponent, ".uno:SortAscending", {}); dispatchCommand(mxComponent, ".uno:GoDown", {}); @@ -602,7 +603,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf81351) CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 3, 0))); CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 4, 0))); - ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange); + lcl_SelectRangeFromString(*pDoc, "A1:F5"); dispatchCommand(mxComponent, ".uno:SortDescending", {}); dispatchCommand(mxComponent, ".uno:GoDown", {}); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits