Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/controller/main/StatusBarCommandDispatch.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 "StatusBarCommandDispatch.hxx"
21
#include <ObjectNameProvider.hxx>
22
#include <com/sun/star/view/XSelectionSupplier.hpp>
23
#include <ChartModel.hxx>
24
#include <utility>
25
26
using namespace ::com::sun::star;
27
28
using ::com::sun::star::uno::Reference;
29
using ::com::sun::star::uno::Sequence;
30
31
namespace chart
32
{
33
34
StatusBarCommandDispatch::StatusBarCommandDispatch(
35
    const Reference< uno::XComponentContext > & xContext,
36
    rtl::Reference<::chart::ChartModel> xModel,
37
    const Reference< view::XSelectionSupplier > & xSelSupp ) :
38
0
        impl::StatusBarCommandDispatch_Base( xContext ),
39
0
        m_xChartModel(std::move( xModel  )),
40
0
        m_xSelectionSupplier( xSelSupp ),
41
0
        m_bIsModified( false )
42
0
{}
Unexecuted instantiation: chart::StatusBarCommandDispatch::StatusBarCommandDispatch(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::Reference<chart::ChartModel>, com::sun::star::uno::Reference<com::sun::star::view::XSelectionSupplier> const&)
Unexecuted instantiation: chart::StatusBarCommandDispatch::StatusBarCommandDispatch(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::Reference<chart::ChartModel>, com::sun::star::uno::Reference<com::sun::star::view::XSelectionSupplier> const&)
43
44
StatusBarCommandDispatch::~StatusBarCommandDispatch()
45
0
{}
46
47
void StatusBarCommandDispatch::initialize()
48
0
{
49
0
    if( m_xChartModel.is())
50
0
    {
51
0
        m_xChartModel->addModifyListener( this );
52
0
    }
53
54
0
    if( m_xSelectionSupplier.is())
55
0
    {
56
0
        m_xSelectionSupplier->addSelectionChangeListener( this );
57
0
    }
58
0
}
59
60
void StatusBarCommandDispatch::fireStatusEvent(
61
    const OUString & rURL,
62
    const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
63
0
{
64
0
    bool bFireAll( rURL.isEmpty() );
65
0
    bool bFireContext(  bFireAll || rURL == ".uno:Context" );
66
0
    bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
67
68
0
    if( bFireContext && m_xChartModel.is())
69
0
    {
70
0
        uno::Any aArg;
71
0
        aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), m_xChartModel );
72
0
        fireStatusEventForURL( u".uno:Context"_ustr, aArg, true, xSingleListener );
73
0
    }
74
0
    if( bFireModified )
75
0
    {
76
0
        uno::Any aArg;
77
0
        if( m_bIsModified )
78
0
            aArg <<= u"*"_ustr;
79
0
        fireStatusEventForURL( u".uno:ModifiedStatus"_ustr, aArg, true, xSingleListener );
80
0
    }
81
0
}
82
83
// ____ XDispatch ____
84
void SAL_CALL StatusBarCommandDispatch::dispatch(
85
    const util::URL& /* URL */,
86
    const Sequence< beans::PropertyValue >& /* Arguments */ )
87
0
{
88
    // nothing to do here
89
0
}
90
91
// ____ WeakComponentImplHelperBase ____
92
/// is called when this is disposed
93
void StatusBarCommandDispatch::disposing(std::unique_lock<std::mutex>& /*rGuard*/)
94
0
{
95
0
    m_xChartModel.clear();
96
0
    m_xSelectionSupplier.clear();
97
0
}
98
99
// ____ XEventListener (base of XModifyListener) ____
100
void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
101
0
{
102
0
    m_xChartModel.clear();
103
0
    m_xSelectionSupplier.clear();
104
0
}
105
106
// ____ XModifyListener ____
107
void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
108
0
{
109
0
    if( m_xChartModel.is())
110
0
        m_bIsModified = m_xChartModel->isModified();
111
112
0
    CommandDispatch::modified( aEvent );
113
0
}
114
115
// ____ XSelectionChangeListener ____
116
void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
117
0
{
118
0
    if( m_xSelectionSupplier.is())
119
0
        m_aSelectedOID = ObjectIdentifier( m_xSelectionSupplier->getSelection() );
120
0
    else
121
0
        m_aSelectedOID = ObjectIdentifier();
122
0
    fireAllStatusEvents( nullptr );
123
0
}
124
125
} //  namespace chart
126
127
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */