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 _XNOTIFYINGDATAOBJECT_HXX_
26 #define _XNOTIFYINGDATAOBJECT_HXX_
27 
28 
29 //------------------------------------------------------------------------
30 // includes
31 //------------------------------------------------------------------------
32 
33 #include <com/sun/star/datatransfer/XTransferable.hpp>
34 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
35 
36 #if defined _MSC_VER
37 #pragma warning(push,1)
38 #endif
39 #include <objidl.h>
40 #include <windows.h>
41 #if defined _MSC_VER
42 #pragma warning(pop)
43 #endif
44 
45 #include <systools/win32/comtools.hxx>
46 
47 /*--------------------------------------------------------------------------
48 	To implement the lostOwnership mechanism cleanly we need this wrapper
49 	object
50 ----------------------------------------------------------------------------*/
51 
52 // forward
53 class CWinClipbImpl;
54 
55 class CXNotifyingDataObject : public IDataObject
56 {
57 public:
58 	CXNotifyingDataObject(
59 		const IDataObjectPtr& aIDataObject,
60 		const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable,
61 		const com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner >& aXClipOwner,
62 		CWinClipbImpl* theWinClipImpl );
63 
~CXNotifyingDataObject()64     virtual ~CXNotifyingDataObject() {}
65 
66 	//-----------------------------------------------------------------
67 	// ole interface implementation
68 	//-----------------------------------------------------------------
69 
70     //IUnknown interface methods
71     STDMETHODIMP           QueryInterface(REFIID iid, LPVOID* ppvObject);
72     STDMETHODIMP_( ULONG ) AddRef( );
73     STDMETHODIMP_( ULONG ) Release( );
74 
75     // IDataObject interface methods
76     STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
77     STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
78     STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
79     STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
80     STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
81     STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
82     STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
83     STDMETHODIMP DUnadvise( DWORD dwConnection );
84     STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
85 
86 	operator IDataObject*( );
87 
88 private:
89 	void SAL_CALL lostOwnership( );
90 
91 private:
92 	sal_Int32																							m_nRefCnt;
93 	IDataObjectPtr																						m_aIDataObject;
94 	const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >					m_XTransferable;
95 	const com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner >	m_XClipboardOwner;
96 	CWinClipbImpl*																						m_pWinClipImpl;
97 
98 	friend class CWinClipbImpl;
99 };
100 
101 #endif
102