cid#1607171 Data race condition
[LibreOffice.git] / sc / source / ui / undo / UndoInsertSparkline.cxx
blob708f3d746f9157248ae2677d778f22b1cae7e315
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/UndoInsertSparkline.hxx>
12 #include <globstr.hrc>
13 #include <scresid.hxx>
15 #include <Sparkline.hxx>
16 #include <SparklineGroup.hxx>
17 #include <SparklineData.hxx>
18 #include <utility>
20 namespace sc
22 UndoInsertSparkline::UndoInsertSparkline(ScDocShell& rDocShell,
23 std::vector<SparklineData> aSparklineDataVector,
24 std::shared_ptr<sc::SparklineGroup> pSparklineGroup)
25 : ScSimpleUndo(&rDocShell)
26 , maSparklineDataVector(std::move(aSparklineDataVector))
27 , mpSparklineGroup(std::move(pSparklineGroup))
31 UndoInsertSparkline::~UndoInsertSparkline() {}
33 void UndoInsertSparkline::Undo()
35 BeginUndo();
37 ScDocument& rDocument = pDocShell->GetDocument();
38 ScRangeList aRanges;
39 for (auto const& rSparklineData : maSparklineDataVector)
41 rDocument.DeleteSparkline(rSparklineData.maPosition);
42 aRanges.push_back(ScRange(rSparklineData.maPosition));
45 pDocShell->PostPaint(aRanges, PaintPartFlags::All);
47 EndUndo();
50 void UndoInsertSparkline::Redo()
52 BeginRedo();
54 ScDocument& rDocument = pDocShell->GetDocument();
55 ScRangeList aRanges;
56 for (auto const& rSparklineData : maSparklineDataVector)
58 auto* pCreated = rDocument.CreateSparkline(rSparklineData.maPosition, mpSparklineGroup);
59 pCreated->setInputRange(rSparklineData.maData);
60 aRanges.push_back(ScRange(rSparklineData.maPosition));
63 pDocShell->PostPaint(aRanges, PaintPartFlags::All);
65 EndRedo();
68 void UndoInsertSparkline::Repeat(SfxRepeatTarget& /*rTarget*/) {}
70 bool UndoInsertSparkline::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
72 OUString UndoInsertSparkline::GetComment() const
74 return ScResId(STR_UNDO_INSERT_SPARKLINE_GROUP);
77 } // end sc namespace
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */