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