Update ooo320-m1
[ooovba.git] / slideshow / source / inc / eventmultiplexer.hxx
blob22b24c020ceb447f21eead838bdc49c90d8ebaeb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: eventmultiplexer.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef INCLUDED_SLIDESHOW_EVENTMULTIPLEXER_HXX
31 #define INCLUDED_SLIDESHOW_EVENTMULTIPLEXER_HXX
33 #include "eventhandler.hxx"
34 #include "hyperlinkhandler.hxx"
35 #include "mouseeventhandler.hxx"
36 #include "animationeventhandler.hxx"
37 #include "pauseeventhandler.hxx"
38 #include "shapelistenereventhandler.hxx"
39 #include "shapecursoreventhandler.hxx"
40 #include "userpainteventhandler.hxx"
41 #include "vieweventhandler.hxx"
42 #include "viewrepainthandler.hxx"
44 #include <boost/scoped_ptr.hpp>
45 #include <boost/noncopyable.hpp>
48 namespace slideshow {
49 namespace internal {
51 class EventQueue;
52 class UnoViewContainer;
53 class AnimationNode;
55 struct EventMultiplexerImpl;
57 /** This class multiplexes user-activated and
58 slide-show global events.
60 This class listens at the XSlideShowView and fires events
61 registered for certain user actions. Furthermore, global
62 slide show state changes (such as start or end of a slide)
63 are handled as well. Note that registered events which
64 have a non-zero timeout (i.e. events that return non-zero
65 from getActivationTime()) will not be fired immediately
66 after the user action occured, but only after the given
67 timeout. Which is actually a feature.
69 class EventMultiplexer : private ::boost::noncopyable
71 public:
72 /** Create an event multiplexer
74 @param rEventQueue
75 Reference to the main event queue. Since we hold this
76 object by plain reference, it must live longer than we
77 do. On the other hand, that queue must not fire events
78 after this object is destroyed, since we might
79 schedule events there which itself contain plain
80 references to this object. Basically, EventQueue and
81 EventMultiplexer should have the same lifetime, and since
82 this is not possible, both must be destructed in a
83 phased mode: first clear both of any remaining events,
84 then destruct them.
86 @param rViewContainer
87 Globally managed list of all registered views. Used to
88 determine event sources, and for registering view listeners
89 at.
91 EventMultiplexer( EventQueue& rEventQueue,
92 UnoViewContainer const& rViewContainer );
93 ~EventMultiplexer();
96 // Management methods
97 // =========================================================
99 /** Clear all registered handlers.
101 void clear();
104 // Automatic mode methods
105 // =========================================================
107 /** Change automatic mode.
109 @param bIsAuto
110 When true, events will be fired automatically, not
111 only triggered by UI events. When false, auto events
112 will quit.
114 void setAutomaticMode( bool bIsAuto );
116 /** Get automatic mode setting.
118 bool getAutomaticMode() const;
120 /** Set the timeout for automatic mode.
122 @param nTimeout
123 Timeout, between end of effect until start of next
124 effect.
126 void setAutomaticTimeout( double nTimeout );
128 /** Get automatic mode timeout value.
130 double getAutomaticTimeout() const;
132 // Handler registration methods
133 // =========================================================
135 /** Register an event handler that will be called when views are
136 changed.
138 For each view added, viewAdded() will be called on the
139 handler. For each view removed, viewRemoved() will be
140 called. Each modified view will cause a viewChanged() call on
141 each handler.
143 You don't need to deregister the handler, it will be
144 automatically removed, once the pointee becomes stale.
146 @param rHandler
147 Handler to call.
149 void addViewHandler( const ViewEventHandlerWeakPtr& rHandler );
150 void removeViewHandler( const ViewEventHandlerWeakPtr& rHandler );
152 /** Register an event handler that will be called when a view gets
153 clobbered.
155 Note that <em>all</em> registered handlers will be called when
156 the event. This is in contrast to the mouse events below.
158 @param rHandler
159 Handler to call when a view needs a repaint
161 void addViewRepaintHandler( const ViewRepaintHandlerSharedPtr& rHandler );
162 void removeViewRepaintHandler( const ViewRepaintHandlerSharedPtr& rHandler );
164 /** Register an event handler that will be called when
165 XShapeListeners are changed.
167 @param rHandler
168 Handler to call when a shape listener changes
170 void addShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr& rHandler );
171 void removeShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr& rHandler );
173 /** Register an event handler that will be called when
174 XShapeListeners are changed.
176 @param rHandler
177 Handler to call when a shape listener changes
179 void addShapeCursorHandler( const ShapeCursorEventHandlerSharedPtr& rHandler );
180 void removeShapeCursorHandler( const ShapeCursorEventHandlerSharedPtr& rHandler );
182 /** Register an event handler that will be called when
183 user paint parameters change.
185 @param rHandler
186 Handler to call when a shape listener changes
188 void addUserPaintHandler( const UserPaintEventHandlerSharedPtr& rHandler );
189 void removeUserPaintHandler( const UserPaintEventHandlerSharedPtr& rHandler );
191 /** Register an event handler that will be called when the
192 user requests the next effect.
194 For every nextEffect event, only one of the handlers
195 registered here is called. The handlers are considered
196 with decreasing priority, i.e. the handler with the
197 currently highest priority will be called.
199 @param rHandler
200 Handler to call when the next effect should start
202 @param nPriority
203 Priority with which the handlers are called. The
204 higher the priority, the earlier this handler will be
205 tried.
207 void addNextEffectHandler( const EventHandlerSharedPtr& rHandler,
208 double nPriority );
209 void removeNextEffectHandler( const EventHandlerSharedPtr& rHandler );
211 /** Register an event handler that will be called when the
212 slide is just shown.
214 Note that <em>all</em> registered handlers will be called
215 when the slide start occurs. This is in contrast to
216 the mouse events below.
218 @param rHandler
219 Handler to call when the next slide starts
221 void addSlideStartHandler( const EventHandlerSharedPtr& rHandler );
222 void removeSlideStartHandler( const EventHandlerSharedPtr& rHandler );
224 /** Register an event handler that will be called when the
225 slide is about to vanish.
227 Note that <em>all</em> registered handlers will be
228 called when the slide end occurs. This is in contrast
229 to the mouse events below.
231 @param rHandler
232 Handler to call when the current slide ends
234 void addSlideEndHandler( const EventHandlerSharedPtr& rHandler );
235 void removeSlideEndHandler( const EventHandlerSharedPtr& rHandler );
237 /** Register an event handler that will be called when an
238 XAnimationNode starts its active duration.
240 Note that <em>all</em> registered handlers will be called
241 when the animation start occurs. This is in contrast to
242 the mouse events below.
244 @param rHandler
245 Handler to call when the animation start
247 void addAnimationStartHandler(
248 const AnimationEventHandlerSharedPtr& rHandler );
249 void removeAnimationStartHandler(
250 const AnimationEventHandlerSharedPtr& rHandler );
252 /** Register an event handler that will be called when an
253 XAnimationNode ends its active duration.
255 Note that <em>all</em> registered handlers will be called
256 when the animation end occurs. This is in contrast to
257 the mouse events below.
259 @param rHandler
260 Handler to call when the animation ends
262 void addAnimationEndHandler(
263 const AnimationEventHandlerSharedPtr& rHandler );
264 void removeAnimationEndHandler(
265 const AnimationEventHandlerSharedPtr& rHandler );
267 /** Register an event handler that will be called when the
268 main animation sequence of a slide ends its active
269 duration.
271 Note that <em>all</em> registered handlers will be
272 called when the animation end occurs. This is in
273 contrast to the mouse events below.
275 @param rHandler
276 Handler to call when the animation ends
278 void addSlideAnimationsEndHandler(
279 const EventHandlerSharedPtr& rHandler );
280 void removeSlideAnimationsEndHandler(
281 const EventHandlerSharedPtr& rHandler );
283 /** Register an event handler that will be called when an
284 XAudio node's sound stops playing.
286 Note that <em>all</em> registered handlers will be
287 called when the audio stops. This is in contrast to
288 the mouse events below.
290 @param rHandler
291 Handler to call when the audio stops
293 void addAudioStoppedHandler(
294 const AnimationEventHandlerSharedPtr& rHandler );
295 void removeAudioStoppedHandler(
296 const AnimationEventHandlerSharedPtr& rHandler );
298 /** Register an event handler that will be called when an
299 XCommand node's with the command STOPAUDIO is activated.
301 Note that <em>all</em> registered handlers will be
302 called when the audio stops. This is in contrast to
303 the mouse events below.
305 @param rHandler
306 Handler to call when command is activated
308 void addCommandStopAudioHandler(
309 const AnimationEventHandlerSharedPtr& rHandler );
310 void removeCommandStopAudioHandler(
311 const AnimationEventHandlerSharedPtr& rHandler );
313 /** Register a handler that is called when the show enters
314 or exits pause mode.
316 void addPauseHandler( const PauseEventHandlerSharedPtr& rHandler );
317 void removePauseHandler( const PauseEventHandlerSharedPtr& rHandler );
319 /** Register a mouse handler that is called on mouse click
321 For every mouse click, only one of the handlers
322 registered here is called. The handlers are considered
323 with decreasing priority, i.e. the handler with the
324 currently highest priority will be called.
326 Since the handlers can reject down and up events
327 individually, handlers should expect to be called with
328 non-matching down and up-press counts. If your handler
329 cannot cope with that, it must have the highest
330 priority of all added handlers.
332 void addClickHandler( const MouseEventHandlerSharedPtr& rHandler,
333 double nPriority );
334 void removeClickHandler( const MouseEventHandlerSharedPtr& rHandler );
336 /** Register a mouse handler that is called on a double
337 mouse click
339 For every mouse double click, only one of the handlers
340 registered here is called. The handlers are considered
341 with decreasing priority, i.e. the handler with the
342 currently highest priority will be called.
344 Since the handlers can reject down and up events
345 individually, handlers should expect to be called with
346 non-matching down and up-press counts. If your handler
347 cannot cope with that, it must have the highest
348 priority of all added handlers.
350 void addDoubleClickHandler( const MouseEventHandlerSharedPtr& rHandler,
351 double nPriority );
352 void removeDoubleClickHandler( const MouseEventHandlerSharedPtr& rHandler );
354 /** Register a mouse handler that is called for mouse moves.
356 For every mouse move, only one of the handlers
357 registered here is called. The handlers are considered
358 with decreasing priority, i.e. the handler with the
359 currently highest priority will be called.
361 void addMouseMoveHandler( const MouseEventHandlerSharedPtr& rHandler,
362 double nPriority );
363 void removeMouseMoveHandler( const MouseEventHandlerSharedPtr& rHandler );
366 /** Registers a hyperlink click handler.
368 For every hyperlink click, only one of the handlers registered
369 here is called. The handlers are considered with decreasing
370 priority, i.e. the handler with the currently highest priority
371 will be called.
373 @param rHandler
374 @param nPriority
376 void addHyperlinkHandler( const HyperlinkHandlerSharedPtr& rHandler,
377 double nPriority );
378 void removeHyperlinkHandler( const HyperlinkHandlerSharedPtr& rHandler );
381 // External event notifications
382 // =========================================================
384 /** View added.
386 This method adds another view, which the show is
387 displayed on. On every added view, the EventMultiplexer
388 registers mouse and motion event listeners.
390 bool notifyViewAdded( const UnoViewSharedPtr& rView );
392 /** View removed
394 This method removes a view. Registered mouse and
395 motion event listeners are revoked.
397 bool notifyViewRemoved( const UnoViewSharedPtr& rView );
399 /** View changed
401 This method announces a changed view to all view
402 listeners. View changes include size and transformation.
404 @param rView
405 View that has changed
407 bool notifyViewChanged( const UnoViewSharedPtr& rView );
409 /** View changed
411 This method announces a changed view to all view
412 listeners. View changes include size and transformation.
414 @param xView
415 View that has changed
417 bool notifyViewChanged( const ::com::sun::star::uno::Reference<
418 ::com::sun::star::presentation::XSlideShowView>& xView );
420 /** All Views changed
422 This method announces to all view listeners that
423 <em>every</em> known view has changed. View changes include
424 size and transformation.
426 bool notifyViewsChanged();
428 /** View clobbered
430 This method announces that the given view has been clobbered
431 by something external to the slideshow, and needs an update.
433 @param xView
434 View that has been clobbered
436 bool notifyViewClobbered( const ::com::sun::star::uno::Reference<
437 ::com::sun::star::presentation::XSlideShowView>& xView );
439 /** New shape event listener added
441 This method announces that the given listener was added for
442 the specified shape.
444 @return true, if at least one handler successfully processed
445 the notification.
447 bool notifyShapeListenerAdded( const ::com::sun::star::uno::Reference<
448 ::com::sun::star::presentation::XShapeEventListener>& xListener,
449 const ::com::sun::star::uno::Reference<
450 ::com::sun::star::drawing::XShape>& xShape );
452 /** A shape event listener was removed
454 This method announces that the given listener was removed for
455 the specified shape.
457 @return true, if at least one handler successfully processed
458 the notification.
460 bool notifyShapeListenerRemoved( const ::com::sun::star::uno::Reference<
461 ::com::sun::star::presentation::XShapeEventListener>& xListener,
462 const ::com::sun::star::uno::Reference<
463 ::com::sun::star::drawing::XShape>& xShape );
465 /** A new shape cursor was set
467 This method announces that the given cursor was set for the
468 specified shape.
470 @return true, if at least one handler successfully processed
471 the notification.
473 bool notifyShapeCursorChange( const ::com::sun::star::uno::Reference<
474 ::com::sun::star::drawing::XShape>& xShape,
475 sal_Int16 nPointerShape );
477 /** Notify a new user paint color
479 Sending this notification also implies that user paint is
480 enabled. User paint denotes the feature to draw colored lines
481 on top of the slide content.
483 @return true, if this event was processed by
484 anybody. If false is returned, no handler processed
485 this event (and probably, nothing will happen at all)
487 bool notifyUserPaintColor( RGBColor const& rUserColor );
489 /** Notify a new user paint width
491 Sending this notification also implies that user paint is
492 enabled. .
494 @return true, if this event was processed by
495 anybody. If false is returned, no handler processed
496 this event (and probably, nothing will happen at all)
498 bool notifyUserPaintStrokeWidth( double rUserStrokeWidth );
500 /** Notify that user paint is disabled
502 User paint denotes the feature to draw colored lines on top of
503 the slide content.
505 @return true, if this event was processed by
506 anybody. If false is returned, no handler processed
507 this event (and probably, nothing will happen at all)
509 bool notifyUserPaintDisabled();
511 /** Notify that the user requested the next effect.
513 This requests the slideshow to display the next
514 effect, or move to the next slide, if none are left.
516 @return true, if this event was processed by
517 anybody. If false is returned, no handler processed
518 this event (and probably, nothing will happen at all)
520 bool notifyNextEffect();
522 /** Notify that a new slide is about to be displayed
524 bool notifySlideTransitionStarted();
526 /** Notify that a new slide has started
528 This method is to be used from the Presentation object
529 to signal that a new slide is starting now. This will
530 invoke all registered slide start handlers.
532 @return true, if this event was processed by
533 anybody. If false is returned, no handler processed
534 this event (and probably, nothing will happen at all)
536 bool notifySlideStartEvent();
538 /** Notify that a slide has ended
540 This method is to be used from the Presentation object
541 to signal that a slide is ending now. This will invoke
542 all registered slide end handlers.
544 @return true, if this event was processed by
545 anybody. If false is returned, no handler processed
546 this event (and probably, nothing will happen at all)
548 bool notifySlideEndEvent();
550 /** Notify that the given node enters its active duration.
552 This method is to be used from the AnimationNode
553 objects to signal that the active duration
554 begins. This will invoke all registered animation
555 start handlers.
557 @param rNode
558 Node which enters active duration.
560 @return true, if this event was processed by
561 anybody. If false is returned, no handler processed
562 this event (and probably, nothing will happen at all)
564 bool notifyAnimationStart( const boost::shared_ptr<AnimationNode>& rNode );
566 /** Notify that the given node leaves its active duration.
568 This method is to be used from the AnimationNode
569 objects to signal that the active duration
570 ends now. This will invoke all registered animation
571 end handlers.
573 @param rNode
574 Node which leaves active duration.
576 @return true, if this event was processed by
577 anybody. If false is returned, no handler processed
578 this event (and probably, nothing will happen at all)
580 bool notifyAnimationEnd( const boost::shared_ptr<AnimationNode>& rNode );
582 /** Notify that the slide animations sequence leaves its
583 active duration.
585 @return true, if this event was processed by
586 anybody. If false is returned, no handler processed
587 this event (and probably, nothing will happen at all)
589 bool notifySlideAnimationsEnd();
591 /** Notify that for the given node, audio output has stopped.
593 This method is to be used from the AnimationNode
594 objects to signal that audio playback has just
595 stopped. This will invoke all registered audio
596 stopped andlers.
598 @param rNode
599 Node for which audio has stopped.
601 @return true, if this event was processed by
602 anybody. If false is returned, no handler processed
603 this event (and probably, nothing will happen at all)
605 bool notifyAudioStopped( const boost::shared_ptr<AnimationNode>& rNode );
607 /** Notify that the show has entered or exited pause mode
609 This method is to be used from the Presentation object
610 to signal that a slide is entering (bPauseShow=true)
611 or exiting (bPauseShow=false) pause mode. This will
612 invoke all registered slide end handlers.
614 @return true, if this event was processed by
615 anybody. If false is returned, no handler processed
616 this event (and probably, nothing will happen at all)
618 bool notifyPauseMode( bool bPauseShow );
620 /** Notify that all audio has to be stoped.
622 This method is used by XCommand nodes and all sound
623 playing nodes should listen for this command and
624 stop theire sounds when its fired.
626 @return true, if this event was processed by
627 anybody. If false is returned, no handler processed
628 this event (and probably, nothing will happen at all)
630 bool notifyCommandStopAudio( const boost::shared_ptr<AnimationNode>& rNode );
632 /** Botifies that a hyperlink has been clicked.
634 @return true, if this event was processed by
635 anybody. If false is returned, no handler processed
636 this event (and probably, nothing will happen at all)
638 bool notifyHyperlinkClicked( ::rtl::OUString const& hyperLink );
640 private:
641 boost::scoped_ptr<EventMultiplexerImpl> mpImpl;
644 } // namespace internal
645 } // namespace Presentation
647 #endif /* INCLUDED_SLIDESHOW_EVENTMULTIPLEXER_HXX */