sc: Add sheet view sync for DeleteSparklineGroupOperation
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202114 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit fa6173c7633602cbd9b0c8ec5f0d2931a3313eeb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205550 Tested-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
d7238871d1
commit
86c3b212a8
@@ -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<beans::PropertyValue>());
|
||||
ScDocShell* pDocShell = dynamic_cast<ScDocShell*>(pModelObj->GetEmbeddedObject());
|
||||
ScDocument& rDocument = pDocShell->GetDocument();
|
||||
|
||||
// Create two sparkline groups with sparklines
|
||||
auto pGroup1 = std::make_shared<sc::SparklineGroup>();
|
||||
auto pGroup2 = std::make_shared<sc::SparklineGroup>();
|
||||
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: */
|
||||
|
||||
@@ -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<UndoDeleteSparklineGroup>(mrDocShell, mpSparklineGroup, mnTab);
|
||||
auto pUndo = std::make_unique<UndoDeleteSparklineGroup>(mrDocShell, mpSparklineGroup, nTab);
|
||||
// delete sparkline group by "redoing"
|
||||
pUndo->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
|
||||
syncSheetViews();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user