xref: /AOO41X/main/sd/source/ui/tools/EventMultiplexer.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "EventMultiplexer.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "MutexOwner.hxx"
34*cdf0e10cSrcweir #include "ViewShellBase.hxx"
35*cdf0e10cSrcweir #include "drawdoc.hxx"
36*cdf0e10cSrcweir #include "DrawController.hxx"
37*cdf0e10cSrcweir #include "SlideSorterViewShell.hxx"
38*cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
44*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
45*cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
46*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir using namespace ::com::sun::star;
49*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
50*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
51*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir using ::rtl::OUString;
54*cdf0e10cSrcweir using ::sd::framework::FrameworkHelper;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir class SdDrawDocument;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir namespace {
59*cdf0e10cSrcweir static const sal_Int32 ResourceActivationEvent = 0;
60*cdf0e10cSrcweir static const sal_Int32 ResourceDeactivationEvent = 1;
61*cdf0e10cSrcweir static const sal_Int32 ConfigurationUpdateEvent = 2;
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir namespace sd { namespace tools {
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir typedef cppu::WeakComponentImplHelper4<
67*cdf0e10cSrcweir       ::com::sun::star::beans::XPropertyChangeListener,
68*cdf0e10cSrcweir       ::com::sun::star::frame::XFrameActionListener,
69*cdf0e10cSrcweir       ::com::sun::star::view::XSelectionChangeListener,
70*cdf0e10cSrcweir       ::com::sun::star::drawing::framework::XConfigurationChangeListener
71*cdf0e10cSrcweir     > EventMultiplexerImplementationInterfaceBase;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir class EventMultiplexer::Implementation
74*cdf0e10cSrcweir     : protected MutexOwner,
75*cdf0e10cSrcweir       public EventMultiplexerImplementationInterfaceBase,
76*cdf0e10cSrcweir       public SfxListener
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir public:
79*cdf0e10cSrcweir     Implementation (ViewShellBase& rBase);
80*cdf0e10cSrcweir     ~Implementation (void);
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     void AddEventListener (
83*cdf0e10cSrcweir         Link& rCallback,
84*cdf0e10cSrcweir         EventMultiplexerEvent::EventId aEventTypes);
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     void RemoveEventListener (
87*cdf0e10cSrcweir         Link& rCallback,
88*cdf0e10cSrcweir         EventMultiplexerEvent::EventId aEventTypes);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	void CallListeners (EventMultiplexerEvent& rEvent);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	ViewShellBase& GetViewShellBase() const { return mrBase; }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     //===== lang::XEventListener ==============================================
95*cdf0e10cSrcweir     virtual void SAL_CALL
96*cdf0e10cSrcweir         disposing (const ::com::sun::star::lang::EventObject& rEventObject)
97*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     //===== beans::XPropertySetListener =======================================
101*cdf0e10cSrcweir     virtual void SAL_CALL
102*cdf0e10cSrcweir         propertyChange (
103*cdf0e10cSrcweir             const com::sun::star::beans::PropertyChangeEvent& rEvent)
104*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     //===== view::XSelectionChangeListener ====================================
107*cdf0e10cSrcweir     virtual void SAL_CALL
108*cdf0e10cSrcweir         selectionChanged (
109*cdf0e10cSrcweir             const com::sun::star::lang::EventObject& rEvent)
110*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     //===== frame::XFrameActionListener  ======================================
113*cdf0e10cSrcweir     /** For certain actions the listener connects to a new controller of the
114*cdf0e10cSrcweir         frame it is listening to.  This usually happens when the view shell
115*cdf0e10cSrcweir         in the center pane is replaced by another view shell.
116*cdf0e10cSrcweir     */
117*cdf0e10cSrcweir     virtual void SAL_CALL
118*cdf0e10cSrcweir         frameAction (const ::com::sun::star::frame::FrameActionEvent& rEvent)
119*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     //===== drawing::framework::XConfigurationChangeListener ==================
122*cdf0e10cSrcweir     virtual void SAL_CALL
123*cdf0e10cSrcweir         notifyConfigurationChange (
124*cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
125*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir protected:
131*cdf0e10cSrcweir     virtual void Notify (
132*cdf0e10cSrcweir         SfxBroadcaster& rBroadcaster,
133*cdf0e10cSrcweir         const SfxHint& rHint);
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir private:
136*cdf0e10cSrcweir     ViewShellBase& mrBase;
137*cdf0e10cSrcweir     typedef ::std::pair<Link,EventMultiplexerEvent::EventId> ListenerDescriptor;
138*cdf0e10cSrcweir     typedef ::std::vector<ListenerDescriptor> ListenerList;
139*cdf0e10cSrcweir     ListenerList maListeners;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     /// Remember whether we are listening to the UNO controller.
142*cdf0e10cSrcweir     bool mbListeningToController;
143*cdf0e10cSrcweir     /// Remember whether we are listening to the frame.
144*cdf0e10cSrcweir     bool mbListeningToFrame;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference<
147*cdf0e10cSrcweir         ::com::sun::star::frame::XController> mxControllerWeak;
148*cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference<
149*cdf0e10cSrcweir         ::com::sun::star::frame::XFrame> mxFrameWeak;
150*cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference<
151*cdf0e10cSrcweir         ::com::sun::star::view::XSelectionSupplier> mxSlideSorterSelectionWeak;
152*cdf0e10cSrcweir     SdDrawDocument* mpDocument;
153*cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference<
154*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationController>
155*cdf0e10cSrcweir         mxConfigurationControllerWeak;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     static const ::rtl::OUString msCurrentPagePropertyName;
158*cdf0e10cSrcweir     static const ::rtl::OUString msEditModePropertyName;
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     void ReleaseListeners (void);
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     void ConnectToController (void);
163*cdf0e10cSrcweir     void DisconnectFromController (void);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     void CallListeners (
166*cdf0e10cSrcweir         EventMultiplexerEvent::EventId eId,
167*cdf0e10cSrcweir         void* pUserData = NULL);
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     /** This method throws a DisposedException when the object has already been
170*cdf0e10cSrcweir         disposed.
171*cdf0e10cSrcweir     */
172*cdf0e10cSrcweir     void ThrowIfDisposed (void)
173*cdf0e10cSrcweir         throw (::com::sun::star::lang::DisposedException);
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     DECL_LINK(SlideSorterSelectionChangeListener, void*);
176*cdf0e10cSrcweir };
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir const ::rtl::OUString EventMultiplexer::Implementation::msCurrentPagePropertyName (
180*cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM("CurrentPage"));
181*cdf0e10cSrcweir const ::rtl::OUString EventMultiplexer::Implementation::msEditModePropertyName (
182*cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode"));
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir //===== EventMultiplexer ======================================================
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir EventMultiplexer::EventMultiplexer (ViewShellBase& rBase)
188*cdf0e10cSrcweir     : mpImpl (new EventMultiplexer::Implementation(rBase))
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir     mpImpl->acquire();
191*cdf0e10cSrcweir }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir EventMultiplexer::~EventMultiplexer (void)
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir     try
199*cdf0e10cSrcweir     {
200*cdf0e10cSrcweir         mpImpl->dispose();
201*cdf0e10cSrcweir         // Now we call release twice.  One decreases the use count of the
202*cdf0e10cSrcweir         // implementation object (if all goes well to zero and thus deletes
203*cdf0e10cSrcweir         // it.)  The other releases the auto_ptr and prevents the
204*cdf0e10cSrcweir         // implementation object from being deleted a second time.
205*cdf0e10cSrcweir         mpImpl->release();
206*cdf0e10cSrcweir         mpImpl.release();
207*cdf0e10cSrcweir     }
208*cdf0e10cSrcweir     catch (RuntimeException aException)
209*cdf0e10cSrcweir     {
210*cdf0e10cSrcweir     }
211*cdf0e10cSrcweir     catch (Exception aException)
212*cdf0e10cSrcweir     {
213*cdf0e10cSrcweir     }
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir void EventMultiplexer::AddEventListener (
220*cdf0e10cSrcweir     Link& rCallback,
221*cdf0e10cSrcweir     EventMultiplexerEvent::EventId aEventTypes)
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir     mpImpl->AddEventListener (rCallback, aEventTypes);
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir void EventMultiplexer::RemoveEventListener (
230*cdf0e10cSrcweir     Link& rCallback,
231*cdf0e10cSrcweir     EventMultiplexerEvent::EventId aEventTypes)
232*cdf0e10cSrcweir {
233*cdf0e10cSrcweir     mpImpl->RemoveEventListener (rCallback, aEventTypes);
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir void EventMultiplexer::MultiplexEvent(
240*cdf0e10cSrcweir     EventMultiplexerEvent::EventId eEventId,
241*cdf0e10cSrcweir     void* pUserData )
242*cdf0e10cSrcweir {
243*cdf0e10cSrcweir 	EventMultiplexerEvent aEvent (mpImpl->GetViewShellBase(), eEventId, pUserData);
244*cdf0e10cSrcweir     mpImpl->CallListeners(aEvent);
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir //===== EventMultiplexer::Implementation ======================================
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir EventMultiplexer::Implementation::Implementation (ViewShellBase& rBase)
253*cdf0e10cSrcweir     : MutexOwner(),
254*cdf0e10cSrcweir       EventMultiplexerImplementationInterfaceBase(maMutex),
255*cdf0e10cSrcweir       SfxListener(),
256*cdf0e10cSrcweir       mrBase (rBase),
257*cdf0e10cSrcweir       mbListeningToController (false),
258*cdf0e10cSrcweir       mbListeningToFrame (false),
259*cdf0e10cSrcweir       mxControllerWeak(NULL),
260*cdf0e10cSrcweir       mxFrameWeak(NULL),
261*cdf0e10cSrcweir       mxSlideSorterSelectionWeak(NULL),
262*cdf0e10cSrcweir       mpDocument(NULL),
263*cdf0e10cSrcweir       mxConfigurationControllerWeak()
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     // Connect to the frame to listen for controllers being exchanged.
266*cdf0e10cSrcweir     // Listen to changes of certain properties.
267*cdf0e10cSrcweir     Reference<frame::XFrame> xFrame (
268*cdf0e10cSrcweir         mrBase.GetFrame()->GetTopFrame().GetFrameInterface(),
269*cdf0e10cSrcweir         uno::UNO_QUERY);
270*cdf0e10cSrcweir     mxFrameWeak = xFrame;
271*cdf0e10cSrcweir     if (xFrame.is())
272*cdf0e10cSrcweir     {
273*cdf0e10cSrcweir         xFrame->addFrameActionListener (
274*cdf0e10cSrcweir             Reference<frame::XFrameActionListener>(
275*cdf0e10cSrcweir                static_cast<XWeak*>(this), UNO_QUERY));
276*cdf0e10cSrcweir         mbListeningToFrame = true;
277*cdf0e10cSrcweir     }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir     // Connect to the current controller.
280*cdf0e10cSrcweir     ConnectToController ();
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir     // Listen for document changes.
283*cdf0e10cSrcweir     mpDocument = mrBase.GetDocument();
284*cdf0e10cSrcweir     if (mpDocument != NULL)
285*cdf0e10cSrcweir         StartListening (*mpDocument);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     // Listen for configuration changes.
288*cdf0e10cSrcweir     Reference<XControllerManager> xControllerManager (
289*cdf0e10cSrcweir         Reference<XWeak>(&mrBase.GetDrawController()), UNO_QUERY);
290*cdf0e10cSrcweir     if (xControllerManager.is())
291*cdf0e10cSrcweir     {
292*cdf0e10cSrcweir         Reference<XConfigurationController> xConfigurationController (
293*cdf0e10cSrcweir             xControllerManager->getConfigurationController());
294*cdf0e10cSrcweir         mxConfigurationControllerWeak = xConfigurationController;
295*cdf0e10cSrcweir         if (xConfigurationController.is())
296*cdf0e10cSrcweir         {
297*cdf0e10cSrcweir             Reference<XComponent> xComponent (xConfigurationController, UNO_QUERY);
298*cdf0e10cSrcweir             if (xComponent.is())
299*cdf0e10cSrcweir                 xComponent->addEventListener(static_cast<beans::XPropertyChangeListener*>(this));
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir             xConfigurationController->addConfigurationChangeListener(
302*cdf0e10cSrcweir                 this,
303*cdf0e10cSrcweir                 FrameworkHelper::msResourceActivationEvent,
304*cdf0e10cSrcweir                 makeAny(ResourceActivationEvent));
305*cdf0e10cSrcweir             xConfigurationController->addConfigurationChangeListener(
306*cdf0e10cSrcweir                 this,
307*cdf0e10cSrcweir                 FrameworkHelper::msResourceDeactivationEvent,
308*cdf0e10cSrcweir                 makeAny(ResourceDeactivationEvent));
309*cdf0e10cSrcweir             xConfigurationController->addConfigurationChangeListener(
310*cdf0e10cSrcweir                 this,
311*cdf0e10cSrcweir                 FrameworkHelper::msConfigurationUpdateEndEvent,
312*cdf0e10cSrcweir                 makeAny(ConfigurationUpdateEvent));
313*cdf0e10cSrcweir         }
314*cdf0e10cSrcweir     }
315*cdf0e10cSrcweir }
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir EventMultiplexer::Implementation::~Implementation (void)
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	DBG_ASSERT( !mbListeningToFrame,
323*cdf0e10cSrcweir         "sd::EventMultiplexer::Implementation::~Implementation(), disposing was not called!" );
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir void EventMultiplexer::Implementation::ReleaseListeners (void)
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir     if (mbListeningToFrame)
332*cdf0e10cSrcweir     {
333*cdf0e10cSrcweir         mbListeningToFrame = false;
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir         // Stop listening for changes of certain properties.
336*cdf0e10cSrcweir         Reference<frame::XFrame> xFrame (mxFrameWeak);
337*cdf0e10cSrcweir         if (xFrame.is())
338*cdf0e10cSrcweir         {
339*cdf0e10cSrcweir             xFrame->removeFrameActionListener (
340*cdf0e10cSrcweir                 Reference<frame::XFrameActionListener>(
341*cdf0e10cSrcweir                     static_cast<XWeak*>(this), UNO_QUERY));
342*cdf0e10cSrcweir         }
343*cdf0e10cSrcweir     }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir     DisconnectFromController ();
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir     if (mpDocument != NULL)
348*cdf0e10cSrcweir     {
349*cdf0e10cSrcweir         EndListening (*mpDocument);
350*cdf0e10cSrcweir         mpDocument = NULL;
351*cdf0e10cSrcweir     }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir     // Stop listening for configuration changes.
354*cdf0e10cSrcweir     Reference<XConfigurationController> xConfigurationController (mxConfigurationControllerWeak);
355*cdf0e10cSrcweir     if (xConfigurationController.is())
356*cdf0e10cSrcweir     {
357*cdf0e10cSrcweir         Reference<XComponent> xComponent (xConfigurationController, UNO_QUERY);
358*cdf0e10cSrcweir         if (xComponent.is())
359*cdf0e10cSrcweir             xComponent->removeEventListener(static_cast<beans::XPropertyChangeListener*>(this));
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir         xConfigurationController->removeConfigurationChangeListener(this);
362*cdf0e10cSrcweir     }
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir void EventMultiplexer::Implementation::AddEventListener (
369*cdf0e10cSrcweir     Link& rCallback,
370*cdf0e10cSrcweir     EventMultiplexerEvent::EventId aEventTypes)
371*cdf0e10cSrcweir {
372*cdf0e10cSrcweir     ListenerList::iterator iListener (maListeners.begin());
373*cdf0e10cSrcweir     ListenerList::const_iterator iEnd (maListeners.end());
374*cdf0e10cSrcweir     for (;iListener!=iEnd; ++iListener)
375*cdf0e10cSrcweir         if (iListener->first == rCallback)
376*cdf0e10cSrcweir             break;
377*cdf0e10cSrcweir     if (iListener != maListeners.end())
378*cdf0e10cSrcweir     {
379*cdf0e10cSrcweir         // Listener exists.  Update its event type set.
380*cdf0e10cSrcweir         iListener->second |= aEventTypes;
381*cdf0e10cSrcweir     }
382*cdf0e10cSrcweir     else
383*cdf0e10cSrcweir     {
384*cdf0e10cSrcweir         maListeners.push_back (ListenerDescriptor(rCallback,aEventTypes));
385*cdf0e10cSrcweir     }
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir void EventMultiplexer::Implementation::RemoveEventListener (
392*cdf0e10cSrcweir     Link& rCallback,
393*cdf0e10cSrcweir     EventMultiplexerEvent::EventId aEventTypes)
394*cdf0e10cSrcweir {
395*cdf0e10cSrcweir     ListenerList::iterator iListener (maListeners.begin());
396*cdf0e10cSrcweir     ListenerList::const_iterator iEnd (maListeners.end());
397*cdf0e10cSrcweir     for (;iListener!=iEnd; ++iListener)
398*cdf0e10cSrcweir         if (iListener->first == rCallback)
399*cdf0e10cSrcweir             break;
400*cdf0e10cSrcweir     if (iListener != maListeners.end())
401*cdf0e10cSrcweir     {
402*cdf0e10cSrcweir         // Update the event type set.
403*cdf0e10cSrcweir         iListener->second &= ~aEventTypes;
404*cdf0e10cSrcweir         // When no events remain in the set then remove the listener.
405*cdf0e10cSrcweir         if (iListener->second == EID_EMPTY_SET)
406*cdf0e10cSrcweir             maListeners.erase (iListener);
407*cdf0e10cSrcweir     }
408*cdf0e10cSrcweir }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir void EventMultiplexer::Implementation::ConnectToController (void)
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir     // Just in case that we missed some event we now disconnect from the old
416*cdf0e10cSrcweir     // controller.
417*cdf0e10cSrcweir     DisconnectFromController ();
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir     // Register at the controller of the main view shell.
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir     // We have to store a (weak) reference to the controller so that we can
422*cdf0e10cSrcweir     // unregister without having to ask the mrBase member (which at that
423*cdf0e10cSrcweir     // time may be destroyed.)
424*cdf0e10cSrcweir     Reference<frame::XController> xController = mrBase.GetController();
425*cdf0e10cSrcweir     mxControllerWeak = mrBase.GetController();
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir     try
428*cdf0e10cSrcweir     {
429*cdf0e10cSrcweir         // Listen for disposing events.
430*cdf0e10cSrcweir         Reference<lang::XComponent> xComponent (xController, UNO_QUERY);
431*cdf0e10cSrcweir         if (xComponent.is())
432*cdf0e10cSrcweir         {
433*cdf0e10cSrcweir             xComponent->addEventListener (
434*cdf0e10cSrcweir                 Reference<lang::XEventListener>(
435*cdf0e10cSrcweir                     static_cast<XWeak*>(this), UNO_QUERY));
436*cdf0e10cSrcweir             mbListeningToController = true;
437*cdf0e10cSrcweir         }
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir         // Listen to changes of certain properties.
440*cdf0e10cSrcweir         Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
441*cdf0e10cSrcweir         if (xSet.is())
442*cdf0e10cSrcweir         {
443*cdf0e10cSrcweir                 try
444*cdf0e10cSrcweir                 {
445*cdf0e10cSrcweir                     xSet->addPropertyChangeListener(msCurrentPagePropertyName, this);
446*cdf0e10cSrcweir                 }
447*cdf0e10cSrcweir                 catch (beans::UnknownPropertyException)
448*cdf0e10cSrcweir                 {
449*cdf0e10cSrcweir                     OSL_TRACE("EventMultiplexer::ConnectToController: CurrentPage unknown");
450*cdf0e10cSrcweir                 }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir                 try
453*cdf0e10cSrcweir                 {
454*cdf0e10cSrcweir                     xSet->addPropertyChangeListener(msEditModePropertyName, this);
455*cdf0e10cSrcweir                 }
456*cdf0e10cSrcweir                 catch (beans::UnknownPropertyException)
457*cdf0e10cSrcweir                 {
458*cdf0e10cSrcweir                     OSL_TRACE("EventMultiplexer::ConnectToController: IsMasterPageMode unknown");
459*cdf0e10cSrcweir                 }
460*cdf0e10cSrcweir         }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir         // Listen for selection change events.
463*cdf0e10cSrcweir         Reference<view::XSelectionSupplier> xSelection (xController, UNO_QUERY);
464*cdf0e10cSrcweir         if (xSelection.is())
465*cdf0e10cSrcweir         {
466*cdf0e10cSrcweir             xSelection->addSelectionChangeListener(this);
467*cdf0e10cSrcweir         }
468*cdf0e10cSrcweir     }
469*cdf0e10cSrcweir     catch (const lang::DisposedException aException)
470*cdf0e10cSrcweir     {
471*cdf0e10cSrcweir         mbListeningToController = false;
472*cdf0e10cSrcweir     }
473*cdf0e10cSrcweir }
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir void EventMultiplexer::Implementation::DisconnectFromController (void)
479*cdf0e10cSrcweir {
480*cdf0e10cSrcweir     if (mbListeningToController)
481*cdf0e10cSrcweir     {
482*cdf0e10cSrcweir         mbListeningToController = false;
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir         Reference<frame::XController> xController = mxControllerWeak;
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir         Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
487*cdf0e10cSrcweir         // Remove the property listener.
488*cdf0e10cSrcweir         if (xSet.is())
489*cdf0e10cSrcweir         {
490*cdf0e10cSrcweir             try
491*cdf0e10cSrcweir             {
492*cdf0e10cSrcweir                 xSet->removePropertyChangeListener(msCurrentPagePropertyName, this);
493*cdf0e10cSrcweir             }
494*cdf0e10cSrcweir             catch (beans::UnknownPropertyException aEvent)
495*cdf0e10cSrcweir             {
496*cdf0e10cSrcweir                 OSL_TRACE ("DisconnectFromController: CurrentPage unknown");
497*cdf0e10cSrcweir             }
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir             try
500*cdf0e10cSrcweir             {
501*cdf0e10cSrcweir                 xSet->removePropertyChangeListener(msEditModePropertyName, this);
502*cdf0e10cSrcweir             }
503*cdf0e10cSrcweir             catch (beans::UnknownPropertyException aEvent)
504*cdf0e10cSrcweir             {
505*cdf0e10cSrcweir                 OSL_TRACE ("DisconnectFromController: IsMasterPageMode unknown");
506*cdf0e10cSrcweir             }
507*cdf0e10cSrcweir         }
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir         // Remove selection change listener.
510*cdf0e10cSrcweir         Reference<view::XSelectionSupplier> xSelection (xController, UNO_QUERY);
511*cdf0e10cSrcweir         if (xSelection.is())
512*cdf0e10cSrcweir         {
513*cdf0e10cSrcweir             xSelection->removeSelectionChangeListener(this);
514*cdf0e10cSrcweir         }
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir         // Remove listener for disposing events.
517*cdf0e10cSrcweir         Reference<lang::XComponent> xComponent (xController, UNO_QUERY);
518*cdf0e10cSrcweir         if (xComponent.is())
519*cdf0e10cSrcweir         {
520*cdf0e10cSrcweir             xComponent->removeEventListener (
521*cdf0e10cSrcweir                 Reference<lang::XEventListener>(static_cast<XWeak*>(this), UNO_QUERY));
522*cdf0e10cSrcweir         }
523*cdf0e10cSrcweir     }
524*cdf0e10cSrcweir }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir //=====  lang::XEventListener  ================================================
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir void SAL_CALL EventMultiplexer::Implementation::disposing (
532*cdf0e10cSrcweir     const lang::EventObject& rEventObject)
533*cdf0e10cSrcweir     throw (RuntimeException)
534*cdf0e10cSrcweir {
535*cdf0e10cSrcweir     if (mbListeningToController)
536*cdf0e10cSrcweir     {
537*cdf0e10cSrcweir         Reference<frame::XController> xController (mxControllerWeak);
538*cdf0e10cSrcweir         if (rEventObject.Source == xController)
539*cdf0e10cSrcweir         {
540*cdf0e10cSrcweir             mbListeningToController = false;
541*cdf0e10cSrcweir         }
542*cdf0e10cSrcweir     }
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir     Reference<XConfigurationController> xConfigurationController (
545*cdf0e10cSrcweir         mxConfigurationControllerWeak);
546*cdf0e10cSrcweir     if (xConfigurationController.is()
547*cdf0e10cSrcweir         && rEventObject.Source == xConfigurationController)
548*cdf0e10cSrcweir     {
549*cdf0e10cSrcweir         mxConfigurationControllerWeak = Reference<XConfigurationController>();
550*cdf0e10cSrcweir     }
551*cdf0e10cSrcweir }
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir //=====  beans::XPropertySetListener  =========================================
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir void SAL_CALL EventMultiplexer::Implementation::propertyChange (
559*cdf0e10cSrcweir     const beans::PropertyChangeEvent& rEvent)
560*cdf0e10cSrcweir     throw (RuntimeException)
561*cdf0e10cSrcweir {
562*cdf0e10cSrcweir     ThrowIfDisposed();
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir     if (rEvent.PropertyName.equals(msCurrentPagePropertyName))
565*cdf0e10cSrcweir     {
566*cdf0e10cSrcweir         CallListeners(EventMultiplexerEvent::EID_CURRENT_PAGE);
567*cdf0e10cSrcweir     }
568*cdf0e10cSrcweir     else if (rEvent.PropertyName.equals(msEditModePropertyName))
569*cdf0e10cSrcweir     {
570*cdf0e10cSrcweir         bool bIsMasterPageMode (false);
571*cdf0e10cSrcweir         rEvent.NewValue >>= bIsMasterPageMode;
572*cdf0e10cSrcweir         if (bIsMasterPageMode)
573*cdf0e10cSrcweir             CallListeners(EventMultiplexerEvent::EID_EDIT_MODE_MASTER);
574*cdf0e10cSrcweir         else
575*cdf0e10cSrcweir             CallListeners(EventMultiplexerEvent::EID_EDIT_MODE_NORMAL);
576*cdf0e10cSrcweir     }
577*cdf0e10cSrcweir }
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir //===== frame::XFrameActionListener  ==========================================
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir void SAL_CALL EventMultiplexer::Implementation::frameAction (
585*cdf0e10cSrcweir     const frame::FrameActionEvent& rEvent)
586*cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
587*cdf0e10cSrcweir {
588*cdf0e10cSrcweir     Reference<frame::XFrame> xFrame (mxFrameWeak);
589*cdf0e10cSrcweir     if (rEvent.Frame == xFrame)
590*cdf0e10cSrcweir         switch (rEvent.Action)
591*cdf0e10cSrcweir         {
592*cdf0e10cSrcweir             case frame::FrameAction_COMPONENT_DETACHING:
593*cdf0e10cSrcweir                 DisconnectFromController();
594*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_CONTROLLER_DETACHED);
595*cdf0e10cSrcweir                 break;
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir             case frame::FrameAction_COMPONENT_REATTACHED:
598*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_CONTROLLER_DETACHED);
599*cdf0e10cSrcweir                 DisconnectFromController();
600*cdf0e10cSrcweir                 ConnectToController();
601*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_CONTROLLER_ATTACHED);
602*cdf0e10cSrcweir                 break;
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir             case frame::FrameAction_COMPONENT_ATTACHED:
605*cdf0e10cSrcweir                 ConnectToController();
606*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_CONTROLLER_ATTACHED);
607*cdf0e10cSrcweir                 break;
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir             default:
610*cdf0e10cSrcweir                 break;
611*cdf0e10cSrcweir         }
612*cdf0e10cSrcweir }
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir //===== view::XSelectionChangeListener ========================================
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir void SAL_CALL EventMultiplexer::Implementation::selectionChanged (
620*cdf0e10cSrcweir     const lang::EventObject& )
621*cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
622*cdf0e10cSrcweir {
623*cdf0e10cSrcweir     CallListeners (EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION);
624*cdf0e10cSrcweir }
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir //===== drawing::framework::XConfigurationChangeListener ==================
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir void SAL_CALL EventMultiplexer::Implementation::notifyConfigurationChange (
632*cdf0e10cSrcweir     const ConfigurationChangeEvent& rEvent)
633*cdf0e10cSrcweir     throw (RuntimeException)
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir     sal_Int32 nEventType = 0;
636*cdf0e10cSrcweir     rEvent.UserData >>= nEventType;
637*cdf0e10cSrcweir     switch (nEventType)
638*cdf0e10cSrcweir     {
639*cdf0e10cSrcweir         case ResourceActivationEvent:
640*cdf0e10cSrcweir             if (rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix))
641*cdf0e10cSrcweir             {
642*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_VIEW_ADDED);
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir                 if (rEvent.ResourceId->isBoundToURL(
645*cdf0e10cSrcweir                     FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
646*cdf0e10cSrcweir                 {
647*cdf0e10cSrcweir                     CallListeners (EventMultiplexerEvent::EID_MAIN_VIEW_ADDED);
648*cdf0e10cSrcweir                 }
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir                 // Add selection change listener at slide sorter.
651*cdf0e10cSrcweir                 if (rEvent.ResourceId->getResourceURL().equals(FrameworkHelper::msSlideSorterURL))
652*cdf0e10cSrcweir                 {
653*cdf0e10cSrcweir                     slidesorter::SlideSorterViewShell* pViewShell
654*cdf0e10cSrcweir                         = dynamic_cast<slidesorter::SlideSorterViewShell*>(
655*cdf0e10cSrcweir                             FrameworkHelper::GetViewShell(
656*cdf0e10cSrcweir                                 Reference<XView>(rEvent.ResourceObject,UNO_QUERY)).get());
657*cdf0e10cSrcweir                     if (pViewShell != NULL)
658*cdf0e10cSrcweir                         pViewShell->AddSelectionChangeListener (
659*cdf0e10cSrcweir                             LINK(this,
660*cdf0e10cSrcweir                                 EventMultiplexer::Implementation,
661*cdf0e10cSrcweir                                 SlideSorterSelectionChangeListener));
662*cdf0e10cSrcweir                 }
663*cdf0e10cSrcweir             }
664*cdf0e10cSrcweir             break;
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir         case ResourceDeactivationEvent:
667*cdf0e10cSrcweir             if (rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix))
668*cdf0e10cSrcweir             {
669*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_VIEW_REMOVED);
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir                 if (rEvent.ResourceId->isBoundToURL(
672*cdf0e10cSrcweir                     FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
673*cdf0e10cSrcweir                 {
674*cdf0e10cSrcweir                     CallListeners (EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED);
675*cdf0e10cSrcweir                 }
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir                 // Remove selection change listener from slide sorter.  Add
678*cdf0e10cSrcweir                 // selection change listener at slide sorter.
679*cdf0e10cSrcweir                 if (rEvent.ResourceId->getResourceURL().equals(FrameworkHelper::msSlideSorterURL))
680*cdf0e10cSrcweir                 {
681*cdf0e10cSrcweir                     slidesorter::SlideSorterViewShell* pViewShell
682*cdf0e10cSrcweir                         = dynamic_cast<slidesorter::SlideSorterViewShell*>(
683*cdf0e10cSrcweir                             FrameworkHelper::GetViewShell(
684*cdf0e10cSrcweir                                 Reference<XView>(rEvent.ResourceObject, UNO_QUERY)).get());
685*cdf0e10cSrcweir                     if (pViewShell != NULL)
686*cdf0e10cSrcweir                         pViewShell->RemoveSelectionChangeListener (
687*cdf0e10cSrcweir                             LINK(this,
688*cdf0e10cSrcweir                                 EventMultiplexer::Implementation,
689*cdf0e10cSrcweir                                 SlideSorterSelectionChangeListener));
690*cdf0e10cSrcweir                 }
691*cdf0e10cSrcweir             }
692*cdf0e10cSrcweir             break;
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir         case ConfigurationUpdateEvent:
695*cdf0e10cSrcweir             CallListeners (EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
696*cdf0e10cSrcweir             break;
697*cdf0e10cSrcweir     }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir void SAL_CALL EventMultiplexer::Implementation::disposing (void)
705*cdf0e10cSrcweir {
706*cdf0e10cSrcweir     CallListeners (EventMultiplexerEvent::EID_DISPOSING);
707*cdf0e10cSrcweir     ReleaseListeners();
708*cdf0e10cSrcweir }
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir void EventMultiplexer::Implementation::ThrowIfDisposed (void)
714*cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
717*cdf0e10cSrcweir 	{
718*cdf0e10cSrcweir         throw lang::DisposedException (
719*cdf0e10cSrcweir             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
720*cdf0e10cSrcweir                 "SlideSorterController object has already been disposed")),
721*cdf0e10cSrcweir             static_cast<uno::XWeak*>(this));
722*cdf0e10cSrcweir     }
723*cdf0e10cSrcweir }
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir 
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir void EventMultiplexer::Implementation::Notify (
729*cdf0e10cSrcweir     SfxBroadcaster&,
730*cdf0e10cSrcweir     const SfxHint& rHint)
731*cdf0e10cSrcweir {
732*cdf0e10cSrcweir     if (rHint.ISA(SdrHint))
733*cdf0e10cSrcweir     {
734*cdf0e10cSrcweir         SdrHint& rSdrHint (*PTR_CAST(SdrHint,&rHint));
735*cdf0e10cSrcweir         switch (rSdrHint.GetKind())
736*cdf0e10cSrcweir         {
737*cdf0e10cSrcweir             case HINT_MODELCLEARED:
738*cdf0e10cSrcweir             case HINT_PAGEORDERCHG:
739*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_PAGE_ORDER);
740*cdf0e10cSrcweir                 break;
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir             case HINT_SWITCHTOPAGE:
743*cdf0e10cSrcweir                 CallListeners (EventMultiplexerEvent::EID_CURRENT_PAGE);
744*cdf0e10cSrcweir                 break;
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir             case HINT_OBJCHG:
747*cdf0e10cSrcweir                 CallListeners(EventMultiplexerEvent::EID_SHAPE_CHANGED,
748*cdf0e10cSrcweir                     const_cast<void*>(static_cast<const void*>(rSdrHint.GetPage())));
749*cdf0e10cSrcweir                 break;
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir             case HINT_OBJINSERTED:
752*cdf0e10cSrcweir                 CallListeners(EventMultiplexerEvent::EID_SHAPE_INSERTED,
753*cdf0e10cSrcweir                     const_cast<void*>(static_cast<const void*>(rSdrHint.GetPage())));
754*cdf0e10cSrcweir                 break;
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir             case HINT_OBJREMOVED:
757*cdf0e10cSrcweir                 CallListeners(EventMultiplexerEvent::EID_SHAPE_REMOVED,
758*cdf0e10cSrcweir                     const_cast<void*>(static_cast<const void*>(rSdrHint.GetPage())));
759*cdf0e10cSrcweir                 break;
760*cdf0e10cSrcweir 			default:
761*cdf0e10cSrcweir 				break;
762*cdf0e10cSrcweir         }
763*cdf0e10cSrcweir     }
764*cdf0e10cSrcweir     else if (rHint.ISA(SfxSimpleHint))
765*cdf0e10cSrcweir     {
766*cdf0e10cSrcweir         SfxSimpleHint& rSimpleHint (*PTR_CAST(SfxSimpleHint, &rHint));
767*cdf0e10cSrcweir         if (rSimpleHint.GetId() == SFX_HINT_DYING)
768*cdf0e10cSrcweir             mpDocument = NULL;
769*cdf0e10cSrcweir     }
770*cdf0e10cSrcweir }
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir void EventMultiplexer::Implementation::CallListeners (
776*cdf0e10cSrcweir     EventMultiplexerEvent::EventId eId,
777*cdf0e10cSrcweir     void* pUserData)
778*cdf0e10cSrcweir {
779*cdf0e10cSrcweir     EventMultiplexerEvent aEvent (mrBase, eId, pUserData);
780*cdf0e10cSrcweir     CallListeners(aEvent);
781*cdf0e10cSrcweir }
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir void EventMultiplexer::Implementation::CallListeners (EventMultiplexerEvent& rEvent)
787*cdf0e10cSrcweir {
788*cdf0e10cSrcweir     ListenerList aCopyListeners( maListeners );
789*cdf0e10cSrcweir     ListenerList::iterator iListener (aCopyListeners.begin());
790*cdf0e10cSrcweir     ListenerList::const_iterator iListenerEnd (aCopyListeners.end());
791*cdf0e10cSrcweir     for (; iListener!=iListenerEnd; ++iListener)
792*cdf0e10cSrcweir     {
793*cdf0e10cSrcweir         if ((iListener->second && rEvent.meEventId) != 0)
794*cdf0e10cSrcweir             iListener->first.Call(&rEvent);
795*cdf0e10cSrcweir     }
796*cdf0e10cSrcweir }
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir IMPL_LINK(EventMultiplexer::Implementation, SlideSorterSelectionChangeListener, void*, EMPTYARG)
802*cdf0e10cSrcweir {
803*cdf0e10cSrcweir     CallListeners (EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION);
804*cdf0e10cSrcweir     return 0;
805*cdf0e10cSrcweir }
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir //===== EventMultiplexerEvent =================================================
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir EventMultiplexerEvent::EventMultiplexerEvent (
813*cdf0e10cSrcweir     const ViewShellBase& rBase,
814*cdf0e10cSrcweir     EventId eEventId,
815*cdf0e10cSrcweir     const void* pUserData)
816*cdf0e10cSrcweir     : mrBase(rBase),
817*cdf0e10cSrcweir       meEventId(eEventId),
818*cdf0e10cSrcweir       mpUserData(pUserData)
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir {
821*cdf0e10cSrcweir }
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir } } // end of namespace ::sd::tools
824