LibreOffice Module sc (master) 1
UndoDeleteSparkline.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
12#include <globstr.hrc>
13#include <scresid.hxx>
14
15#include <Sparkline.hxx>
16#include <SparklineGroup.hxx>
17
18namespace sc
19{
21 : ScSimpleUndo(&rDocShell)
22 , maSparklinePosition(rSparklinePosition)
23{
24}
25
27
29{
30 BeginUndo();
31
32 ScDocument& rDocument = pDocShell->GetDocument();
33 auto pSparkline = rDocument.GetSparkline(maSparklinePosition);
34 if (!pSparkline)
35 {
37 }
38 else
39 {
40 SAL_WARN("sc", "Can't undo deletion if the sparkline at that address already exists.");
41 }
42
44
45 EndUndo();
46}
47
49{
50 BeginRedo();
51
52 ScDocument& rDocument = pDocShell->GetDocument();
53 if (auto pSparkline = rDocument.GetSparkline(maSparklinePosition))
54 {
55 mpSparklineGroup = pSparkline->getSparklineGroup();
57 }
58 else
59 {
60 SAL_WARN("sc", "Can't delete a sparkline that donesn't exist.");
61 }
62
64
65 EndRedo();
66}
67
68void UndoDeleteSparkline::Repeat(SfxRepeatTarget& /*rTarget*/) {}
69
70bool UndoDeleteSparkline::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
71
72OUString UndoDeleteSparkline::GetComment() const { return ScResId(STR_UNDO_DELETE_SPARKLINE); }
73
74} // end sc namespace
75
76/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void PostPaintCell(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: docsh3.cxx:188
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
SC_DLLPUBLIC std::shared_ptr< sc::Sparkline > GetSparkline(ScAddress const &rPosition)
Returns sparkline at the address if it exists.
Definition: document.cxx:6495
SC_DLLPUBLIC sc::Sparkline * CreateSparkline(ScAddress const &rPosition, std::shared_ptr< sc::SparklineGroup > const &pSparklineGroup)
Definition: document.cxx:6508
SC_DLLPUBLIC bool DeleteSparkline(ScAddress const &rPosition)
Definition: document.cxx:6516
void BeginRedo()
Definition: undobase.cxx:145
void EndRedo()
Definition: undobase.cxx:154
void EndUndo()
Definition: undobase.cxx:125
ScDocShell * pDocShell
Definition: undobase.hxx:50
void BeginUndo()
Definition: undobase.cxx:90
std::shared_ptr< sc::SparklineGroup > mpSparklineGroup
OUString GetComment() const override
bool CanRepeat(SfxRepeatTarget &rTarget) const override
void Repeat(SfxRepeatTarget &rTarget) override
virtual ~UndoDeleteSparkline() override
UndoDeleteSparkline(ScDocShell &rDocShell, ScAddress const &rSparklinePosition)
#define SAL_WARN(area, stream)
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90