LibreOffice Module sc (master) 1
UndoInsertSparkline.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#include <SparklineData.hxx>
18#include <utility>
19
20namespace sc
21{
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))
28{
29}
30
32
34{
35 BeginUndo();
36
37 ScDocument& rDocument = pDocShell->GetDocument();
38 ScRangeList aRanges;
39 for (auto const& rSparklineData : maSparklineDataVector)
40 {
41 rDocument.DeleteSparkline(rSparklineData.maPosition);
42 aRanges.push_back(ScRange(rSparklineData.maPosition));
43 }
44
46
47 EndUndo();
48}
49
51{
52 BeginRedo();
53
54 ScDocument& rDocument = pDocShell->GetDocument();
55 ScRangeList aRanges;
56 for (auto const& rSparklineData : maSparklineDataVector)
57 {
58 auto* pCreated = rDocument.CreateSparkline(rSparklineData.maPosition, mpSparklineGroup);
59 pCreated->setInputRange(rSparklineData.maData);
60 aRanges.push_back(ScRange(rSparklineData.maPosition));
61 }
62
64
65 EndRedo();
66}
67
68void UndoInsertSparkline::Repeat(SfxRepeatTarget& /*rTarget*/) {}
69
70bool UndoInsertSparkline::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
71
73{
74 return ScResId(STR_UNDO_INSERT_SPARKLINE_GROUP);
75}
76
77} // end sc namespace
78
79/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
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 push_back(const ScRange &rRange)
Definition: rangelst.cxx:1137
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
UndoInsertSparkline(ScDocShell &rDocShell, std::vector< SparklineData > pSparklineDataVector, std::shared_ptr< sc::SparklineGroup > pSparklineGroup)
bool CanRepeat(SfxRepeatTarget &rTarget) const override
std::shared_ptr< sc::SparklineGroup > mpSparklineGroup
std::vector< sc::SparklineData > maSparklineDataVector
virtual ~UndoInsertSparkline() override
void Repeat(SfxRepeatTarget &rTarget) override
OUString GetComment() const override
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