sc/Library_sc.mk                                 |    1 
 sc/inc/SparklineGroup.hxx                        |    3 
 sc/inc/globstr.hrc                               |    1 
 sc/source/ui/dialogs/SparklineDialog.cxx         |  146 ++++++++++-------------
 sc/source/ui/docshell/docfunc.cxx                |   12 +
 sc/source/ui/inc/SparklineDialog.hxx             |    6 
 sc/source/ui/inc/docfunc.hxx                     |    4 
 sc/source/ui/inc/undo/UndoEditSparklineGroup.hxx |   44 ++++++
 sc/source/ui/sparklines/SparklineGroup.cxx       |    6 
 sc/source/ui/undo/UndoEditSparklineGroup.cxx     |   65 ++++++++++
 10 files changed, 210 insertions(+), 78 deletions(-)

New commits:
commit 55f52ab565dcfe26400f69ab978962353102ad8c
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Mar 31 23:07:44 2022 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Thu Mar 31 23:08:13 2022 +0900

    sc: add SparklineGroup Undo/Redo
    
    As SparklineAttributes are COW, we can just exchange them around
    in the SparklineGroup when undoing and redoing.
    
    This also changes SparklineDialog to work with a local copy of
    SparklineAttributes when editing, or an empty initial copy when
    inserting a new Sparkline into the sheet.
    
    Change-Id: I36e9c887ca640f40266f381e98e57f027a5ca07f

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index e97f6e04b4c2..294c36b4578c 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -555,6 +555,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/ui/undo/undotab \
     sc/source/ui/undo/undoutil \
     sc/source/ui/undo/UndoInsertSparkline \
+    sc/source/ui/undo/UndoEditSparklineGroup \
     sc/source/ui/undo/UndoDeleteSparkline \
     sc/source/ui/unoobj/ChartRangeSelectionListener \
     sc/source/ui/unoobj/addruno \
diff --git a/sc/inc/SparklineGroup.hxx b/sc/inc/SparklineGroup.hxx
index d6cb8cf4402d..f9e0f7784feb 100644
--- a/sc/inc/SparklineGroup.hxx
+++ b/sc/inc/SparklineGroup.hxx
@@ -28,11 +28,14 @@ public:
     SparklineAttributes& getAttributes() { return m_aAttributes; }
     SparklineAttributes const& getAttributes() const { return m_aAttributes; }
 
+    void setAttributes(SparklineAttributes const& rAttributes) { m_aAttributes 
= rAttributes; };
+
     tools::Guid& getID() { return m_aGUID; }
 
     void setID(tools::Guid const& rGuid) { m_aGUID = rGuid; }
 
     SparklineGroup();
+    SparklineGroup(SparklineAttributes const& rSparklineAttributes);
 
     SparklineGroup(SparklineGroup const& pOtherSparkline);
 
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index bed2e10f9b51..adb02782122b 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_EDIT_SPARKLINE_GROUP           
NC_("STR_UNDO_EDIT_SPARKLINE_GROUP", "Edit Sparkline Group")
 
 #endif
 
diff --git a/sc/source/ui/dialogs/SparklineDialog.cxx 
b/sc/source/ui/dialogs/SparklineDialog.cxx
index 59068077b969..4a7fa320a38e 100644
--- a/sc/source/ui/dialogs/SparklineDialog.cxx
+++ b/sc/source/ui/dialogs/SparklineDialog.cxx
@@ -163,7 +163,8 @@ void SparklineDialog::setupValues()
     {
         if (auto pSparkline = mrDocument.GetSparkline(aSelectionRange.aStart))
         {
-            mpLocalSparklineGroup = pSparkline->getSparklineGroup();
+            mpSparklineGroup = pSparkline->getSparklineGroup();
+            maAttributes = mpSparklineGroup->getAttributes();
             mxFrameData->set_visible(false);
             mbEditMode = true;
         }
@@ -173,16 +174,9 @@ void SparklineDialog::setupValues()
         maInputRange = aSelectionRange;
     }
 
-    if (!mpLocalSparklineGroup)
-    {
-        mpLocalSparklineGroup = std::make_shared<sc::SparklineGroup>();
-    }
-
     setInputSelection();
 
-    auto const& rAttribute = mpLocalSparklineGroup->getAttributes();
-
-    switch (rAttribute.getType())
+    switch (maAttributes.getType())
     {
         case sc::SparklineType::Line:
             mxRadioLine->set_active(true);
@@ -195,7 +189,7 @@ void SparklineDialog::setupValues()
             break;
     }
 
-    switch (rAttribute.getDisplayEmptyCellsAs())
+    switch (maAttributes.getDisplayEmptyCellsAs())
     {
         case sc::DisplayEmptyCellsAs::Gap:
             mxRadioDisplayEmptyGap->set_active(true);
@@ -208,28 +202,28 @@ void SparklineDialog::setupValues()
             break;
     }
 
-    mxColorSeries->SelectEntry(rAttribute.getColorSeries());
-    mxColorNegative->SelectEntry(rAttribute.getColorNegative());
-    mxColorMarker->SelectEntry(rAttribute.getColorMarkers());
-    mxColorHigh->SelectEntry(rAttribute.getColorHigh());
-    mxColorLow->SelectEntry(rAttribute.getColorLow());
-    mxColorFirst->SelectEntry(rAttribute.getColorFirst());
-    mxColorLast->SelectEntry(rAttribute.getColorLast());
+    mxColorSeries->SelectEntry(maAttributes.getColorSeries());
+    mxColorNegative->SelectEntry(maAttributes.getColorNegative());
+    mxColorMarker->SelectEntry(maAttributes.getColorMarkers());
+    mxColorHigh->SelectEntry(maAttributes.getColorHigh());
+    mxColorLow->SelectEntry(maAttributes.getColorLow());
+    mxColorFirst->SelectEntry(maAttributes.getColorFirst());
+    mxColorLast->SelectEntry(maAttributes.getColorLast());
 
-    mxCheckButtonNegative->set_active(rAttribute.isNegative());
-    mxCheckButtonMarker->set_active(rAttribute.isMarkers());
-    mxCheckButtonHigh->set_active(rAttribute.isHigh());
-    mxCheckButtonLow->set_active(rAttribute.isLow());
-    mxCheckButtonFirst->set_active(rAttribute.isFirst());
-    mxCheckButtonLast->set_active(rAttribute.isLast());
+    mxCheckButtonNegative->set_active(maAttributes.isNegative());
+    mxCheckButtonMarker->set_active(maAttributes.isMarkers());
+    mxCheckButtonHigh->set_active(maAttributes.isHigh());
+    mxCheckButtonLow->set_active(maAttributes.isLow());
+    mxCheckButtonFirst->set_active(maAttributes.isFirst());
+    mxCheckButtonLast->set_active(maAttributes.isLast());
 
-    mxSpinLineWidth->set_value(sal_Int64(rAttribute.getLineWeight() * 100.0));
+    mxSpinLineWidth->set_value(sal_Int64(maAttributes.getLineWeight() * 
100.0));
 
-    mxCheckDisplayXAxis->set_active(rAttribute.shouldDisplayXAxis());
-    mxCheckDisplayHidden->set_active(rAttribute.shouldDisplayHidden());
-    mxCheckRightToLeft->set_active(rAttribute.isRightToLeft());
+    mxCheckDisplayXAxis->set_active(maAttributes.shouldDisplayXAxis());
+    mxCheckDisplayHidden->set_active(maAttributes.shouldDisplayHidden());
+    mxCheckRightToLeft->set_active(maAttributes.isRightToLeft());
 
-    switch (rAttribute.getMinAxisType())
+    switch (maAttributes.getMinAxisType())
     {
         case sc::AxisType::Individual:
             mxComboMinAxisType->set_active(0);
@@ -241,13 +235,13 @@ void SparklineDialog::setupValues()
             break;
         case sc::AxisType::Custom:
             mxComboMinAxisType->set_active(2);
-            if (rAttribute.getManualMin())
-                
mxSpinCustomMin->GetFormatter().SetValue(*rAttribute.getManualMin());
+            if (maAttributes.getManualMin())
+                
mxSpinCustomMin->GetFormatter().SetValue(*maAttributes.getManualMin());
             break;
     }
     ComboValueChanged(*mxComboMinAxisType);
 
-    switch (rAttribute.getMaxAxisType())
+    switch (maAttributes.getMaxAxisType())
     {
         case sc::AxisType::Individual:
             mxComboMaxAxisType->set_active(0);
@@ -259,8 +253,8 @@ void SparklineDialog::setupValues()
             break;
         case sc::AxisType::Custom:
             mxComboMaxAxisType->set_active(2);
-            if (rAttribute.getManualMin())
-                
mxSpinCustomMax->GetFormatter().SetValue(*rAttribute.getManualMax());
+            if (maAttributes.getManualMin())
+                
mxSpinCustomMax->GetFormatter().SetValue(*maAttributes.getManualMax());
             break;
     }
     ComboValueChanged(*mxComboMaxAxisType);
@@ -405,72 +399,63 @@ IMPL_LINK(SparklineDialog, ButtonClicked, weld::Button&, 
rButton, void)
 
 IMPL_LINK(SparklineDialog, ToggleHandler, weld::Toggleable&, rToggle, void)
 {
-    auto& rAttribute = mpLocalSparklineGroup->getAttributes();
-
     if (mxCheckButtonNegative.get() == &rToggle)
-        rAttribute.setNegative(mxCheckButtonNegative->get_active());
+        maAttributes.setNegative(mxCheckButtonNegative->get_active());
     if (mxCheckButtonMarker.get() == &rToggle)
-        rAttribute.setMarkers(mxCheckButtonMarker->get_active());
+        maAttributes.setMarkers(mxCheckButtonMarker->get_active());
     if (mxCheckButtonHigh.get() == &rToggle)
-        rAttribute.setHigh(mxCheckButtonHigh->get_active());
+        maAttributes.setHigh(mxCheckButtonHigh->get_active());
     if (mxCheckButtonLow.get() == &rToggle)
-        rAttribute.setLow(mxCheckButtonLow->get_active());
+        maAttributes.setLow(mxCheckButtonLow->get_active());
     if (mxCheckButtonFirst.get() == &rToggle)
-        rAttribute.setFirst(mxCheckButtonFirst->get_active());
+        maAttributes.setFirst(mxCheckButtonFirst->get_active());
     if (mxCheckButtonLast.get() == &rToggle)
-        rAttribute.setLast(mxCheckButtonLast->get_active());
+        maAttributes.setLast(mxCheckButtonLast->get_active());
     if (mxCheckDisplayXAxis.get() == &rToggle)
-        rAttribute.setDisplayXAxis(mxCheckDisplayXAxis->get_active());
+        maAttributes.setDisplayXAxis(mxCheckDisplayXAxis->get_active());
     if (mxCheckDisplayHidden.get() == &rToggle)
-        rAttribute.setDisplayHidden(mxCheckDisplayHidden->get_active());
+        maAttributes.setDisplayHidden(mxCheckDisplayHidden->get_active());
     if (mxCheckRightToLeft.get() == &rToggle)
-        rAttribute.setRightToLeft(mxCheckRightToLeft->get_active());
+        maAttributes.setRightToLeft(mxCheckRightToLeft->get_active());
 }
 
 IMPL_LINK_NOARG(SparklineDialog, SelectSparklineType, weld::Toggleable&, void)
 {
-    auto& rAttribute = mpLocalSparklineGroup->getAttributes();
-
     if (mxRadioLine->get_active())
-        rAttribute.setType(sc::SparklineType::Line);
+        maAttributes.setType(sc::SparklineType::Line);
     else if (mxRadioColumn->get_active())
-        rAttribute.setType(sc::SparklineType::Column);
+        maAttributes.setType(sc::SparklineType::Column);
     else if (mxRadioStacked->get_active())
-        rAttribute.setType(sc::SparklineType::Stacked);
+        maAttributes.setType(sc::SparklineType::Stacked);
 
     if (mxRadioDisplayEmptyGap->get_active())
-        rAttribute.setDisplayEmptyCellsAs(sc::DisplayEmptyCellsAs::Gap);
+        maAttributes.setDisplayEmptyCellsAs(sc::DisplayEmptyCellsAs::Gap);
     else if (mxRadioDisplayEmptyZero->get_active())
-        rAttribute.setDisplayEmptyCellsAs(sc::DisplayEmptyCellsAs::Zero);
+        maAttributes.setDisplayEmptyCellsAs(sc::DisplayEmptyCellsAs::Zero);
     else if (mxRadioDisplayEmptySpan->get_active())
-        rAttribute.setDisplayEmptyCellsAs(sc::DisplayEmptyCellsAs::Span);
+        maAttributes.setDisplayEmptyCellsAs(sc::DisplayEmptyCellsAs::Span);
 }
 
 IMPL_LINK_NOARG(SparklineDialog, SpinLineWidthChanged, weld::SpinButton&, void)
 {
-    auto& rAttribute = mpLocalSparklineGroup->getAttributes();
-
     double value = mxSpinLineWidth->get_value() / 100.0;
-    rAttribute.setLineWeight(value);
+    maAttributes.setLineWeight(value);
 }
 
 IMPL_LINK(SparklineDialog, SpinCustomChanged, weld::FormattedSpinButton&, 
rFormatted, void)
 {
-    auto& rAttribute = mpLocalSparklineGroup->getAttributes();
-
     if (mxSpinCustomMin.get() == &rFormatted)
     {
-        rAttribute.setManualMin(rFormatted.GetFormatter().GetValue());
+        maAttributes.setManualMin(rFormatted.GetFormatter().GetValue());
     }
     else if (mxSpinCustomMax.get() == &rFormatted)
     {
-        rAttribute.setManualMax(rFormatted.GetFormatter().GetValue());
+        maAttributes.setManualMax(rFormatted.GetFormatter().GetValue());
     }
 }
 
 IMPL_LINK(SparklineDialog, ComboValueChanged, weld::ComboBox&, rComboBox, void)
 {
-    auto& rAttribute = mpLocalSparklineGroup->getAttributes();
     int nActive = rComboBox.get_active();
 
     if (mxComboMinAxisType.get() == &rComboBox)
@@ -478,15 +463,15 @@ IMPL_LINK(SparklineDialog, ComboValueChanged, 
weld::ComboBox&, rComboBox, void)
         switch (nActive)
         {
             case 0:
-                rAttribute.setMinAxisType(sc::AxisType::Individual);
+                maAttributes.setMinAxisType(sc::AxisType::Individual);
                 mxSpinCustomMin->set_sensitive(false);
                 break;
             case 1:
-                rAttribute.setMinAxisType(sc::AxisType::Group);
+                maAttributes.setMinAxisType(sc::AxisType::Group);
                 mxSpinCustomMin->set_sensitive(false);
                 break;
             case 2:
-                rAttribute.setMinAxisType(sc::AxisType::Custom);
+                maAttributes.setMinAxisType(sc::AxisType::Custom);
                 mxSpinCustomMin->set_sensitive(true);
                 break;
             default:
@@ -498,15 +483,15 @@ IMPL_LINK(SparklineDialog, ComboValueChanged, 
weld::ComboBox&, rComboBox, void)
         switch (nActive)
         {
             case 0:
-                rAttribute.setMaxAxisType(sc::AxisType::Individual);
+                maAttributes.setMaxAxisType(sc::AxisType::Individual);
                 mxSpinCustomMax->set_sensitive(false);
                 break;
             case 1:
-                rAttribute.setMaxAxisType(sc::AxisType::Group);
+                maAttributes.setMaxAxisType(sc::AxisType::Group);
                 mxSpinCustomMax->set_sensitive(false);
                 break;
             case 2:
-                rAttribute.setMaxAxisType(sc::AxisType::Custom);
+                maAttributes.setMaxAxisType(sc::AxisType::Custom);
                 mxSpinCustomMax->set_sensitive(true);
                 break;
             default:
@@ -540,20 +525,27 @@ bool SparklineDialog::checkValidInputOutput()
 
 void SparklineDialog::perform()
 {
-    auto& rAttribute = mpLocalSparklineGroup->getAttributes();
-
-    rAttribute.setColorSeries(mxColorSeries->GetSelectEntryColor());
-    rAttribute.setColorNegative(mxColorNegative->GetSelectEntryColor());
-    rAttribute.setColorMarkers(mxColorMarker->GetSelectEntryColor());
-    rAttribute.setColorHigh(mxColorHigh->GetSelectEntryColor());
-    rAttribute.setColorLow(mxColorLow->GetSelectEntryColor());
-    rAttribute.setColorFirst(mxColorFirst->GetSelectEntryColor());
-    rAttribute.setColorLast(mxColorLast->GetSelectEntryColor());
+    maAttributes.setColorSeries(mxColorSeries->GetSelectEntryColor());
+    maAttributes.setColorNegative(mxColorNegative->GetSelectEntryColor());
+    maAttributes.setColorMarkers(mxColorMarker->GetSelectEntryColor());
+    maAttributes.setColorHigh(mxColorHigh->GetSelectEntryColor());
+    maAttributes.setColorLow(mxColorLow->GetSelectEntryColor());
+    maAttributes.setColorFirst(mxColorFirst->GetSelectEntryColor());
+    maAttributes.setColorLast(mxColorLast->GetSelectEntryColor());
 
     auto& rDocFunc = mrViewData.GetDocShell()->GetDocFunc();
 
-    rDocFunc.InsertSparklines(maInputRange, maOutputRange, 
mpLocalSparklineGroup);
-}
+    if (mpSparklineGroup)
+    {
+        rDocFunc.ChangeSparklineGroupAttributes(mpSparklineGroup, 
maAttributes);
+    }
+    else
+    {
+        auto pNewSparklineGroup = 
std::make_shared<sc::SparklineGroup>(maAttributes);
+        rDocFunc.InsertSparklines(maInputRange, maOutputRange, 
pNewSparklineGroup);
+    }
 }
 
+} // end sc
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index e5972d54b7af..265d65f79e28 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -95,9 +95,11 @@
 #include <columnspanset.hxx>
 #include <validat.hxx>
 #include <SparklineGroup.hxx>
+#include <SparklineAttributes.hxx>
 #include <SparklineData.hxx>
 #include <undo/UndoInsertSparkline.hxx>
 #include <undo/UndoDeleteSparkline.hxx>
+#include <undo/UndoEditSparklineGroup.hxx>
 #include <config_features.h>
 
 #include <memory>
@@ -5857,4 +5859,14 @@ bool ScDocFunc::DeleteSparkline(ScAddress const& 
rAddress)
     return true;
 }
 
+bool 
ScDocFunc::ChangeSparklineGroupAttributes(std::shared_ptr<sc::SparklineGroup> 
const& pExistingSparklineGroup,
+                                               sc::SparklineAttributes const& 
rNewAttributes)
+{
+    auto pUndo = std::make_unique<sc::UndoEditSparklneGroup>(rDocShell, 
pExistingSparklineGroup, rNewAttributes);
+    // change sparkline group attributes by "redoing"
+    pUndo->Redo();
+    rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
+    return true;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/SparklineDialog.hxx 
b/sc/source/ui/inc/SparklineDialog.hxx
index 776480b05fce..1be81e80f7d6 100644
--- a/sc/source/ui/inc/SparklineDialog.hxx
+++ b/sc/source/ui/inc/SparklineDialog.hxx
@@ -13,6 +13,9 @@
 #include "anyrefdg.hxx"
 #include <viewdata.hxx>
 
+#include <SparklineGroup.hxx>
+#include <SparklineAttributes.hxx>
+
 class ColorListBox;
 
 namespace sc
@@ -88,7 +91,8 @@ private:
     DECL_LINK(SpinLineWidthChanged, weld::SpinButton&, void);
     DECL_LINK(SpinCustomChanged, weld::FormattedSpinButton&, void);
 
-    std::shared_ptr<sc::SparklineGroup> mpLocalSparklineGroup;
+    std::shared_ptr<sc::SparklineGroup> mpSparklineGroup;
+    sc::SparklineAttributes maAttributes;
 
     bool mbEditMode;
 
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 9ac438639585..72ac0fbcb9f0 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -54,6 +54,7 @@ enum class CreateNameFlags;
 namespace sc
 {
     struct ColRowSpan;
+    class SparklineAttributes;
     class SparklineGroup;
 }
 
@@ -241,6 +242,9 @@ public:
 
     SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rAddress);
 
+    SC_DLLPUBLIC bool 
ChangeSparklineGroupAttributes(std::shared_ptr<sc::SparklineGroup> const& 
pExistingSparklineGroup,
+                                                     sc::SparklineAttributes 
const& rNewAttributes);
+
 private:
     void ProtectDocument(const ScDocProtection& rProtect);
 };
diff --git a/sc/source/ui/inc/undo/UndoEditSparklineGroup.hxx 
b/sc/source/ui/inc/undo/UndoEditSparklineGroup.hxx
new file mode 100644
index 000000000000..373ebd35eb69
--- /dev/null
+++ b/sc/source/ui/inc/undo/UndoEditSparklineGroup.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 <memory>
+
+#include <SparklineAttributes.hxx>
+#include <SparklineGroup.hxx>
+
+namespace sc
+{
+/** Undo action for editing a Sparkline */
+class UndoEditSparklneGroup : public ScSimpleUndo
+{
+private:
+    std::shared_ptr<sc::SparklineGroup> m_pSparklineGroup;
+    sc::SparklineAttributes m_aNewAttributes;
+    sc::SparklineAttributes m_aOriginalAttributes;
+
+public:
+    UndoEditSparklneGroup(ScDocShell& rDocShell,
+                          std::shared_ptr<sc::SparklineGroup> const& 
rSparklineGroup,
+                          sc::SparklineAttributes const& rAttributes);
+    virtual ~UndoEditSparklneGroup() 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/sparklines/SparklineGroup.cxx 
b/sc/source/ui/sparklines/SparklineGroup.cxx
index 9ef2c7044ab0..1ba235e75014 100644
--- a/sc/source/ui/sparklines/SparklineGroup.cxx
+++ b/sc/source/ui/sparklines/SparklineGroup.cxx
@@ -12,6 +12,12 @@
 
 namespace sc
 {
+SparklineGroup::SparklineGroup(SparklineAttributes const& rSparklineAttributes)
+    : m_aAttributes(rSparklineAttributes)
+    , m_aGUID(tools::Guid::Generate)
+{
+}
+
 SparklineGroup::SparklineGroup()
     : m_aGUID(tools::Guid::Generate)
 {
diff --git a/sc/source/ui/undo/UndoEditSparklineGroup.cxx 
b/sc/source/ui/undo/UndoEditSparklineGroup.cxx
new file mode 100644
index 000000000000..8136003d6b20
--- /dev/null
+++ b/sc/source/ui/undo/UndoEditSparklineGroup.cxx
@@ -0,0 +1,65 @@
+/* -*- 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/UndoEditSparklineGroup.hxx>
+
+#include <globstr.hrc>
+#include <scresid.hxx>
+
+#include <Sparkline.hxx>
+#include <SparklineGroup.hxx>
+#include <SparklineAttributes.hxx>
+
+namespace sc
+{
+UndoEditSparklneGroup::UndoEditSparklneGroup(
+    ScDocShell& rDocShell, std::shared_ptr<sc::SparklineGroup> const& 
pSparklineGroup,
+    sc::SparklineAttributes const& rAttributes)
+    : ScSimpleUndo(&rDocShell)
+    , m_pSparklineGroup(pSparklineGroup)
+    , m_aNewAttributes(rAttributes)
+    , m_aOriginalAttributes(pSparklineGroup->getAttributes())
+{
+}
+
+UndoEditSparklneGroup::~UndoEditSparklneGroup() = default;
+
+void UndoEditSparklneGroup::Undo()
+{
+    BeginUndo();
+
+    m_pSparklineGroup->setAttributes(m_aOriginalAttributes);
+    pDocShell->PostPaintGridAll();
+
+    EndUndo();
+}
+
+void UndoEditSparklneGroup::Redo()
+{
+    BeginRedo();
+
+    m_pSparklineGroup->setAttributes(m_aNewAttributes);
+    pDocShell->PostPaintGridAll();
+
+    EndRedo();
+}
+
+void UndoEditSparklneGroup::Repeat(SfxRepeatTarget& /*rTarget*/) {}
+
+bool UndoEditSparklneGroup::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { 
return false; }
+
+OUString UndoEditSparklneGroup::GetComment() const
+{
+    return ScResId(STR_UNDO_EDIT_SPARKLINE_GROUP);
+}
+
+} // end sc namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to