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 _APNDATAOBJECT_HXX_
25 #define _APNDATAOBJECT_HXX_
26 
27 #include <systools/win32/comtools.hxx>
28 
29 //------------------------------------------------------------------------
30 // declarations
31 //------------------------------------------------------------------------
32 
33 /*
34 	an APartment Neutral dataobject wrapper; this wrapper of a IDataObject
35 	pointer can be used from any apartment without RPC_E_WRONG_THREAD
36 	which normally occurs if an apartment tries to use an interface
37 	pointer of another apartment; we use containment to hold the original
38 	DataObject
39 */
40 class CAPNDataObject : public IDataObject
41 {
42 public:
43 	CAPNDataObject( IDataObjectPtr rIDataObject );
44 	virtual ~CAPNDataObject( );
45 
46 	//-----------------------------------------------------------------
47 	// IUnknown interface methods
48 	//-----------------------------------------------------------------
49 
50 	STDMETHODIMP           QueryInterface(REFIID iid, LPVOID* ppvObject);
51 	STDMETHODIMP_( ULONG ) AddRef( );
52 	STDMETHODIMP_( ULONG ) Release( );
53 
54 	//-----------------------------------------------------------------
55 	// IDataObject interface methods
56 	//-----------------------------------------------------------------
57 
58 	STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
59 	STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
60 	STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
61 	STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
62 	STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
63 	STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
64 	STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
65 	STDMETHODIMP DUnadvise( DWORD dwConnection );
66 	STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
67 
68 	operator IDataObject*( );
69 
70 private:
71 	HRESULT MarshalIDataObjectIntoCurrentApartment( IDataObject** ppIDataObj );
72 
73 private:
74 	IDataObjectPtr	m_rIDataObjectOrg;
75 	HGLOBAL			m_hGlobal;
76 	LONG			m_nRefCnt;
77 
78 // prevent copy and assignment
79 private:
80 	CAPNDataObject( const CAPNDataObject& theOther );
81 	CAPNDataObject& operator=( const CAPNDataObject& theOther );
82 };
83 
84 #endif
85