1fbcf0fe9SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3fbcf0fe9SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4fbcf0fe9SAndrew Rist * or more contributor license agreements. See the NOTICE file 5fbcf0fe9SAndrew Rist * distributed with this work for additional information 6fbcf0fe9SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7fbcf0fe9SAndrew Rist * to you under the Apache License, Version 2.0 (the 8fbcf0fe9SAndrew Rist * "License"); you may not use this file except in compliance 9fbcf0fe9SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11fbcf0fe9SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13fbcf0fe9SAndrew Rist * Unless required by applicable law or agreed to in writing, 14fbcf0fe9SAndrew Rist * software distributed under the License is distributed on an 15fbcf0fe9SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16fbcf0fe9SAndrew Rist * KIND, either express or implied. See the License for the 17fbcf0fe9SAndrew Rist * specific language governing permissions and limitations 18fbcf0fe9SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20fbcf0fe9SAndrew Rist *************************************************************/ 21fbcf0fe9SAndrew Rist 22fbcf0fe9SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _APNDATAOBJECT_HXX_ 25cdf0e10cSrcweir #define _APNDATAOBJECT_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <systools/win32/comtools.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir //------------------------------------------------------------------------ 30*c58c9863Smseidel // declarations 31cdf0e10cSrcweir //------------------------------------------------------------------------ 32cdf0e10cSrcweir 33cdf0e10cSrcweir /* 34cdf0e10cSrcweir an APartment Neutral dataobject wrapper; this wrapper of a IDataObject 35cdf0e10cSrcweir pointer can be used from any apartment without RPC_E_WRONG_THREAD 36cdf0e10cSrcweir which normally occurs if an apartment tries to use an interface 37cdf0e10cSrcweir pointer of another apartment; we use containment to hold the original 38cdf0e10cSrcweir DataObject 39cdf0e10cSrcweir */ 40cdf0e10cSrcweir class CAPNDataObject : public IDataObject 41cdf0e10cSrcweir { 42cdf0e10cSrcweir public: 43cdf0e10cSrcweir CAPNDataObject( IDataObjectPtr rIDataObject ); 44cdf0e10cSrcweir virtual ~CAPNDataObject( ); 45cdf0e10cSrcweir 46cdf0e10cSrcweir //----------------------------------------------------------------- 47cdf0e10cSrcweir // IUnknown interface methods 48cdf0e10cSrcweir //----------------------------------------------------------------- 49cdf0e10cSrcweir 50cdf0e10cSrcweir STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject); 51cdf0e10cSrcweir STDMETHODIMP_( ULONG ) AddRef( ); 52cdf0e10cSrcweir STDMETHODIMP_( ULONG ) Release( ); 53cdf0e10cSrcweir 54cdf0e10cSrcweir //----------------------------------------------------------------- 55cdf0e10cSrcweir // IDataObject interface methods 56cdf0e10cSrcweir //----------------------------------------------------------------- 57cdf0e10cSrcweir 58cdf0e10cSrcweir STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); 59cdf0e10cSrcweir STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); 60cdf0e10cSrcweir STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc ); 61cdf0e10cSrcweir STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut ); 62cdf0e10cSrcweir STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease ); 63cdf0e10cSrcweir STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc ); 64cdf0e10cSrcweir STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection ); 65cdf0e10cSrcweir STDMETHODIMP DUnadvise( DWORD dwConnection ); 66cdf0e10cSrcweir STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir operator IDataObject*( ); 69cdf0e10cSrcweir 70cdf0e10cSrcweir private: 71cdf0e10cSrcweir HRESULT MarshalIDataObjectIntoCurrentApartment( IDataObject** ppIDataObj ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir private: 74cdf0e10cSrcweir IDataObjectPtr m_rIDataObjectOrg; 75cdf0e10cSrcweir HGLOBAL m_hGlobal; 76cdf0e10cSrcweir LONG m_nRefCnt; 77cdf0e10cSrcweir 78cdf0e10cSrcweir // prevent copy and assignment 79cdf0e10cSrcweir private: 80cdf0e10cSrcweir CAPNDataObject( const CAPNDataObject& theOther ); 81cdf0e10cSrcweir CAPNDataObject& operator=( const CAPNDataObject& theOther ); 82cdf0e10cSrcweir }; 83cdf0e10cSrcweir 84cdf0e10cSrcweir #endif 85