Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/form/fmtextcontrolfeature.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 <fmtextcontrolfeature.hxx>
21
#include <fmtextcontrolshell.hxx>
22
#include <utility>
23
24
#include <osl/diagnose.h>
25
#include <comphelper/diagnose_ex.hxx>
26
27
namespace svx
28
{
29
30
31
    using namespace ::com::sun::star::uno;
32
    using namespace ::com::sun::star::frame;
33
    using namespace ::com::sun::star::lang;
34
    using namespace ::com::sun::star::beans;
35
    using namespace ::com::sun::star::util;
36
37
    FmTextControlFeature::FmTextControlFeature( const Reference< XDispatch >& _rxDispatcher, URL _aFeatureURL, SfxSlotId _nSlotId, FmTextControlShell* _pInvalidator )
38
0
        :m_xDispatcher    ( _rxDispatcher )
39
0
        ,m_aFeatureURL    (std::move( _aFeatureURL  ))
40
0
        ,m_nSlotId        ( _nSlotId      )
41
0
        ,m_pInvalidator   ( _pInvalidator )
42
0
        ,m_bFeatureEnabled( false         )
43
0
    {
44
0
        OSL_ENSURE( _rxDispatcher.is(), "FmTextControlFeature::FmTextControlFeature: invalid dispatcher!"  );
45
0
        OSL_ENSURE( m_nSlotId,          "FmTextControlFeature::FmTextControlFeature: invalid slot id!"     );
46
0
        OSL_ENSURE( m_pInvalidator,     "FmTextControlFeature::FmTextControlFeature: invalid invalidator!" );
47
48
0
        osl_atomic_increment( &m_refCount );
49
0
        try
50
0
        {
51
0
            m_xDispatcher->addStatusListener( this, m_aFeatureURL );
52
0
        }
53
0
        catch( const Exception& )
54
0
        {
55
0
            TOOLS_WARN_EXCEPTION( "svx", "FmTextControlFeature::FmTextControlFeature" );
56
0
        }
57
0
        osl_atomic_decrement( &m_refCount );
58
0
    }
59
60
61
    FmTextControlFeature::~FmTextControlFeature( )
62
0
    {
63
0
    }
64
65
66
    void FmTextControlFeature::dispatch() const
67
0
    {
68
0
        dispatch( Sequence< PropertyValue >( ) );
69
0
    }
70
71
72
    void FmTextControlFeature::dispatch( const Sequence< PropertyValue >& _rArgs ) const
73
0
    {
74
0
        try
75
0
        {
76
0
            if ( m_xDispatcher.is() )
77
0
                m_xDispatcher->dispatch( m_aFeatureURL, _rArgs );
78
0
        }
79
0
        catch( const Exception& )
80
0
        {
81
0
            TOOLS_WARN_EXCEPTION( "svx", "FmTextControlFeature::dispatch" );
82
0
        }
83
0
    }
84
85
86
    void SAL_CALL FmTextControlFeature::statusChanged( const FeatureStateEvent& _rState )
87
0
    {
88
0
        m_aFeatureState   = _rState.State;
89
0
        m_bFeatureEnabled = _rState.IsEnabled;
90
91
0
        if ( m_pInvalidator )
92
0
            m_pInvalidator->Invalidate( m_nSlotId );
93
0
    }
94
95
96
    void SAL_CALL FmTextControlFeature::disposing( const EventObject& /*Source*/ )
97
0
    {
98
        // nothing to do
99
0
    }
100
101
102
    void FmTextControlFeature::dispose()
103
0
    {
104
0
        try
105
0
        {
106
0
            m_xDispatcher->removeStatusListener( this, m_aFeatureURL );
107
0
            m_xDispatcher.clear();
108
0
        }
109
0
        catch( const Exception& )
110
0
        {
111
0
            TOOLS_WARN_EXCEPTION( "svx", "FmTextControlFeature::dispose" );
112
0
        }
113
0
    }
114
115
116
}
117
118
119
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */