xref: /aoo42x/main/dtrans/source/win32/dnd/source.hxx (revision 99e632bc)
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 		throw(Exception, RuntimeException);
106 
107 
108 	// XDragSource
109 	virtual sal_Bool SAL_CALL isDragImageSupported(  ) throw(RuntimeException);
110 	virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction )
111 		throw( IllegalArgumentException, RuntimeException);
112 	virtual void SAL_CALL startDrag( const DragGestureEvent& trigger,
113 									 sal_Int8 sourceActions,
114 									 sal_Int32 cursor,
115 									 sal_Int32 image,
116 									 const Reference<XTransferable >& trans,
117 									 const Reference<XDragSourceListener >& listener )
118 				throw( RuntimeException);
119 
120 	// XServiceInfo
121 	virtual OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
122 	virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException);
123 	virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
124 
125 
126 
127 	virtual HRESULT STDMETHODCALLTYPE QueryInterface(
128 			/* [in] */ REFIID riid,
129 			/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
130 
131 	virtual ULONG STDMETHODCALLTYPE AddRef( );
132 
133 	virtual ULONG STDMETHODCALLTYPE Release( );
134 
135 
136 	// IDropSource
137 	virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(
138 		/* [in] */ BOOL fEscapePressed,
139 		/* [in] */ DWORD grfKeyState);
140 
141 	virtual HRESULT STDMETHODCALLTYPE GiveFeedback(
142 		/* [in] */ DWORD dwEffect);
143 
144 };
145 
146 
147 #endif
148