1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SVX_FMDISPATCH_HXX
21 #define SVX_FMDISPATCH_HXX
23 #include <com/sun/star/frame/XDispatch.hpp>
24 #include <com/sun/star/lang/DisposedException.hpp>
25 #include <com/sun/star/form/runtime/XFormOperations.hpp>
27 #include <cppuhelper/implbase1.hxx>
28 #include <cppuhelper/interfacecontainer.hxx>
30 //........................................................................
33 //........................................................................
35 //====================================================================
36 //= OSingleFeatureDispatcher
37 //====================================================================
38 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::frame::XDispatch
39 > OSingleFeatureDispatcher_Base
;
41 class OSingleFeatureDispatcher
: public OSingleFeatureDispatcher_Base
44 ::osl::Mutex
& m_rMutex
;
45 ::cppu::OInterfaceContainerHelper m_aStatusListeners
;
46 ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormOperations
>
48 const ::com::sun::star::util::URL m_aFeatureURL
;
49 ::com::sun::star::uno::Any m_aLastKnownState
;
50 const sal_Int16 m_nFormFeature
;
51 sal_Bool m_bLastKnownEnabled
;
55 /** constructs the dispatcher
58 the URL of the feature which this instance is responsible for
61 the feature which this instance is responsible for
64 the controller which is responsible for providing the state of feature of this instance,
65 and for executing it. After disposing the dispatcher instance, the controller will
66 not be accessed anymore
70 OSingleFeatureDispatcher(
71 const ::com::sun::star::util::URL
& _rFeatureURL
,
72 const sal_Int16 _nFormFeature
,
73 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormOperations
>& _rxFormOperations
,
77 /** notifies all our listeners of the current state
79 void updateAllListeners();
83 virtual void SAL_CALL
dispatch( const ::com::sun::star::util::URL
& _rURL
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _rArguments
) throw (::com::sun::star::uno::RuntimeException
);
84 virtual void SAL_CALL
addStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& _rxControl
, const ::com::sun::star::util::URL
& _rURL
) throw (::com::sun::star::uno::RuntimeException
);
85 virtual void SAL_CALL
removeStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& _rxControl
, const ::com::sun::star::util::URL
& _rURL
) throw (::com::sun::star::uno::RuntimeException
);
88 /** notifies our current state to one or all listeners
91 the listener to notify. May be NULL, in this case all our listeners will be
92 notified with the current state
94 @param _rFreeForNotification
95 a guard which currently locks our mutex, and which is to be cleared
96 for actually doing the notification(s)
99 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& _rxListener
,
100 ::osl::ClearableMutexGuard
& _rFreeForNotification
104 /** checks whether our instance is alive
106 If the instance already received a <member>dispose</member> call, then a
107 <type scope="com::sun::star::lang">DisposedException</type> is thrown.
110 our Mutex is locked - else calling the method would not make sense, since
111 it's result could be out-of-date as soon as it's returned to the caller.
113 void checkAlive() const SAL_THROW((::com::sun::star::lang::DisposedException
));
115 /** retrieves the current status of our feature, in a format which can be used
116 for UNO notifications
121 void getUnoState( ::com::sun::star::frame::FeatureStateEvent
& /* [out] */ _rState
) const;
124 //........................................................................
126 //........................................................................
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */