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