1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
11 #include <undo/UndoDeleteSparkline.hxx>
12 #include <globstr.hrc>
13 #include <scresid.hxx>
15 #include <Sparkline.hxx>
19 UndoDeleteSparkline::UndoDeleteSparkline(ScDocShell
& rDocShell
, ScAddress
const& rSparklinePosition
)
20 : ScSimpleUndo(&rDocShell
)
21 , maSparklinePosition(rSparklinePosition
)
25 UndoDeleteSparkline::~UndoDeleteSparkline() {}
27 void UndoDeleteSparkline::Undo()
31 ScDocument
& rDocument
= pDocShell
->GetDocument();
32 auto pSparkline
= rDocument
.GetSparkline(maSparklinePosition
);
35 rDocument
.CreateSparkline(maSparklinePosition
, mpSparklineGroup
);
39 SAL_WARN("sc", "Can't undo deletion if the sparkline at that address already exists.");
42 pDocShell
->PostPaintCell(maSparklinePosition
);
47 void UndoDeleteSparkline::Redo()
51 ScDocument
& rDocument
= pDocShell
->GetDocument();
52 if (auto pSparkline
= rDocument
.GetSparkline(maSparklinePosition
))
54 mpSparklineGroup
= pSparkline
->getSparklineGroup();
55 rDocument
.DeleteSparkline(maSparklinePosition
);
59 SAL_WARN("sc", "Can't delete a sparkline that donesn't exist.");
62 pDocShell
->PostPaintCell(maSparklinePosition
);
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
); }
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */