cid#1607171 Data race condition
[LibreOffice.git] / sc / source / ui / undo / UndoDeleteSparklineGroup.cxx
blob71702560b03cc48dd54e0111078eca3f088b7ef5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #include <undo/UndoDeleteSparklineGroup.hxx>
12 #include <globstr.hrc>
13 #include <scresid.hxx>
14 #include <document.hxx>
16 #include <Sparkline.hxx>
17 #include <SparklineList.hxx>
18 #include <SparklineGroup.hxx>
19 #include <utility>
21 namespace sc
23 UndoDeleteSparklineGroup::UndoDeleteSparklineGroup(
24 ScDocShell& rDocShell, std::shared_ptr<sc::SparklineGroup> pSparklineGroup, SCTAB nTab)
25 : ScSimpleUndo(&rDocShell)
26 , mpSparklineGroup(std::move(pSparklineGroup))
27 , mnTab(nTab)
31 UndoDeleteSparklineGroup::~UndoDeleteSparklineGroup() {}
33 void UndoDeleteSparklineGroup::Undo()
35 BeginUndo();
37 ScDocument& rDocument = pDocShell->GetDocument();
39 for (auto const& pSparkline : maSparklines)
41 ScAddress aAddress(pSparkline->getColumn(), pSparkline->getRow(), mnTab);
42 auto* pNewSparkline = rDocument.CreateSparkline(aAddress, mpSparklineGroup);
43 pNewSparkline->setInputRange(pSparkline->getInputRange());
46 pDocShell->PostPaintGridAll();
48 EndUndo();
51 void UndoDeleteSparklineGroup::Redo()
53 BeginRedo();
55 ScDocument& rDocument = pDocShell->GetDocument();
56 auto* pList = rDocument.GetSparklineList(mnTab);
57 if (pList)
59 maSparklines = pList->getSparklinesFor(mpSparklineGroup);
61 for (auto const& pSparkline : maSparklines)
63 ScAddress aAddress(pSparkline->getColumn(), pSparkline->getRow(), mnTab);
64 rDocument.DeleteSparkline(aAddress);
67 pDocShell->PostPaintGridAll();
69 EndRedo();
72 void UndoDeleteSparklineGroup::Repeat(SfxRepeatTarget& /*rTarget*/) {}
74 bool UndoDeleteSparklineGroup::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
76 OUString UndoDeleteSparklineGroup::GetComment() const
78 return ScResId(STR_UNDO_DELETE_SPARKLINE_GROUP);
81 } // end sc namespace
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */