1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SLIDESHOW_EVENTMULTIPLEXER_HXX
20 #define INCLUDED_SLIDESHOW_EVENTMULTIPLEXER_HXX
22 #include "eventhandler.hxx"
23 #include "hyperlinkhandler.hxx"
24 #include "mouseeventhandler.hxx"
25 #include "animationeventhandler.hxx"
26 #include "pauseeventhandler.hxx"
27 #include "shapelistenereventhandler.hxx"
28 #include "shapecursoreventhandler.hxx"
29 #include "userpainteventhandler.hxx"
30 #include "vieweventhandler.hxx"
31 #include "viewrepainthandler.hxx"
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/noncopyable.hpp>
41 class UnoViewContainer
;
44 struct EventMultiplexerImpl
;
46 /** This class multiplexes user-activated and
47 slide-show global events.
49 This class listens at the XSlideShowView and fires events
50 registered for certain user actions. Furthermore, global
51 slide show state changes (such as start or end of a slide)
52 are handled as well. Note that registered events which
53 have a non-zero timeout (i.e. events that return non-zero
54 from getActivationTime()) will not be fired immediately
55 after the user action occurred, but only after the given
56 timeout. Which is actually a feature.
58 class EventMultiplexer
: private ::boost::noncopyable
61 /** Create an event multiplexer
64 Reference to the main event queue. Since we hold this
65 object by plain reference, it must live longer than we
66 do. On the other hand, that queue must not fire events
67 after this object is destroyed, since we might
68 schedule events there which itself contain plain
69 references to this object. Basically, EventQueue and
70 EventMultiplexer should have the same lifetime, and since
71 this is not possible, both must be destructed in a
72 phased mode: first clear both of any remaining events,
76 Globally managed list of all registered views. Used to
77 determine event sources, and for registering view listeners
80 EventMultiplexer( EventQueue
& rEventQueue
,
81 UnoViewContainer
const& rViewContainer
);
86 // =========================================================
88 /** Clear all registered handlers.
93 // Automatic mode methods
94 // =========================================================
96 /** Change automatic mode.
99 When true, events will be fired automatically, not
100 only triggered by UI events. When false, auto events
103 void setAutomaticMode( bool bIsAuto
);
105 /** Get automatic mode setting.
107 bool getAutomaticMode() const;
109 /** Set the timeout for automatic mode.
112 Timeout, between end of effect until start of next
115 void setAutomaticTimeout( double nTimeout
);
117 /** Get automatic mode timeout value.
119 double getAutomaticTimeout() const;
121 // Handler registration methods
122 // =========================================================
124 /** Register an event handler that will be called when views are
127 For each view added, viewAdded() will be called on the
128 handler. For each view removed, viewRemoved() will be
129 called. Each modified view will cause a viewChanged() call on
132 You don't need to deregister the handler, it will be
133 automatically removed, once the pointee becomes stale.
138 void addViewHandler( const ViewEventHandlerWeakPtr
& rHandler
);
139 void removeViewHandler( const ViewEventHandlerWeakPtr
& rHandler
);
141 /** Register an event handler that will be called when a view gets
144 Note that <em>all</em> registered handlers will be called when
145 the event. This is in contrast to the mouse events below.
148 Handler to call when a view needs a repaint
150 void addViewRepaintHandler( const ViewRepaintHandlerSharedPtr
& rHandler
);
151 void removeViewRepaintHandler( const ViewRepaintHandlerSharedPtr
& rHandler
);
153 /** Register an event handler that will be called when
154 XShapeListeners are changed.
157 Handler to call when a shape listener changes
159 void addShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr
& rHandler
);
160 void removeShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr
& rHandler
);
162 /** Register an event handler that will be called when
163 user paint parameters change.
166 Handler to call when a shape listener changes
168 void addUserPaintHandler( const UserPaintEventHandlerSharedPtr
& rHandler
);
170 /** Register an event handler that will be called when the
171 user requests the next effect.
173 For every nextEffect event, only one of the handlers
174 registered here is called. The handlers are considered
175 with decreasing priority, i.e. the handler with the
176 currently highest priority will be called.
179 Handler to call when the next effect should start
182 Priority with which the handlers are called. The
183 higher the priority, the earlier this handler will be
186 void addNextEffectHandler( const EventHandlerSharedPtr
& rHandler
,
188 void removeNextEffectHandler( const EventHandlerSharedPtr
& rHandler
);
190 /** Register an event handler that will be called when the
193 Note that <em>all</em> registered handlers will be called
194 when the slide start occurs. This is in contrast to
195 the mouse events below.
198 Handler to call when the next slide starts
200 void addSlideStartHandler( const EventHandlerSharedPtr
& rHandler
);
201 void removeSlideStartHandler( const EventHandlerSharedPtr
& rHandler
);
203 /** Register an event handler that will be called when the
204 slide is about to vanish.
206 Note that <em>all</em> registered handlers will be
207 called when the slide end occurs. This is in contrast
208 to the mouse events below.
211 Handler to call when the current slide ends
213 void addSlideEndHandler( const EventHandlerSharedPtr
& rHandler
);
214 void removeSlideEndHandler( const EventHandlerSharedPtr
& rHandler
);
216 /** Register an event handler that will be called when an
217 XAnimationNode starts its active duration.
219 Note that <em>all</em> registered handlers will be called
220 when the animation start occurs. This is in contrast to
221 the mouse events below.
224 Handler to call when the animation start
226 void addAnimationStartHandler(
227 const AnimationEventHandlerSharedPtr
& rHandler
);
228 void removeAnimationStartHandler(
229 const AnimationEventHandlerSharedPtr
& rHandler
);
231 /** Register an event handler that will be called when an
232 XAnimationNode ends its active duration.
234 Note that <em>all</em> registered handlers will be called
235 when the animation end occurs. This is in contrast to
236 the mouse events below.
239 Handler to call when the animation ends
241 void addAnimationEndHandler(
242 const AnimationEventHandlerSharedPtr
& rHandler
);
243 void removeAnimationEndHandler(
244 const AnimationEventHandlerSharedPtr
& rHandler
);
246 /** Register an event handler that will be called when the
247 main animation sequence of a slide ends its active
250 Note that <em>all</em> registered handlers will be
251 called when the animation end occurs. This is in
252 contrast to the mouse events below.
255 Handler to call when the animation ends
257 void addSlideAnimationsEndHandler(
258 const EventHandlerSharedPtr
& rHandler
);
259 void removeSlideAnimationsEndHandler(
260 const EventHandlerSharedPtr
& rHandler
);
262 /** Register an event handler that will be called when an
263 XAudio node's sound stops playing.
265 Note that <em>all</em> registered handlers will be
266 called when the audio stops. This is in contrast to
267 the mouse events below.
270 Handler to call when the audio stops
272 void addAudioStoppedHandler(
273 const AnimationEventHandlerSharedPtr
& rHandler
);
274 void removeAudioStoppedHandler(
275 const AnimationEventHandlerSharedPtr
& rHandler
);
277 /** Register an event handler that will be called when an
278 XCommand node's with the command STOPAUDIO is activated.
280 Note that <em>all</em> registered handlers will be
281 called when the audio stops. This is in contrast to
282 the mouse events below.
285 Handler to call when command is activated
287 void addCommandStopAudioHandler(
288 const AnimationEventHandlerSharedPtr
& rHandler
);
289 void removeCommandStopAudioHandler(
290 const AnimationEventHandlerSharedPtr
& rHandler
);
292 /** Register a handler that is called when the show enters
295 void addPauseHandler( const PauseEventHandlerSharedPtr
& rHandler
);
296 void removePauseHandler( const PauseEventHandlerSharedPtr
& rHandler
);
298 /** Register a mouse handler that is called on mouse click
300 For every mouse click, only one of the handlers
301 registered here is called. The handlers are considered
302 with decreasing priority, i.e. the handler with the
303 currently highest priority will be called.
305 Since the handlers can reject down and up events
306 individually, handlers should expect to be called with
307 non-matching down and up-press counts. If your handler
308 cannot cope with that, it must have the highest
309 priority of all added handlers.
311 void addClickHandler( const MouseEventHandlerSharedPtr
& rHandler
,
313 void removeClickHandler( const MouseEventHandlerSharedPtr
& rHandler
);
315 /** Register a mouse handler that is called on a double
318 For every mouse double click, only one of the handlers
319 registered here is called. The handlers are considered
320 with decreasing priority, i.e. the handler with the
321 currently highest priority will be called.
323 Since the handlers can reject down and up events
324 individually, handlers should expect to be called with
325 non-matching down and up-press counts. If your handler
326 cannot cope with that, it must have the highest
327 priority of all added handlers.
329 void addDoubleClickHandler( const MouseEventHandlerSharedPtr
& rHandler
,
331 void removeDoubleClickHandler( const MouseEventHandlerSharedPtr
& rHandler
);
333 /** Register a mouse handler that is called for mouse moves.
335 For every mouse move, only one of the handlers
336 registered here is called. The handlers are considered
337 with decreasing priority, i.e. the handler with the
338 currently highest priority will be called.
340 void addMouseMoveHandler( const MouseEventHandlerSharedPtr
& rHandler
,
342 void removeMouseMoveHandler( const MouseEventHandlerSharedPtr
& rHandler
);
345 /** Registers a hyperlink click handler.
347 For every hyperlink click, only one of the handlers registered
348 here is called. The handlers are considered with decreasing
349 priority, i.e. the handler with the currently highest priority
355 void addHyperlinkHandler( const HyperlinkHandlerSharedPtr
& rHandler
,
357 void removeHyperlinkHandler( const HyperlinkHandlerSharedPtr
& rHandler
);
360 // External event notifications
361 // =========================================================
365 This method adds another view, which the show is
366 displayed on. On every added view, the EventMultiplexer
367 registers mouse and motion event listeners.
369 bool notifyViewAdded( const UnoViewSharedPtr
& rView
);
373 This method removes a view. Registered mouse and
374 motion event listeners are revoked.
376 bool notifyViewRemoved( const UnoViewSharedPtr
& rView
);
380 This method announces a changed view to all view
381 listeners. View changes include size and transformation.
384 View that has changed
386 bool notifyViewChanged( const UnoViewSharedPtr
& rView
);
390 This method announces a changed view to all view
391 listeners. View changes include size and transformation.
394 View that has changed
396 bool notifyViewChanged( const ::com::sun::star::uno::Reference
<
397 ::com::sun::star::presentation::XSlideShowView
>& xView
);
399 /** All Views changed
401 This method announces to all view listeners that
402 <em>every</em> known view has changed. View changes include
403 size and transformation.
405 bool notifyViewsChanged();
409 This method announces that the given view has been clobbered
410 by something external to the slideshow, and needs an update.
413 View that has been clobbered
415 bool notifyViewClobbered( const ::com::sun::star::uno::Reference
<
416 ::com::sun::star::presentation::XSlideShowView
>& xView
);
418 /** New shape event listener added
420 This method announces that the given listener was added for
423 @return true, if at least one handler successfully processed
426 bool notifyShapeListenerAdded( const ::com::sun::star::uno::Reference
<
427 ::com::sun::star::presentation::XShapeEventListener
>& xListener
,
428 const ::com::sun::star::uno::Reference
<
429 ::com::sun::star::drawing::XShape
>& xShape
);
431 /** A shape event listener was removed
433 This method announces that the given listener was removed for
436 @return true, if at least one handler successfully processed
439 bool notifyShapeListenerRemoved( const ::com::sun::star::uno::Reference
<
440 ::com::sun::star::presentation::XShapeEventListener
>& xListener
,
441 const ::com::sun::star::uno::Reference
<
442 ::com::sun::star::drawing::XShape
>& xShape
);
444 /** A new shape cursor was set
446 This method announces that the given cursor was set for the
449 @return true, if at least one handler successfully processed
452 bool notifyShapeCursorChange( const ::com::sun::star::uno::Reference
<
453 ::com::sun::star::drawing::XShape
>& xShape
,
454 sal_Int16 nPointerShape
);
456 /** Notify a new user paint color
458 Sending this notification also implies that user paint is
459 enabled. User paint denotes the feature to draw colored lines
460 on top of the slide content.
462 @return true, if this event was processed by
463 anybody. If false is returned, no handler processed
464 this event (and probably, nothing will happen at all)
466 bool notifyUserPaintColor( RGBColor
const& rUserColor
);
468 /** Notify a new user paint width
470 Sending this notification also implies that user paint is
473 @return true, if this event was processed by
474 anybody. If false is returned, no handler processed
475 this event (and probably, nothing will happen at all)
477 bool notifyUserPaintStrokeWidth( double rUserStrokeWidth
);
480 /** Notify a new user paint erase all ink mode
482 Sending this notification also implies that user paint is
483 enabled. User paint denotes the feature to draw colored lines
484 on top of the slide content.
486 @return true, if this event was processed by
487 anybody. If false is returned, no handler processed
488 this event (and probably, nothing will happen at all)
490 bool notifyEraseAllInk( bool const& rEraseAllInk
);
491 bool notifySwitchPenMode();
492 bool notifySwitchEraserMode();
493 bool notifyEraseInkWidth( sal_Int32 rEraseInkSize
);
495 /** Notify that user paint is disabled
497 User paint denotes the feature to draw colored lines on top of
500 @return true, if this event was processed by
501 anybody. If false is returned, no handler processed
502 this event (and probably, nothing will happen at all)
504 bool notifyUserPaintDisabled();
506 /** Notify that the user requested the next effect.
508 This requests the slideshow to display the next
509 effect, or move to the next slide, if none are left.
511 @return true, if this event was processed by
512 anybody. If false is returned, no handler processed
513 this event (and probably, nothing will happen at all)
515 bool notifyNextEffect();
517 /** Notify that a new slide is about to be displayed
519 bool notifySlideTransitionStarted();
521 /** Notify that a new slide has started
523 This method is to be used from the Presentation object
524 to signal that a new slide is starting now. This will
525 invoke all registered slide start handlers.
527 @return true, if this event was processed by
528 anybody. If false is returned, no handler processed
529 this event (and probably, nothing will happen at all)
531 bool notifySlideStartEvent();
533 /** Notify that a slide has ended
535 This method is to be used from the Presentation object
536 to signal that a slide is ending now. This will invoke
537 all registered slide end handlers.
539 @return true, if this event was processed by
540 anybody. If false is returned, no handler processed
541 this event (and probably, nothing will happen at all)
543 bool notifySlideEndEvent();
545 /** Notify that the given node enters its active duration.
547 This method is to be used from the AnimationNode
548 objects to signal that the active duration
549 begins. This will invoke all registered animation
553 Node which enters active duration.
555 @return true, if this event was processed by
556 anybody. If false is returned, no handler processed
557 this event (and probably, nothing will happen at all)
559 bool notifyAnimationStart( const boost::shared_ptr
<AnimationNode
>& rNode
);
561 /** Notify that the given node leaves its active duration.
563 This method is to be used from the AnimationNode
564 objects to signal that the active duration
565 ends now. This will invoke all registered animation
569 Node which leaves active duration.
571 @return true, if this event was processed by
572 anybody. If false is returned, no handler processed
573 this event (and probably, nothing will happen at all)
575 bool notifyAnimationEnd( const boost::shared_ptr
<AnimationNode
>& rNode
);
577 /** Notify that the slide animations sequence leaves its
580 @return true, if this event was processed by
581 anybody. If false is returned, no handler processed
582 this event (and probably, nothing will happen at all)
584 bool notifySlideAnimationsEnd();
586 /** Notify that for the given node, audio output has stopped.
588 This method is to be used from the AnimationNode
589 objects to signal that audio playback has just
590 stopped. This will invoke all registered audio
594 Node for which audio has stopped.
596 @return true, if this event was processed by
597 anybody. If false is returned, no handler processed
598 this event (and probably, nothing will happen at all)
600 bool notifyAudioStopped( const boost::shared_ptr
<AnimationNode
>& rNode
);
602 /** Notify that the show has entered or exited pause mode
604 This method is to be used from the Presentation object
605 to signal that a slide is entering (bPauseShow=true)
606 or exiting (bPauseShow=false) pause mode. This will
607 invoke all registered slide end handlers.
609 @return true, if this event was processed by
610 anybody. If false is returned, no handler processed
611 this event (and probably, nothing will happen at all)
613 bool notifyPauseMode( bool bPauseShow
);
615 /** Notify that all audio has to be stoped.
617 This method is used by XCommand nodes and all sound
618 playing nodes should listen for this command and
619 stop theire sounds when its fired.
621 @return true, if this event was processed by
622 anybody. If false is returned, no handler processed
623 this event (and probably, nothing will happen at all)
625 bool notifyCommandStopAudio( const boost::shared_ptr
<AnimationNode
>& rNode
);
627 /** Botifies that a hyperlink has been clicked.
629 @return true, if this event was processed by
630 anybody. If false is returned, no handler processed
631 this event (and probably, nothing will happen at all)
633 bool notifyHyperlinkClicked( OUString
const& hyperLink
);
636 boost::scoped_ptr
<EventMultiplexerImpl
> mpImpl
;
639 } // namespace internal
640 } // namespace Presentation
642 #endif /* INCLUDED_SLIDESHOW_EVENTMULTIPLEXER_HXX */
644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */