1*fbcf0fe9SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*fbcf0fe9SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*fbcf0fe9SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*fbcf0fe9SAndrew Rist  * distributed with this work for additional information
6*fbcf0fe9SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*fbcf0fe9SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*fbcf0fe9SAndrew Rist  * "License"); you may not use this file except in compliance
9*fbcf0fe9SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*fbcf0fe9SAndrew Rist  *
11*fbcf0fe9SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*fbcf0fe9SAndrew Rist  *
13*fbcf0fe9SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*fbcf0fe9SAndrew Rist  * software distributed under the License is distributed on an
15*fbcf0fe9SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*fbcf0fe9SAndrew Rist  * KIND, either express or implied.  See the License for the
17*fbcf0fe9SAndrew Rist  * specific language governing permissions and limitations
18*fbcf0fe9SAndrew Rist  * under the License.
19*fbcf0fe9SAndrew Rist  *
20*fbcf0fe9SAndrew Rist  *************************************************************/
21*fbcf0fe9SAndrew Rist 
22*fbcf0fe9SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef _XTDATAOBJECT_HXX_
26cdf0e10cSrcweir #define _XTDATAOBJECT_HXX_
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir // includes
31cdf0e10cSrcweir //------------------------------------------------------------------------
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #if defined _MSC_VER
34cdf0e10cSrcweir #pragma warning(push,1)
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <windows.h>
37cdf0e10cSrcweir #include <ole2.h>
38cdf0e10cSrcweir #include <objidl.h>
39cdf0e10cSrcweir #if defined _MSC_VER
40cdf0e10cSrcweir #pragma warning(pop)
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <vector>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir // forward declaration
46cdf0e10cSrcweir //class CWinClipbImpl;
47cdf0e10cSrcweir class EnumFormatEtc;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir /*--------------------------------------------------------------------------
50cdf0e10cSrcweir 	- the function principle of the windows clipboard:
51cdf0e10cSrcweir 	  a data provider offers all formats he can deliver on the clipboard
52cdf0e10cSrcweir 	  a clipboard client ask for the available formats on the clipboard
53cdf0e10cSrcweir 	  and decides if there is a format he can use
54cdf0e10cSrcweir 	  if there is one, he requests the data in this format
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	- This class inherits from IDataObject an so can be placed on the
57cdf0e10cSrcweir 	  OleClipboard. The class wrapps a transferable object which is the
58cdf0e10cSrcweir 	  original DataSource
59cdf0e10cSrcweir 	- DataFlavors offerd by this transferable will be translated into
60cdf0e10cSrcweir 	  appropriate clipboard formats
61cdf0e10cSrcweir 	- if the transferable contains text data always text and unicodetext
62cdf0e10cSrcweir 	  will be offered or vice versa
63cdf0e10cSrcweir 	- text data will be automaticaly converted between text und unicode text
64cdf0e10cSrcweir 	- although the transferable may support text in different charsets
65cdf0e10cSrcweir 	  (codepages) only text in one codepage can be offered by the clipboard
66cdf0e10cSrcweir 
67cdf0e10cSrcweir ----------------------------------------------------------------------------*/
68cdf0e10cSrcweir 
69cdf0e10cSrcweir class CXTDataObject : public IDataObject
70cdf0e10cSrcweir {
71cdf0e10cSrcweir public:
72cdf0e10cSrcweir 	CXTDataObject( );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	//-----------------------------------------------------------------
75cdf0e10cSrcweir 	// ole interface implementation
76cdf0e10cSrcweir 	//-----------------------------------------------------------------
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     //IUnknown interface methods
79cdf0e10cSrcweir     STDMETHODIMP           QueryInterface(REFIID iid, LPVOID* ppvObject);
80cdf0e10cSrcweir     STDMETHODIMP_( ULONG ) AddRef( );
81cdf0e10cSrcweir     STDMETHODIMP_( ULONG ) Release( );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     // IDataObject interface methods
84cdf0e10cSrcweir     STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
85cdf0e10cSrcweir     STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
86cdf0e10cSrcweir     STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
87cdf0e10cSrcweir     STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
88cdf0e10cSrcweir     STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
89cdf0e10cSrcweir     STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
90cdf0e10cSrcweir     STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
91cdf0e10cSrcweir     STDMETHODIMP DUnadvise( DWORD dwConnection );
92cdf0e10cSrcweir     STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	operator IDataObject*( );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir private:
97cdf0e10cSrcweir 
98cdf0e10cSrcweir private:
99cdf0e10cSrcweir 	LONG m_nRefCnt;
100cdf0e10cSrcweir };
101cdf0e10cSrcweir 
102cdf0e10cSrcweir //------------------------------------------------------------------------
103cdf0e10cSrcweir //
104cdf0e10cSrcweir //------------------------------------------------------------------------
105cdf0e10cSrcweir 
106cdf0e10cSrcweir class CEnumFormatEtc : public IEnumFORMATETC
107cdf0e10cSrcweir {
108cdf0e10cSrcweir public:
109cdf0e10cSrcweir 	CEnumFormatEtc( LPUNKNOWN pUnkDataObj );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     // IUnknown
112cdf0e10cSrcweir     STDMETHODIMP           QueryInterface( REFIID iid, LPVOID* ppvObject );
113cdf0e10cSrcweir     STDMETHODIMP_( ULONG ) AddRef( );
114cdf0e10cSrcweir     STDMETHODIMP_( ULONG ) Release( );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     //IEnumFORMATETC
117cdf0e10cSrcweir     STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched );
118cdf0e10cSrcweir     STDMETHODIMP Skip( ULONG celt );
119cdf0e10cSrcweir     STDMETHODIMP Reset( );
120cdf0e10cSrcweir     STDMETHODIMP Clone( IEnumFORMATETC** ppenum );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir private:
123cdf0e10cSrcweir 	LONG								m_nRefCnt;
124cdf0e10cSrcweir 	LPUNKNOWN							m_pUnkDataObj;
125cdf0e10cSrcweir     ULONG								m_nCurrPos;
126cdf0e10cSrcweir };
127cdf0e10cSrcweir 
128cdf0e10cSrcweir typedef CEnumFormatEtc *PCEnumFormatEtc;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir #endif
131