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_SOURCE_INC_EVENTMULTIPLEXER_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_INC_EVENTMULTIPLEXER_HXX
22 #include "eventhandler.hxx"
23 #include "mouseeventhandler.hxx"
24 #include "animationeventhandler.hxx"
25 #include "pauseeventhandler.hxx"
26 #include "shapelistenereventhandler.hxx"
27 #include "vieweventhandler.hxx"
30 #include <com/sun/star/uno/Reference.hxx>
32 #include "unoview.hxx"
34 namespace basegfx
{ class B2DPoint
; }
36 namespace com::sun::star::drawing
{ class XShape
; }
38 namespace slideshow::internal
{
41 class UnoViewContainer
;
44 struct EventMultiplexerImpl
;
48 /** Interface for handling view repaint events.
50 Classes implementing this interface can be added to an
51 EventMultiplexer object, and are called from there to
52 handle view repaint events.
54 class ViewRepaintHandler
57 virtual ~ViewRepaintHandler() {}
59 /** Notify clobbered view.
61 Reasons for a viewChanged notification can be
62 different view size, transformation, or other device
63 properties (color resolution or profile, etc.)
68 virtual void viewClobbered( const UnoViewSharedPtr
& rView
) = 0;
71 typedef ::std::shared_ptr
< ViewRepaintHandler
> ViewRepaintHandlerSharedPtr
;
73 /** Interface for handling hyperlink clicks.
75 Classes implementing this interface can be added to an
76 EventMultiplexer object, and are called from there to
77 handle hyperlink events.
79 class HyperlinkHandler
85 The actual hyperlink URI
87 @return true, if this handler has successfully
88 processed the event. When this method returns false,
89 possibly other, less prioritized handlers are called,
92 virtual bool handleHyperlink( OUString
const& rLink
) = 0;
95 ~HyperlinkHandler() {}
98 typedef ::std::shared_ptr
< HyperlinkHandler
> HyperlinkHandlerSharedPtr
;
100 /** Interface for handling user paint state changes.
102 Classes implementing this interface can be added to an
103 EventMultiplexer object, and are called from there to
104 handle user paint events.
106 class UserPaintEventHandler
109 virtual ~UserPaintEventHandler() {}
110 virtual bool colorChanged( RGBColor
const& rUserColor
) = 0;
111 virtual bool widthChanged( double nUserStrokeWidth
) = 0;
112 virtual bool eraseAllInkChanged(bool bEraseAllInk
) =0;
113 virtual bool eraseInkWidthChanged(sal_Int32 rEraseInkSize
) =0;
114 virtual bool switchEraserMode() = 0;
115 virtual bool switchPenMode() = 0;
116 virtual bool disable() = 0;
119 typedef ::std::shared_ptr
< UserPaintEventHandler
> UserPaintEventHandlerSharedPtr
;
121 /** This class multiplexes user-activated and
122 slide-show global events.
124 This class listens at the XSlideShowView and fires events
125 registered for certain user actions. Furthermore, global
126 slide show state changes (such as start or end of a slide)
127 are handled as well. Note that registered events which
128 have a non-zero timeout (i.e. events that return non-zero
129 from getActivationTime()) will not be fired immediately
130 after the user action occurred, but only after the given
131 timeout. Which is actually a feature.
133 class EventMultiplexer
136 /** Create an event multiplexer
139 Reference to the main event queue. Since we hold this
140 object by plain reference, it must live longer than we
141 do. On the other hand, that queue must not fire events
142 after this object is destroyed, since we might
143 schedule events there which itself contain plain
144 references to this object. Basically, EventQueue and
145 EventMultiplexer should have the same lifetime, and since
146 this is not possible, both must be destructed in a
147 phased mode: first clear both of any remaining events,
150 @param rViewContainer
151 Globally managed list of all registered views. Used to
152 determine event sources, and for registering view listeners
155 EventMultiplexer( EventQueue
& rEventQueue
,
156 UnoViewContainer
const& rViewContainer
);
158 EventMultiplexer(const EventMultiplexer
&) = delete;
159 EventMultiplexer
& operator=(const EventMultiplexer
&) = delete;
161 // Management methods
164 /** Clear all registered handlers.
169 // Automatic mode methods
172 /** Change automatic mode.
175 When true, events will be fired automatically, not
176 only triggered by UI events. When false, auto events
179 void setAutomaticMode( bool bIsAuto
);
181 /** Get automatic mode setting.
183 bool getAutomaticMode() const;
185 /** Set the timeout for automatic mode.
188 Timeout, between end of effect until start of next
191 void setAutomaticTimeout( double nTimeout
);
193 /** Get automatic mode timeout value.
195 double getAutomaticTimeout() const;
197 // Handler registration methods
200 /** Register an event handler that will be called when views are
203 For each view added, viewAdded() will be called on the
204 handler. For each view removed, viewRemoved() will be
205 called. Each modified view will cause a viewChanged() call on
208 You don't need to deregister the handler, it will be
209 automatically removed, once the pointee becomes stale.
214 void addViewHandler( const ViewEventHandlerWeakPtr
& rHandler
);
215 void removeViewHandler( const ViewEventHandlerWeakPtr
& rHandler
);
217 /** Register an event handler that will be called when a view gets
220 Note that <em>all</em> registered handlers will be called when
221 the event. This is in contrast to the mouse events below.
224 Handler to call when a view needs a repaint
226 void addViewRepaintHandler( const ViewRepaintHandlerSharedPtr
& rHandler
);
227 void removeViewRepaintHandler( const ViewRepaintHandlerSharedPtr
& rHandler
);
229 /** Register an event handler that will be called when
230 XShapeListeners are changed.
233 Handler to call when a shape listener changes
235 void addShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr
& rHandler
);
236 void removeShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr
& rHandler
);
238 /** Register an event handler that will be called when
239 user paint parameters change.
242 Handler to call when a shape listener changes
244 void addUserPaintHandler( const UserPaintEventHandlerSharedPtr
& rHandler
);
246 /** Register an event handler that will be called when the
247 user requests the next effect.
249 For every nextEffect event, only one of the handlers
250 registered here is called. The handlers are considered
251 with decreasing priority, i.e. the handler with the
252 currently highest priority will be called.
255 Handler to call when the next effect should start
258 Priority with which the handlers are called. The
259 higher the priority, the earlier this handler will be
262 void addNextEffectHandler( const EventHandlerSharedPtr
& rHandler
,
264 void removeNextEffectHandler( const EventHandlerSharedPtr
& rHandler
);
266 /** Register an event handler that will be called when the
269 Note that <em>all</em> registered handlers will be called
270 when the slide start occurs. This is in contrast to
271 the mouse events below.
274 Handler to call when the next slide starts
276 void addSlideStartHandler( const EventHandlerSharedPtr
& rHandler
);
277 void removeSlideStartHandler( const EventHandlerSharedPtr
& rHandler
);
279 /** Register an event handler that will be called when the
280 slide is about to vanish.
282 Note that <em>all</em> registered handlers will be
283 called when the slide end occurs. This is in contrast
284 to the mouse events below.
287 Handler to call when the current slide ends
289 void addSlideEndHandler( const EventHandlerSharedPtr
& rHandler
);
290 void removeSlideEndHandler( const EventHandlerSharedPtr
& rHandler
);
292 /** Register an event handler that will be called when an
293 XAnimationNode starts its active duration.
295 Note that <em>all</em> registered handlers will be called
296 when the animation start occurs. This is in contrast to
297 the mouse events below.
300 Handler to call when the animation start
302 void addAnimationStartHandler(
303 const AnimationEventHandlerSharedPtr
& rHandler
);
304 void removeAnimationStartHandler(
305 const AnimationEventHandlerSharedPtr
& rHandler
);
307 /** Register an event handler that will be called when an
308 XAnimationNode ends its active duration.
310 Note that <em>all</em> registered handlers will be called
311 when the animation end occurs. This is in contrast to
312 the mouse events below.
315 Handler to call when the animation ends
317 void addAnimationEndHandler(
318 const AnimationEventHandlerSharedPtr
& rHandler
);
319 void removeAnimationEndHandler(
320 const AnimationEventHandlerSharedPtr
& rHandler
);
322 /** Register an event handler that will be called when the
323 main animation sequence of a slide ends its active
326 Note that <em>all</em> registered handlers will be
327 called when the animation end occurs. This is in
328 contrast to the mouse events below.
331 Handler to call when the animation ends
333 void addSlideAnimationsEndHandler(
334 const EventHandlerSharedPtr
& rHandler
);
335 void removeSlideAnimationsEndHandler(
336 const EventHandlerSharedPtr
& rHandler
);
338 /** Register an event handler that will be called when an
339 XAudio node's sound stops playing.
341 Note that <em>all</em> registered handlers will be
342 called when the audio stops. This is in contrast to
343 the mouse events below.
346 Handler to call when the audio stops
348 void addAudioStoppedHandler(
349 const AnimationEventHandlerSharedPtr
& rHandler
);
350 void removeAudioStoppedHandler(
351 const AnimationEventHandlerSharedPtr
& rHandler
);
353 /** Register an event handler that will be called when an
354 XCommand node's with the command STOPAUDIO is activated.
356 Note that <em>all</em> registered handlers will be
357 called when the audio stops. This is in contrast to
358 the mouse events below.
361 Handler to call when command is activated
363 void addCommandStopAudioHandler(
364 const AnimationEventHandlerSharedPtr
& rHandler
);
365 void removeCommandStopAudioHandler(
366 const AnimationEventHandlerSharedPtr
& rHandler
);
368 /** Register a handler that is called when the show enters
371 void addPauseHandler( const PauseEventHandlerSharedPtr
& rHandler
);
372 void removePauseHandler( const PauseEventHandlerSharedPtr
& rHandler
);
374 /** Register a mouse handler that is called on mouse click
376 For every mouse click, only one of the handlers
377 registered here is called. The handlers are considered
378 with decreasing priority, i.e. the handler with the
379 currently highest priority will be called.
381 Since the handlers can reject down and up events
382 individually, handlers should expect to be called with
383 non-matching down and up-press counts. If your handler
384 cannot cope with that, it must have the highest
385 priority of all added handlers.
387 void addClickHandler( const MouseEventHandlerSharedPtr
& rHandler
,
389 void removeClickHandler( const MouseEventHandlerSharedPtr
& rHandler
);
391 /** Register a mouse handler that is called on a double
394 For every mouse double click, only one of the handlers
395 registered here is called. The handlers are considered
396 with decreasing priority, i.e. the handler with the
397 currently highest priority will be called.
399 Since the handlers can reject down and up events
400 individually, handlers should expect to be called with
401 non-matching down and up-press counts. If your handler
402 cannot cope with that, it must have the highest
403 priority of all added handlers.
405 void addDoubleClickHandler( const MouseEventHandlerSharedPtr
& rHandler
,
407 void removeDoubleClickHandler( const MouseEventHandlerSharedPtr
& rHandler
);
409 /** Register a mouse handler that is called for mouse moves.
411 For every mouse move, only one of the handlers
412 registered here is called. The handlers are considered
413 with decreasing priority, i.e. the handler with the
414 currently highest priority will be called.
416 void addMouseMoveHandler( const MouseEventHandlerSharedPtr
& rHandler
,
418 void removeMouseMoveHandler( const MouseEventHandlerSharedPtr
& rHandler
);
421 /** Registers a hyperlink click handler.
423 For every hyperlink click, only one of the handlers registered
424 here is called. The handlers are considered with decreasing
425 priority, i.e. the handler with the currently highest priority
431 void addHyperlinkHandler( const HyperlinkHandlerSharedPtr
& rHandler
,
433 void removeHyperlinkHandler( const HyperlinkHandlerSharedPtr
& rHandler
);
436 // External event notifications
441 This method adds another view, which the show is
442 displayed on. On every added view, the EventMultiplexer
443 registers mouse and motion event listeners.
445 void notifyViewAdded( const UnoViewSharedPtr
& rView
);
449 This method removes a view. Registered mouse and
450 motion event listeners are revoked.
452 void notifyViewRemoved( const UnoViewSharedPtr
& rView
);
456 This method announces a changed view to all view
457 listeners. View changes include size and transformation.
460 View that has changed
462 void notifyViewChanged( const UnoViewSharedPtr
& rView
);
466 This method announces a changed view to all view
467 listeners. View changes include size and transformation.
470 View that has changed
472 void notifyViewChanged( const css::uno::Reference
<css::presentation::XSlideShowView
>& xView
);
474 /** All Views changed
476 This method announces to all view listeners that
477 <em>every</em> known view has changed. View changes include
478 size and transformation.
480 void notifyViewsChanged();
484 This method announces that the given view has been clobbered
485 by something external to the slideshow, and needs an update.
488 View that has been clobbered
490 void notifyViewClobbered( const css::uno::Reference
<css::presentation::XSlideShowView
>& xView
);
492 /** New shape event listener added
494 This method announces that the given listener was added for
497 void notifyShapeListenerAdded( const css::uno::Reference
<css::drawing::XShape
>& xShape
);
499 /** A shape event listener was removed
501 This method announces that the given listener was removed for
504 void notifyShapeListenerRemoved( const css::uno::Reference
<css::drawing::XShape
>& xShape
);
506 /** Notify a new user paint color
508 Sending this notification also implies that user paint is
509 enabled. User paint denotes the feature to draw colored lines
510 on top of the slide content.
512 void notifyUserPaintColor( RGBColor
const& rUserColor
);
514 /** Notify a new user paint width
516 Sending this notification also implies that user paint is
519 void notifyUserPaintStrokeWidth( double rUserStrokeWidth
);
522 /** Notify a new user paint erase all ink mode
524 Sending this notification also implies that user paint is
525 enabled. User paint denotes the feature to draw colored lines
526 on top of the slide content.
528 void notifyEraseAllInk( bool bEraseAllInk
);
529 void notifySwitchPenMode();
530 void notifySwitchEraserMode();
531 void notifyEraseInkWidth( sal_Int32 rEraseInkSize
);
533 /** Notify that user paint is disabled
535 User paint denotes the feature to draw colored lines on top of
538 void notifyUserPaintDisabled();
540 /** Notify that the user requested the next effect.
542 This requests the slideshow to display the next
543 effect, or move to the next slide, if none are left.
545 @return true, if this event was processed by
546 anybody. If false is returned, no handler processed
547 this event (and probably, nothing will happen at all)
549 bool notifyNextEffect();
551 /** Notify that a new slide has started
553 This method is to be used from the Presentation object
554 to signal that a new slide is starting now. This will
555 invoke all registered slide start handlers.
557 void notifySlideStartEvent();
559 /** Notify that a slide has ended
561 This method is to be used from the Presentation object
562 to signal that a slide is ending now. This will invoke
563 all registered slide end handlers.
565 @return true, if this event was processed by
566 anybody. If false is returned, no handler processed
567 this event (and probably, nothing will happen at all)
569 bool notifySlideEndEvent();
571 /** Notify that the given node enters its active duration.
573 This method is to be used from the AnimationNode
574 objects to signal that the active duration
575 begins. This will invoke all registered animation
579 Node which enters active duration.
581 @return true, if this event was processed by
582 anybody. If false is returned, no handler processed
583 this event (and probably, nothing will happen at all)
585 bool notifyAnimationStart( const AnimationNodeSharedPtr
& rNode
);
587 /** Notify that the given node leaves its active duration.
589 This method is to be used from the AnimationNode
590 objects to signal that the active duration
591 ends now. This will invoke all registered animation
595 Node which leaves active duration.
597 @return true, if this event was processed by
598 anybody. If false is returned, no handler processed
599 this event (and probably, nothing will happen at all)
601 bool notifyAnimationEnd( const AnimationNodeSharedPtr
& rNode
);
603 /** Notify that the slide animations sequence leaves its
606 @return true, if this event was processed by
607 anybody. If false is returned, no handler processed
608 this event (and probably, nothing will happen at all)
610 bool notifySlideAnimationsEnd();
612 /** Notify that for the given node, audio output has stopped.
614 This method is to be used from the AnimationNode
615 objects to signal that audio playback has just
616 stopped. This will invoke all registered audio
620 Node for which audio has stopped.
622 @return true, if this event was processed by
623 anybody. If false is returned, no handler processed
624 this event (and probably, nothing will happen at all)
626 bool notifyAudioStopped( const AnimationNodeSharedPtr
& rNode
);
628 /** Notify that the show has entered or exited pause mode
630 This method is to be used from the Presentation object
631 to signal that a slide is entering (bPauseShow=true)
632 or exiting (bPauseShow=false) pause mode. This will
633 invoke all registered slide end handlers.
635 void notifyPauseMode( bool bPauseShow
);
637 /** Notify that all audio has to be stopped.
639 This method is used by XCommand nodes and all sound
640 playing nodes should listen for this command and
641 stop their sounds when it's fired.
643 @return true, if this event was processed by
644 anybody. If false is returned, no handler processed
645 this event (and probably, nothing will happen at all)
647 bool notifyCommandStopAudio( const AnimationNodeSharedPtr
& rNode
);
649 /** Notifies that a hyperlink has been clicked.
651 void notifyHyperlinkClicked( OUString
const& hyperLink
);
653 basegfx::B2DPoint
toMatrixPoint(css::uno::Reference
<css::uno::XInterface
> xInterface
,
654 basegfx::B2DPoint pnt
);
656 basegfx::B2DPoint
toNormalPoint(css::uno::Reference
<css::uno::XInterface
> xInterface
,
657 basegfx::B2DPoint pnt
);
660 std::unique_ptr
<EventMultiplexerImpl
> mpImpl
;
663 } // namespace Presentation::internal
665 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_EVENTMULTIPLEXER_HXX
667 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */