1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <dndevdis.hxx> 28cdf0e10cSrcweir #include <dndlcon.hxx> 29cdf0e10cSrcweir #include <window.h> 30cdf0e10cSrcweir #include <svdata.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <vos/mutex.hxx> 33cdf0e10cSrcweir #include <vcl/svapp.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir using namespace ::osl; 36cdf0e10cSrcweir using namespace ::vos; 37cdf0e10cSrcweir using namespace ::cppu; 38cdf0e10cSrcweir using namespace ::com::sun::star::uno; 39cdf0e10cSrcweir using namespace ::com::sun::star::lang; 40cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer; 41cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::dnd; 42cdf0e10cSrcweir 43cdf0e10cSrcweir //================================================================================================== 44cdf0e10cSrcweir // DNDEventDispatcher::DNDEventDispatcher 45cdf0e10cSrcweir //================================================================================================== 46cdf0e10cSrcweir 47cdf0e10cSrcweir DNDEventDispatcher::DNDEventDispatcher( Window * pTopWindow ): 48cdf0e10cSrcweir m_pTopWindow( pTopWindow ), 49cdf0e10cSrcweir m_pCurrentWindow( NULL ) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir //================================================================================================== 54cdf0e10cSrcweir // DNDEventDispatcher::~DNDEventDispatcher 55cdf0e10cSrcweir //================================================================================================== 56cdf0e10cSrcweir 57cdf0e10cSrcweir DNDEventDispatcher::~DNDEventDispatcher() 58cdf0e10cSrcweir { 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir //================================================================================================== 62cdf0e10cSrcweir // DNDEventDispatcher::drop 63cdf0e10cSrcweir //================================================================================================== 64cdf0e10cSrcweir 65cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::drop( const DropTargetDropEvent& dtde ) 66cdf0e10cSrcweir throw(RuntimeException) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir MutexGuard aImplGuard( m_aMutex ); 69cdf0e10cSrcweir 70cdf0e10cSrcweir Point location( dtde.LocationX, dtde.LocationY ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir // find the window that is toplevel for this coordinates 73cdf0e10cSrcweir OClearableGuard aSolarGuard( Application::GetSolarMutex() ); 74cdf0e10cSrcweir 75cdf0e10cSrcweir // because those coordinates come from outside, they must be mirrored if RTL layout is active 76cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 77cdf0e10cSrcweir m_pTopWindow->ImplMirrorFramePos( location ); 78cdf0e10cSrcweir Window * pChildWindow = m_pTopWindow->ImplFindWindow( location ); 79cdf0e10cSrcweir 80cdf0e10cSrcweir if( NULL == pChildWindow ) 81cdf0e10cSrcweir pChildWindow = m_pTopWindow; 82cdf0e10cSrcweir 83cdf0e10cSrcweir while( pChildWindow->ImplGetClientWindow() ) 84cdf0e10cSrcweir pChildWindow = pChildWindow->ImplGetClientWindow(); 85cdf0e10cSrcweir 86cdf0e10cSrcweir if( pChildWindow->ImplIsAntiparallel() ) 87cdf0e10cSrcweir pChildWindow->ImplReMirror( location ); 88cdf0e10cSrcweir 89cdf0e10cSrcweir aSolarGuard.clear(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir // handle the case that drop is in an other vcl window than the last dragOver 92cdf0e10cSrcweir if( pChildWindow != m_pCurrentWindow ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir // fire dragExit on listeners of previous window 95cdf0e10cSrcweir fireDragExitEvent( m_pCurrentWindow ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir fireDragEnterEvent( pChildWindow, static_cast < XDropTargetDragContext * > (this), 98cdf0e10cSrcweir dtde.DropAction, location, dtde.SourceActions, m_aDataFlavorList ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir sal_Int32 nListeners = 0; 102cdf0e10cSrcweir 103cdf0e10cSrcweir // send drop event to the child window 104cdf0e10cSrcweir nListeners = fireDropEvent( pChildWindow, dtde.Context, dtde.DropAction, 105cdf0e10cSrcweir location, dtde.SourceActions, dtde.Transferable ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // reject drop if no listeners found 108cdf0e10cSrcweir if( nListeners == 0 ) { 109cdf0e10cSrcweir OSL_TRACE( "rejecting drop due to missing listeners." ); 110cdf0e10cSrcweir dtde.Context->rejectDrop(); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir // this is a drop -> no further drag overs 114cdf0e10cSrcweir m_pCurrentWindow = NULL; 115cdf0e10cSrcweir m_aDataFlavorList.realloc( 0 ); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir //================================================================================================== 119cdf0e10cSrcweir // DNDEventDispatcher::dragEnter 120cdf0e10cSrcweir //================================================================================================== 121cdf0e10cSrcweir 122cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::dragEnter( const DropTargetDragEnterEvent& dtdee ) 123cdf0e10cSrcweir throw(RuntimeException) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir MutexGuard aImplGuard( m_aMutex ); 126cdf0e10cSrcweir Point location( dtdee.LocationX, dtdee.LocationY ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // find the window that is toplevel for this coordinates 129cdf0e10cSrcweir OClearableGuard aSolarGuard( Application::GetSolarMutex() ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir // because those coordinates come from outside, they must be mirrored if RTL layout is active 132cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 133cdf0e10cSrcweir m_pTopWindow->ImplMirrorFramePos( location ); 134cdf0e10cSrcweir Window * pChildWindow = m_pTopWindow->ImplFindWindow( location ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir if( NULL == pChildWindow ) 137cdf0e10cSrcweir pChildWindow = m_pTopWindow; 138cdf0e10cSrcweir 139cdf0e10cSrcweir while( pChildWindow->ImplGetClientWindow() ) 140cdf0e10cSrcweir pChildWindow = pChildWindow->ImplGetClientWindow(); 141cdf0e10cSrcweir 142cdf0e10cSrcweir if( pChildWindow->ImplIsAntiparallel() ) 143cdf0e10cSrcweir pChildWindow->ImplReMirror( location ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir aSolarGuard.clear(); 146cdf0e10cSrcweir 147cdf0e10cSrcweir // assume pointer write operation to be atomic 148cdf0e10cSrcweir m_pCurrentWindow = pChildWindow; 149cdf0e10cSrcweir m_aDataFlavorList = dtdee.SupportedDataFlavors; 150cdf0e10cSrcweir 151cdf0e10cSrcweir // fire dragEnter on listeners of current window 152cdf0e10cSrcweir sal_Int32 nListeners = fireDragEnterEvent( pChildWindow, dtdee.Context, dtdee.DropAction, location, 153cdf0e10cSrcweir dtdee.SourceActions, dtdee.SupportedDataFlavors ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir // reject drag if no listener found 156cdf0e10cSrcweir if( nListeners == 0 ) { 157cdf0e10cSrcweir OSL_TRACE( "rejecting drag enter due to missing listeners." ); 158cdf0e10cSrcweir dtdee.Context->rejectDrag(); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir //================================================================================================== 164cdf0e10cSrcweir // DNDEventDispatcher::dragExit 165cdf0e10cSrcweir //================================================================================================== 166cdf0e10cSrcweir 167cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::dragExit( const DropTargetEvent& /*dte*/ ) 168cdf0e10cSrcweir throw(RuntimeException) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir MutexGuard aImplGuard( m_aMutex ); 171cdf0e10cSrcweir 172cdf0e10cSrcweir fireDragExitEvent( m_pCurrentWindow ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir // reset member values 175cdf0e10cSrcweir m_pCurrentWindow = NULL; 176cdf0e10cSrcweir m_aDataFlavorList.realloc( 0 ); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir //================================================================================================== 180cdf0e10cSrcweir // DNDEventDispatcher::dragOver 181cdf0e10cSrcweir //================================================================================================== 182cdf0e10cSrcweir 183cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::dragOver( const DropTargetDragEvent& dtde ) 184cdf0e10cSrcweir throw(RuntimeException) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir MutexGuard aImplGuard( m_aMutex ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir Point location( dtde.LocationX, dtde.LocationY ); 189cdf0e10cSrcweir sal_Int32 nListeners; 190cdf0e10cSrcweir 191cdf0e10cSrcweir // find the window that is toplevel for this coordinates 192cdf0e10cSrcweir OClearableGuard aSolarGuard( Application::GetSolarMutex() ); 193cdf0e10cSrcweir 194cdf0e10cSrcweir // because those coordinates come from outside, they must be mirrored if RTL layout is active 195cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 196cdf0e10cSrcweir m_pTopWindow->ImplMirrorFramePos( location ); 197cdf0e10cSrcweir Window * pChildWindow = m_pTopWindow->ImplFindWindow( location ); 198cdf0e10cSrcweir 199cdf0e10cSrcweir if( NULL == pChildWindow ) 200cdf0e10cSrcweir pChildWindow = m_pTopWindow; 201cdf0e10cSrcweir 202cdf0e10cSrcweir while( pChildWindow->ImplGetClientWindow() ) 203cdf0e10cSrcweir pChildWindow = pChildWindow->ImplGetClientWindow(); 204cdf0e10cSrcweir 205cdf0e10cSrcweir if( pChildWindow->ImplIsAntiparallel() ) 206cdf0e10cSrcweir pChildWindow->ImplReMirror( location ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir aSolarGuard.clear(); 209cdf0e10cSrcweir 210cdf0e10cSrcweir if( pChildWindow != m_pCurrentWindow ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir // fire dragExit on listeners of previous window 213cdf0e10cSrcweir fireDragExitEvent( m_pCurrentWindow ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir // remember new window 216cdf0e10cSrcweir m_pCurrentWindow = pChildWindow; 217cdf0e10cSrcweir 218cdf0e10cSrcweir // fire dragEnter on listeners of current window 219cdf0e10cSrcweir nListeners = fireDragEnterEvent( pChildWindow, dtde.Context, dtde.DropAction, location, 220cdf0e10cSrcweir dtde.SourceActions, m_aDataFlavorList ); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir else 223cdf0e10cSrcweir { 224cdf0e10cSrcweir // fire dragOver on listeners of current window 225cdf0e10cSrcweir nListeners = fireDragOverEvent( pChildWindow, dtde.Context, dtde.DropAction, location, 226cdf0e10cSrcweir dtde.SourceActions ); 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir // reject drag if no listener found 230cdf0e10cSrcweir if( nListeners == 0 ) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir OSL_TRACE( "rejecting drag over due to missing listeners." ); 233cdf0e10cSrcweir dtde.Context->rejectDrag(); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir //================================================================================================== 238cdf0e10cSrcweir // DNDEventDispatcher::dropActionChanged 239cdf0e10cSrcweir //================================================================================================== 240cdf0e10cSrcweir 241cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::dropActionChanged( const DropTargetDragEvent& dtde ) 242cdf0e10cSrcweir throw(RuntimeException) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir MutexGuard aImplGuard( m_aMutex ); 245cdf0e10cSrcweir 246cdf0e10cSrcweir Point location( dtde.LocationX, dtde.LocationY ); 247cdf0e10cSrcweir sal_Int32 nListeners; 248cdf0e10cSrcweir 249cdf0e10cSrcweir // find the window that is toplevel for this coordinates 250cdf0e10cSrcweir OClearableGuard aSolarGuard( Application::GetSolarMutex() ); 251cdf0e10cSrcweir 252cdf0e10cSrcweir // because those coordinates come from outside, they must be mirrored if RTL layout is active 253cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 254cdf0e10cSrcweir m_pTopWindow->ImplMirrorFramePos( location ); 255cdf0e10cSrcweir Window * pChildWindow = m_pTopWindow->ImplFindWindow( location ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir if( NULL == pChildWindow ) 258cdf0e10cSrcweir pChildWindow = m_pTopWindow; 259cdf0e10cSrcweir 260cdf0e10cSrcweir while( pChildWindow->ImplGetClientWindow() ) 261cdf0e10cSrcweir pChildWindow = pChildWindow->ImplGetClientWindow(); 262cdf0e10cSrcweir 263cdf0e10cSrcweir if( pChildWindow->ImplIsAntiparallel() ) 264cdf0e10cSrcweir pChildWindow->ImplReMirror( location ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir aSolarGuard.clear(); 267cdf0e10cSrcweir 268cdf0e10cSrcweir if( pChildWindow != m_pCurrentWindow ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir // fire dragExit on listeners of previous window 271cdf0e10cSrcweir fireDragExitEvent( m_pCurrentWindow ); 272cdf0e10cSrcweir 273cdf0e10cSrcweir // remember new window 274cdf0e10cSrcweir m_pCurrentWindow = pChildWindow; 275cdf0e10cSrcweir 276cdf0e10cSrcweir // fire dragEnter on listeners of current window 277cdf0e10cSrcweir nListeners = fireDragEnterEvent( pChildWindow, dtde.Context, dtde.DropAction, location, 278cdf0e10cSrcweir dtde.SourceActions, m_aDataFlavorList ); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir else 281cdf0e10cSrcweir { 282cdf0e10cSrcweir // fire dropActionChanged on listeners of current window 283cdf0e10cSrcweir nListeners = fireDropActionChangedEvent( pChildWindow, dtde.Context, dtde.DropAction, location, 284cdf0e10cSrcweir dtde.SourceActions ); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir // reject drag if no listener found 288cdf0e10cSrcweir if( nListeners == 0 ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir OSL_TRACE( "rejecting dropActionChanged due to missing listeners." ); 291cdf0e10cSrcweir dtde.Context->rejectDrag(); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir 296cdf0e10cSrcweir //================================================================================================== 297cdf0e10cSrcweir // DNDEventDispatcher::dragGestureRecognized 298cdf0e10cSrcweir //================================================================================================== 299cdf0e10cSrcweir 300cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::dragGestureRecognized( const DragGestureEvent& dge ) 301cdf0e10cSrcweir throw(RuntimeException) 302cdf0e10cSrcweir { MutexGuard aImplGuard( m_aMutex ); 303cdf0e10cSrcweir 304cdf0e10cSrcweir Point origin( dge.DragOriginX, dge.DragOriginY ); 305cdf0e10cSrcweir 306cdf0e10cSrcweir // find the window that is toplevel for this coordinates 307cdf0e10cSrcweir OClearableGuard aSolarGuard( Application::GetSolarMutex() ); 308cdf0e10cSrcweir 309cdf0e10cSrcweir // because those coordinates come from outside, they must be mirrored if RTL layout is active 310cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 311cdf0e10cSrcweir m_pTopWindow->ImplMirrorFramePos( origin ); 312cdf0e10cSrcweir Window * pChildWindow = m_pTopWindow->ImplFindWindow( origin ); 313cdf0e10cSrcweir 314cdf0e10cSrcweir if( NULL == pChildWindow ) 315cdf0e10cSrcweir pChildWindow = m_pTopWindow; 316cdf0e10cSrcweir 317cdf0e10cSrcweir while( pChildWindow->ImplGetClientWindow() ) 318cdf0e10cSrcweir pChildWindow = pChildWindow->ImplGetClientWindow(); 319cdf0e10cSrcweir 320cdf0e10cSrcweir if( pChildWindow->ImplIsAntiparallel() ) 321cdf0e10cSrcweir pChildWindow->ImplReMirror( origin ); 322cdf0e10cSrcweir 323cdf0e10cSrcweir aSolarGuard.clear(); 324cdf0e10cSrcweir 325cdf0e10cSrcweir fireDragGestureEvent( pChildWindow, dge.DragSource, dge.Event, origin, dge.DragAction ); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir //================================================================================================== 329cdf0e10cSrcweir // DNDEventDispatcher::disposing 330cdf0e10cSrcweir //================================================================================================== 331cdf0e10cSrcweir 332cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::disposing( const EventObject& ) 333cdf0e10cSrcweir throw(RuntimeException) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir //================================================================================================== 338cdf0e10cSrcweir // DNDEventDispatcher::acceptDrag 339cdf0e10cSrcweir //================================================================================================== 340cdf0e10cSrcweir 341cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::acceptDrag( sal_Int8 /*dropAction*/ ) throw(RuntimeException) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir //================================================================================================== 346cdf0e10cSrcweir // DNDEventDispatcher::rejectDrag 347cdf0e10cSrcweir //================================================================================================== 348cdf0e10cSrcweir 349cdf0e10cSrcweir void SAL_CALL DNDEventDispatcher::rejectDrag() throw(RuntimeException) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir //================================================================================================== 354cdf0e10cSrcweir // DNDEventDispatcher::fireDragEnterEvent 355cdf0e10cSrcweir //================================================================================================== 356cdf0e10cSrcweir 357cdf0e10cSrcweir sal_Int32 DNDEventDispatcher::fireDragEnterEvent( Window *pWindow, 358cdf0e10cSrcweir const Reference< XDropTargetDragContext >& xContext, const sal_Int8 nDropAction, 359cdf0e10cSrcweir const Point& rLocation, const sal_Int8 nSourceActions, const Sequence< DataFlavor >& aFlavorList 360cdf0e10cSrcweir ) 361cdf0e10cSrcweir throw(RuntimeException) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir sal_Int32 n = 0; 364cdf0e10cSrcweir 365cdf0e10cSrcweir if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir OClearableGuard aGuard( Application::GetSolarMutex() ); 368cdf0e10cSrcweir 369cdf0e10cSrcweir // set an UI lock 370cdf0e10cSrcweir pWindow->IncrementLockCount(); 371cdf0e10cSrcweir 372cdf0e10cSrcweir // query DropTarget from window 373cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = pWindow->GetDropTarget(); 374cdf0e10cSrcweir 375cdf0e10cSrcweir if( xDropTarget.is() ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir // retrieve relative mouse position 378cdf0e10cSrcweir Point relLoc = pWindow->ImplFrameToOutput( rLocation ); 379cdf0e10cSrcweir aGuard.clear(); 380cdf0e10cSrcweir 381cdf0e10cSrcweir n = static_cast < DNDListenerContainer * > ( xDropTarget.get() )->fireDragEnterEvent( 382cdf0e10cSrcweir xContext, nDropAction, relLoc.X(), relLoc.Y(), nSourceActions, aFlavorList ); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir return n; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir //================================================================================================== 390cdf0e10cSrcweir // DNDEventDispatcher::fireDragOverEvent 391cdf0e10cSrcweir //================================================================================================== 392cdf0e10cSrcweir 393cdf0e10cSrcweir sal_Int32 DNDEventDispatcher::fireDragOverEvent( Window *pWindow, 394cdf0e10cSrcweir const Reference< XDropTargetDragContext >& xContext, const sal_Int8 nDropAction, 395cdf0e10cSrcweir const Point& rLocation, const sal_Int8 nSourceActions 396cdf0e10cSrcweir ) 397cdf0e10cSrcweir throw(RuntimeException) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir sal_Int32 n = 0; 400cdf0e10cSrcweir 401cdf0e10cSrcweir if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir OClearableGuard aGuard( Application::GetSolarMutex() ); 404cdf0e10cSrcweir 405cdf0e10cSrcweir // query DropTarget from window 406cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = pWindow->GetDropTarget(); 407cdf0e10cSrcweir 408cdf0e10cSrcweir if( xDropTarget.is() ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir // retrieve relative mouse position 411cdf0e10cSrcweir Point relLoc = pWindow->ImplFrameToOutput( rLocation ); 412cdf0e10cSrcweir aGuard.clear(); 413cdf0e10cSrcweir 414cdf0e10cSrcweir n = static_cast < DNDListenerContainer * > ( xDropTarget.get() )->fireDragOverEvent( 415cdf0e10cSrcweir xContext, nDropAction, relLoc.X(), relLoc.Y(), nSourceActions ); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir return n; 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir //================================================================================================== 423cdf0e10cSrcweir // DNDEventDispatcher::fireDragExitEvent 424cdf0e10cSrcweir //================================================================================================== 425cdf0e10cSrcweir 426cdf0e10cSrcweir sal_Int32 DNDEventDispatcher::fireDragExitEvent( Window *pWindow ) throw(RuntimeException) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir sal_Int32 n = 0; 429cdf0e10cSrcweir 430cdf0e10cSrcweir if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir OClearableGuard aGuard( Application::GetSolarMutex() ); 433cdf0e10cSrcweir 434cdf0e10cSrcweir // query DropTarget from window 435cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = pWindow->GetDropTarget(); 436cdf0e10cSrcweir 437cdf0e10cSrcweir aGuard.clear(); 438cdf0e10cSrcweir 439cdf0e10cSrcweir if( xDropTarget.is() ) 440cdf0e10cSrcweir n = static_cast < DNDListenerContainer * > ( xDropTarget.get() )->fireDragExitEvent(); 441cdf0e10cSrcweir 442cdf0e10cSrcweir // release UI lock 443cdf0e10cSrcweir pWindow->DecrementLockCount(); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir return n; 447cdf0e10cSrcweir } 448cdf0e10cSrcweir 449cdf0e10cSrcweir //================================================================================================== 450cdf0e10cSrcweir // DNDEventDispatcher::fireDropActionChangedEvent 451cdf0e10cSrcweir //================================================================================================== 452cdf0e10cSrcweir 453cdf0e10cSrcweir sal_Int32 DNDEventDispatcher::fireDropActionChangedEvent( Window *pWindow, 454cdf0e10cSrcweir const Reference< XDropTargetDragContext >& xContext, const sal_Int8 nDropAction, 455cdf0e10cSrcweir const Point& rLocation, const sal_Int8 nSourceActions 456cdf0e10cSrcweir ) 457cdf0e10cSrcweir throw(RuntimeException) 458cdf0e10cSrcweir { 459cdf0e10cSrcweir sal_Int32 n = 0; 460cdf0e10cSrcweir 461cdf0e10cSrcweir if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir OClearableGuard aGuard( Application::GetSolarMutex() ); 464cdf0e10cSrcweir 465cdf0e10cSrcweir // query DropTarget from window 466cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = pWindow->GetDropTarget(); 467cdf0e10cSrcweir 468cdf0e10cSrcweir if( xDropTarget.is() ) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir // retrieve relative mouse position 471cdf0e10cSrcweir Point relLoc = pWindow->ImplFrameToOutput( rLocation ); 472cdf0e10cSrcweir aGuard.clear(); 473cdf0e10cSrcweir 474cdf0e10cSrcweir n = static_cast < DNDListenerContainer * > ( xDropTarget.get() )->fireDropActionChangedEvent( 475cdf0e10cSrcweir xContext, nDropAction, relLoc.X(), relLoc.Y(), nSourceActions ); 476cdf0e10cSrcweir } 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir return n; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir //================================================================================================== 483cdf0e10cSrcweir // DNDEventDispatcher::fireDropEvent 484cdf0e10cSrcweir //================================================================================================== 485cdf0e10cSrcweir 486cdf0e10cSrcweir sal_Int32 DNDEventDispatcher::fireDropEvent( Window *pWindow, 487cdf0e10cSrcweir const Reference< XDropTargetDropContext >& xContext, const sal_Int8 nDropAction, const Point& rLocation, 488cdf0e10cSrcweir const sal_Int8 nSourceActions, const Reference< XTransferable >& xTransferable 489cdf0e10cSrcweir ) 490cdf0e10cSrcweir throw(RuntimeException) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir sal_Int32 n = 0; 493cdf0e10cSrcweir 494cdf0e10cSrcweir if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir OClearableGuard aGuard( Application::GetSolarMutex() ); 497cdf0e10cSrcweir 498cdf0e10cSrcweir // query DropTarget from window 499cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = pWindow->GetDropTarget(); 500cdf0e10cSrcweir 501cdf0e10cSrcweir // window may be destroyed in drop event handler 502cdf0e10cSrcweir ImplDelData aDelData; 503cdf0e10cSrcweir pWindow->ImplAddDel( &aDelData ); 504cdf0e10cSrcweir 505cdf0e10cSrcweir if( xDropTarget.is() ) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir // retrieve relative mouse position 508cdf0e10cSrcweir Point relLoc = pWindow->ImplFrameToOutput( rLocation ); 509cdf0e10cSrcweir aGuard.clear(); 510cdf0e10cSrcweir 511cdf0e10cSrcweir n = static_cast < DNDListenerContainer * > ( xDropTarget.get() )->fireDropEvent( 512cdf0e10cSrcweir xContext, nDropAction, relLoc.X(), relLoc.Y(), nSourceActions, xTransferable ); 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir if ( !aDelData.IsDelete() ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir pWindow->ImplRemoveDel( &aDelData ); 518cdf0e10cSrcweir // release UI lock 519cdf0e10cSrcweir pWindow->DecrementLockCount(); 520cdf0e10cSrcweir } 521cdf0e10cSrcweir 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir return n; 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527cdf0e10cSrcweir //================================================================================================== 528cdf0e10cSrcweir // DNDEventDispatcher::fireDragGestureRecognized 529cdf0e10cSrcweir //================================================================================================== 530cdf0e10cSrcweir 531cdf0e10cSrcweir sal_Int32 DNDEventDispatcher::fireDragGestureEvent( Window *pWindow, 532cdf0e10cSrcweir const Reference< XDragSource >& xSource, const Any event, 533cdf0e10cSrcweir const Point& rOrigin, const sal_Int8 nDragAction 534cdf0e10cSrcweir ) 535cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir sal_Int32 n = 0; 538cdf0e10cSrcweir 539cdf0e10cSrcweir if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir OClearableGuard aGuard( Application::GetSolarMutex() ); 542cdf0e10cSrcweir 543cdf0e10cSrcweir // query DropTarget from window 544cdf0e10cSrcweir Reference< XDragGestureRecognizer > xDragGestureRecognizer = pWindow->GetDragGestureRecognizer(); 545cdf0e10cSrcweir 546cdf0e10cSrcweir if( xDragGestureRecognizer.is() ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir // retrieve relative mouse position 549cdf0e10cSrcweir Point relLoc = pWindow->ImplFrameToOutput( rOrigin ); 550cdf0e10cSrcweir aGuard.clear(); 551cdf0e10cSrcweir 552cdf0e10cSrcweir n = static_cast < DNDListenerContainer * > ( xDragGestureRecognizer.get() )->fireDragGestureEvent( 553cdf0e10cSrcweir nDragAction, relLoc.X(), relLoc.Y(), xSource, event ); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir // release UI lock 557cdf0e10cSrcweir pWindow->DecrementLockCount(); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir return n; 561cdf0e10cSrcweir } 562