21#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
22#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
23#include <com/sun/star/drawing/framework/XResource.hpp>
24#include <com/sun/star/lang/IllegalArgumentException.hpp>
25#include <com/sun/star/lang/DisposedException.hpp>
35 const Reference<XConfigurationController>& rxController)
36 : mxConfigurationController(rxController)
41 const Reference<XConfigurationChangeListener>& rxListener,
42 const OUString& rsEventType,
45 if ( ! rxListener.is())
46 throw lang::IllegalArgumentException(
"invalid listener",
59 const Reference<XConfigurationChangeListener>& rxListener)
61 if ( ! rxListener.is())
62 throw lang::IllegalArgumentException(
"invalid listener",
66 ListenerList::iterator iList;
69 iList = std::find_if(rMap.second.begin(), rMap.second.end(),
70 [&rxListener](
const ListenerDescriptor& rList) { return rList.mxListener == rxListener; });
71 if (iList != rMap.second.end())
72 rMap.second.erase(iList);
77 const ListenerList& rList,
78 const ConfigurationChangeEvent& rEvent)
82 ConfigurationChangeEvent
aEvent (rEvent);
84 for (
const auto& rListener : rList)
88 aEvent.UserData = rListener.maUserData;
89 rListener.mxListener->notifyConfigurationChange(aEvent);
91 catch (
const lang::DisposedException& rException)
95 if (rException.Context == rListener.mxListener)
108 ListenerMap::const_iterator iMap (
maListenerMap.find(rEvent.Type));
113 ListenerList aList (iMap->second.begin(), iMap->second.end());
123 ListenerList aList (iMap->second.begin(), iMap->second.end());
129 const OUString& rsEventType,
130 const Reference<XResourceId>& rxResourceId,
131 const Reference<XResource>& rxResourceObject)
133 ConfigurationChangeEvent
aEvent;
134 aEvent.Type = rsEventType;
135 aEvent.ResourceId = rxResourceId;
136 aEvent.ResourceObject = rxResourceObject;
141 catch (
const lang::DisposedException&)
157 if (iMap->second.empty())
164 Reference<XConfigurationChangeListener> xListener (
165 iMap->second.front().mxListener );
174 xListener->disposing(
aEvent);
184 iMap->second.erase(iMap->second.begin());
css::uno::Reference< css::drawing::framework::XConfigurationChangeListener > mxListener
ListenerMap maListenerMap
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
void DisposeAndClear()
Call all listeners and inform them that the ConfigurationController is being disposed.
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.
void RemoveListener(const css::uno::Reference< css::drawing::framework::XConfigurationChangeListener > &rxListener)
Remove all references to the given listener.
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...
ConfigurationControllerBroadcaster(const css::uno::Reference< css::drawing::framework::XConfigurationController > &rxController)
The given controller is used as origin of thrown exceptions.
std::vector< ListenerDescriptor > ListenerList
#define DBG_UNHANDLED_EXCEPTION(...)