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