1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmtextcontrolfeature.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include "fmtextcontrolfeature.hxx"
35 /** === begin UNO includes === **/
36 /** === end UNO includes === **/
38 //........................................................................
41 //........................................................................
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::frame
;
45 using namespace ::com::sun::star::lang
;
46 using namespace ::com::sun::star::beans
;
47 using namespace ::com::sun::star::util
;
49 //====================================================================
50 //= FmTextControlFeature
51 //====================================================================
52 //--------------------------------------------------------------------
53 FmTextControlFeature::FmTextControlFeature( const Reference
< XDispatch
>& _rxDispatcher
, const URL
& _rFeatureURL
, SfxSlotId _nSlotId
, ISlotInvalidator
* _pInvalidator
)
54 :m_xDispatcher ( _rxDispatcher
)
55 ,m_aFeatureURL ( _rFeatureURL
)
56 ,m_nSlotId ( _nSlotId
)
57 ,m_pInvalidator ( _pInvalidator
)
58 ,m_bFeatureEnabled( false )
60 OSL_ENSURE( _rxDispatcher
.is(), "FmTextControlFeature::FmTextControlFeature: invalid dispatcher!" );
61 OSL_ENSURE( m_nSlotId
, "FmTextControlFeature::FmTextControlFeature: invalid slot id!" );
62 OSL_ENSURE( m_pInvalidator
, "FmTextControlFeature::FmTextControlFeature: invalid invalidator!" );
64 osl_incrementInterlockedCount( &m_refCount
);
67 m_xDispatcher
->addStatusListener( this, m_aFeatureURL
);
69 catch( const Exception
& )
71 OSL_ENSURE( sal_False
, "FmTextControlFeature::FmTextControlFeature: caught an exception!" );
73 osl_decrementInterlockedCount( &m_refCount
);
76 //--------------------------------------------------------------------
77 FmTextControlFeature::~FmTextControlFeature( )
81 //--------------------------------------------------------------------
82 void FmTextControlFeature::dispatch() const SAL_THROW(())
84 dispatch( Sequence
< PropertyValue
>( ) );
87 //--------------------------------------------------------------------
88 void FmTextControlFeature::dispatch( const Sequence
< PropertyValue
>& _rArgs
) const SAL_THROW(())
92 if ( m_xDispatcher
.is() )
93 m_xDispatcher
->dispatch( m_aFeatureURL
, _rArgs
);
95 catch( const Exception
& )
97 OSL_ENSURE( sal_False
, "FmTextControlFeature::dispatch: caught an exception!" );
101 //--------------------------------------------------------------------
102 void SAL_CALL
FmTextControlFeature::statusChanged( const FeatureStateEvent
& _rState
) throw (RuntimeException
)
104 m_aFeatureState
= _rState
.State
;
105 m_bFeatureEnabled
= _rState
.IsEnabled
;
107 if ( m_pInvalidator
)
108 m_pInvalidator
->Invalidate( m_nSlotId
);
111 //--------------------------------------------------------------------
112 void SAL_CALL
FmTextControlFeature::disposing( const EventObject
& /*Source*/ ) throw (RuntimeException
)
117 //--------------------------------------------------------------------
118 void FmTextControlFeature::dispose() SAL_THROW(())
122 m_xDispatcher
->removeStatusListener( this, m_aFeatureURL
);
123 m_xDispatcher
.clear();
125 catch( const Exception
& )
127 OSL_ENSURE( sal_False
, "FmTextControlFeature::dispose: caught an exception!" );
131 //........................................................................
133 //........................................................................