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/UndoInsertSparkline.hxx>
12 #include <globstr.hrc>
13 #include <scresid.hxx>
15 #include <Sparkline.hxx>
16 #include <SparklineGroup.hxx>
17 #include <SparklineData.hxx>
22 UndoInsertSparkline::UndoInsertSparkline(ScDocShell
& rDocShell
,
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
))
31 UndoInsertSparkline::~UndoInsertSparkline() {}
33 void UndoInsertSparkline::Undo()
37 ScDocument
& rDocument
= pDocShell
->GetDocument();
39 for (auto const& rSparklineData
: maSparklineDataVector
)
41 rDocument
.DeleteSparkline(rSparklineData
.maPosition
);
42 aRanges
.push_back(ScRange(rSparklineData
.maPosition
));
45 pDocShell
->PostPaint(aRanges
, PaintPartFlags::All
);
50 void UndoInsertSparkline::Redo()
54 ScDocument
& rDocument
= pDocShell
->GetDocument();
56 for (auto const& rSparklineData
: maSparklineDataVector
)
58 auto* pCreated
= rDocument
.CreateSparkline(rSparklineData
.maPosition
, mpSparklineGroup
);
59 pCreated
->setInputRange(rSparklineData
.maData
);
60 aRanges
.push_back(ScRange(rSparklineData
.maPosition
));
63 pDocShell
->PostPaint(aRanges
, PaintPartFlags::All
);
68 void UndoInsertSparkline::Repeat(SfxRepeatTarget
& /*rTarget*/) {}
70 bool UndoInsertSparkline::CanRepeat(SfxRepeatTarget
& /*rTarget*/) const { return false; }
72 OUString
UndoInsertSparkline::GetComment() const
74 return ScResId(STR_UNDO_INSERT_SPARKLINE_GROUP
);
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */