officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 8 + sc/inc/sc.hrc | 3 sc/sdi/cellsh.sdi | 1 sc/sdi/scalc.sdi | 19 ++++ sc/source/ui/view/cellsh.cxx | 41 ++++++++++ sc/source/ui/view/cellsh1.cxx | 8 + sc/uiconfig/scalc/popupmenu/cell.xml | 1 7 files changed, 79 insertions(+), 2 deletions(-)
New commits: commit 84dfdac1f7139337e61288af0e75aef66c19b29a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Mar 15 15:47:08 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun Apr 3 12:13:17 2022 +0200 sc: add "Delete Sparkline" context menu command Change-Id: I0e2bf2172da3cbba391ca64c93fad6bccd82f3ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132468 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index e64af0f86161..51cd21e0d33a 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -1082,6 +1082,14 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:DeleteSparkline" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Delete Sparkline</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> <node oor:name=".uno:EditHeaderAndFooter" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Headers and Footers...</value> diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index b9dc48169235..a0acd3f9c94a 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -309,7 +309,8 @@ class SvxZoomSliderItem; #define FID_INS_COLUMNS_BEFORE (INSERT_MENU_START + 23) #define FID_DEFINE_CURRENT_NAME (INSERT_MENU_START + 24) #define SID_INSERT_SPARKLINE (INSERT_MENU_START + 25) -#define INSERT_MENU_END (INSERT_MENU_START + 26) +#define SID_DELETE_SPARKLINE (INSERT_MENU_START + 26) +#define INSERT_MENU_END (INSERT_MENU_START + 27) #define FORMAT_MENU_START (INSERT_MENU_END) #define FID_CELL_FORMAT (FORMAT_MENU_START) diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 8feaf0c590e0..5ad7926b24c6 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -236,6 +236,7 @@ interface CellSelection SID_SELECT_VISIBLE_COLUMNS [ ExecMethod = ExecuteEdit;] SID_CURRENT_FORMULA_RANGE [ ExecMethod = ExecuteEdit;] SID_INSERT_SPARKLINE [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] + SID_DELETE_SPARKLINE [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_THESAURUS [ ExecMethod = ExecuteEdit; StateMethod = GetCellState; ] SID_SPELL_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetState; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 4a8d8747cc14..c95aa01a7e2c 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -2301,7 +2301,24 @@ SfxVoidItem InsertSparkline SID_INSERT_SPARKLINE AccelConfig = TRUE, MenuConfig = TRUE, ToolBoxConfig = TRUE, - GroupId = SfxGroupId::Insert; + GroupId = SfxGroupId::Edit; +] + +SfxVoidItem DeleteSparkline SID_DELETE_SPARKLINE +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Edit; ] SfxVoidItem SearchResultsDialog SID_SEARCH_RESULTS_DIALOG diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index 13d4430a956a..72e4b3c74e1d 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -52,6 +52,8 @@ #include <clipparam.hxx> #include <markdata.hxx> #include <gridwin.hxx> +#include <Sparkline.hxx> +#include <SparklineGroup.hxx> #define ShellClass_ScCellShell #define ShellClass_CellMovement @@ -96,6 +98,38 @@ ScCellShell::~ScCellShell() delete pImpl->m_pRequest; } +namespace +{ + +bool canShowDeleteSparkline(ScDocument& rDocument, ScRange const& rRange) +{ + sc::SparklineGroup* pGroup = nullptr; + SCTAB nTab = rRange.aStart.Tab(); + + for (SCCOL nX = rRange.aStart.Col(); nX <= rRange.aEnd.Col(); nX++) + { + for (SCROW nY = rRange.aStart.Row(); nY <= rRange.aEnd.Row(); nY++) + { + auto* pSparkline = rDocument.GetSparkline(ScAddress(nX, nY, nTab)); + if (pSparkline == nullptr) + { + return false; + } + else if (!pGroup) + { + pGroup = pSparkline->getSparklineGroup().get(); + } + else if (pGroup != pSparkline->getSparklineGroup().get()) + { + return false; + } + } + } + return true; +} + +} // end anonymous namespace + void ScCellShell::GetBlockState( SfxItemSet& rSet ) { ScTabViewShell* pTabViewShell = GetViewData().GetViewShell(); @@ -113,6 +147,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) nRow1 = aMarkRange.aStart.Row(); nCol2 = aMarkRange.aEnd.Col(); nRow2 = aMarkRange.aEnd.Row(); + SCTAB nTab = GetViewData().GetTabNo(); SfxWhichIter aIter(rSet); sal_uInt16 nWhich = aIter.FirstWhich(); @@ -185,6 +220,12 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) } break; + case SID_DELETE_SPARKLINE: + { + bDisable = !canShowDeleteSparkline(rDoc, ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab)); + } + break; + case FID_FILL_SERIES: // fill block case SID_OPENDLG_TABOP: // multiple-cell operations, are at least 2 cells marked? if (rDoc.GetChangeTrack()!=nullptr &&nWhich ==SID_OPENDLG_TABOP) diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 44c640eb8aed..04757e04e1b1 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1060,6 +1060,14 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) } break; + case SID_DELETE_SPARKLINE: + { + pTabViewShell->DeleteContents(InsertDeleteFlags::SPARKLINES); + + rReq.Done(); + } + break; + // disposal (Outlines) // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl) diff --git a/sc/uiconfig/scalc/popupmenu/cell.xml b/sc/uiconfig/scalc/popupmenu/cell.xml index 135cfb2e742e..719de09ae8bc 100644 --- a/sc/uiconfig/scalc/popupmenu/cell.xml +++ b/sc/uiconfig/scalc/popupmenu/cell.xml @@ -64,6 +64,7 @@ <menu:menuitem menu:id=".uno:HideNote"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:InsertSparkline"/> + <menu:menuitem menu:id=".uno:DeleteSparkline"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:CurrentConditionalFormatDialog"/> <menu:menuitem menu:id=".uno:CurrentConditionalFormatManagerDialog"/>