cid#1607171 Data race condition
[LibreOffice.git] / sc / source / ui / undo / UndoDeleteSparkline.cxx
blob4e01ac8934cd5bde403adf2b2c2c5b91ad7bfc99
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/UndoDeleteSparkline.hxx>
12 #include <globstr.hrc>
13 #include <scresid.hxx>
15 #include <Sparkline.hxx>
17 namespace sc
19 UndoDeleteSparkline::UndoDeleteSparkline(ScDocShell& rDocShell, ScAddress const& rSparklinePosition)
20 : ScSimpleUndo(&rDocShell)
21 , maSparklinePosition(rSparklinePosition)
25 UndoDeleteSparkline::~UndoDeleteSparkline() {}
27 void UndoDeleteSparkline::Undo()
29 BeginUndo();
31 ScDocument& rDocument = pDocShell->GetDocument();
32 auto pSparkline = rDocument.GetSparkline(maSparklinePosition);
33 if (!pSparkline)
35 rDocument.CreateSparkline(maSparklinePosition, mpSparklineGroup);
37 else
39 SAL_WARN("sc", "Can't undo deletion if the sparkline at that address already exists.");
42 pDocShell->PostPaintCell(maSparklinePosition);
44 EndUndo();
47 void UndoDeleteSparkline::Redo()
49 BeginRedo();
51 ScDocument& rDocument = pDocShell->GetDocument();
52 if (auto pSparkline = rDocument.GetSparkline(maSparklinePosition))
54 mpSparklineGroup = pSparkline->getSparklineGroup();
55 rDocument.DeleteSparkline(maSparklinePosition);
57 else
59 SAL_WARN("sc", "Can't delete a sparkline that donesn't exist.");
62 pDocShell->PostPaintCell(maSparklinePosition);
64 EndRedo();
67 void UndoDeleteSparkline::Repeat(SfxRepeatTarget& /*rTarget*/) {}
69 bool UndoDeleteSparkline::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
71 OUString UndoDeleteSparkline::GetComment() const { return ScResId(STR_UNDO_DELETE_SPARKLINE); }
73 } // end sc namespace
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */