Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/undo/UndoDeleteSparkline.cxx
Line
Count
Source
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
11
#include <undo/UndoDeleteSparkline.hxx>
12
#include <globstr.hrc>
13
#include <scresid.hxx>
14
15
#include <Sparkline.hxx>
16
17
namespace sc
18
{
19
UndoDeleteSparkline::UndoDeleteSparkline(ScDocShell& rShell, ScAddress const& rSparklinePosition)
20
0
    : ScSimpleUndo(rShell)
21
0
    , maSparklinePosition(rSparklinePosition)
22
0
{
23
0
}
24
25
0
UndoDeleteSparkline::~UndoDeleteSparkline() {}
26
27
void UndoDeleteSparkline::Undo()
28
0
{
29
0
    BeginUndo();
30
31
0
    ScDocument& rDocument = rDocShell.GetDocument();
32
0
    auto pSparkline = rDocument.GetSparkline(maSparklinePosition);
33
0
    if (!pSparkline)
34
0
    {
35
0
        rDocument.CreateSparkline(maSparklinePosition, mpSparklineGroup);
36
0
    }
37
0
    else
38
0
    {
39
0
        SAL_WARN("sc", "Can't undo deletion if the sparkline at that address already exists.");
40
0
    }
41
42
0
    rDocShell.PostPaintCell(maSparklinePosition);
43
44
0
    EndUndo();
45
0
}
46
47
void UndoDeleteSparkline::Redo()
48
0
{
49
0
    BeginRedo();
50
51
0
    ScDocument& rDocument = rDocShell.GetDocument();
52
0
    if (auto pSparkline = rDocument.GetSparkline(maSparklinePosition))
53
0
    {
54
0
        mpSparklineGroup = pSparkline->getSparklineGroup();
55
0
        rDocument.DeleteSparkline(maSparklinePosition);
56
0
    }
57
0
    else
58
0
    {
59
0
        SAL_WARN("sc", "Can't delete a sparkline that donesn't exist.");
60
0
    }
61
62
0
    rDocShell.PostPaintCell(maSparklinePosition);
63
64
0
    EndRedo();
65
0
}
66
67
0
void UndoDeleteSparkline::Repeat(SfxRepeatTarget& /*rTarget*/) {}
68
69
0
bool UndoDeleteSparkline::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
70
71
0
OUString UndoDeleteSparkline::GetComment() const { return ScResId(STR_UNDO_DELETE_SPARKLINE); }
72
73
} // end sc namespace
74
75
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */