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 #ifndef _SOURCE_HXX_ 29*cdf0e10cSrcweir #define _SOURCE_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 34*cdf0e10cSrcweir #ifndef _OSL_MUTEX_H_ 35*cdf0e10cSrcweir #include <osl/mutex.hxx> 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #ifndef _CPPUHELPER_COMPBASE2_HXX_ 38*cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx> 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 41*cdf0e10cSrcweir #include "../../inc/DtObjFactory.hxx" 42*cdf0e10cSrcweir #include "globals.hxx" 43*cdf0e10cSrcweir #include <oleidl.h> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <systools/win32/comtools.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 48*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 49*cdf0e10cSrcweir using namespace cppu; 50*cdf0e10cSrcweir using namespace osl; 51*cdf0e10cSrcweir using namespace rtl; 52*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer; 53*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::dnd; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir class SourceContext; 58*cdf0e10cSrcweir // RIGHT MOUSE BUTTON drag and drop not supportet currently. 59*cdf0e10cSrcweir // ALT modifier is considered to effect a user selection of effects 60*cdf0e10cSrcweir class DragSource: 61*cdf0e10cSrcweir public MutexDummy, 62*cdf0e10cSrcweir public WeakComponentImplHelper3<XDragSource, XInitialization, XServiceInfo>, 63*cdf0e10cSrcweir public IDropSource 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir Reference<XMultiServiceFactory> m_serviceFactory; 67*cdf0e10cSrcweir HWND m_hAppWindow; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir // The mouse button that set off the drag and drop operation 70*cdf0e10cSrcweir short m_MouseButton; 71*cdf0e10cSrcweir // Converts XTransferable objects to IDataObject objects. 72*cdf0e10cSrcweir CDTransObjFactory m_aDataConverter; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir DragSource(); 75*cdf0e10cSrcweir DragSource(const DragSource&); 76*cdf0e10cSrcweir DragSource &operator= ( const DragSource&); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // First starting a new drag and drop thread if 79*cdf0e10cSrcweir // the last one has finished 80*cdf0e10cSrcweir void StartDragImpl( 81*cdf0e10cSrcweir const DragGestureEvent& trigger, 82*cdf0e10cSrcweir sal_Int8 sourceActions, 83*cdf0e10cSrcweir sal_Int32 cursor, 84*cdf0e10cSrcweir sal_Int32 image, 85*cdf0e10cSrcweir const Reference<XTransferable >& trans, 86*cdf0e10cSrcweir const Reference<XDragSourceListener >& listener); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir public: 89*cdf0e10cSrcweir long m_RunningDndOperationCount; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir public: 92*cdf0e10cSrcweir // only valid for one dnd operation 93*cdf0e10cSrcweir // the thread ID of the thread which created the window 94*cdf0e10cSrcweir DWORD m_threadIdWindow; 95*cdf0e10cSrcweir // The context notifies the XDragSourceListener s 96*cdf0e10cSrcweir Reference<XDragSourceContext> m_currentContext; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir // the wrapper for the Transferable ( startDrag) 99*cdf0e10cSrcweir IDataObjectPtr m_spDataObject; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir sal_Int8 m_sourceActions; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir public: 104*cdf0e10cSrcweir DragSource(const Reference<XMultiServiceFactory>& sf); 105*cdf0e10cSrcweir virtual ~DragSource(); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // XInitialization 108*cdf0e10cSrcweir virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) 109*cdf0e10cSrcweir throw(Exception, RuntimeException); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // XDragSource 113*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(RuntimeException); 114*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) 115*cdf0e10cSrcweir throw( IllegalArgumentException, RuntimeException); 116*cdf0e10cSrcweir virtual void SAL_CALL startDrag( const DragGestureEvent& trigger, 117*cdf0e10cSrcweir sal_Int8 sourceActions, 118*cdf0e10cSrcweir sal_Int32 cursor, 119*cdf0e10cSrcweir sal_Int32 image, 120*cdf0e10cSrcweir const Reference<XTransferable >& trans, 121*cdf0e10cSrcweir const Reference<XDragSourceListener >& listener ) 122*cdf0e10cSrcweir throw( RuntimeException); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // XServiceInfo 125*cdf0e10cSrcweir virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); 126*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); 127*cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir virtual HRESULT STDMETHODCALLTYPE QueryInterface( 132*cdf0e10cSrcweir /* [in] */ REFIID riid, 133*cdf0e10cSrcweir /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir virtual ULONG STDMETHODCALLTYPE AddRef( ); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir virtual ULONG STDMETHODCALLTYPE Release( ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir // IDropSource 141*cdf0e10cSrcweir virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( 142*cdf0e10cSrcweir /* [in] */ BOOL fEscapePressed, 143*cdf0e10cSrcweir /* [in] */ DWORD grfKeyState); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir virtual HRESULT STDMETHODCALLTYPE GiveFeedback( 146*cdf0e10cSrcweir /* [in] */ DWORD dwEffect); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir }; 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir #endif 152