1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include "fmtextcontrolfeature.hxx"
27 
28 /** === begin UNO includes === **/
29 /** === end UNO includes === **/
30 
31 //........................................................................
32 namespace svx
33 {
34 //........................................................................
35 
36     using namespace ::com::sun::star::uno;
37     using namespace ::com::sun::star::frame;
38     using namespace ::com::sun::star::lang;
39     using namespace ::com::sun::star::beans;
40     using namespace ::com::sun::star::util;
41 
42     //====================================================================
43 	//= FmTextControlFeature
44 	//====================================================================
45 	//--------------------------------------------------------------------
FmTextControlFeature(const Reference<XDispatch> & _rxDispatcher,const URL & _rFeatureURL,SfxSlotId _nSlotId,ISlotInvalidator * _pInvalidator)46     FmTextControlFeature::FmTextControlFeature( const Reference< XDispatch >& _rxDispatcher, const URL& _rFeatureURL, SfxSlotId _nSlotId, ISlotInvalidator* _pInvalidator )
47         :m_xDispatcher    ( _rxDispatcher )
48         ,m_aFeatureURL    ( _rFeatureURL  )
49         ,m_nSlotId        ( _nSlotId      )
50         ,m_pInvalidator   ( _pInvalidator )
51         ,m_bFeatureEnabled( false         )
52     {
53         OSL_ENSURE( _rxDispatcher.is(), "FmTextControlFeature::FmTextControlFeature: invalid dispatcher!"  );
54         OSL_ENSURE( m_nSlotId,          "FmTextControlFeature::FmTextControlFeature: invalid slot id!"     );
55         OSL_ENSURE( m_pInvalidator,     "FmTextControlFeature::FmTextControlFeature: invalid invalidator!" );
56 
57         osl_incrementInterlockedCount( &m_refCount );
58         try
59         {
60             m_xDispatcher->addStatusListener( this, m_aFeatureURL );
61         }
62         catch( const Exception& )
63         {
64         	OSL_ENSURE( sal_False, "FmTextControlFeature::FmTextControlFeature: caught an exception!" );
65         }
66         osl_decrementInterlockedCount( &m_refCount );
67     }
68 
69 	//--------------------------------------------------------------------
~FmTextControlFeature()70     FmTextControlFeature::~FmTextControlFeature( )
71     {
72     }
73 
74 	//--------------------------------------------------------------------
dispatch() const75     void FmTextControlFeature::dispatch() const SAL_THROW(())
76     {
77         dispatch( Sequence< PropertyValue >( ) );
78     }
79 
80     //--------------------------------------------------------------------
dispatch(const Sequence<PropertyValue> & _rArgs) const81     void FmTextControlFeature::dispatch( const Sequence< PropertyValue >& _rArgs ) const SAL_THROW(())
82     {
83         try
84         {
85             if ( m_xDispatcher.is() )
86                 m_xDispatcher->dispatch( m_aFeatureURL, _rArgs );
87         }
88         catch( const Exception& )
89         {
90         	OSL_ENSURE( sal_False, "FmTextControlFeature::dispatch: caught an exception!" );
91         }
92     }
93 
94     //--------------------------------------------------------------------
statusChanged(const FeatureStateEvent & _rState)95     void SAL_CALL FmTextControlFeature::statusChanged( const FeatureStateEvent& _rState ) throw (RuntimeException)
96     {
97         m_aFeatureState   = _rState.State;
98         m_bFeatureEnabled = _rState.IsEnabled;
99 
100         if ( m_pInvalidator )
101             m_pInvalidator->Invalidate( m_nSlotId );
102     }
103 
104     //--------------------------------------------------------------------
disposing(const EventObject &)105     void SAL_CALL FmTextControlFeature::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
106     {
107         // nothing to do
108     }
109 
110     //--------------------------------------------------------------------
dispose()111     void FmTextControlFeature::dispose() SAL_THROW(())
112     {
113         try
114         {
115             m_xDispatcher->removeStatusListener( this, m_aFeatureURL );
116             m_xDispatcher.clear();
117         }
118         catch( const Exception& )
119         {
120         	OSL_ENSURE( sal_False, "FmTextControlFeature::dispose: caught an exception!" );
121         }
122     }
123 
124 //........................................................................
125 }   // namespace svx
126 //........................................................................
127 
128