officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu |    8 
 sc/Library_sc.mk                                                  |    1 
 sc/inc/document.hxx                                               |   11 +
 sc/inc/globstr.hrc                                                |    1 
 sc/inc/sc.hrc                                                     |    5 
 sc/qa/unit/SparklineTest.cxx                                      |   65 
+++++++
 sc/sdi/cellsh.sdi                                                 |    1 
 sc/sdi/scalc.sdi                                                  |   17 ++
 sc/source/core/data/document.cxx                                  |   17 +-
 sc/source/ui/docshell/docfunc.cxx                                 |   18 ++
 sc/source/ui/inc/docfunc.hxx                                      |    1 
 sc/source/ui/inc/undo/UndoDeleteSparklineGroup.hxx                |   45 +++++
 sc/source/ui/undo/UndoDeleteSparklineGroup.cxx                    |   82 
++++++++++
 sc/source/ui/view/cellsh.cxx                                      |    1 
 sc/source/ui/view/cellsh1.cxx                                     |   16 +
 sc/uiconfig/scalc/popupmenu/cell.xml                              |    1 
 16 files changed, 281 insertions(+), 9 deletions(-)

New commits:
commit ec18c7bf707e85d85f362d43454d35b1636de40f
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Apr 1 23:03:52 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Apr 6 02:58:45 2022 +0200

    sc: add "Delete Sparkline Group" context menu action + Undo/Redo
    
    Change-Id: I34e11a4881c564351c3e08d157fb42ac4bb8ef3c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132544
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>
    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 98f4c9695acd..70f6b83ef8ed 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1098,6 +1098,14 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:DeleteSparklineGroup" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Delete Sparkline Group</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:EditSparklineGroup" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Edit Sparkline Group...</value>
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 294c36b4578c..9eb23e39240e 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -557,6 +557,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/ui/undo/UndoInsertSparkline \
     sc/source/ui/undo/UndoEditSparklineGroup \
     sc/source/ui/undo/UndoDeleteSparkline \
+    sc/source/ui/undo/UndoDeleteSparklineGroup \
     sc/source/ui/unoobj/ChartRangeSelectionListener \
     sc/source/ui/unoobj/addruno \
     sc/source/ui/unoobj/afmtuno \
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 1cde9b95fe4c..43c2fa96a133 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1249,16 +1249,23 @@ public:
      */
     sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const;
 
-    /** Spaklines */
+    // Spaklines
+    /** Returns sparkline at the addrss if it exists */
     SC_DLLPUBLIC std::shared_ptr<sc::Sparkline> GetSparkline(ScAddress const & 
rPosition);
     SC_DLLPUBLIC bool HasSparkline(ScAddress const & rPosition);
     SC_DLLPUBLIC sc::Sparkline* CreateSparkline(ScAddress const & rPosition, 
std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup);
     SC_DLLPUBLIC sc::SparklineList* GetSparklineList(SCTAB nTab);
     SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rPosition);
+
+    /**
+     * Returns true if the whole range covers one and the same sparkline
+     * group and returns the group via out parameter
+     */
+    SC_DLLPUBLIC bool GetSparklineGroupInRange(ScRange const& rRange, 
std::shared_ptr<sc::SparklineGroup>& rGroup);
     SC_DLLPUBLIC bool HasOneSparklineGroup(ScRange const& rRange);
     SC_DLLPUBLIC std::shared_ptr<sc::SparklineGroup> 
SearchSparklineGroup(tools::Guid const& rGuid);
 
-    /** Notes **/
+    // Notes
     SC_DLLPUBLIC ScPostIt*       GetNote(const ScAddress& rPos);
     SC_DLLPUBLIC ScPostIt*       GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
     void                         SetNote(const ScAddress& rPos, 
std::unique_ptr<ScPostIt> pNote);
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index de33f2d4e61b..6c9318179380 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -541,6 +541,7 @@
 #define STR_INDENTCELL                          NC_("STR_INDENTCELL", "Indent: 
")
 #define STR_UNDO_INSERT_SPARKLINE_GROUP         
NC_("STR_UNDO_INSERT_SPARKLINE", "Insert Sparkline Group")
 #define STR_UNDO_DELETE_SPARKLINE               
NC_("STR_UNDO_DELETE_SPARKLINE", "Delete Sparkline")
+#define STR_UNDO_DELETE_SPARKLINE_GROUP         
NC_("STR_UNDO_DELETE_SPARKLINE_GROUP", "Delete Sparkline Group")
 #define STR_UNDO_EDIT_SPARKLINE_GROUP           
NC_("STR_UNDO_EDIT_SPARKLINE_GROUP", "Edit Sparkline Group")
 
 #endif
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 8555e34ae0b3..3aecfc5cdb31 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -310,8 +310,9 @@ class SvxZoomSliderItem;
 #define FID_DEFINE_CURRENT_NAME (INSERT_MENU_START + 24)
 #define SID_INSERT_SPARKLINE    (INSERT_MENU_START + 25)
 #define SID_DELETE_SPARKLINE    (INSERT_MENU_START + 26)
-#define SID_EDIT_SPARKLINE_GROUP    (INSERT_MENU_START + 27)
-#define INSERT_MENU_END         (INSERT_MENU_START + 28)
+#define SID_EDIT_SPARKLINE_GROUP      (INSERT_MENU_START + 27)
+#define SID_DELETE_SPARKLINE_GROUP    (INSERT_MENU_START + 28)
+#define INSERT_MENU_END         (INSERT_MENU_START + 29)
 
 #define FORMAT_MENU_START       (INSERT_MENU_END)
 #define FID_CELL_FORMAT         (FORMAT_MENU_START)
diff --git a/sc/qa/unit/SparklineTest.cxx b/sc/qa/unit/SparklineTest.cxx
index 46aed9510ba5..aea9d45152e0 100644
--- a/sc/qa/unit/SparklineTest.cxx
+++ b/sc/qa/unit/SparklineTest.cxx
@@ -53,6 +53,7 @@ public:
     void testCutPasteSparkline();
     void testUndoRedoInsertSparkline();
     void testUndoRedoDeleteSparkline();
+    void testUndoRedoDeleteSparklineGroup();
     void testUndoRedoClearContentForSparkline();
     void testUndoRedoEditSparklineGroup();
     void testSparklineList();
@@ -64,6 +65,7 @@ public:
     CPPUNIT_TEST(testCutPasteSparkline);
     CPPUNIT_TEST(testUndoRedoInsertSparkline);
     CPPUNIT_TEST(testUndoRedoDeleteSparkline);
+    CPPUNIT_TEST(testUndoRedoDeleteSparklineGroup);
     CPPUNIT_TEST(testUndoRedoClearContentForSparkline);
     CPPUNIT_TEST(testUndoRedoEditSparklineGroup);
     CPPUNIT_TEST(testSparklineList);
@@ -371,6 +373,69 @@ void SparklineTest::testUndoRedoDeleteSparkline()
     xDocSh->DoClose();
 }
 
+void SparklineTest::testUndoRedoDeleteSparklineGroup()
+{
+    ScDocShellRef xDocSh = loadEmptyDocument();
+    CPPUNIT_ASSERT(xDocSh);
+
+    ScDocument& rDocument = xDocSh->GetDocument();
+    ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false);
+    CPPUNIT_ASSERT(pViewShell);
+
+    auto& rDocFunc = xDocSh->GetDocFunc();
+
+    // insert test data - A1:A6
+    insertTestData(rDocument);
+
+    // Sparkline range
+    ScRange aDataRange(0, 0, 0, 3, 5, 0); //A1:D6
+    ScRange aRange(0, 6, 0, 3, 6, 0); // A7:D7
+
+    auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
+    CPPUNIT_ASSERT(rDocFunc.InsertSparklines(aDataRange, aRange, 
pSparklineGroup));
+
+    // Check Sparklines
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(0, 6, 0))); // 
A7
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(1, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(2, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(3, 6, 0))); // 
D7
+
+    // Delete Sparkline
+    CPPUNIT_ASSERT(rDocFunc.DeleteSparklineGroup(pSparklineGroup, SCTAB(0)));
+
+    // Check Sparklines
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(0, 6, 0))); 
// A7
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(1, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(2, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(3, 6, 0))); 
// D7
+
+    // Undo
+    rDocument.GetUndoManager()->Undo();
+
+    // Check Sparklines
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(0, 6, 0))); // 
A7
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(1, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(2, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(true, rDocument.HasSparkline(ScAddress(3, 6, 0))); // 
D7
+
+    // Check if the sparkline has the input range set
+    auto const& pSparkline = rDocument.GetSparkline(ScAddress(3, 6, 0));
+    ScRangeList rRangeList = pSparkline->getInputRange();
+    CPPUNIT_ASSERT_EQUAL(size_t(1), rRangeList.size());
+    CPPUNIT_ASSERT_EQUAL(ScRange(3, 0, 0, 3, 5, 0), rRangeList[0]);
+
+    // Redo
+    rDocument.GetUndoManager()->Redo();
+
+    // Check Sparklines
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(0, 6, 0))); 
// A7
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(1, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(2, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(false, rDocument.HasSparkline(ScAddress(3, 6, 0))); 
// D7
+
+    xDocSh->DoClose();
+}
+
 void SparklineTest::testUndoRedoClearContentForSparkline()
 {
     ScDocShellRef xDocSh = loadEmptyDocument();
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index c330aeed2fd8..2adf15b60f8f 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -238,6 +238,7 @@ interface CellSelection
     SID_INSERT_SPARKLINE                [ ExecMethod = ExecuteEdit; 
StateMethod = GetBlockState; ]
     SID_DELETE_SPARKLINE                [ ExecMethod = ExecuteEdit; 
StateMethod = GetBlockState; ]
     SID_EDIT_SPARKLINE_GROUP            [ ExecMethod = ExecuteEdit; 
StateMethod = GetBlockState; ]
+    SID_DELETE_SPARKLINE_GROUP          [ 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 a83578ea9693..c33ffa1cb7d8 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -2338,6 +2338,23 @@ SfxVoidItem EditSparklineGroup SID_EDIT_SPARKLINE_GROUP
     GroupId = SfxGroupId::Edit;
 ]
 
+SfxVoidItem DeleteSparklineGroup SID_DELETE_SPARKLINE_GROUP
+()
+[
+    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
 (SfxBoolItem Visible SID_SEARCH_RESULTS_DIALOG)
 [
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index e428ccb6f568..32ab6d73538d 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6617,10 +6617,15 @@ sc::SparklineList* ScDocument::GetSparklineList(SCTAB 
nTab)
     return nullptr;
 }
 
-
 bool ScDocument::HasOneSparklineGroup(ScRange const& rRange)
 {
-    sc::SparklineGroup* pGroup = nullptr;
+    std::shared_ptr<sc::SparklineGroup> pSparklineGroup;
+    return GetSparklineGroupInRange(rRange, pSparklineGroup);
+}
+
+bool ScDocument::GetSparklineGroupInRange(ScRange const& rRange, 
std::shared_ptr<sc::SparklineGroup>& rGroup)
+{
+    std::shared_ptr<sc::SparklineGroup> pFoundGroup;
     SCTAB nTab = rRange.aStart.Tab();
 
     for (SCCOL nX = rRange.aStart.Col(); nX <= rRange.aEnd.Col(); nX++)
@@ -6632,16 +6637,18 @@ bool ScDocument::HasOneSparklineGroup(ScRange const& 
rRange)
             {
                 return false;
             }
-            else if (!pGroup)
+            else if (!pFoundGroup)
             {
-               pGroup = pSparkline->getSparklineGroup().get();
+               pFoundGroup = pSparkline->getSparklineGroup();
             }
-            else if (pGroup != pSparkline->getSparklineGroup().get())
+            else if (pFoundGroup != pSparkline->getSparklineGroup())
             {
                 return false;
             }
         }
     }
+
+    rGroup = pFoundGroup;
     return true;
 }
 
diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index 265d65f79e28..bb45db9a44ea 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -99,6 +99,7 @@
 #include <SparklineData.hxx>
 #include <undo/UndoInsertSparkline.hxx>
 #include <undo/UndoDeleteSparkline.hxx>
+#include <undo/UndoDeleteSparklineGroup.hxx>
 #include <undo/UndoEditSparklineGroup.hxx>
 #include <config_features.h>
 
@@ -5859,6 +5860,23 @@ bool ScDocFunc::DeleteSparkline(ScAddress const& 
rAddress)
     return true;
 }
 
+bool ScDocFunc::DeleteSparklineGroup(std::shared_ptr<sc::SparklineGroup> 
const& pSparklineGroup, SCTAB nTab)
+{
+    if (!pSparklineGroup)
+        return false;
+
+    auto& rDocument = rDocShell.GetDocument();
+
+    if (!rDocument.HasTable(nTab))
+        return false;
+
+    auto pUndo = std::make_unique<sc::UndoDeleteSparklineGroup>(rDocShell, 
pSparklineGroup, nTab);
+    // delete sparkline group  by "redoing"
+    pUndo->Redo();
+    rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
+    return true;
+}
+
 bool 
ScDocFunc::ChangeSparklineGroupAttributes(std::shared_ptr<sc::SparklineGroup> 
const& pExistingSparklineGroup,
                                                sc::SparklineAttributes const& 
rNewAttributes)
 {
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 72ac0fbcb9f0..b1111fd48bbf 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -241,6 +241,7 @@ public:
                                        std::shared_ptr<sc::SparklineGroup> 
pSparklineGroup);
 
     SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rAddress);
+    SC_DLLPUBLIC bool DeleteSparklineGroup(std::shared_ptr<sc::SparklineGroup> 
const& pSparklineGroup, SCTAB nTab);
 
     SC_DLLPUBLIC bool 
