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