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