xref: /aoo41x/main/dtrans/source/win32/dnd/source.hxx (revision fbcf0fe9)
1*fbcf0fe9SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*fbcf0fe9SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*fbcf0fe9SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*fbcf0fe9SAndrew Rist  * distributed with this work for additional information
6*fbcf0fe9SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*fbcf0fe9SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*fbcf0fe9SAndrew Rist  * "License"); you may not use this file except in compliance
9*fbcf0fe9SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*fbcf0fe9SAndrew Rist  *
11*fbcf0fe9SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*fbcf0fe9SAndrew Rist  *
13*fbcf0fe9SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*fbcf0fe9SAndrew Rist  * software distributed under the License is distributed on an
15*fbcf0fe9SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*fbcf0fe9SAndrew Rist  * KIND, either express or implied.  See the License for the
17*fbcf0fe9SAndrew Rist  * specific language governing permissions and limitations
18*fbcf0fe9SAndrew Rist  * under the License.
19*fbcf0fe9SAndrew Rist  *
20*fbcf0fe9SAndrew Rist  *************************************************************/
21*fbcf0fe9SAndrew Rist 
22*fbcf0fe9SAndrew 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;
54cdf0e10cSrcweir // RIGHT MOUSE BUTTON drag and drop not supportet 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;
67cdf0e10cSrcweir     // Converts XTransferable objects to IDataObject objects.
68cdf0e10cSrcweir     CDTransObjFactory m_aDataConverter;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	DragSource();
71cdf0e10cSrcweir 	DragSource(const DragSource&);
72cdf0e10cSrcweir 	DragSource &operator= ( const DragSource&);
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     // First starting a new drag and drop thread if
75cdf0e10cSrcweir     // the last one has finished
76cdf0e10cSrcweir     void StartDragImpl(
77cdf0e10cSrcweir         const DragGestureEvent& trigger,
78cdf0e10cSrcweir         sal_Int8 sourceActions,
79cdf0e10cSrcweir         sal_Int32 cursor,
80cdf0e10cSrcweir         sal_Int32 image,
81cdf0e10cSrcweir         const Reference<XTransferable >& trans,
82cdf0e10cSrcweir 		const Reference<XDragSourceListener >& listener);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir public:
85cdf0e10cSrcweir     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 
103cdf0e10cSrcweir   // XInitialization
104cdf0e10cSrcweir     virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
105cdf0e10cSrcweir 		throw(Exception, RuntimeException);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	// XDragSource
109cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isDragImageSupported(  ) throw(RuntimeException);
110cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction )
111cdf0e10cSrcweir 		throw( IllegalArgumentException, RuntimeException);
112cdf0e10cSrcweir     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 
120cdf0e10cSrcweir     // XServiceInfo
121cdf0e10cSrcweir     virtual OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
122cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException);
123cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	virtual HRESULT STDMETHODCALLTYPE QueryInterface(
128cdf0e10cSrcweir             /* [in] */ REFIID riid,
129cdf0e10cSrcweir             /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     virtual ULONG STDMETHODCALLTYPE AddRef( );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     virtual ULONG STDMETHODCALLTYPE Release( );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	// IDropSource
137cdf0e10cSrcweir     virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(
138cdf0e10cSrcweir         /* [in] */ BOOL fEscapePressed,
139cdf0e10cSrcweir         /* [in] */ DWORD grfKeyState);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     virtual HRESULT STDMETHODCALLTYPE GiveFeedback(
142cdf0e10cSrcweir         /* [in] */ DWORD dwEffect);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir };
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir #endif
148