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