From 86c3b212a8d5dd4e4978d2cb17de8fb42d8ba12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Vajngerl?= Date: Fri, 13 Mar 2026 23:51:34 +0900 Subject: [PATCH] sc: Add sheet view sync for DeleteSparklineGroupOperation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only input tab needs converting to the default view tab. Then sync sheet views. Change-Id: I384fa13ba1158930defca61d1da0dd65ac1512a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201653 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202114 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl (cherry picked from commit fa6173c7633602cbd9b0c8ec5f0d2931a3313eeb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205550 Tested-by: Xisco Fauli Reviewed-by: Xisco Fauli --- sc/qa/unit/tiledrendering/SheetViewTest.cxx | 58 +++++++++++++++++++ .../DeleteSparklineGroupOperation.cxx | 12 ++-- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/sc/qa/unit/tiledrendering/SheetViewTest.cxx b/sc/qa/unit/tiledrendering/SheetViewTest.cxx index 5fa2b3ae7504..509575c4fc59 100644 --- a/sc/qa/unit/tiledrendering/SheetViewTest.cxx +++ b/sc/qa/unit/tiledrendering/SheetViewTest.cxx @@ -3666,6 +3666,64 @@ CPPUNIT_TEST_FIXTURE(SyncTest, testSync_ChangeSparklineGroupAttributes_DefaultAn } } +CPPUNIT_TEST_FIXTURE(SyncTest, testSync_DeleteSparklineGroup_DefaultAndSheetView) +{ + ScModelObj* pModelObj = createDoc("empty.ods"); + pModelObj->initializeForTiledRendering(uno::Sequence()); + ScDocShell* pDocShell = dynamic_cast(pModelObj->GetEmbeddedObject()); + ScDocument& rDocument = pDocShell->GetDocument(); + + // Create two sparkline groups with sparklines + auto pGroup1 = std::make_shared(); + auto pGroup2 = std::make_shared(); + rDocument.CreateSparkline(ScAddress(1, 0, 0), pGroup1); + rDocument.CreateSparkline(ScAddress(1, 1, 0), pGroup1); + rDocument.CreateSparkline(ScAddress(1, 2, 0), pGroup2); + + setupViews(); + + // Create sheet view + { + switchToSheetView(); + createNewSheetViewInCurrentView(); + } + + SCTAB nSheetViewTab = mpTabViewSheetView->GetViewData().GetTabNumber(); + + // Delete sparkline group 1 from default view + { + switchToDefaultView(); + + bool bResult = pDocShell->GetDocFunc().DeleteSparklineGroup(pGroup1, 0); + CPPUNIT_ASSERT(bResult); + + // Verify sparklines from group 1 are gone on default view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 0, 0))); + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 1, 0))); + // Group 2 sparkline still exists + CPPUNIT_ASSERT(rDocument.HasSparkline(ScAddress(1, 2, 0))); + + // Verify synced to sheet view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 0, nSheetViewTab))); + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 1, nSheetViewTab))); + CPPUNIT_ASSERT(rDocument.HasSparkline(ScAddress(1, 2, nSheetViewTab))); + } + + // Delete sparkline group 2 from sheet view + { + switchToSheetView(); + + bool bResult = pDocShell->GetDocFunc().DeleteSparklineGroup(pGroup2, nSheetViewTab); + CPPUNIT_ASSERT(bResult); + + // Verify all sparklines are gone on default view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 2, 0))); + + // Verify synced to sheet view + CPPUNIT_ASSERT(!rDocument.HasSparkline(ScAddress(1, 2, nSheetViewTab))); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/operation/DeleteSparklineGroupOperation.cxx b/sc/source/ui/operation/DeleteSparklineGroupOperation.cxx index f1f22eb96532..2408e9ccb4fc 100644 --- a/sc/source/ui/operation/DeleteSparklineGroupOperation.cxx +++ b/sc/source/ui/operation/DeleteSparklineGroupOperation.cxx @@ -29,18 +29,20 @@ bool DeleteSparklineGroupOperation::runImplementation() if (!mpSparklineGroup) return false; + SCTAB nTab = convertTab(mnTab); + auto& rDocument = mrDocShell.GetDocument(); - if (!rDocument.HasTable(mnTab)) + if (!rDocument.HasTable(nTab)) return false; - if (!checkSheetViewProtection()) - return false; - - auto pUndo = std::make_unique(mrDocShell, mpSparklineGroup, mnTab); + auto pUndo = std::make_unique(mrDocShell, mpSparklineGroup, nTab); // delete sparkline group by "redoing" pUndo->Redo(); mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo)); + + syncSheetViews(); + return true; } }