LibreOffice Module sd (master) 1
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
sd::framework::ConfigurationControllerBroadcaster Class Reference

This class manages the set of XConfigurationChangeListeners and calls them when the ConfigurationController wants to broadcast an event. More...

#include <ConfigurationControllerBroadcaster.hxx>

Classes

class  ListenerDescriptor
 

Public Member Functions

 ConfigurationControllerBroadcaster (const css::uno::Reference< css::drawing::framework::XConfigurationController > &rxController)
 The given controller is used as origin of thrown exceptions. More...
 
void AddListener (const css::uno::Reference< css::drawing::framework::XConfigurationChangeListener > &rxListener, const OUString &rsEventType, const css::uno::Any &rUserData)
 Add a listener for one type of event. More...
 
void RemoveListener (const css::uno::Reference< css::drawing::framework::XConfigurationChangeListener > &rxListener)
 Remove all references to the given listener. More...
 
void NotifyListeners (const css::drawing::framework::ConfigurationChangeEvent &rEvent)
 Broadcast the given event to all listeners that have been registered for its type of event as well as all universal listeners. More...
 
void NotifyListeners (const OUString &rsEventType, const css::uno::Reference< css::drawing::framework::XResourceId > &rxResourceId, const css::uno::Reference< css::drawing::framework::XResource > &rxResourceObject)
 This convenience variant of NotifyListeners create the event from the given arguments. More...
 
void DisposeAndClear ()
 Call all listeners and inform them that the ConfigurationController is being disposed. More...
 

Private Types

typedef std::vector< ListenerDescriptorListenerList
 
typedef std::unordered_map< OUString, ListenerListListenerMap
 

Private Member Functions

void NotifyListeners (const ListenerList &rList, const css::drawing::framework::ConfigurationChangeEvent &rEvent)
 Broadcast the given event to all listeners in the given list. More...
 

Private Attributes

css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
 
ListenerMap maListenerMap
 

Detailed Description

This class manages the set of XConfigurationChangeListeners and calls them when the ConfigurationController wants to broadcast an event.

For every registered combination of listener and event type a user data object is stored. This user data object is then given to the listener whenever it is called for an event. With this the listener can use a switch statement to handle different event types.

Definition at line 44 of file ConfigurationControllerBroadcaster.hxx.

Member Typedef Documentation

◆ ListenerList

Definition at line 120 of file ConfigurationControllerBroadcaster.hxx.

◆ ListenerMap

Definition at line 123 of file ConfigurationControllerBroadcaster.hxx.

Constructor & Destructor Documentation

◆ ConfigurationControllerBroadcaster()

sd::framework::ConfigurationControllerBroadcaster::ConfigurationControllerBroadcaster ( const css::uno::Reference< css::drawing::framework::XConfigurationController > &  rxController)
explicit

The given controller is used as origin of thrown exceptions.

Definition at line 34 of file ConfigurationControllerBroadcaster.cxx.

Member Function Documentation

◆ AddListener()

void sd::framework::ConfigurationControllerBroadcaster::AddListener ( const css::uno::Reference< css::drawing::framework::XConfigurationChangeListener > &  rxListener,
const OUString &  rsEventType,
const css::uno::Any &  rUserData 
)

Add a listener for one type of event.

When one listener is interested in more than one event type this method has to be called once for every event type. Alternatively it can register as universal listener that will be called for all event types.

Parameters
rxListenerA valid reference to a listener.
rsEventTypeThe type of event that the listener will be called for. The empty string is a special value in that the listener will be called for all event types.
rUserDataThis object is passed to the listener whenever it is called for the specified event type. For different event types different user data objects can be provided.
Exceptions
IllegalArgumentExceptionwhen an empty listener reference is given.

Definition at line 40 of file ConfigurationControllerBroadcaster.cxx.

References maListenerMap, sd::framework::ConfigurationControllerBroadcaster::ListenerDescriptor::maUserData, mxConfigurationController, and sd::framework::ConfigurationControllerBroadcaster::ListenerDescriptor::mxListener.

◆ DisposeAndClear()

void sd::framework::ConfigurationControllerBroadcaster::DisposeAndClear ( )

Call all listeners and inform them that the ConfigurationController is being disposed.

When this method returns the list of registered listeners is empty. Further calls to RemoveListener() are not necessary but do not result in an error.

Definition at line 146 of file ConfigurationControllerBroadcaster.cxx.

References aEvent, DBG_UNHANDLED_EXCEPTION, maListenerMap, mxConfigurationController, and RemoveListener().

◆ NotifyListeners() [1/3]

void sd::framework::ConfigurationControllerBroadcaster::NotifyListeners ( const css::drawing::framework::ConfigurationChangeEvent &  rEvent)

Broadcast the given event to all listeners that have been registered for its type of event as well as all universal listeners.

When calling a listener results in a DisposedException being thrown the listener is unregistered automatically.

◆ NotifyListeners() [2/3]

void sd::framework::ConfigurationControllerBroadcaster::NotifyListeners ( const ListenerList rList,
const css::drawing::framework::ConfigurationChangeEvent &  rEvent 
)
private

Broadcast the given event to all listeners in the given list.

When calling a listener results in a DisposedException being thrown the listener is unregistered automatically.

◆ NotifyListeners() [3/3]

void sd::framework::ConfigurationControllerBroadcaster::NotifyListeners ( const OUString &  rsEventType,
const css::uno::Reference< css::drawing::framework::XResourceId > &  rxResourceId,
const css::uno::Reference< css::drawing::framework::XResource > &  rxResourceObject 
)

This convenience variant of NotifyListeners create the event from the given arguments.

◆ RemoveListener()

void sd::framework::ConfigurationControllerBroadcaster::RemoveListener ( const css::uno::Reference< css::drawing::framework::XConfigurationChangeListener > &  rxListener)

Remove all references to the given listener.

When one listener has been registered for more than one type of event then it is removed for all of them.

Parameters
rxListenerA valid reference to a listener.
Exceptions
IllegalArgumentExceptionwhen an empty listener reference is given.

Definition at line 58 of file ConfigurationControllerBroadcaster.cxx.

References maListenerMap, and mxConfigurationController.

Referenced by DisposeAndClear().

Member Data Documentation

◆ maListenerMap

ListenerMap sd::framework::ConfigurationControllerBroadcaster::maListenerMap
private

◆ mxConfigurationController

css::uno::Reference<css::drawing::framework::XConfigurationController> sd::framework::ConfigurationControllerBroadcaster::mxConfigurationController
private

The documentation for this class was generated from the following files: