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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dtrans.hxx"
26 #include "idroptarget.hxx"
27 #include <rtl/unload.h>
28 
29 #ifdef __MINGW32__
30 #define __uuidof(I) IID_##I
31 #endif
32 
33 extern rtl_StandardModuleCount g_moduleCount;
34 
IDropTargetImpl(DropTarget & pTarget)35 IDropTargetImpl::IDropTargetImpl( DropTarget& pTarget): m_nRefCount( 0),
36                                     m_rDropTarget( pTarget)
37 {
38 	g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
39 }
40 
~IDropTargetImpl()41 IDropTargetImpl::~IDropTargetImpl()
42 {
43 	g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
44 }
45 
46 
47 //IDropTarget
QueryInterface(REFIID riid,void ** ppvObject)48 HRESULT STDMETHODCALLTYPE IDropTargetImpl::QueryInterface( REFIID riid, void  **ppvObject)
49 {
50 	if( !ppvObject)
51 		return E_POINTER;
52 	*ppvObject= NULL;
53 
54 	if( riid == __uuidof( IUnknown))
55 		*ppvObject= static_cast<IUnknown*>( this);
56 	else if (  riid == __uuidof( IDropTarget))
57 		*ppvObject= static_cast<IDropTarget*>( this);
58 
59 	if(*ppvObject)
60 	{
61 		AddRef();
62 		return S_OK;
63 	}
64 	else
65 		return E_NOINTERFACE;
66 
67 }
68 
AddRef(void)69 ULONG STDMETHODCALLTYPE IDropTargetImpl::AddRef( void)
70 {
71     return InterlockedIncrement( &m_nRefCount);
72 }
73 
Release(void)74 ULONG STDMETHODCALLTYPE IDropTargetImpl::Release( void)
75 {
76     LONG count= InterlockedDecrement( &m_nRefCount);
77     if( m_nRefCount == 0 )
78         delete this;
79 	return count;
80 }
81 
DragEnter(IDataObject __RPC_FAR * pDataObj,DWORD grfKeyState,POINTL pt,DWORD * pdwEffect)82 STDMETHODIMP IDropTargetImpl::DragEnter( IDataObject __RPC_FAR *pDataObj,
83 									DWORD grfKeyState,
84 									POINTL pt,
85 									DWORD  *pdwEffect)
86 {
87     return m_rDropTarget.DragEnter( pDataObj, grfKeyState,
88                                   pt, pdwEffect);
89 }
90 
DragOver(DWORD grfKeyState,POINTL pt,DWORD * pdwEffect)91 STDMETHODIMP IDropTargetImpl::DragOver( DWORD grfKeyState,
92 								   POINTL pt,
93 								   DWORD  *pdwEffect)
94 {
95     return m_rDropTarget.DragOver( grfKeyState, pt, pdwEffect);
96 }
97 
DragLeave(void)98 STDMETHODIMP IDropTargetImpl::DragLeave( void)
99 {
100     return m_rDropTarget.DragLeave();
101 }
102 
Drop(IDataObject * pDataObj,DWORD grfKeyState,POINTL pt,DWORD __RPC_FAR * pdwEffect)103 STDMETHODIMP IDropTargetImpl::Drop( IDataObject  *pDataObj,
104 				   DWORD grfKeyState,
105 				   POINTL pt,
106 				   DWORD __RPC_FAR *pdwEffect)
107 {
108     return m_rDropTarget.Drop( pDataObj, grfKeyState,
109                                    pt, pdwEffect);
110 }
111