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