LibreOffice Module sc (master) 1
UndoDeleteSparklineGroup.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#include <document.hxx>
15
16#include <Sparkline.hxx>
17#include <SparklineList.hxx>
18#include <SparklineGroup.hxx>
19#include <utility>
20
21namespace sc
22{
24 ScDocShell& rDocShell, std::shared_ptr<sc::SparklineGroup> pSparklineGroup, SCTAB nTab)
25 : ScSimpleUndo(&rDocShell)
26 , mpSparklineGroup(std::move(pSparklineGroup))
27 , mnTab(nTab)
28{
29}
30
32
34{
35 BeginUndo();
36
37 ScDocument& rDocument = pDocShell->GetDocument();
38
39 for (auto const& pSparkline : maSparklines)
40 {
41 ScAddress aAddress(pSparkline->getColumn(), pSparkline->getRow(), mnTab);
42 auto* pNewSparkline = rDocument.CreateSparkline(aAddress, mpSparklineGroup);
43 pNewSparkline->setInputRange(pSparkline->getInputRange());
44 }
45
47
48 EndUndo();
49}
50
52{
53 BeginRedo();
54
55 ScDocument& rDocument = pDocShell->GetDocument();
56 auto* pList = rDocument.GetSparklineList(mnTab);
57 if (pList)
58 {
59 maSparklines = pList->getSparklinesFor(mpSparklineGroup);
60
61 for (auto const& pSparkline : maSparklines)
62 {
63 ScAddress aAddress(pSparkline->getColumn(), pSparkline->getRow(), mnTab);
64 rDocument.DeleteSparkline(aAddress);
65 }
66 }
68
69 EndRedo();
70}
71
73
74bool UndoDeleteSparklineGroup::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
75
77{
78 return ScResId(STR_UNDO_DELETE_SPARKLINE_GROUP);
79}
80
81} // end sc namespace
82
83/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void PostPaintGridAll()
Definition: docsh3.cxx:183
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
SC_DLLPUBLIC sc::Sparkline * CreateSparkline(ScAddress const &rPosition, std::shared_ptr< sc::SparklineGroup > const &pSparklineGroup)
Definition: document.cxx:6635
SC_DLLPUBLIC bool DeleteSparkline(ScAddress const &rPosition)
Definition: document.cxx:6647
SC_DLLPUBLIC sc::SparklineList * GetSparklineList(SCTAB nTab)
Definition: document.cxx:6659
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
void setInputRange(ScRangeList const &rInputRange)
Definition: Sparkline.hxx:47
UndoDeleteSparklineGroup(ScDocShell &rDocShell, std::shared_ptr< sc::SparklineGroup > pSparklineGroup, SCTAB nSheetIndex)
std::vector< std::shared_ptr< sc::Sparkline > > maSparklines
bool CanRepeat(SfxRepeatTarget &rTarget) const override
std::shared_ptr< sc::SparklineGroup > mpSparklineGroup
OUString GetComment() const override
void Repeat(SfxRepeatTarget &rTarget) override
CAUTION! The following defines must be in the same namespace as the respective type.
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
sal_Int16 SCTAB
Definition: types.hxx:22