sc/qa/unit/tiledrendering/SheetViewTest.cxx | 57 ++++++++++++++++++++ sc/source/ui/operation/DeleteSparklineOperation.cxx | 11 ++- 2 files changed, 63 insertions(+), 5 deletions(-)
New commits: commit 5a536b2cdaa9728bcf777ecaa8bb540e2117c5f7 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Fri Mar 13 23:34:05 2026 +0900 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Mar 16 09:29:29 2026 +0100 sc: Add sheet view sync and test for DeleteSparklineOperation Only address as input. Change-Id: I4efaea4274fcbc6e838c1f468d776a3fff38dd05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201647 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sc/qa/unit/tiledrendering/SheetViewTest.cxx b/sc/qa/unit/tiledrendering/SheetViewTest.cxx index 92f8aa5e3c02..e8c648d7c804 100644 --- a/sc/qa/unit/tiledrendering/SheetViewTest.cxx +++ b/sc/qa/unit/tiledrendering/SheetViewTest.cxx @@ -3448,6 +3448,63 @@ CPPUNIT_TEST_FIXTURE(SyncTest, testSync_ChangeSparkline_DefaultAndSheetView) } } +CPPUNIT_TEST_FIXTURE(SyncTest, testSync_DeleteSparkline_DefaultAndSheetView) +{ + ScModelObj* pModelObj = createDoc("empty.ods"); + pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + ScDocShell* pDocShell = dynamic_cast<ScDocShell*>(pModelObj->GetEmbeddedObject()); + ScDocument& rDocument = pDocShell->GetDocument(); + + // Create sparklines at B1 and B2 + auto pSparklineGroup = std::make_shared<sc::SparklineGroup>(); + rDocument.CreateSparkline(ScAddress(1, 0, 0), pSparklineGroup); + rDocument.CreateSparkline(ScAddress(1, 1, 0), pSparklineGroup); + + setupViews(); + + // Create sheet view + { + switchToSheetView(); + createNewSheetViewInCurrentView(); + } + + SCTAB nSheetViewTab = mpTabViewSheetView->GetViewData().GetTabNumber(); + + // Verify sparklines exist on both views + CPPUNIT_ASSERT(rDocument.HasSparkline(ScAddress(1, 0, 0))); + CPPUNIT_ASSERT(rDocument.HasSparkline(ScAddress(1, 1, 0))); + CPPUNIT_ASSERT(rDocument.HasSparkline(ScAddress(1, 0, nSheetViewTab))); + CPPUNIT_ASSERT(rDocument.HasSparkline(ScAddress(1, 1, nSheetViewTab))); + + // Delete sparkline at B1 from default view + { + switchToDefaultView(); + + bool bResult = pDocShell->GetDocFunc().DeleteSparkline(ScAddress(1, 0, 0)); + CPPUNIT_ASSERT(bResult); + + // Verify deleted on default view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 0, 0))); + + // Verify synced to sheet view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 0, nSheetViewTab))); + } + + // Delete sparkline at B2 from sheet view + { + switchToSheetView(); + + bool bResult = pDocShell->GetDocFunc().DeleteSparkline(ScAddress(1, 1, nSheetViewTab)); + CPPUNIT_ASSERT(bResult); + + // Verify deleted on default view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 1, 0))); + + // Verify synced to sheet view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 1, nSheetViewTab))); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/operation/DeleteSparklineOperation.cxx b/sc/source/ui/operation/DeleteSparklineOperation.cxx index 06e7d5f497cd..37947dfbfd2f 100644 --- a/sc/source/ui/operation/DeleteSparklineOperation.cxx +++ b/sc/source/ui/operation/DeleteSparklineOperation.cxx @@ -23,19 +23,20 @@ DeleteSparklineOperation::DeleteSparklineOperation(ScDocShell& rDocShell, ScAddr bool DeleteSparklineOperation::runImplementation() { - auto& rDocument = mrDocShell.GetDocument(); + ScAddress aAddress = convertAddress(maAddress); - if (!rDocument.HasSparkline(maAddress)) - return false; + auto& rDocument = mrDocShell.GetDocument(); - if (!checkSheetViewProtection()) + if (!rDocument.HasSparkline(aAddress)) return false; - auto pUndoDeleteSparkline = std::make_unique<UndoDeleteSparkline>(mrDocShell, maAddress); + auto pUndoDeleteSparkline = std::make_unique<UndoDeleteSparkline>(mrDocShell, aAddress); // delete sparkline by "redoing" pUndoDeleteSparkline->Redo(); mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndoDeleteSparkline)); + syncSheetViews(); + return true; } }
