1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SOURCE_HXX_ 25 #define _SOURCE_HXX_ 26 27 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> 28 #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp> 29 #include <com/sun/star/lang/XInitialization.hpp> 30 #ifndef _OSL_MUTEX_H_ 31 #include <osl/mutex.hxx> 32 #endif 33 #ifndef _CPPUHELPER_COMPBASE2_HXX_ 34 #include <cppuhelper/compbase3.hxx> 35 #endif 36 #include <com/sun/star/lang/XServiceInfo.hpp> 37 #include "../../inc/DtObjFactory.hxx" 38 #include "globals.hxx" 39 #include <oleidl.h> 40 41 #include <systools/win32/comtools.hxx> 42 43 using namespace ::com::sun::star::lang; 44 using namespace ::com::sun::star::uno; 45 using namespace cppu; 46 using namespace osl; 47 using namespace rtl; 48 using namespace ::com::sun::star::datatransfer; 49 using namespace ::com::sun::star::datatransfer::dnd; 50 51 52 53 class SourceContext; 54 // RIGHT MOUSE BUTTON drag and drop not supported currently. 55 // ALT modifier is considered to effect a user selection of effects 56 class DragSource: 57 public MutexDummy, 58 public WeakComponentImplHelper3<XDragSource, XInitialization, XServiceInfo>, 59 public IDropSource 60 61 { 62 Reference<XMultiServiceFactory> m_serviceFactory; 63 HWND m_hAppWindow; 64 65 // The mouse button that set off the drag and drop operation 66 short m_MouseButton; 67 // Converts XTransferable objects to IDataObject objects. 68 CDTransObjFactory m_aDataConverter; 69 70 DragSource(); 71 DragSource(const DragSource&); 72 DragSource &operator= ( const DragSource&); 73 74 // First starting a new drag and drop thread if 75 // the last one has finished 76 void StartDragImpl( 77 const DragGestureEvent& trigger, 78 sal_Int8 sourceActions, 79 sal_Int32 cursor, 80 sal_Int32 image, 81 const Reference<XTransferable >& trans, 82 const Reference<XDragSourceListener >& listener); 83 84 public: 85 long m_RunningDndOperationCount; 86 87 public: 88 // only valid for one dnd operation 89 // the thread ID of the thread which created the window 90 DWORD m_threadIdWindow; 91 // The context notifies the XDragSourceListener s 92 Reference<XDragSourceContext> m_currentContext; 93 94 // the wrapper for the Transferable ( startDrag) 95 IDataObjectPtr m_spDataObject; 96 97 sal_Int8 m_sourceActions; 98 99 public: 100 DragSource(const Reference<XMultiServiceFactory>& sf); 101 virtual ~DragSource(); 102 103 // XInitialization 104 virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ); 105 106 107 // XDragSource 108 virtual sal_Bool SAL_CALL isDragImageSupported( ); 109 virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ); 110 virtual void SAL_CALL startDrag( const DragGestureEvent& trigger, 111 sal_Int8 sourceActions, 112 sal_Int32 cursor, 113 sal_Int32 image, 114 const Reference<XTransferable >& trans, 115 const Reference<XDragSourceListener >& listener ); 116 117 // XServiceInfo 118 virtual OUString SAL_CALL getImplementationName( ); 119 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ); 120 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ); 121 122 123 124 virtual HRESULT STDMETHODCALLTYPE QueryInterface( 125 /* [in] */ REFIID riid, 126 /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 127 128 virtual ULONG STDMETHODCALLTYPE AddRef( ); 129 130 virtual ULONG STDMETHODCALLTYPE Release( ); 131 132 133 // IDropSource 134 virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( 135 /* [in] */ BOOL fEscapePressed, 136 /* [in] */ DWORD grfKeyState); 137 138 virtual HRESULT STDMETHODCALLTYPE GiveFeedback( 139 /* [in] */ DWORD dwEffect); 140 141 }; 142 143 144 #endif 145