1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SOURCE_HXX_ 29 #define _SOURCE_HXX_ 30 31 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> 32 #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp> 33 #include <com/sun/star/lang/XInitialization.hpp> 34 #ifndef _OSL_MUTEX_H_ 35 #include <osl/mutex.hxx> 36 #endif 37 #ifndef _CPPUHELPER_COMPBASE2_HXX_ 38 #include <cppuhelper/compbase3.hxx> 39 #endif 40 #include <com/sun/star/lang/XServiceInfo.hpp> 41 #include "../../inc/DtObjFactory.hxx" 42 #include "globals.hxx" 43 #include <oleidl.h> 44 45 #include <systools/win32/comtools.hxx> 46 47 using namespace ::com::sun::star::lang; 48 using namespace ::com::sun::star::uno; 49 using namespace cppu; 50 using namespace osl; 51 using namespace rtl; 52 using namespace ::com::sun::star::datatransfer; 53 using namespace ::com::sun::star::datatransfer::dnd; 54 55 56 57 class SourceContext; 58 // RIGHT MOUSE BUTTON drag and drop not supportet currently. 59 // ALT modifier is considered to effect a user selection of effects 60 class DragSource: 61 public MutexDummy, 62 public WeakComponentImplHelper3<XDragSource, XInitialization, XServiceInfo>, 63 public IDropSource 64 65 { 66 Reference<XMultiServiceFactory> m_serviceFactory; 67 HWND m_hAppWindow; 68 69 // The mouse button that set off the drag and drop operation 70 short m_MouseButton; 71 // Converts XTransferable objects to IDataObject objects. 72 CDTransObjFactory m_aDataConverter; 73 74 DragSource(); 75 DragSource(const DragSource&); 76 DragSource &operator= ( const DragSource&); 77 78 // First starting a new drag and drop thread if 79 // the last one has finished 80 void StartDragImpl( 81 const DragGestureEvent& trigger, 82 sal_Int8 sourceActions, 83 sal_Int32 cursor, 84 sal_Int32 image, 85 const Reference<XTransferable >& trans, 86 const Reference<XDragSourceListener >& listener); 87 88 public: 89 long m_RunningDndOperationCount; 90 91 public: 92 // only valid for one dnd operation 93 // the thread ID of the thread which created the window 94 DWORD m_threadIdWindow; 95 // The context notifies the XDragSourceListener s 96 Reference<XDragSourceContext> m_currentContext; 97 98 // the wrapper for the Transferable ( startDrag) 99 IDataObjectPtr m_spDataObject; 100 101 sal_Int8 m_sourceActions; 102 103 public: 104 DragSource(const Reference<XMultiServiceFactory>& sf); 105 virtual ~DragSource(); 106 107 // XInitialization 108 virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) 109 throw(Exception, RuntimeException); 110 111 112 // XDragSource 113 virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(RuntimeException); 114 virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) 115 throw( IllegalArgumentException, RuntimeException); 116 virtual void SAL_CALL startDrag( const DragGestureEvent& trigger, 117 sal_Int8 sourceActions, 118 sal_Int32 cursor, 119 sal_Int32 image, 120 const Reference<XTransferable >& trans, 121 const Reference<XDragSourceListener >& listener ) 122 throw( RuntimeException); 123 124 // XServiceInfo 125 virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); 126 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); 127 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); 128 129 130 131 virtual HRESULT STDMETHODCALLTYPE QueryInterface( 132 /* [in] */ REFIID riid, 133 /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 134 135 virtual ULONG STDMETHODCALLTYPE AddRef( ); 136 137 virtual ULONG STDMETHODCALLTYPE Release( ); 138 139 140 // IDropSource 141 virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( 142 /* [in] */ BOOL fEscapePressed, 143 /* [in] */ DWORD grfKeyState); 144 145 virtual HRESULT STDMETHODCALLTYPE GiveFeedback( 146 /* [in] */ DWORD dwEffect); 147 148 }; 149 150 151 #endif 152