LibreOffice Module sd (master) 1
|
Listen for state changes of slots. More...
#include <SlotStateListener.hxx>
Public Member Functions | |
SlotStateListener (Link< const OUString &, void > const &rCallback, const css::uno::Reference< css::frame::XDispatchProvider > &rxDispatchProvider, const OUString &rSlotName) | |
This convenience version of the constructor takes all parameters that are necessary to observe a single slot. More... | |
virtual | ~SlotStateListener () override |
The constructor de-registers all remaining listeners. More... | |
void | SetCallback (const Link< const OUString &, void > &rCallback) |
Set the callback to the given value. More... | |
void | ConnectToDispatchProvider (const css::uno::Reference< css::frame::XDispatchProvider > &rxDispatchProvider) |
Set the frame whose slots shall be observed. More... | |
void | ObserveSlot (const OUString &rSlotName) |
Observe the slot specified by the given name. More... | |
virtual void SAL_CALL | statusChanged (const css::frame::FeatureStateEvent &rState) override |
Called by slot state change broadcasters. More... | |
virtual void SAL_CALL | disposing (const css::lang::EventObject &rEvent) override |
![]() | |
virtual void SAL_CALL | acquire () noexcept override |
virtual void SAL_CALL | release () noexcept override |
virtual void SAL_CALL | dispose () noexcept final override |
virtual void SAL_CALL | addEventListener (css::uno::Reference< css::lang::XEventListener > const &rxListener) final override |
virtual void SAL_CALL | removeEventListener (css::uno::Reference< css::lang::XEventListener > const &rxListener) final override |
virtual css::uno::Any SAL_CALL | queryInterface (css::uno::Type const &rType) override |
virtual css::uno::Sequence< css::uno::Type > SAL_CALL | getTypes () override |
virtual css::uno::Sequence< sal_Int8 > SAL_CALL | getImplementationId () override |
![]() | |
virtual | ~WeakComponentImplHelperBase () override |
virtual void SAL_CALL | dispose () override |
virtual void SAL_CALL | addEventListener (css::uno::Reference< css::lang::XEventListener > const &rxListener) override |
virtual void SAL_CALL | removeEventListener (css::uno::Reference< css::lang::XEventListener > const &rxListener) override |
virtual css::uno::Any SAL_CALL | queryInterface (css::uno::Type const &rType) override |
virtual void | disposing (std::unique_lock< std::mutex > &) |
![]() | |
virtual | ~UnoImplBase () |
Private Member Functions | |
virtual void | disposing (std::unique_lock< std::mutex > &) override |
This method is called by the WeakComponentImplHelper base class in reaction to a XComponent::dispose() call. More... | |
void | ReleaseListeners () |
Deregister all currently active state change listeners. More... | |
void | ThrowIfDisposed () |
css::uno::Reference< css::frame::XDispatch > | GetDispatch (const css::util::URL &rURL) const |
Return an XDispatch object for the given URL. More... | |
Static Private Member Functions | |
static css::util::URL | MakeURL (const OUString &rSlotName) |
Transform the given string into a URL object. More... | |
Private Attributes | |
Link< const OUString &, void > | maCallback |
std::vector< css::util::URL > | maRegisteredURLList |
Remember the URLs that describe slots whose state changes we are listening to. More... | |
css::uno::WeakReference< css::frame::XDispatchProvider > | mxDispatchProviderWeak |
Additional Inherited Members | |
![]() | |
void | throwIfDisposed (std::unique_lock< std::mutex > &) |
![]() | |
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > | maEventListeners |
![]() | |
std::mutex | m_aMutex |
bool | m_bDisposed |
Listen for state changes of slots.
This class has been created in order to be informed when the support for vertical writing changes but it can be used to relay state changes of other slots as well.
Definition at line 42 of file SlotStateListener.hxx.
sd::tools::SlotStateListener::SlotStateListener | ( | Link< const OUString &, void > const & | rCallback, |
const css::uno::Reference< css::frame::XDispatchProvider > & | rxDispatchProvider, | ||
const OUString & | rSlotName | ||
) |
This convenience version of the constructor takes all parameters that are necessary to observe a single slot.
See descriptions of the SetCallback(), ConnectToFrame(), and ObserveSlot() methods for explanations about the parameters.
Definition at line 32 of file SlotStateListener.cxx.
References ConnectToDispatchProvider(), ObserveSlot(), and SetCallback().
|
overridevirtual |
The constructor de-registers all remaining listeners.
Usually a prior dispose() call should have done that already.
Definition at line 43 of file SlotStateListener.cxx.
References ReleaseListeners().
void sd::tools::SlotStateListener::ConnectToDispatchProvider | ( | const css::uno::Reference< css::frame::XDispatchProvider > & | rxDispatchProvider | ) |
Set the frame whose slots shall be observed.
When an object of this class is already observing slots of another frame then these listeners are released first.
DisposedException |
Definition at line 55 of file SlotStateListener.cxx.
References maRegisteredURLList, mxDispatchProviderWeak, ReleaseListeners(), and ThrowIfDisposed().
Referenced by SlotStateListener().
|
overridevirtual |
|
overrideprivatevirtual |
This method is called by the WeakComponentImplHelper base class in reaction to a XComponent::dispose() call.
It releases all currently active listeners.
Reimplemented from comphelper::WeakComponentImplHelperBase.
Definition at line 85 of file SlotStateListener.cxx.
References maCallback, mxDispatchProviderWeak, and ReleaseListeners().
|
private |
Return an XDispatch object for the given URL.
Definition at line 104 of file SlotStateListener.cxx.
References mxDispatchProviderWeak, and xDispatch.
Referenced by ObserveSlot(), and ReleaseListeners().
|
staticprivate |
Transform the given string into a URL object.
Definition at line 92 of file SlotStateListener.cxx.
References aURL.
Referenced by ObserveSlot().
void sd::tools::SlotStateListener::ObserveSlot | ( | const OUString & | rSlotName | ) |
Observe the slot specified by the given name.
Note that ConnectToFrame() has to have been called earlier.
rSlotName | The name of the slot to observe. An example is ".uno:VerticalTextState". |
DisposedException |
Definition at line 68 of file SlotStateListener.cxx.
References aURL, GetDispatch(), Link< typename Arg, typename Ret >::IsSet(), maCallback, MakeURL(), maRegisteredURLList, ThrowIfDisposed(), and xDispatch.
Referenced by SlotStateListener().
|
private |
Deregister all currently active state change listeners.
Definition at line 123 of file SlotStateListener.cxx.
References GetDispatch(), maRegisteredURLList, and xDispatch.
Referenced by ConnectToDispatchProvider(), disposing(), and ~SlotStateListener().
void sd::tools::SlotStateListener::SetCallback | ( | const Link< const OUString &, void > & | rCallback | ) |
Set the callback to the given value.
Whenever one of the observed slots changes its state this callback is informed about it. Changing the callback does not release the listeners.
DisposedException |
Definition at line 48 of file SlotStateListener.cxx.
References maCallback, and ThrowIfDisposed().
Referenced by SlotStateListener().
|
overridevirtual |
Called by slot state change broadcasters.
In turn the callback is informed about the state change.
DisposedException |
Definition at line 115 of file SlotStateListener.cxx.
References Link< typename Arg, typename Ret >::Call(), maCallback, and ThrowIfDisposed().
|
private |
css::lang::DisposedException | when the object has already been disposed. |
Definition at line 142 of file SlotStateListener.cxx.
References comphelper::UnoImplBase::m_bDisposed.
Referenced by ConnectToDispatchProvider(), ObserveSlot(), SetCallback(), and statusChanged().
|
private |
Definition at line 107 of file SlotStateListener.hxx.
Referenced by disposing(), ObserveSlot(), SetCallback(), and statusChanged().
|
private |
Remember the URLs that describe slots whose state changes we are listening to.
Definition at line 112 of file SlotStateListener.hxx.
Referenced by ConnectToDispatchProvider(), ObserveSlot(), and ReleaseListeners().
|
private |
Definition at line 114 of file SlotStateListener.hxx.
Referenced by ConnectToDispatchProvider(), disposing(), and GetDispatch().