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_slideshow.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // must be first 32*cdf0e10cSrcweir #include <canvas/debug.hxx> 33*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <rtl/ref.hxx> 36*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 37*cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <com/sun/star/awt/XMouseListener.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/awt/XMouseMotionListener.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/awt/SystemPointer.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/awt/MouseButton.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShowView.hpp> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 47*cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include "tools.hxx" 50*cdf0e10cSrcweir #include "eventqueue.hxx" 51*cdf0e10cSrcweir #include "eventmultiplexer.hxx" 52*cdf0e10cSrcweir #include "listenercontainer.hxx" 53*cdf0e10cSrcweir #include "delayevent.hxx" 54*cdf0e10cSrcweir #include "unoview.hxx" 55*cdf0e10cSrcweir #include "unoviewcontainer.hxx" 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 58*cdf0e10cSrcweir #include <boost/weak_ptr.hpp> 59*cdf0e10cSrcweir #include <boost/function.hpp> 60*cdf0e10cSrcweir #include <boost/noncopyable.hpp> 61*cdf0e10cSrcweir #include <boost/bind.hpp> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #include <vector> 64*cdf0e10cSrcweir #include <hash_map> 65*cdf0e10cSrcweir #include <algorithm> 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir using namespace ::com::sun::star; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir namespace boost 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir // add operator== for weak_ptr 72*cdf0e10cSrcweir template<typename T> bool operator==( weak_ptr<T> const& rLHS, 73*cdf0e10cSrcweir weak_ptr<T> const& rRHS ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir return !(rLHS<rRHS) && !(rRHS<rLHS); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir namespace slideshow { 80*cdf0e10cSrcweir namespace internal { 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir template <typename HandlerT> 83*cdf0e10cSrcweir class PrioritizedHandlerEntry 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir typedef boost::shared_ptr<HandlerT> HandlerSharedPtrT; 86*cdf0e10cSrcweir HandlerSharedPtrT mpHandler; 87*cdf0e10cSrcweir double mnPrio; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir public: 90*cdf0e10cSrcweir PrioritizedHandlerEntry( HandlerSharedPtrT const& pHandler, 91*cdf0e10cSrcweir double nPrio ) : 92*cdf0e10cSrcweir mpHandler(pHandler), 93*cdf0e10cSrcweir mnPrio(nPrio) 94*cdf0e10cSrcweir {} 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir HandlerSharedPtrT const& getHandler() const { return mpHandler; } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir /// To sort according to priority 99*cdf0e10cSrcweir bool operator<( PrioritizedHandlerEntry const& rRHS ) const 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir // reversed order - high prioritized entries 102*cdf0e10cSrcweir // should be at the beginning of the queue 103*cdf0e10cSrcweir return mnPrio > rRHS.mnPrio; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /// To permit std::remove in removeHandler template 107*cdf0e10cSrcweir bool operator==( PrioritizedHandlerEntry const& rRHS ) const 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir // ignore prio, for removal, only the handler ptr matters 110*cdf0e10cSrcweir return mpHandler == rRHS.mpHandler; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir }; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir template<typename T> inline T* get_pointer(PrioritizedHandlerEntry<T> const& handler) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir return handler.getHandler().get(); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////// 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir typedef cppu::WeakComponentImplHelper2< 125*cdf0e10cSrcweir awt::XMouseListener, 126*cdf0e10cSrcweir awt::XMouseMotionListener > Listener_UnoBase; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir /** Listener class, to decouple UNO lifetime from EventMultiplexer 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir This class gets registered as the XMouse(Motion)Listener on the 131*cdf0e10cSrcweir XSlideViews, and passes on the events to the EventMultiplexer (via 132*cdf0e10cSrcweir EventQueue indirection, to force the events into the main thread) 133*cdf0e10cSrcweir */ 134*cdf0e10cSrcweir class EventMultiplexerListener : private cppu::BaseMutex, 135*cdf0e10cSrcweir public Listener_UnoBase, 136*cdf0e10cSrcweir private ::boost::noncopyable 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir public: 139*cdf0e10cSrcweir EventMultiplexerListener( EventQueue& rEventQueue, 140*cdf0e10cSrcweir EventMultiplexerImpl& rEventMultiplexer ) : 141*cdf0e10cSrcweir Listener_UnoBase( m_aMutex ), 142*cdf0e10cSrcweir mpEventQueue( &rEventQueue ), 143*cdf0e10cSrcweir mpEventMultiplexer( &rEventMultiplexer ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir // WeakComponentImplHelperBase::disposing 148*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir private: 151*cdf0e10cSrcweir virtual void SAL_CALL disposing( const lang::EventObject& Source ) 152*cdf0e10cSrcweir throw (uno::RuntimeException); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // XMouseListener implementation 155*cdf0e10cSrcweir virtual void SAL_CALL mousePressed( const awt::MouseEvent& e ) 156*cdf0e10cSrcweir throw (uno::RuntimeException); 157*cdf0e10cSrcweir virtual void SAL_CALL mouseReleased( const awt::MouseEvent& e ) 158*cdf0e10cSrcweir throw (uno::RuntimeException); 159*cdf0e10cSrcweir virtual void SAL_CALL mouseEntered( const awt::MouseEvent& e ) 160*cdf0e10cSrcweir throw (uno::RuntimeException); 161*cdf0e10cSrcweir virtual void SAL_CALL mouseExited( const awt::MouseEvent& e ) 162*cdf0e10cSrcweir throw (uno::RuntimeException); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // XMouseMotionListener implementation 165*cdf0e10cSrcweir virtual void SAL_CALL mouseDragged( const awt::MouseEvent& e ) 166*cdf0e10cSrcweir throw (uno::RuntimeException); 167*cdf0e10cSrcweir virtual void SAL_CALL mouseMoved( const awt::MouseEvent& e ) 168*cdf0e10cSrcweir throw (uno::RuntimeException); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir EventQueue* mpEventQueue; 172*cdf0e10cSrcweir EventMultiplexerImpl* mpEventMultiplexer; 173*cdf0e10cSrcweir }; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////// 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir struct EventMultiplexerImpl 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir EventMultiplexerImpl( EventQueue& rEventQueue, 182*cdf0e10cSrcweir UnoViewContainer const& rViewContainer ) : 183*cdf0e10cSrcweir mrEventQueue(rEventQueue), 184*cdf0e10cSrcweir mrViewContainer(rViewContainer), 185*cdf0e10cSrcweir mxListener( new EventMultiplexerListener(rEventQueue, 186*cdf0e10cSrcweir *this) ), 187*cdf0e10cSrcweir maNextEffectHandlers(), 188*cdf0e10cSrcweir maSlideStartHandlers(), 189*cdf0e10cSrcweir maSlideEndHandlers(), 190*cdf0e10cSrcweir maAnimationStartHandlers(), 191*cdf0e10cSrcweir maAnimationEndHandlers(), 192*cdf0e10cSrcweir maSlideAnimationsEndHandlers(), 193*cdf0e10cSrcweir maAudioStoppedHandlers(), 194*cdf0e10cSrcweir maCommandStopAudioHandlers(), 195*cdf0e10cSrcweir maPauseHandlers(), 196*cdf0e10cSrcweir maViewHandlers(), 197*cdf0e10cSrcweir maViewRepaintHandlers(), 198*cdf0e10cSrcweir maShapeListenerHandlers(), 199*cdf0e10cSrcweir maUserPaintEventHandlers(), 200*cdf0e10cSrcweir maShapeCursorHandlers(), 201*cdf0e10cSrcweir maMouseClickHandlers(), 202*cdf0e10cSrcweir maMouseDoubleClickHandlers(), 203*cdf0e10cSrcweir maMouseMoveHandlers(), 204*cdf0e10cSrcweir maHyperlinkHandlers(), 205*cdf0e10cSrcweir mnTimeout(0.0), 206*cdf0e10cSrcweir mpTickEvent(), 207*cdf0e10cSrcweir mbIsAutoMode(false) 208*cdf0e10cSrcweir {} 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir ~EventMultiplexerImpl() 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir if( mxListener.is() ) 213*cdf0e10cSrcweir mxListener->dispose(); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir /// Remove all handlers 217*cdf0e10cSrcweir void clear(); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // actual handler callbacks (get called from the UNO interface 220*cdf0e10cSrcweir // listeners via event queue) 221*cdf0e10cSrcweir void mousePressed( const awt::MouseEvent& e ); 222*cdf0e10cSrcweir void mouseReleased( const awt::MouseEvent& e ); 223*cdf0e10cSrcweir void mouseDragged( const awt::MouseEvent& e ); 224*cdf0e10cSrcweir void mouseMoved( const awt::MouseEvent& e ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir bool isMouseListenerRegistered() const; 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 229*cdf0e10cSrcweir PrioritizedHandlerEntry<EventHandler>, 230*cdf0e10cSrcweir std::vector< 231*cdf0e10cSrcweir PrioritizedHandlerEntry<EventHandler> > > ImplNextEffectHandlers; 232*cdf0e10cSrcweir typedef PrioritizedHandlerEntry<MouseEventHandler> ImplMouseHandlerEntry; 233*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 234*cdf0e10cSrcweir ImplMouseHandlerEntry, 235*cdf0e10cSrcweir std::vector<ImplMouseHandlerEntry> > ImplMouseHandlers; 236*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 237*cdf0e10cSrcweir EventHandlerSharedPtr, 238*cdf0e10cSrcweir std::vector<EventHandlerSharedPtr> > ImplEventHandlers; 239*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 240*cdf0e10cSrcweir AnimationEventHandlerSharedPtr, 241*cdf0e10cSrcweir std::vector<AnimationEventHandlerSharedPtr> > ImplAnimationHandlers; 242*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 243*cdf0e10cSrcweir PauseEventHandlerSharedPtr, 244*cdf0e10cSrcweir std::vector<PauseEventHandlerSharedPtr> > ImplPauseHandlers; 245*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 246*cdf0e10cSrcweir ViewEventHandlerWeakPtr, 247*cdf0e10cSrcweir std::vector<ViewEventHandlerWeakPtr> > ImplViewHandlers; 248*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 249*cdf0e10cSrcweir ViewRepaintHandlerSharedPtr, 250*cdf0e10cSrcweir std::vector<ViewRepaintHandlerSharedPtr> > ImplRepaintHandlers; 251*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 252*cdf0e10cSrcweir ShapeListenerEventHandlerSharedPtr, 253*cdf0e10cSrcweir std::vector<ShapeListenerEventHandlerSharedPtr> > ImplShapeListenerHandlers; 254*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 255*cdf0e10cSrcweir UserPaintEventHandlerSharedPtr, 256*cdf0e10cSrcweir std::vector<UserPaintEventHandlerSharedPtr> > ImplUserPaintEventHandlers; 257*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 258*cdf0e10cSrcweir ShapeCursorEventHandlerSharedPtr, 259*cdf0e10cSrcweir std::vector<ShapeCursorEventHandlerSharedPtr> > ImplShapeCursorHandlers; 260*cdf0e10cSrcweir typedef ThreadUnsafeListenerContainer< 261*cdf0e10cSrcweir PrioritizedHandlerEntry<HyperlinkHandler>, 262*cdf0e10cSrcweir std::vector<PrioritizedHandlerEntry<HyperlinkHandler> > > ImplHyperLinkHandlers; 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir template <typename XSlideShowViewFunc> 265*cdf0e10cSrcweir void forEachView( XSlideShowViewFunc pViewMethod ); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir UnoViewSharedPtr findUnoView(const uno::Reference< 268*cdf0e10cSrcweir presentation::XSlideShowView>& xView) const; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir template< typename RegisterFunction > 271*cdf0e10cSrcweir void addMouseHandler( ImplMouseHandlers& rHandlerContainer, 272*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler, 273*cdf0e10cSrcweir double nPriority, 274*cdf0e10cSrcweir RegisterFunction pRegisterListener ); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir bool notifyAllAnimationHandlers( ImplAnimationHandlers const& rContainer, 277*cdf0e10cSrcweir AnimationNodeSharedPtr const& rNode ); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir bool notifyMouseHandlers( 280*cdf0e10cSrcweir const ImplMouseHandlers& rQueue, 281*cdf0e10cSrcweir bool (MouseEventHandler::*pHandlerMethod)( 282*cdf0e10cSrcweir const awt::MouseEvent& ), 283*cdf0e10cSrcweir const awt::MouseEvent& e ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir bool notifyNextEffect(); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir /// Called for automatic nextEffect 288*cdf0e10cSrcweir void tick(); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir /// Schedules a tick event 291*cdf0e10cSrcweir void scheduleTick(); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir /// Schedules tick events, if mbIsAutoMode is true 294*cdf0e10cSrcweir void handleTicks(); 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir EventQueue& mrEventQueue; 298*cdf0e10cSrcweir UnoViewContainer const& mrViewContainer; 299*cdf0e10cSrcweir ::rtl::Reference< 300*cdf0e10cSrcweir EventMultiplexerListener> mxListener; 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir ImplNextEffectHandlers maNextEffectHandlers; 303*cdf0e10cSrcweir ImplEventHandlers maSlideStartHandlers; 304*cdf0e10cSrcweir ImplEventHandlers maSlideEndHandlers; 305*cdf0e10cSrcweir ImplAnimationHandlers maAnimationStartHandlers; 306*cdf0e10cSrcweir ImplAnimationHandlers maAnimationEndHandlers; 307*cdf0e10cSrcweir ImplEventHandlers maSlideAnimationsEndHandlers; 308*cdf0e10cSrcweir ImplAnimationHandlers maAudioStoppedHandlers; 309*cdf0e10cSrcweir ImplAnimationHandlers maCommandStopAudioHandlers; 310*cdf0e10cSrcweir ImplPauseHandlers maPauseHandlers; 311*cdf0e10cSrcweir ImplViewHandlers maViewHandlers; 312*cdf0e10cSrcweir ImplRepaintHandlers maViewRepaintHandlers; 313*cdf0e10cSrcweir ImplShapeListenerHandlers maShapeListenerHandlers; 314*cdf0e10cSrcweir ImplUserPaintEventHandlers maUserPaintEventHandlers; 315*cdf0e10cSrcweir ImplShapeCursorHandlers maShapeCursorHandlers; 316*cdf0e10cSrcweir ImplMouseHandlers maMouseClickHandlers; 317*cdf0e10cSrcweir ImplMouseHandlers maMouseDoubleClickHandlers; 318*cdf0e10cSrcweir ImplMouseHandlers maMouseMoveHandlers; 319*cdf0e10cSrcweir ImplHyperLinkHandlers maHyperlinkHandlers; 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir /// automatic next effect mode timeout 322*cdf0e10cSrcweir double mnTimeout; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir /** Holds ptr to optional tick event weakly 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir When event queue is cleansed, the next 327*cdf0e10cSrcweir setAutomaticMode(true) call is then able to 328*cdf0e10cSrcweir regenerate the event. 329*cdf0e10cSrcweir */ 330*cdf0e10cSrcweir ::boost::weak_ptr< Event > mpTickEvent; 331*cdf0e10cSrcweir bool mbIsAutoMode; 332*cdf0e10cSrcweir }; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::disposing() 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir osl::MutexGuard const guard( m_aMutex ); 341*cdf0e10cSrcweir mpEventQueue = NULL; 342*cdf0e10cSrcweir mpEventMultiplexer = NULL; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::disposing( 346*cdf0e10cSrcweir const lang::EventObject& /*rSource*/ ) throw (uno::RuntimeException) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir // there's no real point in acting on this message - after all, 349*cdf0e10cSrcweir // the event sources are the XSlideShowViews, which must be 350*cdf0e10cSrcweir // explicitely removed from the slideshow via 351*cdf0e10cSrcweir // XSlideShow::removeView(). thus, if a XSlideShowView has 352*cdf0e10cSrcweir // properly removed itself from the slideshow, it will not be 353*cdf0e10cSrcweir // found here. and if it hasn't, there'll be other references at 354*cdf0e10cSrcweir // other places within the slideshow, anyway... 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::mousePressed( 358*cdf0e10cSrcweir const awt::MouseEvent& e ) throw (uno::RuntimeException) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir osl::MutexGuard const guard( m_aMutex ); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir // notify mouse press. Don't call handlers directly, this 363*cdf0e10cSrcweir // might not be the main thread! 364*cdf0e10cSrcweir if( mpEventQueue ) 365*cdf0e10cSrcweir mpEventQueue->addEvent( 366*cdf0e10cSrcweir makeEvent( boost::bind( &EventMultiplexerImpl::mousePressed, 367*cdf0e10cSrcweir mpEventMultiplexer, 368*cdf0e10cSrcweir e ), 369*cdf0e10cSrcweir "EventMultiplexerImpl::mousePressed") ); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::mouseReleased( 373*cdf0e10cSrcweir const awt::MouseEvent& e ) throw (uno::RuntimeException) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir osl::MutexGuard const guard( m_aMutex ); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir // notify mouse release. Don't call handlers directly, 378*cdf0e10cSrcweir // this might not be the main thread! 379*cdf0e10cSrcweir if( mpEventQueue ) 380*cdf0e10cSrcweir mpEventQueue->addEvent( 381*cdf0e10cSrcweir makeEvent( boost::bind( &EventMultiplexerImpl::mouseReleased, 382*cdf0e10cSrcweir mpEventMultiplexer, 383*cdf0e10cSrcweir e ), 384*cdf0e10cSrcweir "EventMultiplexerImpl::mouseReleased") ); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::mouseEntered( 388*cdf0e10cSrcweir const awt::MouseEvent& /*e*/ ) throw (uno::RuntimeException) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir // not used here 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::mouseExited( 394*cdf0e10cSrcweir const awt::MouseEvent& /*e*/ ) throw (uno::RuntimeException) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir // not used here 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir // XMouseMotionListener implementation 400*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::mouseDragged( 401*cdf0e10cSrcweir const awt::MouseEvent& e ) throw (uno::RuntimeException) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir osl::MutexGuard const guard( m_aMutex ); 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir // notify mouse drag. Don't call handlers directly, this 406*cdf0e10cSrcweir // might not be the main thread! 407*cdf0e10cSrcweir if( mpEventQueue ) 408*cdf0e10cSrcweir mpEventQueue->addEvent( 409*cdf0e10cSrcweir makeEvent( boost::bind( &EventMultiplexerImpl::mouseDragged, 410*cdf0e10cSrcweir mpEventMultiplexer, 411*cdf0e10cSrcweir e ), 412*cdf0e10cSrcweir "EventMultiplexerImpl::mouseDragged") ); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir void SAL_CALL EventMultiplexerListener::mouseMoved( 416*cdf0e10cSrcweir const awt::MouseEvent& e ) throw (uno::RuntimeException) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir osl::MutexGuard const guard( m_aMutex ); 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir // notify mouse move. Don't call handlers directly, this 421*cdf0e10cSrcweir // might not be the main thread! 422*cdf0e10cSrcweir if( mpEventQueue ) 423*cdf0e10cSrcweir mpEventQueue->addEvent( 424*cdf0e10cSrcweir makeEvent( boost::bind( &EventMultiplexerImpl::mouseMoved, 425*cdf0e10cSrcweir mpEventMultiplexer, 426*cdf0e10cSrcweir e ), 427*cdf0e10cSrcweir "EventMultiplexerImpl::mouseMoved") ); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir bool EventMultiplexerImpl::notifyAllAnimationHandlers( ImplAnimationHandlers const& rContainer, 435*cdf0e10cSrcweir AnimationNodeSharedPtr const& rNode ) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir return rContainer.applyAll( 438*cdf0e10cSrcweir boost::bind( &AnimationEventHandler::handleAnimationEvent, 439*cdf0e10cSrcweir _1, boost::cref(rNode) ) ); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir template <typename XSlideShowViewFunc> 443*cdf0e10cSrcweir void EventMultiplexerImpl::forEachView( XSlideShowViewFunc pViewMethod ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir if( pViewMethod ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir // (un)register mouse listener on all views 448*cdf0e10cSrcweir for( UnoViewVector::const_iterator aIter( mrViewContainer.begin() ), 449*cdf0e10cSrcweir aEnd( mrViewContainer.end() ); aIter != aEnd; ++aIter ) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir uno::Reference<presentation::XSlideShowView> xView ((*aIter)->getUnoView()); 452*cdf0e10cSrcweir if (xView.is()) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir (xView.get()->*pViewMethod)( mxListener.get() ); 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir else 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir OSL_ASSERT(xView.is()); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir UnoViewSharedPtr EventMultiplexerImpl::findUnoView( 465*cdf0e10cSrcweir const uno::Reference<presentation::XSlideShowView>& xView) const 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir // find view from which the change originated 468*cdf0e10cSrcweir UnoViewVector::const_iterator aIter; 469*cdf0e10cSrcweir const UnoViewVector::const_iterator aEnd ( mrViewContainer.end() ); 470*cdf0e10cSrcweir if( (aIter=std::find_if( mrViewContainer.begin(), 471*cdf0e10cSrcweir aEnd, 472*cdf0e10cSrcweir boost::bind( 473*cdf0e10cSrcweir std::equal_to<uno::Reference<presentation::XSlideShowView> >(), 474*cdf0e10cSrcweir boost::cref( xView ), 475*cdf0e10cSrcweir boost::bind( &UnoView::getUnoView, _1 )))) == aEnd ) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir OSL_ENSURE(false, "EventMultiplexer::findUnoView(): unexpected message source" ); 478*cdf0e10cSrcweir return UnoViewSharedPtr(); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir return *aIter; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir template< typename RegisterFunction > 485*cdf0e10cSrcweir void EventMultiplexerImpl::addMouseHandler( 486*cdf0e10cSrcweir ImplMouseHandlers& rHandlerContainer, 487*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler, 488*cdf0e10cSrcweir double nPriority, 489*cdf0e10cSrcweir RegisterFunction pRegisterListener ) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir ENSURE_OR_THROW( 492*cdf0e10cSrcweir rHandler, 493*cdf0e10cSrcweir "EventMultiplexer::addMouseHandler(): Invalid handler" ); 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir // register mouse listener on all views 496*cdf0e10cSrcweir forEachView( pRegisterListener ); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir // add into sorted container: 499*cdf0e10cSrcweir rHandlerContainer.addSorted( 500*cdf0e10cSrcweir typename ImplMouseHandlers::container_type::value_type( 501*cdf0e10cSrcweir rHandler, 502*cdf0e10cSrcweir nPriority )); 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir bool EventMultiplexerImpl::isMouseListenerRegistered() const 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir return !(maMouseClickHandlers.isEmpty() && 508*cdf0e10cSrcweir maMouseDoubleClickHandlers.isEmpty()); 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir void EventMultiplexerImpl::tick() 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir if( !mbIsAutoMode ) 514*cdf0e10cSrcweir return; // this event is just a left-over, ignore 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir notifyNextEffect(); 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir if( !maNextEffectHandlers.isEmpty() ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir // still handlers left, schedule next timeout 521*cdf0e10cSrcweir // event. Will also set mbIsTickEventOn back to true 522*cdf0e10cSrcweir scheduleTick(); 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir void EventMultiplexerImpl::scheduleTick() 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir EventSharedPtr pEvent( 529*cdf0e10cSrcweir makeDelay( boost::bind( &EventMultiplexerImpl::tick, 530*cdf0e10cSrcweir this ), 531*cdf0e10cSrcweir mnTimeout, 532*cdf0e10cSrcweir "EventMultiplexerImpl::tick with delay")); 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir // store weak reference to generated event, to notice when 535*cdf0e10cSrcweir // the event queue gets cleansed (we then have to 536*cdf0e10cSrcweir // regenerate the tick event!) 537*cdf0e10cSrcweir mpTickEvent = pEvent; 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir // enabled auto mode: simply schedule a timeout event, 540*cdf0e10cSrcweir // which will eventually call our tick() method 541*cdf0e10cSrcweir mrEventQueue.addEventForNextRound( pEvent ); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir void EventMultiplexerImpl::handleTicks() 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir if( !mbIsAutoMode ) 547*cdf0e10cSrcweir return; // nothing to do, don't need no ticks 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir EventSharedPtr pTickEvent( mpTickEvent.lock() ); 550*cdf0e10cSrcweir if( pTickEvent ) 551*cdf0e10cSrcweir return; // nothing to do, there's already a tick 552*cdf0e10cSrcweir // pending 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir // schedule initial tick (which reschedules itself 555*cdf0e10cSrcweir // after that, all by itself) 556*cdf0e10cSrcweir scheduleTick(); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir void EventMultiplexerImpl::clear() 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir // deregister from all views. 563*cdf0e10cSrcweir if( isMouseListenerRegistered() ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir for( UnoViewVector::const_iterator aIter=mrViewContainer.begin(), 566*cdf0e10cSrcweir aEnd=mrViewContainer.end(); 567*cdf0e10cSrcweir aIter!=aEnd; 568*cdf0e10cSrcweir ++aIter ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir if( (*aIter)->getUnoView().is() ) 571*cdf0e10cSrcweir (*aIter)->getUnoView()->removeMouseListener( mxListener.get() ); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir if( !maMouseMoveHandlers.isEmpty() ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir for( UnoViewVector::const_iterator aIter=mrViewContainer.begin(), 578*cdf0e10cSrcweir aEnd=mrViewContainer.end(); 579*cdf0e10cSrcweir aIter!=aEnd; 580*cdf0e10cSrcweir ++aIter ) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir if( (*aIter)->getUnoView().is() ) 583*cdf0e10cSrcweir (*aIter)->getUnoView()->removeMouseMotionListener( mxListener.get() ); 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir // clear all handlers (releases all references) 588*cdf0e10cSrcweir maNextEffectHandlers.clear(); 589*cdf0e10cSrcweir maSlideStartHandlers.clear(); 590*cdf0e10cSrcweir maSlideEndHandlers.clear(); 591*cdf0e10cSrcweir maAnimationStartHandlers.clear(); 592*cdf0e10cSrcweir maAnimationEndHandlers.clear(); 593*cdf0e10cSrcweir maSlideAnimationsEndHandlers.clear(); 594*cdf0e10cSrcweir maAudioStoppedHandlers.clear(); 595*cdf0e10cSrcweir maCommandStopAudioHandlers.clear(); 596*cdf0e10cSrcweir maPauseHandlers.clear(); 597*cdf0e10cSrcweir maViewHandlers.clear(); 598*cdf0e10cSrcweir maViewRepaintHandlers.clear(); 599*cdf0e10cSrcweir maMouseClickHandlers.clear(); 600*cdf0e10cSrcweir maMouseDoubleClickHandlers.clear(); 601*cdf0e10cSrcweir maMouseMoveHandlers.clear(); 602*cdf0e10cSrcweir maHyperlinkHandlers.clear(); 603*cdf0e10cSrcweir mpTickEvent.reset(); 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir // XMouseListener implementation 607*cdf0e10cSrcweir bool EventMultiplexerImpl::notifyMouseHandlers( 608*cdf0e10cSrcweir const ImplMouseHandlers& rQueue, 609*cdf0e10cSrcweir bool (MouseEventHandler::*pHandlerMethod)( const awt::MouseEvent& ), 610*cdf0e10cSrcweir const awt::MouseEvent& e ) 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir uno::Reference<presentation::XSlideShowView> xView( 613*cdf0e10cSrcweir e.Source, uno::UNO_QUERY ); 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir ENSURE_OR_RETURN_FALSE( xView.is(), "EventMultiplexer::notifyHandlers(): " 616*cdf0e10cSrcweir "event source is not an XSlideShowView" ); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir // find corresponding view (to map mouse position into user 619*cdf0e10cSrcweir // coordinate space) 620*cdf0e10cSrcweir UnoViewVector::const_iterator aIter; 621*cdf0e10cSrcweir const UnoViewVector::const_iterator aBegin( mrViewContainer.begin() ); 622*cdf0e10cSrcweir const UnoViewVector::const_iterator aEnd ( mrViewContainer.end() ); 623*cdf0e10cSrcweir if( (aIter=::std::find_if( 624*cdf0e10cSrcweir aBegin, aEnd, 625*cdf0e10cSrcweir boost::bind( std::equal_to< uno::Reference< 626*cdf0e10cSrcweir presentation::XSlideShowView > >(), 627*cdf0e10cSrcweir boost::cref( xView ), 628*cdf0e10cSrcweir boost::bind( &UnoView::getUnoView, _1 ) ) ) ) == aEnd) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir ENSURE_OR_RETURN_FALSE( 631*cdf0e10cSrcweir false, "EventMultiplexer::notifyHandlers(): " 632*cdf0e10cSrcweir "event source not found under registered views" ); 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir // convert mouse position to user coordinate space 636*cdf0e10cSrcweir ::basegfx::B2DPoint aPosition( e.X, e.Y ); 637*cdf0e10cSrcweir ::basegfx::B2DHomMatrix aMatrix( (*aIter)->getTransformation() ); 638*cdf0e10cSrcweir if( !aMatrix.invert() ) 639*cdf0e10cSrcweir ENSURE_OR_THROW( false, "EventMultiplexer::notifyHandlers():" 640*cdf0e10cSrcweir " view matrix singular" ); 641*cdf0e10cSrcweir aPosition *= aMatrix; 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir awt::MouseEvent aEvent( e ); 644*cdf0e10cSrcweir aEvent.X = ::basegfx::fround( aPosition.getX() ); 645*cdf0e10cSrcweir aEvent.Y = ::basegfx::fround( aPosition.getY() ); 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir // fire event on handlers, try in order of precedence. If 648*cdf0e10cSrcweir // one high-priority handler rejects the event 649*cdf0e10cSrcweir // (i.e. returns false), try next handler. 650*cdf0e10cSrcweir return rQueue.apply( 651*cdf0e10cSrcweir boost::bind( 652*cdf0e10cSrcweir pHandlerMethod, 653*cdf0e10cSrcweir boost::bind( 654*cdf0e10cSrcweir &ImplMouseHandlers::container_type::value_type::getHandler, 655*cdf0e10cSrcweir _1 ), 656*cdf0e10cSrcweir aEvent )); 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir void EventMultiplexerImpl::mousePressed( const awt::MouseEvent& e ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir // fire double-click events for every second click 662*cdf0e10cSrcweir sal_Int32 nCurrClickCount = e.ClickCount; 663*cdf0e10cSrcweir while( nCurrClickCount > 1 && 664*cdf0e10cSrcweir notifyMouseHandlers( maMouseDoubleClickHandlers, 665*cdf0e10cSrcweir &MouseEventHandler::handleMousePressed, 666*cdf0e10cSrcweir e )) 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir nCurrClickCount -= 2; 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir // fire single-click events for all remaining clicks 672*cdf0e10cSrcweir while( nCurrClickCount > 0 && 673*cdf0e10cSrcweir notifyMouseHandlers( maMouseClickHandlers, 674*cdf0e10cSrcweir &MouseEventHandler::handleMousePressed, 675*cdf0e10cSrcweir e )) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir --nCurrClickCount; 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir void EventMultiplexerImpl::mouseReleased( const awt::MouseEvent& e ) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir // fire double-click events for every second click 684*cdf0e10cSrcweir sal_Int32 nCurrClickCount = e.ClickCount; 685*cdf0e10cSrcweir while( nCurrClickCount > 1 && 686*cdf0e10cSrcweir notifyMouseHandlers( maMouseDoubleClickHandlers, 687*cdf0e10cSrcweir &MouseEventHandler::handleMouseReleased, 688*cdf0e10cSrcweir e )) 689*cdf0e10cSrcweir { 690*cdf0e10cSrcweir nCurrClickCount -= 2; 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir // fire single-click events for all remaining clicks 694*cdf0e10cSrcweir while( nCurrClickCount > 0 && 695*cdf0e10cSrcweir notifyMouseHandlers( maMouseClickHandlers, 696*cdf0e10cSrcweir &MouseEventHandler::handleMouseReleased, 697*cdf0e10cSrcweir e )) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir --nCurrClickCount; 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir void EventMultiplexerImpl::mouseDragged( const awt::MouseEvent& e ) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir notifyMouseHandlers( maMouseMoveHandlers, 706*cdf0e10cSrcweir &MouseEventHandler::handleMouseDragged, 707*cdf0e10cSrcweir e ); 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir void EventMultiplexerImpl::mouseMoved( const awt::MouseEvent& e ) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir notifyMouseHandlers( maMouseMoveHandlers, 713*cdf0e10cSrcweir &MouseEventHandler::handleMouseMoved, 714*cdf0e10cSrcweir e ); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir bool EventMultiplexerImpl::notifyNextEffect() 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir // fire event on handlers, try in order of precedence. If one 720*cdf0e10cSrcweir // high-priority handler rejects the event (i.e. returns false), 721*cdf0e10cSrcweir // try next handler. 722*cdf0e10cSrcweir return maNextEffectHandlers.apply( 723*cdf0e10cSrcweir boost::bind( 724*cdf0e10cSrcweir &EventHandler::handleEvent, 725*cdf0e10cSrcweir boost::bind( 726*cdf0e10cSrcweir &ImplNextEffectHandlers::container_type::value_type::getHandler, 727*cdf0e10cSrcweir _1 )) ); 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////// 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir EventMultiplexer::EventMultiplexer( EventQueue& rEventQueue, 734*cdf0e10cSrcweir UnoViewContainer const& rViewContainer ) : 735*cdf0e10cSrcweir mpImpl( new EventMultiplexerImpl(rEventQueue, rViewContainer) ) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir EventMultiplexer::~EventMultiplexer() 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir // outline because of EventMultiplexerImpl's incomplete type 742*cdf0e10cSrcweir } 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir void EventMultiplexer::clear() 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir mpImpl->clear(); 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir void EventMultiplexer::setAutomaticMode( bool bIsAuto ) 750*cdf0e10cSrcweir { 751*cdf0e10cSrcweir if( bIsAuto == mpImpl->mbIsAutoMode ) 752*cdf0e10cSrcweir return; // no change, nothing to do 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir mpImpl->mbIsAutoMode = bIsAuto; 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir mpImpl->handleTicks(); 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir bool EventMultiplexer::getAutomaticMode() const 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir return mpImpl->mbIsAutoMode; 762*cdf0e10cSrcweir } 763*cdf0e10cSrcweir 764*cdf0e10cSrcweir void EventMultiplexer::setAutomaticTimeout( double nTimeout ) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir mpImpl->mnTimeout = nTimeout; 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir double EventMultiplexer::getAutomaticTimeout() const 770*cdf0e10cSrcweir { 771*cdf0e10cSrcweir return mpImpl->mnTimeout; 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir void EventMultiplexer::addNextEffectHandler( 775*cdf0e10cSrcweir EventHandlerSharedPtr const& rHandler, 776*cdf0e10cSrcweir double nPriority ) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir mpImpl->maNextEffectHandlers.addSorted( 779*cdf0e10cSrcweir EventMultiplexerImpl::ImplNextEffectHandlers::container_type::value_type( 780*cdf0e10cSrcweir rHandler, 781*cdf0e10cSrcweir nPriority) ); 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir // Enable tick events, if not done already 784*cdf0e10cSrcweir mpImpl->handleTicks(); 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir void EventMultiplexer::removeNextEffectHandler( 788*cdf0e10cSrcweir const EventHandlerSharedPtr& rHandler ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir mpImpl->maNextEffectHandlers.remove( 791*cdf0e10cSrcweir EventMultiplexerImpl::ImplNextEffectHandlers::container_type::value_type( 792*cdf0e10cSrcweir rHandler, 793*cdf0e10cSrcweir 0.0) ); 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir void EventMultiplexer::addSlideStartHandler( 797*cdf0e10cSrcweir const EventHandlerSharedPtr& rHandler ) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir mpImpl->maSlideStartHandlers.add( rHandler ); 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir void EventMultiplexer::removeSlideStartHandler( 803*cdf0e10cSrcweir const EventHandlerSharedPtr& rHandler ) 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir mpImpl->maSlideStartHandlers.remove( rHandler ); 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir void EventMultiplexer::addSlideEndHandler( 809*cdf0e10cSrcweir const EventHandlerSharedPtr& rHandler ) 810*cdf0e10cSrcweir { 811*cdf0e10cSrcweir mpImpl->maSlideEndHandlers.add( rHandler ); 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir void EventMultiplexer::removeSlideEndHandler( 815*cdf0e10cSrcweir const EventHandlerSharedPtr& rHandler ) 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir mpImpl->maSlideEndHandlers.remove( rHandler ); 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir void EventMultiplexer::addAnimationStartHandler( 821*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir mpImpl->maAnimationStartHandlers.add( rHandler ); 824*cdf0e10cSrcweir } 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir void EventMultiplexer::removeAnimationStartHandler( 827*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir mpImpl->maAnimationStartHandlers.remove( rHandler ); 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir void EventMultiplexer::addAnimationEndHandler( 833*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir mpImpl->maAnimationEndHandlers.add( rHandler ); 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir void EventMultiplexer::removeAnimationEndHandler( 839*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir mpImpl->maAnimationEndHandlers.remove( rHandler ); 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir void EventMultiplexer::addSlideAnimationsEndHandler( 845*cdf0e10cSrcweir const EventHandlerSharedPtr& rHandler ) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir mpImpl->maSlideAnimationsEndHandlers.add( rHandler ); 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir void EventMultiplexer::removeSlideAnimationsEndHandler( 851*cdf0e10cSrcweir const EventHandlerSharedPtr& rHandler ) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir mpImpl->maSlideAnimationsEndHandlers.remove( rHandler ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir void EventMultiplexer::addAudioStoppedHandler( 857*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir mpImpl->maAudioStoppedHandlers.add( rHandler ); 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir void EventMultiplexer::removeAudioStoppedHandler( 863*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir mpImpl->maAudioStoppedHandlers.remove( rHandler ); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir void EventMultiplexer::addCommandStopAudioHandler( 869*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir mpImpl->maCommandStopAudioHandlers.add( rHandler ); 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir void EventMultiplexer::removeCommandStopAudioHandler( 875*cdf0e10cSrcweir const AnimationEventHandlerSharedPtr& rHandler ) 876*cdf0e10cSrcweir { 877*cdf0e10cSrcweir mpImpl->maCommandStopAudioHandlers.remove( rHandler ); 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir void EventMultiplexer::addPauseHandler( 881*cdf0e10cSrcweir const PauseEventHandlerSharedPtr& rHandler ) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir mpImpl->maPauseHandlers.add( rHandler ); 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir void EventMultiplexer::removePauseHandler( 887*cdf0e10cSrcweir const PauseEventHandlerSharedPtr& rHandler ) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir mpImpl->maPauseHandlers.remove( rHandler ); 890*cdf0e10cSrcweir } 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir void EventMultiplexer::addViewHandler( 893*cdf0e10cSrcweir const ViewEventHandlerWeakPtr& rHandler ) 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir mpImpl->maViewHandlers.add( rHandler ); 896*cdf0e10cSrcweir } 897*cdf0e10cSrcweir 898*cdf0e10cSrcweir void EventMultiplexer::removeViewHandler( const ViewEventHandlerWeakPtr& rHandler ) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir mpImpl->maViewHandlers.remove( rHandler ); 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir void EventMultiplexer::addViewRepaintHandler( const ViewRepaintHandlerSharedPtr& rHandler ) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir mpImpl->maViewRepaintHandlers.add( rHandler ); 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir void EventMultiplexer::removeViewRepaintHandler( const ViewRepaintHandlerSharedPtr& rHandler ) 909*cdf0e10cSrcweir { 910*cdf0e10cSrcweir mpImpl->maViewRepaintHandlers.remove( rHandler ); 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir void EventMultiplexer::addShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr& rHandler ) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir mpImpl->maShapeListenerHandlers.add( rHandler ); 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir void EventMultiplexer::removeShapeListenerHandler( const ShapeListenerEventHandlerSharedPtr& rHandler ) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir mpImpl->maShapeListenerHandlers.remove( rHandler ); 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir void EventMultiplexer::addUserPaintHandler( const UserPaintEventHandlerSharedPtr& rHandler ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir mpImpl->maUserPaintEventHandlers.add( rHandler ); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir void EventMultiplexer::removeUserPaintHandler( const UserPaintEventHandlerSharedPtr& rHandler ) 929*cdf0e10cSrcweir { 930*cdf0e10cSrcweir mpImpl->maUserPaintEventHandlers.remove( rHandler ); 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir void EventMultiplexer::addShapeCursorHandler( const ShapeCursorEventHandlerSharedPtr& rHandler ) 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir mpImpl->maShapeCursorHandlers.add( rHandler ); 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir void EventMultiplexer::removeShapeCursorHandler( const ShapeCursorEventHandlerSharedPtr& rHandler ) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir mpImpl->maShapeCursorHandlers.remove( rHandler ); 941*cdf0e10cSrcweir } 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir void EventMultiplexer::addClickHandler( 944*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler, 945*cdf0e10cSrcweir double nPriority ) 946*cdf0e10cSrcweir { 947*cdf0e10cSrcweir mpImpl->addMouseHandler( 948*cdf0e10cSrcweir mpImpl->maMouseClickHandlers, 949*cdf0e10cSrcweir rHandler, 950*cdf0e10cSrcweir nPriority, 951*cdf0e10cSrcweir mpImpl->isMouseListenerRegistered() 952*cdf0e10cSrcweir ? NULL 953*cdf0e10cSrcweir : &presentation::XSlideShowView::addMouseListener ); 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir void EventMultiplexer::removeClickHandler( 957*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler ) 958*cdf0e10cSrcweir { 959*cdf0e10cSrcweir mpImpl->maMouseClickHandlers.remove( 960*cdf0e10cSrcweir EventMultiplexerImpl::ImplMouseHandlers::container_type::value_type( 961*cdf0e10cSrcweir rHandler, 962*cdf0e10cSrcweir 0.0) ); 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir if( !mpImpl->isMouseListenerRegistered() ) 965*cdf0e10cSrcweir mpImpl->forEachView( &presentation::XSlideShowView::removeMouseListener ); 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir 968*cdf0e10cSrcweir void EventMultiplexer::addDoubleClickHandler( 969*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler, 970*cdf0e10cSrcweir double nPriority ) 971*cdf0e10cSrcweir { 972*cdf0e10cSrcweir mpImpl->addMouseHandler( 973*cdf0e10cSrcweir mpImpl->maMouseDoubleClickHandlers, 974*cdf0e10cSrcweir rHandler, 975*cdf0e10cSrcweir nPriority, 976*cdf0e10cSrcweir mpImpl->isMouseListenerRegistered() 977*cdf0e10cSrcweir ? NULL 978*cdf0e10cSrcweir : &presentation::XSlideShowView::addMouseListener ); 979*cdf0e10cSrcweir } 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir void EventMultiplexer::removeDoubleClickHandler( 982*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler ) 983*cdf0e10cSrcweir { 984*cdf0e10cSrcweir mpImpl->maMouseDoubleClickHandlers.remove( 985*cdf0e10cSrcweir EventMultiplexerImpl::ImplMouseHandlers::container_type::value_type( 986*cdf0e10cSrcweir rHandler, 987*cdf0e10cSrcweir 0.0) ); 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir if( !mpImpl->isMouseListenerRegistered() ) 990*cdf0e10cSrcweir mpImpl->forEachView( &presentation::XSlideShowView::removeMouseListener ); 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir void EventMultiplexer::addMouseMoveHandler( 994*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler, 995*cdf0e10cSrcweir double nPriority ) 996*cdf0e10cSrcweir { 997*cdf0e10cSrcweir mpImpl->addMouseHandler( 998*cdf0e10cSrcweir mpImpl->maMouseMoveHandlers, 999*cdf0e10cSrcweir rHandler, 1000*cdf0e10cSrcweir nPriority, 1001*cdf0e10cSrcweir mpImpl->maMouseMoveHandlers.isEmpty() 1002*cdf0e10cSrcweir ? &presentation::XSlideShowView::addMouseMotionListener 1003*cdf0e10cSrcweir : NULL ); 1004*cdf0e10cSrcweir } 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir void EventMultiplexer::removeMouseMoveHandler( 1007*cdf0e10cSrcweir const MouseEventHandlerSharedPtr& rHandler ) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir mpImpl->maMouseMoveHandlers.remove( 1010*cdf0e10cSrcweir EventMultiplexerImpl::ImplMouseHandlers::container_type::value_type( 1011*cdf0e10cSrcweir rHandler, 1012*cdf0e10cSrcweir 0.0) ); 1013*cdf0e10cSrcweir 1014*cdf0e10cSrcweir if( mpImpl->maMouseMoveHandlers.isEmpty() ) 1015*cdf0e10cSrcweir mpImpl->forEachView( 1016*cdf0e10cSrcweir &presentation::XSlideShowView::removeMouseMotionListener ); 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir void EventMultiplexer::addHyperlinkHandler( const HyperlinkHandlerSharedPtr& rHandler, 1020*cdf0e10cSrcweir double nPriority ) 1021*cdf0e10cSrcweir { 1022*cdf0e10cSrcweir mpImpl->maHyperlinkHandlers.addSorted( 1023*cdf0e10cSrcweir EventMultiplexerImpl::ImplHyperLinkHandlers::container_type::value_type( 1024*cdf0e10cSrcweir rHandler, 1025*cdf0e10cSrcweir nPriority) ); 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir void EventMultiplexer::removeHyperlinkHandler( const HyperlinkHandlerSharedPtr& rHandler ) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir mpImpl->maHyperlinkHandlers.remove( 1031*cdf0e10cSrcweir EventMultiplexerImpl::ImplHyperLinkHandlers::container_type::value_type( 1032*cdf0e10cSrcweir rHandler, 1033*cdf0e10cSrcweir 0.0) ); 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir bool EventMultiplexer::notifyShapeListenerAdded( 1037*cdf0e10cSrcweir const uno::Reference<presentation::XShapeEventListener>& xListener, 1038*cdf0e10cSrcweir const uno::Reference<drawing::XShape>& xShape ) 1039*cdf0e10cSrcweir { 1040*cdf0e10cSrcweir return mpImpl->maShapeListenerHandlers.applyAll( 1041*cdf0e10cSrcweir boost::bind(&ShapeListenerEventHandler::listenerAdded, 1042*cdf0e10cSrcweir _1, 1043*cdf0e10cSrcweir boost::cref(xListener), 1044*cdf0e10cSrcweir boost::cref(xShape)) ); 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir bool EventMultiplexer::notifyShapeListenerRemoved( 1048*cdf0e10cSrcweir const uno::Reference<presentation::XShapeEventListener>& xListener, 1049*cdf0e10cSrcweir const uno::Reference<drawing::XShape>& xShape ) 1050*cdf0e10cSrcweir { 1051*cdf0e10cSrcweir return mpImpl->maShapeListenerHandlers.applyAll( 1052*cdf0e10cSrcweir boost::bind(&ShapeListenerEventHandler::listenerRemoved, 1053*cdf0e10cSrcweir _1, 1054*cdf0e10cSrcweir boost::cref(xListener), 1055*cdf0e10cSrcweir boost::cref(xShape)) ); 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir bool EventMultiplexer::notifyShapeCursorChange( 1059*cdf0e10cSrcweir const uno::Reference<drawing::XShape>& xShape, 1060*cdf0e10cSrcweir sal_Int16 nPointerShape ) 1061*cdf0e10cSrcweir { 1062*cdf0e10cSrcweir return mpImpl->maShapeCursorHandlers.applyAll( 1063*cdf0e10cSrcweir boost::bind(&ShapeCursorEventHandler::cursorChanged, 1064*cdf0e10cSrcweir _1, 1065*cdf0e10cSrcweir boost::cref(xShape), 1066*cdf0e10cSrcweir nPointerShape)); 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir bool EventMultiplexer::notifyUserPaintColor( RGBColor const& rUserColor ) 1070*cdf0e10cSrcweir { 1071*cdf0e10cSrcweir return mpImpl->maUserPaintEventHandlers.applyAll( 1072*cdf0e10cSrcweir boost::bind(&UserPaintEventHandler::colorChanged, 1073*cdf0e10cSrcweir _1, 1074*cdf0e10cSrcweir boost::cref(rUserColor))); 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir 1077*cdf0e10cSrcweir bool EventMultiplexer::notifyUserPaintStrokeWidth( double rUserStrokeWidth ) 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir return mpImpl->maUserPaintEventHandlers.applyAll( 1080*cdf0e10cSrcweir boost::bind(&UserPaintEventHandler::widthChanged, 1081*cdf0e10cSrcweir _1, 1082*cdf0e10cSrcweir rUserStrokeWidth)); 1083*cdf0e10cSrcweir } 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir bool EventMultiplexer::notifyUserPaintDisabled() 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir return mpImpl->maUserPaintEventHandlers.applyAll( 1088*cdf0e10cSrcweir boost::mem_fn(&UserPaintEventHandler::disable)); 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir bool EventMultiplexer::notifySwitchPenMode(){ 1092*cdf0e10cSrcweir return mpImpl->maUserPaintEventHandlers.applyAll( 1093*cdf0e10cSrcweir boost::mem_fn(&UserPaintEventHandler::switchPenMode)); 1094*cdf0e10cSrcweir } 1095*cdf0e10cSrcweir 1096*cdf0e10cSrcweir bool EventMultiplexer::notifySwitchEraserMode(){ 1097*cdf0e10cSrcweir return mpImpl->maUserPaintEventHandlers.applyAll( 1098*cdf0e10cSrcweir boost::mem_fn(&UserPaintEventHandler::switchEraserMode)); 1099*cdf0e10cSrcweir } 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir //adding erasing all ink features with UserPaintOverlay 1102*cdf0e10cSrcweir bool EventMultiplexer::notifyEraseAllInk( bool const& rEraseAllInk ) 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir return mpImpl->maUserPaintEventHandlers.applyAll( 1105*cdf0e10cSrcweir boost::bind(&UserPaintEventHandler::eraseAllInkChanged, 1106*cdf0e10cSrcweir _1, 1107*cdf0e10cSrcweir boost::cref(rEraseAllInk))); 1108*cdf0e10cSrcweir } 1109*cdf0e10cSrcweir 1110*cdf0e10cSrcweir //adding erasing features with UserPaintOverlay 1111*cdf0e10cSrcweir bool EventMultiplexer::notifyEraseInkWidth( sal_Int32 rEraseInkSize ) 1112*cdf0e10cSrcweir { 1113*cdf0e10cSrcweir return mpImpl->maUserPaintEventHandlers.applyAll( 1114*cdf0e10cSrcweir boost::bind(&UserPaintEventHandler::eraseInkWidthChanged, 1115*cdf0e10cSrcweir _1, 1116*cdf0e10cSrcweir boost::cref(rEraseInkSize))); 1117*cdf0e10cSrcweir } 1118*cdf0e10cSrcweir 1119*cdf0e10cSrcweir bool EventMultiplexer::notifyNextEffect() 1120*cdf0e10cSrcweir { 1121*cdf0e10cSrcweir return mpImpl->notifyNextEffect(); 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir bool EventMultiplexer::notifySlideStartEvent() 1125*cdf0e10cSrcweir { 1126*cdf0e10cSrcweir return mpImpl->maSlideStartHandlers.applyAll( 1127*cdf0e10cSrcweir boost::mem_fn(&EventHandler::handleEvent) ); 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir bool EventMultiplexer::notifySlideEndEvent() 1131*cdf0e10cSrcweir { 1132*cdf0e10cSrcweir return mpImpl->maSlideEndHandlers.applyAll( 1133*cdf0e10cSrcweir boost::mem_fn(&EventHandler::handleEvent) ); 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir 1136*cdf0e10cSrcweir bool EventMultiplexer::notifyAnimationStart( 1137*cdf0e10cSrcweir const AnimationNodeSharedPtr& rNode ) 1138*cdf0e10cSrcweir { 1139*cdf0e10cSrcweir return mpImpl->notifyAllAnimationHandlers( mpImpl->maAnimationStartHandlers, 1140*cdf0e10cSrcweir rNode ); 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir bool EventMultiplexer::notifyAnimationEnd( 1144*cdf0e10cSrcweir const AnimationNodeSharedPtr& rNode ) 1145*cdf0e10cSrcweir { 1146*cdf0e10cSrcweir return mpImpl->notifyAllAnimationHandlers( mpImpl->maAnimationEndHandlers, 1147*cdf0e10cSrcweir rNode ); 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir 1150*cdf0e10cSrcweir bool EventMultiplexer::notifySlideAnimationsEnd() 1151*cdf0e10cSrcweir { 1152*cdf0e10cSrcweir return mpImpl->maSlideAnimationsEndHandlers.applyAll( 1153*cdf0e10cSrcweir boost::mem_fn(&EventHandler::handleEvent)); 1154*cdf0e10cSrcweir } 1155*cdf0e10cSrcweir 1156*cdf0e10cSrcweir bool EventMultiplexer::notifyAudioStopped( 1157*cdf0e10cSrcweir const AnimationNodeSharedPtr& rNode ) 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir return mpImpl->notifyAllAnimationHandlers( 1160*cdf0e10cSrcweir mpImpl->maAudioStoppedHandlers, 1161*cdf0e10cSrcweir rNode ); 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir bool EventMultiplexer::notifyCommandStopAudio( 1165*cdf0e10cSrcweir const AnimationNodeSharedPtr& rNode ) 1166*cdf0e10cSrcweir { 1167*cdf0e10cSrcweir return mpImpl->notifyAllAnimationHandlers( 1168*cdf0e10cSrcweir mpImpl->maCommandStopAudioHandlers, 1169*cdf0e10cSrcweir rNode ); 1170*cdf0e10cSrcweir } 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir bool EventMultiplexer::notifyPauseMode( bool bPauseShow ) 1173*cdf0e10cSrcweir { 1174*cdf0e10cSrcweir return mpImpl->maPauseHandlers.applyAll( 1175*cdf0e10cSrcweir boost::bind( &PauseEventHandler::handlePause, 1176*cdf0e10cSrcweir _1, bPauseShow )); 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir 1179*cdf0e10cSrcweir bool EventMultiplexer::notifyViewAdded( const UnoViewSharedPtr& rView ) 1180*cdf0e10cSrcweir { 1181*cdf0e10cSrcweir ENSURE_OR_THROW( rView, "EventMultiplexer::notifyViewAdded(): Invalid view"); 1182*cdf0e10cSrcweir 1183*cdf0e10cSrcweir // register event listener 1184*cdf0e10cSrcweir uno::Reference<presentation::XSlideShowView> const rUnoView( 1185*cdf0e10cSrcweir rView->getUnoView() ); 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir if( mpImpl->isMouseListenerRegistered() ) 1188*cdf0e10cSrcweir rUnoView->addMouseListener( 1189*cdf0e10cSrcweir mpImpl->mxListener.get() ); 1190*cdf0e10cSrcweir 1191*cdf0e10cSrcweir if( !mpImpl->maMouseMoveHandlers.isEmpty() ) 1192*cdf0e10cSrcweir rUnoView->addMouseMotionListener( 1193*cdf0e10cSrcweir mpImpl->mxListener.get() ); 1194*cdf0e10cSrcweir 1195*cdf0e10cSrcweir return mpImpl->maViewHandlers.applyAll( 1196*cdf0e10cSrcweir boost::bind( &ViewEventHandler::viewAdded, 1197*cdf0e10cSrcweir _1, 1198*cdf0e10cSrcweir boost::cref(rView) )); 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir bool EventMultiplexer::notifyViewRemoved( const UnoViewSharedPtr& rView ) 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir ENSURE_OR_THROW( rView, 1204*cdf0e10cSrcweir "EventMultiplexer::removeView(): Invalid view" ); 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir // revoke event listeners 1207*cdf0e10cSrcweir uno::Reference<presentation::XSlideShowView> const rUnoView( 1208*cdf0e10cSrcweir rView->getUnoView() ); 1209*cdf0e10cSrcweir 1210*cdf0e10cSrcweir if( mpImpl->isMouseListenerRegistered() ) 1211*cdf0e10cSrcweir rUnoView->removeMouseListener( 1212*cdf0e10cSrcweir mpImpl->mxListener.get() ); 1213*cdf0e10cSrcweir 1214*cdf0e10cSrcweir if( !mpImpl->maMouseMoveHandlers.isEmpty() ) 1215*cdf0e10cSrcweir rUnoView->removeMouseMotionListener( 1216*cdf0e10cSrcweir mpImpl->mxListener.get() ); 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir return mpImpl->maViewHandlers.applyAll( 1219*cdf0e10cSrcweir boost::bind( &ViewEventHandler::viewRemoved, 1220*cdf0e10cSrcweir _1, 1221*cdf0e10cSrcweir boost::cref(rView) )); 1222*cdf0e10cSrcweir } 1223*cdf0e10cSrcweir 1224*cdf0e10cSrcweir bool EventMultiplexer::notifyViewChanged( const UnoViewSharedPtr& rView ) 1225*cdf0e10cSrcweir { 1226*cdf0e10cSrcweir return mpImpl->maViewHandlers.applyAll( 1227*cdf0e10cSrcweir boost::bind( &ViewEventHandler::viewChanged, 1228*cdf0e10cSrcweir _1, 1229*cdf0e10cSrcweir boost::cref(rView) )); 1230*cdf0e10cSrcweir } 1231*cdf0e10cSrcweir 1232*cdf0e10cSrcweir bool EventMultiplexer::notifyViewChanged( const uno::Reference<presentation::XSlideShowView>& xView ) 1233*cdf0e10cSrcweir { 1234*cdf0e10cSrcweir UnoViewSharedPtr pView( mpImpl->findUnoView(xView) ); 1235*cdf0e10cSrcweir 1236*cdf0e10cSrcweir if( !pView ) 1237*cdf0e10cSrcweir return false; // view not registered here 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir return notifyViewChanged( pView ); 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir bool EventMultiplexer::notifyViewsChanged() 1243*cdf0e10cSrcweir { 1244*cdf0e10cSrcweir return mpImpl->maViewHandlers.applyAll( 1245*cdf0e10cSrcweir boost::mem_fn( &ViewEventHandler::viewsChanged )); 1246*cdf0e10cSrcweir } 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir bool EventMultiplexer::notifyViewClobbered( 1249*cdf0e10cSrcweir const uno::Reference<presentation::XSlideShowView>& xView ) 1250*cdf0e10cSrcweir { 1251*cdf0e10cSrcweir UnoViewSharedPtr pView( mpImpl->findUnoView(xView) ); 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir if( !pView ) 1254*cdf0e10cSrcweir return false; // view not registered here 1255*cdf0e10cSrcweir 1256*cdf0e10cSrcweir return mpImpl->maViewRepaintHandlers.applyAll( 1257*cdf0e10cSrcweir boost::bind( &ViewRepaintHandler::viewClobbered, 1258*cdf0e10cSrcweir _1, 1259*cdf0e10cSrcweir boost::cref(pView) )); 1260*cdf0e10cSrcweir } 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir bool EventMultiplexer::notifyHyperlinkClicked( 1263*cdf0e10cSrcweir rtl::OUString const& hyperLink ) 1264*cdf0e10cSrcweir { 1265*cdf0e10cSrcweir return mpImpl->maHyperlinkHandlers.apply( 1266*cdf0e10cSrcweir boost::bind(&HyperlinkHandler::handleHyperlink, 1267*cdf0e10cSrcweir _1, 1268*cdf0e10cSrcweir boost::cref(hyperLink)) ); 1269*cdf0e10cSrcweir } 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir bool EventMultiplexer::notifySlideTransitionStarted() 1272*cdf0e10cSrcweir { 1273*cdf0e10cSrcweir return true; 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir } // namespace internal 1277*cdf0e10cSrcweir } // namespace presentation 1278*cdf0e10cSrcweir 1279