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 #include <vcl/event.hxx> 31*cdf0e10cSrcweir #include <vcl/svapp.hxx> 32*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 33*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 34*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 35*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 36*cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 37*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 38*cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp> 47*cdf0e10cSrcweir #include <vos/process.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <stdio.h> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace ::rtl; 52*cdf0e10cSrcweir using namespace ::vos; 53*cdf0e10cSrcweir using namespace ::com::sun::star::io; 54*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 56*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer; 57*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::clipboard; 58*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::dnd; 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir // ----------------------------------------------------------------------- 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir class MyApp : public Application 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir public: 65*cdf0e10cSrcweir void Main(); 66*cdf0e10cSrcweir }; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir MyApp aMyApp; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // ----------------------------------------------------------------------- 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir class MyWin : public WorkWindow 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir public: 75*cdf0e10cSrcweir MyWin( Window* pParent, WinBits nWinStyle ); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir void MouseMove( const MouseEvent& rMEvt ); 78*cdf0e10cSrcweir void MouseButtonDown( const MouseEvent& rMEvt ); 79*cdf0e10cSrcweir void MouseButtonUp( const MouseEvent& rMEvt ); 80*cdf0e10cSrcweir void KeyInput( const KeyEvent& rKEvt ); 81*cdf0e10cSrcweir void KeyUp( const KeyEvent& rKEvt ); 82*cdf0e10cSrcweir void Paint( const Rectangle& rRect ); 83*cdf0e10cSrcweir void Resize(); 84*cdf0e10cSrcweir }; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // ----------------------------------------------------------------------- 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir class MyDragAndDropListener: public ::cppu::WeakImplHelper3 < XDropTargetListener, XDragGestureListener, XDragSourceListener > 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir Window * m_pWindow; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir public: 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir MyDragAndDropListener( Window * pWindow ) : m_pWindow( pWindow ) {}; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir virtual void SAL_CALL dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException); 97*cdf0e10cSrcweir virtual void SAL_CALL drop( const DropTargetDropEvent& dtde ) throw(RuntimeException); 98*cdf0e10cSrcweir virtual void SAL_CALL dragEnter( const DropTargetDragEnterEvent& dtde ) throw(RuntimeException); 99*cdf0e10cSrcweir virtual void SAL_CALL dragExit( const DropTargetEvent& dte ) throw(RuntimeException); 100*cdf0e10cSrcweir virtual void SAL_CALL dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException); 101*cdf0e10cSrcweir virtual void SAL_CALL dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException); 102*cdf0e10cSrcweir virtual void SAL_CALL dragDropEnd( const DragSourceDropEvent& dsde ) throw(RuntimeException); 103*cdf0e10cSrcweir virtual void SAL_CALL dragEnter( const DragSourceDragEvent& dsdee ) throw(RuntimeException); 104*cdf0e10cSrcweir virtual void SAL_CALL dragExit( const DragSourceEvent& dse ) throw(RuntimeException); 105*cdf0e10cSrcweir virtual void SAL_CALL dragOver( const DragSourceDragEvent& dsde ) throw(RuntimeException); 106*cdf0e10cSrcweir virtual void SAL_CALL dropActionChanged( const DragSourceDragEvent& dsde ) throw(RuntimeException); 107*cdf0e10cSrcweir virtual void SAL_CALL disposing( const EventObject& eo ) throw(RuntimeException); 108*cdf0e10cSrcweir }; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // ----------------------------------------------------------------------- 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir class MyInfoBox : public InfoBox 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir public: 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir MyInfoBox( Window* pParent ); 118*cdf0e10cSrcweir }; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // ----------------------------------------------------------------------- 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir class MyListBox : public ListBox 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir public: 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir MyListBox( Window* pParent ); 128*cdf0e10cSrcweir }; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir // ----------------------------------------------------------------------- 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir class StringTransferable : public ::cppu::WeakImplHelper1< XTransferable > 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir const OUString m_aData; 135*cdf0e10cSrcweir Sequence< DataFlavor > m_aFlavorList; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir public: 138*cdf0e10cSrcweir StringTransferable( const OUString& rString ) : m_aData( rString ), m_aFlavorList( 1 ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir DataFlavor df; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir df.MimeType = OUString::createFromAscii( "text/plain;charset=utf-16" ); 143*cdf0e10cSrcweir df.DataType = getCppuType( static_cast < OUString * > ( 0 ) ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir m_aFlavorList[0] = df; 146*cdf0e10cSrcweir }; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException); 149*cdf0e10cSrcweir virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(RuntimeException); 150*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException); 151*cdf0e10cSrcweir }; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // ----------------------------------------------------------------------- 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir void MyApp::Main() 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir OUString aRegistry; 159*cdf0e10cSrcweir OStartupInfo aInfo; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir for( sal_Int32 n = 0, nmax = aInfo.getCommandArgCount(); n < nmax; n++ ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir OUString aArg; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir aInfo.getCommandArg( n, aArg ); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir if( aArg.compareTo( OUString::createFromAscii( "-r" ), 2 ) == 0 ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir if ( n + 1 < nmax ) 170*cdf0e10cSrcweir aInfo.getCommandArg( ++n, aRegistry ); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir Reference< XMultiServiceFactory > xServiceManager; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir if( aRegistry.getLength() ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir xServiceManager = ::cppu::createRegistryServiceFactory( aRegistry, sal_True ); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir if( xServiceManager.is() ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir ::comphelper::setProcessServiceFactory( xServiceManager ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir if( ! xServiceManager.is() ) 186*cdf0e10cSrcweir printf( "No servicemanager available.\n" ); 187*cdf0e10cSrcweir else 188*cdf0e10cSrcweir printf( "Ok\n" ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir else 192*cdf0e10cSrcweir fprintf( stderr, "Usage: %s -r full-path-to-applicat.rdb\n", "dnddemo" ); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir MyWin aMainWin( NULL, WB_APP | WB_STDWORK ); 196*cdf0e10cSrcweir aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Drag And Drop - Workbench" ) ) ); 197*cdf0e10cSrcweir aMainWin.Show(); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // test the clipboard code 200*cdf0e10cSrcweir Reference< XClipboard > xClipboard = aMainWin.GetClipboard(); 201*cdf0e10cSrcweir if( xClipboard.is() ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir printf( "System clipboard available.\n" ); 204*cdf0e10cSrcweir xClipboard->getContents(); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir else 207*cdf0e10cSrcweir fprintf( stderr, "System clipboard not available.\n" ); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir MyInfoBox aInfoBox( &aMainWin ); 210*cdf0e10cSrcweir aInfoBox.Execute(); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir MyListBox aListBox( &aMainWin ); 213*cdf0e10cSrcweir aListBox.SetPosSizePixel( 10, 10, 100, 100 ); 214*cdf0e10cSrcweir aListBox.InsertEntry( OUString::createFromAscii( "TestItem" )); 215*cdf0e10cSrcweir aListBox.Show(); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir Execute(); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir Reference< XComponent > xComponent( xServiceManager, UNO_QUERY ); 220*cdf0e10cSrcweir if( xComponent.is() ) 221*cdf0e10cSrcweir xComponent->dispose(); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir // ----------------------------------------------------------------------- 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir MyWin::MyWin( Window* pParent, WinBits nWinStyle ) : 228*cdf0e10cSrcweir WorkWindow( pParent, nWinStyle ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir Reference< XDropTargetListener > xListener = new MyDragAndDropListener( this ); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = GetDropTarget(); 233*cdf0e10cSrcweir if( xDropTarget.is() ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir xDropTarget->addDropTargetListener( xListener ); 236*cdf0e10cSrcweir xDropTarget->setActive( sal_True ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir Reference< XDragGestureRecognizer > xRecognizer = GetDragGestureRecognizer(); 240*cdf0e10cSrcweir if( xRecognizer.is() ) 241*cdf0e10cSrcweir xRecognizer->addDragGestureListener( Reference< XDragGestureListener > ( xListener, UNO_QUERY ) ); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir // ----------------------------------------------------------------------- 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir void MyWin::MouseMove( const MouseEvent& rMEvt ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir WorkWindow::MouseMove( rMEvt ); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir // ----------------------------------------------------------------------- 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir void MyWin::MouseButtonDown( const MouseEvent& rMEvt ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir WorkWindow::MouseButtonDown( rMEvt ); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir // ----------------------------------------------------------------------- 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir void MyWin::MouseButtonUp( const MouseEvent& rMEvt ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir WorkWindow::MouseButtonUp( rMEvt ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir // ----------------------------------------------------------------------- 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir void MyWin::KeyInput( const KeyEvent& rKEvt ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir WorkWindow::KeyInput( rKEvt ); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir // ----------------------------------------------------------------------- 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir void MyWin::KeyUp( const KeyEvent& rKEvt ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir WorkWindow::KeyUp( rKEvt ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir // ----------------------------------------------------------------------- 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir void MyWin::Paint( const Rectangle& rRect ) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir WorkWindow::Paint( rRect ); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir // ----------------------------------------------------------------------- 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void MyWin::Resize() 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir WorkWindow::Resize(); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir // ----------------------------------------------------------------------- 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir printf( "XDragGestureListener::dragGestureRecognized called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dge.DragOriginX, dge.DragOriginY ); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir Reference< XDragSource > xDragSource( dge.DragSource, UNO_QUERY ); 300*cdf0e10cSrcweir xDragSource->startDrag( dge, -1, 0, 0, new StringTransferable( OUString::createFromAscii( "TestString" ) ), this ); 301*cdf0e10cSrcweir printf( "XDragSource::startDrag returned.\n" ); 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir // ----------------------------------------------------------------------- 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) throw(RuntimeException) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir printf( "XDropTargetListener::drop called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY ); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir dtde.Context->dropComplete( sal_True ); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir // ----------------------------------------------------------------------- 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent& dtdee ) throw(RuntimeException) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir printf( "XDropTargetListener::dragEnter called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtdee.LocationX, dtdee.LocationY ); 318*cdf0e10cSrcweir dtdee.Context->acceptDrag( dtdee.DropAction ); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // ----------------------------------------------------------------------- 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragExit( const DropTargetEvent& ) throw(RuntimeException) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir printf( "XDropTargetListener::dragExit called ( Window: %p ).\n", m_pWindow ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir // ----------------------------------------------------------------------- 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir printf( "XDropTargetListener::dragOver called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY ); 333*cdf0e10cSrcweir dtde.Context->acceptDrag( dtde.DropAction ); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir // ----------------------------------------------------------------------- 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir printf( "XDropTargetListener::dropActionChanged called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY ); 341*cdf0e10cSrcweir dtde.Context->acceptDrag( dtde.DropAction ); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir // ----------------------------------------------------------------------- 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragDropEnd( const DragSourceDropEvent& dsde ) throw(RuntimeException) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir printf( "XDragSourceListener::dropDropEnd called ( Window: %p, %s ).\n", m_pWindow, dsde.DropSuccess ? "sucess" : "failed" ); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir // ----------------------------------------------------------------------- 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragEnter( const DragSourceDragEvent& ) throw(RuntimeException) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir printf( "XDragSourceListener::dragEnter called ( Window: %p ).\n", m_pWindow ); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // ----------------------------------------------------------------------- 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragExit( const DragSourceEvent& ) throw(RuntimeException) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir printf( "XDragSourceListener::dragExit called ( Window: %p ).\n", m_pWindow ); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir // ----------------------------------------------------------------------- 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragOver( const DragSourceDragEvent& ) throw(RuntimeException) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir printf( "XDragSourceListener::dragOver called ( Window: %p ).\n", m_pWindow ); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir // ----------------------------------------------------------------------- 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dropActionChanged( const DragSourceDragEvent& ) throw(RuntimeException) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir printf( "XDragSourceListener::dropActionChanged called ( Window: %p ).\n", m_pWindow ); 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // ----------------------------------------------------------------------- 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::disposing( const EventObject& ) throw(RuntimeException) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir printf( "XEventListener::disposing called ( Window: %p ).\n", m_pWindow ); 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // ----------------------------------------------------------------------- 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir MyInfoBox::MyInfoBox( Window* pParent ) : InfoBox( pParent, 389*cdf0e10cSrcweir OUString::createFromAscii( "dragging over this box should result in another window id in the drag log." ) ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir Reference< XDropTargetListener > xListener = new MyDragAndDropListener( this ); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = GetDropTarget(); 394*cdf0e10cSrcweir if( xDropTarget.is() ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir xDropTarget->addDropTargetListener( xListener ); 397*cdf0e10cSrcweir xDropTarget->setActive( sal_True ); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir Reference< XDragGestureRecognizer > xRecognizer = GetDragGestureRecognizer(); 401*cdf0e10cSrcweir if( xRecognizer.is() ) 402*cdf0e10cSrcweir xRecognizer->addDragGestureListener( Reference< XDragGestureListener > ( xListener, UNO_QUERY ) ); 403*cdf0e10cSrcweir }; 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir // ----------------------------------------------------------------------- 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir MyListBox::MyListBox( Window* pParent ) : ListBox( pParent ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir Reference< XDropTargetListener > xListener = new MyDragAndDropListener( this ); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir Reference< XDropTarget > xDropTarget = GetDropTarget(); 412*cdf0e10cSrcweir if( xDropTarget.is() ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir xDropTarget->addDropTargetListener( xListener ); 415*cdf0e10cSrcweir xDropTarget->setActive( sal_True ); 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir Reference< XDragGestureRecognizer > xRecognizer = GetDragGestureRecognizer(); 419*cdf0e10cSrcweir if( xRecognizer.is() ) 420*cdf0e10cSrcweir xRecognizer->addDragGestureListener( Reference< XDragGestureListener > ( xListener, UNO_QUERY ) ); 421*cdf0e10cSrcweir }; 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir // ----------------------------------------------------------------------- 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir Any SAL_CALL StringTransferable::getTransferData( const DataFlavor& ) 426*cdf0e10cSrcweir throw(UnsupportedFlavorException, IOException, RuntimeException) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir return makeAny( m_aData ); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir // ----------------------------------------------------------------------- 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir Sequence< DataFlavor > SAL_CALL StringTransferable::getTransferDataFlavors( ) 434*cdf0e10cSrcweir throw(RuntimeException) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir return m_aFlavorList; 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir // ----------------------------------------------------------------------- 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir sal_Bool SAL_CALL StringTransferable::isDataFlavorSupported( const DataFlavor& ) 442*cdf0e10cSrcweir throw(RuntimeException) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir return sal_True; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir 448