1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef _APNDATAOBJECT_HXX_
30 #define _APNDATAOBJECT_HXX_
31 
32 //------------------------------------------------------------------------
33 // deklarations
34 //------------------------------------------------------------------------
35 
36 /*
37 	an APartment Neutral dataobject wrapper; this wrapper of a IDataObject
38 	pointer can be used from any apartment without RPC_E_WRONG_THREAD
39 	which normally occurs if an apartment tries to use an interface
40 	pointer of another apartment; we use containment to hold the original
41 	DataObject
42 */
43 class CAPNDataObject : public IDataObject
44 {
45 public:
46 	CAPNDataObject( IDataObjectPtr rIDataObject );
47 	~CAPNDataObject( );
48 
49 	//-----------------------------------------------------------------
50     //IUnknown interface methods
51 	//-----------------------------------------------------------------
52 
53     STDMETHODIMP           QueryInterface(REFIID iid, LPVOID* ppvObject);
54     STDMETHODIMP_( ULONG ) AddRef( );
55     STDMETHODIMP_( ULONG ) Release( );
56 
57 	//-----------------------------------------------------------------
58     // IDataObject interface methods
59 	//-----------------------------------------------------------------
60 
61     STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
62     STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
63     STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
64     STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
65     STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
66     STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
67     STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
68     STDMETHODIMP DUnadvise( DWORD dwConnection );
69     STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
70 
71 	operator IDataObject*( );
72 
73 private:
74 	HRESULT MarshalIDataObjectIntoCurrentApartment( IDataObject** ppIDataObj );
75 
76 private:
77 	IDataObjectPtr  m_rIDataObjectOrg;
78 	HGLOBAL			m_hGlobal;
79 	LONG			m_nRefCnt;
80 
81 // prevent copy and assignment
82 private:
83 	CAPNDataObject( const CAPNDataObject& theOther );
84 	CAPNDataObject& operator=( const CAPNDataObject& theOther );
85 };
86 
87 #endif
88