fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dtrans / source / win32 / dnd / target.hxx
blob708f21a7e6d310ac1172436c4e00f3a00ea2ee3f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_DTRANS_SOURCE_WIN32_DND_TARGET_HXX
20 #define INCLUDED_DTRANS_SOURCE_WIN32_DND_TARGET_HXX
22 #include <com/sun/star/lang/XInitialization.hpp>
23 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
24 #include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <cppuhelper/compbase3.hxx>
28 #include <cppuhelper/interfacecontainer.hxx>
29 #include <osl/mutex.hxx>
31 #if defined _MSC_VER
32 #pragma warning(push,1)
33 #endif
34 #include <oleidl.h>
35 #if defined _MSC_VER
36 #pragma warning(pop)
37 #endif
38 #include "globals.hxx"
39 #include "../../inc/DtObjFactory.hxx"
41 using namespace ::com::sun::star::lang;
42 using namespace ::com::sun::star::uno;
43 using namespace cppu;
44 using namespace osl;
45 using namespace ::com::sun::star::datatransfer;
46 using namespace ::com::sun::star::datatransfer::dnd;
48 // The client
49 // has to call XComponent::dispose. The thread that calls initialize
50 // must also execute the destruction of the instance. This is because
51 // initialize calls OleInitialize and the destructor calls OleUninitialize.
52 // If the service calls OleInitialize then it also calls OleUnitialize when
53 // it is destroyed. Therefore no second instance may exist which was
54 // created in the same thread and still needs OLE.
55 class DropTarget: public MutexDummy,
56 public WeakComponentImplHelper3< XInitialization, XDropTarget, XServiceInfo>
59 private:
60 friend DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams);
61 // The native window which acts as drop target.
62 // It is set in initialize. In case RegisterDragDrop fails it is set
63 // to NULL
64 HWND m_hWnd; // set by initialize
65 // Holds the thread id of the thread which created the window that is the
66 // drop target. Only used when DropTarget::initialize is called from an MTA
67 // thread
68 DWORD m_threadIdWindow;
69 // This is the thread id of the OLE thread that is created in DropTarget::initialize
70 // when the calling thread is an MTA
71 DWORD m_threadIdTarget;
72 // The handle of the thread that is created in DropTarget::initialize
73 // when the calling thread is an MTA
74 HANDLE m_hOleThread;
75 // The thread id of the thread which called initialize. When the service dies
76 // than m_oleThreadId is used to determine if the service successfully called
77 // OleInitialize. If so then OleUninitialize has to be called.
78 DWORD m_oleThreadId;
79 // An Instance of IDropTargetImpl which receives calls from the system's drag
80 // and drop implementation. It delegate the calls to name alike functions in
81 // this class.
82 IDropTarget* m_pDropTarget;
84 Reference<XComponentContext> m_xContext;
85 // If m_bActive == sal_True then events are fired to XDropTargetListener s,
86 // none otherwise. The default value is sal_True.
87 sal_Bool m_bActive;
88 sal_Int8 m_nDefaultActions;
90 // This value is set when a XDropTargetListener calls accept or reject on
91 // the XDropTargetDropContext or XDropTargetDragContext.
92 // The values are from the DNDConstants group.
93 sal_Int8 m_nCurrentDropAction;
94 // This value is manipulated by the XDropTargetListener
95 sal_Int8 m_nLastDropAction;
97 Reference<XTransferable> m_currentData;
98 // The current action is used to determine if the USER
99 // action has changed (dropActionChanged)
100 // sal_Int8 m_userAction;
101 // Set by listeners when they call XDropTargetDropContext::dropComplete
102 sal_Bool m_bDropComplete;
103 // converts IDataObject objects to XTransferable objects.
104 CDTransObjFactory m_aDataConverter;
105 Reference<XDropTargetDragContext> m_currentDragContext;
106 Reference<XDropTargetDropContext> m_currentDropContext;
108 private:
109 DropTarget();
110 DropTarget(DropTarget&);
111 DropTarget &operator= (DropTarget&);
113 public:
114 DropTarget(const Reference<XComponentContext>& rxContext);
115 virtual ~DropTarget();
117 // Overrides WeakComponentImplHelper::disposing which is called by
118 // WeakComponentImplHelper::dispose
119 // Must be called.
120 virtual void SAL_CALL disposing();
121 // XInitialization
122 virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
123 throw(Exception, RuntimeException);
125 // XDropTarget
126 virtual void SAL_CALL addDropTargetListener( const Reference< XDropTargetListener >& dtl )
127 throw(RuntimeException);
128 virtual void SAL_CALL removeDropTargetListener( const Reference< XDropTargetListener >& dtl )
129 throw(RuntimeException);
130 // Default is not active
131 virtual sal_Bool SAL_CALL isActive( ) throw(RuntimeException);
132 virtual void SAL_CALL setActive( sal_Bool isActive ) throw(RuntimeException);
133 virtual sal_Int8 SAL_CALL getDefaultActions( ) throw(RuntimeException);
134 virtual void SAL_CALL setDefaultActions( sal_Int8 actions ) throw(RuntimeException);
136 // XServiceInfo
137 virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
138 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException);
139 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
141 // Functions called from the IDropTarget implementation ( m_pDropTarget)
142 virtual HRESULT DragEnter(
143 /* [unique][in] */ IDataObject *pDataObj,
144 /* [in] */ DWORD grfKeyState,
145 /* [in] */ POINTL pt,
146 /* [out][in] */ DWORD *pdwEffect);
148 virtual HRESULT STDMETHODCALLTYPE DragOver(
149 /* [in] */ DWORD grfKeyState,
150 /* [in] */ POINTL pt,
151 /* [out][in] */ DWORD *pdwEffect);
153 virtual HRESULT STDMETHODCALLTYPE DragLeave( ) ;
155 virtual HRESULT STDMETHODCALLTYPE Drop(
156 /* [unique][in] */ IDataObject *pDataObj,
157 /* [in] */ DWORD grfKeyState,
158 /* [in] */ POINTL pt,
159 /* [out][in] */ DWORD *pdwEffect);
161 // Non - interface functions --------------------------------------------------
162 // XDropTargetDropContext delegated from DropContext
164 void _acceptDrop( sal_Int8 dropOperation, const Reference<XDropTargetDropContext>& context);
165 void _rejectDrop( const Reference<XDropTargetDropContext>& context);
166 void _dropComplete( sal_Bool success, const Reference<XDropTargetDropContext>& context);
168 // XDropTargetDragContext delegated from DragContext
169 void _acceptDrag( sal_Int8 dragOperation, const Reference<XDropTargetDragContext>& context);
170 void _rejectDrag( const Reference<XDropTargetDragContext>& context);
172 protected:
173 // Gets the current action dependent on the pressed modifiers, the effects
174 // supported by the drop source (IDropSource) and the default actions of the
175 // drop target (XDropTarget, this class))
176 inline sal_Int8 getFilteredActions( DWORD grfKeyState, DWORD sourceActions);
177 // Only filters with the default actions
178 inline sal_Int8 getFilteredActions( DWORD grfKeyState);
180 void fire_drop( const DropTargetDropEvent& dte);
181 void fire_dragEnter( const DropTargetDragEnterEvent& dtde );
182 void fire_dragExit( const DropTargetEvent& dte );
183 void fire_dragOver( const DropTargetDragEvent& dtde );
184 void fire_dropActionChanged( const DropTargetDragEvent& dtde );
188 #endif
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */