From 94ca402cd1fe2fd9776d08448f7216b7f638e69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=BCnde=20T=C3=B3th?= Date: Tue, 18 Jul 2023 15:20:47 +0200 Subject: [PATCH] tdf#156174 sc DBData: fix regression of database ranges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regression from commit 0c0444c44107f1a18f23dd0833d462d8dbf56569 "tdf#126926 sc DBData: delete the database range". Change-Id: If6cccc41af42a44cadbb8485bfa5b9a8eca5a757 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154582 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh --- sc/qa/unit/uicalc/uicalc2.cxx | 26 ++++++++++++++++++++++++++ sc/source/core/tool/refupdat.cxx | 7 +------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx index 44ebf12935bc..4e154f8bbb83 100644 --- a/sc/qa/unit/uicalc/uicalc2.cxx +++ b/sc/qa/unit/uicalc/uicalc2.cxx @@ -1446,6 +1446,32 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf155796) CPPUNIT_ASSERT_EQUAL(OUString("Sheet1.A1:Sheet1.A3"), aMarkedAreaString); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf156174) +{ + createScDoc(); + ScDocument* pDoc = getScDoc(); + + insertNewSheet(*pDoc); + + insertStringToCell("A1", u"1"); + insertStringToCell("A2", u"2"); + insertStringToCell("B1", u"3"); + insertStringToCell("B2", u"4"); + + ScDBData* pDBData = new ScDBData("testDB", 1, 0, 0, 1, 1); + bool bInserted + = pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr(pDBData)); + CPPUNIT_ASSERT(bInserted); + + insertNewSheet(*pDoc); + uno::Sequence aArgs( + comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(3)) } })); + dispatchCommand(mxComponent, ".uno:Remove", aArgs); + + ScDBCollection* pDBs = pDoc->GetDBCollection(); + CPPUNIT_ASSERT(!pDBs->empty()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx index ef0902aab3f4..e05a14d0137f 100644 --- a/sc/source/core/tool/refupdat.cxx +++ b/sc/source/core/tool/refupdat.cxx @@ -286,12 +286,7 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, UpdateRefMode eUpdat bool bExp = (bExpand && IsExpand( theTab1, theTab2, nTab1, nDz )); bCut1 = lcl_MoveStart( theTab1, nTab1, nDz, nMaxTab ); bCut2 = lcl_MoveEnd( theTab2, nTab1, nDz, nMaxTab ); - if ( theTab2 < theTab1 ) - { - eRet = UR_INVALID; - theTab2 = theTab1; - } - else if ( bCut1 || bCut2 ) + if ( bCut1 || bCut2 ) eRet = UR_UPDATED; if ( bExp ) {