ChangeSparklineGroupAttributes(std::shared_ptr<sc::SparklineGroup> const& 
pExistingSparklineGroup,
                                                      sc::SparklineAttributes 
const& rNewAttributes);
diff --git a/sc/source/ui/inc/undo/UndoDeleteSparklineGroup.hxx 
b/sc/source/ui/inc/undo/UndoDeleteSparklineGroup.hxx
new file mode 100644
index 000000000000..081a741ab347
--- /dev/null
+++ b/sc/source/ui/inc/undo/UndoDeleteSparklineGroup.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <undobase.hxx>
+#include <address.hxx>
+#include <memory>
+
+namespace sc
+{
+class SparklineGroup;
+
+/** Undo action for deleting a sparkline group and all associated sparklines */
+class UndoDeleteSparklineGroup : public ScSimpleUndo
+{
+private:
+    std::shared_ptr<sc::SparklineGroup> mpSparklineGroup;
+    std::vector<std::shared_ptr<sc::Sparkline>> maSparklines;
+    SCTAB mnTab;
+
+public:
+    UndoDeleteSparklineGroup(ScDocShell& rDocShell,
+                             std::shared_ptr<sc::SparklineGroup> const& 
pSparklineGroup,
+                             SCTAB nSheetIndex);
+
+    virtual ~UndoDeleteSparklineGroup() override;
+
+    void Undo() override;
+    void Redo() override;
+    bool CanRepeat(SfxRepeatTarget& rTarget) const override;
+    void Repeat(SfxRepeatTarget& rTarget) override;
+    OUString GetComment() const override;
+};
+
+} // namespace sc
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/UndoDeleteSparklineGroup.cxx 
b/sc/source/ui/undo/UndoDeleteSparklineGroup.cxx
new file mode 100644
index 000000000000..9a8e4eb5df48
--- /dev/null
+++ b/sc/source/ui/undo/UndoDeleteSparklineGroup.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <undo/UndoDeleteSparklineGroup.hxx>
+#include <globstr.hrc>
+#include <scresid.hxx>
+#include <document.hxx>
+
+#include <Sparkline.hxx>
+#include <SparklineList.hxx>
+#include <SparklineGroup.hxx>
+
+namespace sc
+{
+UndoDeleteSparklineGroup::UndoDeleteSparklineGroup(
+    ScDocShell& rDocShell, std::shared_ptr<sc::SparklineGroup> const& 
pSparklineGroup, SCTAB nTab)
+    : ScSimpleUndo(&rDocShell)
+    , mpSparklineGroup(pSparklineGroup)
+    , mnTab(nTab)
+{
+}
+
+UndoDeleteSparklineGroup::~UndoDeleteSparklineGroup() {}
+
+void UndoDeleteSparklineGroup::Undo()
+{
+    BeginUndo();
+
+    ScDocument& rDocument = pDocShell->GetDocument();
+
+    for (auto const& pSparkline : maSparklines)
+    {
+        ScAddress aAddress(pSparkline->getColumn(), pSparkline->getRow(), 
mnTab);
+        auto* pNewSparkline = rDocument.CreateSparkline(aAddress, 
mpSparklineGroup);
+        pNewSparkline->setInputRange(pSparkline->getInputRange());
+    }
+
+    pDocShell->PostPaintGridAll();
+
+    EndUndo();
+}
+
+void UndoDeleteSparklineGroup::Redo()
+{
+    BeginRedo();
+
+    ScDocument& rDocument = pDocShell->GetDocument();
+    auto* pList = rDocument.GetSparklineList(mnTab);
+    if (pList)
+    {
+        maSparklines = pList->getSparklinesFor(mpSparklineGroup);
+
+        for (auto const& pSparkline : maSparklines)
+        {
+            ScAddress aAddress(pSparkline->getColumn(), pSparkline->getRow(), 
mnTab);
+            rDocument.DeleteSparkline(aAddress);
+        }
+    }
+    pDocShell->PostPaintGridAll();
+
+    EndRedo();
+}
+
+void UndoDeleteSparklineGroup::Repeat(SfxRepeatTarget& /*rTarget*/) {}
+
+bool UndoDeleteSparklineGroup::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { 
return false; }
+
+OUString UndoDeleteSparklineGroup::GetComment() const
+{
+    return ScResId(STR_UNDO_DELETE_SPARKLINE_GROUP);
+}
+
+} // end sc namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index de2a40da3daf..68be82997b7c 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -190,6 +190,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
 
             case SID_DELETE_SPARKLINE:
             case SID_EDIT_SPARKLINE_GROUP:
+            case SID_DELETE_SPARKLINE_GROUP:
             {
                 bDisable = !rDoc.HasOneSparklineGroup(ScRange(nCol1, nRow1, 
nTab, nCol2, nRow2, nTab));
             }
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 86e028b5396c..74d31f68fb89 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1070,6 +1070,22 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
         }
         break;
 
+        case SID_DELETE_SPARKLINE_GROUP:
+        {
+            ScRange aMarkRange;
+            ScMarkType eMarkType = GetViewData().GetSimpleArea(aMarkRange);
+            if (eMarkType == SC_MARK_SIMPLE)
+            {
+                std::shared_ptr<sc::SparklineGroup> pSparklineGroup;
+                if 
(GetViewData().GetDocument().GetSparklineGroupInRange(aMarkRange, 
pSparklineGroup) && pSparklineGroup)
+                {
+                    
GetViewData().GetDocShell()->GetDocFunc().DeleteSparklineGroup(pSparklineGroup, 
GetViewData().GetTabNo());
+                }
+            }
+            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 55e33f7e09b2..d2eab7422839 100644
--- a/sc/uiconfig/scalc/popupmenu/cell.xml
+++ b/sc/uiconfig/scalc/popupmenu/cell.xml
@@ -67,6 +67,7 @@
     <menu:menupopup>
       <menu:menuitem menu:id=".uno:InsertSparkline"/>
       <menu:menuitem menu:id=".uno:DeleteSparkline"/>
+      <menu:menuitem menu:id=".uno:DeleteSparklineGroup"/>
       <menu:menuitem menu:id=".uno:EditSparklineGroup"/>
     </menu:menupopup>
   </menu:menu>

Reply via email to