Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/controller/main/UndoActions.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
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#include "UndoActions.hxx"
21
#include "ChartModelClone.hxx"
22
#include <ChartModel.hxx>
23
24
#include <com/sun/star/lang/DisposedException.hpp>
25
26
#include <svx/svdundo.hxx>
27
28
#include <memory>
29
#include <utility>
30
31
using namespace ::com::sun::star;
32
33
namespace chart::impl
34
{
35
    using ::com::sun::star::lang::DisposedException;
36
37
UndoElement::UndoElement( OUString i_actionString, rtl::Reference<::chart::ChartModel> i_documentModel, std::shared_ptr< ChartModelClone > i_modelClone )
38
0
    :m_sActionString(std::move( i_actionString ))
39
0
    ,m_xDocumentModel(std::move( i_documentModel ))
40
0
    ,m_pModelClone(std::move( i_modelClone ))
41
0
{
42
0
}
Unexecuted instantiation: chart::impl::UndoElement::UndoElement(rtl::OUString, rtl::Reference<chart::ChartModel>, std::__1::shared_ptr<chart::ChartModelClone>)
Unexecuted instantiation: chart::impl::UndoElement::UndoElement(rtl::OUString, rtl::Reference<chart::ChartModel>, std::__1::shared_ptr<chart::ChartModelClone>)
43
44
UndoElement::~UndoElement()
45
0
{
46
0
}
47
48
void UndoElement::disposing(std::unique_lock<std::mutex>&)
49
0
{
50
0
    if ( m_pModelClone )
51
0
        m_pModelClone->dispose();
52
0
    m_pModelClone.reset();
53
0
    m_xDocumentModel.clear();
54
0
}
55
56
OUString SAL_CALL UndoElement::getTitle()
57
0
{
58
0
    return m_sActionString;
59
0
}
60
61
void UndoElement::impl_toggleModelState()
62
0
{
63
    // get a snapshot of the current state of our model
64
0
    auto pNewClone = std::make_shared<ChartModelClone>( m_xDocumentModel, m_pModelClone->getFacet() );
65
    // apply the previous snapshot to our model
66
0
    m_pModelClone->applyToModel( m_xDocumentModel );
67
    // remember the new snapshot, for the next toggle
68
0
    m_pModelClone = std::move(pNewClone);
69
0
}
70
71
void SAL_CALL UndoElement::undo(  )
72
0
{
73
0
    impl_toggleModelState();
74
0
}
75
76
void SAL_CALL UndoElement::redo(  )
77
0
{
78
0
    impl_toggleModelState();
79
0
}
80
81
// = ShapeUndoElement
82
83
ShapeUndoElement::ShapeUndoElement( std::unique_ptr<SdrUndoAction> xSdrUndoAction )
84
0
    :m_xAction( std::move(xSdrUndoAction) )
85
0
{
86
0
}
Unexecuted instantiation: chart::impl::ShapeUndoElement::ShapeUndoElement(std::__1::unique_ptr<SdrUndoAction, std::__1::default_delete<SdrUndoAction> >)
Unexecuted instantiation: chart::impl::ShapeUndoElement::ShapeUndoElement(std::__1::unique_ptr<SdrUndoAction, std::__1::default_delete<SdrUndoAction> >)
87
88
ShapeUndoElement::~ShapeUndoElement()
89
0
{
90
0
}
91
92
OUString SAL_CALL ShapeUndoElement::getTitle()
93
0
{
94
0
    if ( !m_xAction )
95
0
        throw DisposedException( OUString(), *this );
96
0
    return m_xAction->GetComment();
97
0
}
98
99
void SAL_CALL ShapeUndoElement::undo(  )
100
0
{
101
0
    if ( !m_xAction )
102
0
        throw DisposedException( OUString(), *this );
103
0
    m_xAction->Undo();
104
0
}
105
106
void SAL_CALL ShapeUndoElement::redo(  )
107
0
{
108
0
    if ( !m_xAction )
109
0
        throw DisposedException( OUString(), *this );
110
0
    m_xAction->Redo();
111
0
}
112
113
} //  namespace chart::impl
114
115
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */