1*48123e16SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*48123e16SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*48123e16SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*48123e16SAndrew Rist  * distributed with this work for additional information
6*48123e16SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*48123e16SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*48123e16SAndrew Rist  * "License"); you may not use this file except in compliance
9*48123e16SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*48123e16SAndrew Rist  *
11*48123e16SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*48123e16SAndrew Rist  *
13*48123e16SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*48123e16SAndrew Rist  * software distributed under the License is distributed on an
15*48123e16SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*48123e16SAndrew Rist  * KIND, either express or implied.  See the License for the
17*48123e16SAndrew Rist  * specific language governing permissions and limitations
18*48123e16SAndrew Rist  * under the License.
19*48123e16SAndrew Rist  *
20*48123e16SAndrew Rist  *************************************************************/
21*48123e16SAndrew Rist 
22*48123e16SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dtrans.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //------------------------------------------------------------------------
28cdf0e10cSrcweir // includes
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir #include <osl/diagnose.h>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "..\DTransHelper.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #ifndef _TWRAPPERDATAOBJECT_HXX_
35cdf0e10cSrcweir #include "XTDo.hxx"
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #if defined _MSC_VER
39cdf0e10cSrcweir #pragma warning(push,1)
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #include <windows.h>
42cdf0e10cSrcweir #include <ole2.h>
43cdf0e10cSrcweir #if defined _MSC_VER
44cdf0e10cSrcweir #pragma warning(pop)
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #include <memory>
47cdf0e10cSrcweir #include <tchar.h>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //------------------------------------------------------------------------
50cdf0e10cSrcweir // namespace directives
51cdf0e10cSrcweir //------------------------------------------------------------------------
52cdf0e10cSrcweir 
53cdf0e10cSrcweir using namespace ::std;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //============================================================================
56cdf0e10cSrcweir // OTWrapperDataObject
57cdf0e10cSrcweir //============================================================================
58cdf0e10cSrcweir 
59cdf0e10cSrcweir //------------------------------------------------------------------------
60cdf0e10cSrcweir // ctor
61cdf0e10cSrcweir //------------------------------------------------------------------------
62cdf0e10cSrcweir /*
63cdf0e10cSrcweir 	in the constructor we enumerate all formats offered by the transferable
64cdf0e10cSrcweir 	and convert the formats into formatetc structures
65cdf0e10cSrcweir 	if the transferable supports text in different charsets we use either
66cdf0e10cSrcweir 	the charset equal to the charset of the current thread or an arbitrary
67cdf0e10cSrcweir 	charset supported by the transferable and the system
68cdf0e10cSrcweir 	if the transferable supports only unicodetext we offer in addition to
69cdf0e10cSrcweir 	this text in the charset of the current thread
70cdf0e10cSrcweir 	in order to allow the consumer of the clipboard to query for the charset
71cdf0e10cSrcweir 	of the text in the clipboard we offer a CF_LOCALE
72cdf0e10cSrcweir */
CXTDataObject()73cdf0e10cSrcweir CXTDataObject::CXTDataObject( ) :
74cdf0e10cSrcweir 	m_nRefCnt( 0 )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir //------------------------------------------------------------------------
80cdf0e10cSrcweir // IUnknown->QueryInterface
81cdf0e10cSrcweir //------------------------------------------------------------------------
82cdf0e10cSrcweir 
QueryInterface(REFIID iid,LPVOID * ppvObject)83cdf0e10cSrcweir STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	OSL_ASSERT( NULL != ppvObject );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	if ( NULL == ppvObject )
88cdf0e10cSrcweir 		return E_INVALIDARG;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	HRESULT hr = E_NOINTERFACE;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	*ppvObject = NULL;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) )
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		*ppvObject = static_cast< IUnknown* >( this );
97cdf0e10cSrcweir 		( (LPUNKNOWN)*ppvObject )->AddRef( );
98cdf0e10cSrcweir 		hr = S_OK;
99cdf0e10cSrcweir 	}
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	return hr;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir //------------------------------------------------------------------------
105cdf0e10cSrcweir // IUnknown->AddRef
106cdf0e10cSrcweir //------------------------------------------------------------------------
107cdf0e10cSrcweir 
STDMETHODIMP_(ULONG)108cdf0e10cSrcweir STDMETHODIMP_(ULONG) CXTDataObject::AddRef( )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) );
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir //------------------------------------------------------------------------
114cdf0e10cSrcweir // IUnknown->Release
115cdf0e10cSrcweir //------------------------------------------------------------------------
116cdf0e10cSrcweir 
STDMETHODIMP_(ULONG)117cdf0e10cSrcweir STDMETHODIMP_(ULONG) CXTDataObject::Release( )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	// we need a helper variable because it's
120cdf0e10cSrcweir 	// not allowed to access a member variable
121cdf0e10cSrcweir 	// after an object is destroyed
122cdf0e10cSrcweir 	ULONG nRefCnt = static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	if ( 0 == nRefCnt )
125cdf0e10cSrcweir 	{
126cdf0e10cSrcweir 		delete this;
127cdf0e10cSrcweir 	}
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	return nRefCnt;
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir /*------------------------------------------------------------------------
133cdf0e10cSrcweir 
134cdf0e10cSrcweir  IDataObject->GetData
135cdf0e10cSrcweir  we deliver data only into global memory
136cdf0e10cSrcweir 
137cdf0e10cSrcweir  algo:
138cdf0e10cSrcweir  1. convert the given formatect struct into a valid dataflavor
139cdf0e10cSrcweir  2. if the transferable directly supports the requested format
140cdf0e10cSrcweir  2.1. if text data requested add a trailing '\0' in order to prevent
141cdf0e10cSrcweir 		problems (windows needs '\0' terminated strings
142cdf0e10cSrcweir  2.2. we expect unicode data as Sequence< sal_Unicode > and all other
143cdf0e10cSrcweir 	    text and raw data as Sequence< sal_Int8 >
144cdf0e10cSrcweir 
145cdf0e10cSrcweir ------------------------------------------------------------------------*/
146cdf0e10cSrcweir 
GetData(LPFORMATETC pFormatetc,LPSTGMEDIUM pmedium)147cdf0e10cSrcweir STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	if ( ( NULL == pFormatetc ) || ( NULL == pmedium ) )
150cdf0e10cSrcweir 		return E_INVALIDARG;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	HRESULT hr = E_FAIL;
153cdf0e10cSrcweir 	char    pBuff[] = "Test OleClipboard";
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	if ( CF_TEXT == pFormatetc->cfFormat )
156cdf0e10cSrcweir 	{
157cdf0e10cSrcweir 		CHGlobalHelper hGlobHlp( TRUE );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		hGlobHlp.Write( pBuff, sizeof( pBuff ), NULL );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 		pmedium->tymed          = TYMED_HGLOBAL;
162cdf0e10cSrcweir 		pmedium->hGlobal        = hGlobHlp.GetHGlobal( );
163cdf0e10cSrcweir 		pmedium->pUnkForRelease = NULL;
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 		hr = S_OK;
166cdf0e10cSrcweir 	}
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	return hr;
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir //------------------------------------------------------------------------
172cdf0e10cSrcweir // IDataObject->EnumFormatEtc
173cdf0e10cSrcweir //------------------------------------------------------------------------
174cdf0e10cSrcweir 
EnumFormatEtc(DWORD dwDirection,IEnumFORMATETC ** ppenumFormatetc)175cdf0e10cSrcweir STDMETHODIMP CXTDataObject::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir 	if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) )
178cdf0e10cSrcweir 		return E_INVALIDARG;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	*ppenumFormatetc = NULL;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	HRESULT hr = E_FAIL;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	if ( DATADIR_GET == dwDirection )
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir 		*ppenumFormatetc = new CEnumFormatEtc( this );
187cdf0e10cSrcweir 		static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( );
188cdf0e10cSrcweir 		hr = S_OK;
189cdf0e10cSrcweir 	}
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	return hr;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir //------------------------------------------------------------------------
195cdf0e10cSrcweir // IDataObject->QueryGetData
196cdf0e10cSrcweir //------------------------------------------------------------------------
197cdf0e10cSrcweir 
QueryGetData(LPFORMATETC pFormatetc)198cdf0e10cSrcweir STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir 	return E_NOTIMPL;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir //------------------------------------------------------------------------
204cdf0e10cSrcweir // IDataObject->GetDataHere
205cdf0e10cSrcweir //------------------------------------------------------------------------
206cdf0e10cSrcweir 
GetDataHere(LPFORMATETC,LPSTGMEDIUM)207cdf0e10cSrcweir STDMETHODIMP CXTDataObject::GetDataHere( LPFORMATETC, LPSTGMEDIUM )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	return E_NOTIMPL;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir //------------------------------------------------------------------------
213cdf0e10cSrcweir // IDataObject->GetCanonicalFormatEtc
214cdf0e10cSrcweir //------------------------------------------------------------------------
215cdf0e10cSrcweir 
GetCanonicalFormatEtc(LPFORMATETC,LPFORMATETC)216cdf0e10cSrcweir STDMETHODIMP CXTDataObject::GetCanonicalFormatEtc( LPFORMATETC, LPFORMATETC )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir 	return E_NOTIMPL;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir //------------------------------------------------------------------------
222cdf0e10cSrcweir // IDataObject->SetData
223cdf0e10cSrcweir //------------------------------------------------------------------------
224cdf0e10cSrcweir 
SetData(LPFORMATETC,LPSTGMEDIUM,BOOL)225cdf0e10cSrcweir STDMETHODIMP CXTDataObject::SetData( LPFORMATETC, LPSTGMEDIUM, BOOL )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir 	return E_NOTIMPL;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir //------------------------------------------------------------------------
231cdf0e10cSrcweir // IDataObject->DAdvise
232cdf0e10cSrcweir //------------------------------------------------------------------------
233cdf0e10cSrcweir 
DAdvise(LPFORMATETC,DWORD,LPADVISESINK,DWORD *)234cdf0e10cSrcweir STDMETHODIMP CXTDataObject::DAdvise( LPFORMATETC, DWORD, LPADVISESINK, DWORD * )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir 	return E_NOTIMPL;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir //------------------------------------------------------------------------
240cdf0e10cSrcweir // IDataObject->DUnadvise
241cdf0e10cSrcweir //------------------------------------------------------------------------
242cdf0e10cSrcweir 
DUnadvise(DWORD)243cdf0e10cSrcweir STDMETHODIMP CXTDataObject::DUnadvise( DWORD )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	return E_NOTIMPL;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //------------------------------------------------------------------------
249cdf0e10cSrcweir // IDataObject->EnumDAdvise
250cdf0e10cSrcweir //------------------------------------------------------------------------
251cdf0e10cSrcweir 
EnumDAdvise(LPENUMSTATDATA *)252cdf0e10cSrcweir STDMETHODIMP CXTDataObject::EnumDAdvise( LPENUMSTATDATA * )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir 	return E_NOTIMPL;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir //------------------------------------------------------------------------
258cdf0e10cSrcweir // for our convenience
259cdf0e10cSrcweir //------------------------------------------------------------------------
260cdf0e10cSrcweir 
operator IDataObject*()261cdf0e10cSrcweir CXTDataObject::operator IDataObject*( )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	return static_cast< IDataObject* >( this );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 
267cdf0e10cSrcweir //============================================================================
268cdf0e10cSrcweir // CEnumFormatEtc
269cdf0e10cSrcweir //============================================================================
270cdf0e10cSrcweir 
271cdf0e10cSrcweir //----------------------------------------------------------------------------
272cdf0e10cSrcweir // ctor
273cdf0e10cSrcweir //----------------------------------------------------------------------------
274cdf0e10cSrcweir 
CEnumFormatEtc(LPUNKNOWN pUnkDataObj)275cdf0e10cSrcweir CEnumFormatEtc::CEnumFormatEtc( LPUNKNOWN pUnkDataObj ) :
276cdf0e10cSrcweir 	m_nRefCnt( 0 ),
277cdf0e10cSrcweir 	m_pUnkDataObj( pUnkDataObj ),
278cdf0e10cSrcweir 	m_nCurrPos( 0 )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir //----------------------------------------------------------------------------
283cdf0e10cSrcweir // IUnknown->QueryInterface
284cdf0e10cSrcweir //----------------------------------------------------------------------------
285cdf0e10cSrcweir 
QueryInterface(REFIID iid,LPVOID * ppvObject)286cdf0e10cSrcweir STDMETHODIMP CEnumFormatEtc::QueryInterface( REFIID iid, LPVOID* ppvObject )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 	if ( NULL == ppvObject )
289cdf0e10cSrcweir 		return E_INVALIDARG;
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 	HRESULT hr = E_NOINTERFACE;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 	*ppvObject = NULL;
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IEnumFORMATETC ) == iid ) )
296cdf0e10cSrcweir 	{
297cdf0e10cSrcweir 		*ppvObject = static_cast< IUnknown* >( this );
298cdf0e10cSrcweir 		static_cast< LPUNKNOWN >( *ppvObject )->AddRef( );
299cdf0e10cSrcweir 		hr = S_OK;
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	return hr;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
305cdf0e10cSrcweir //----------------------------------------------------------------------------
306cdf0e10cSrcweir // IUnknown->AddRef
307cdf0e10cSrcweir //----------------------------------------------------------------------------
308cdf0e10cSrcweir 
STDMETHODIMP_(ULONG)309cdf0e10cSrcweir STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef( )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	// keep the dataobject alive
312cdf0e10cSrcweir 	m_pUnkDataObj->AddRef( );
313cdf0e10cSrcweir 	return InterlockedIncrement( &m_nRefCnt );
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir //----------------------------------------------------------------------------
317cdf0e10cSrcweir // IUnknown->Release
318cdf0e10cSrcweir //----------------------------------------------------------------------------
319cdf0e10cSrcweir 
STDMETHODIMP_(ULONG)320cdf0e10cSrcweir STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir 	// release the outer dataobject
323cdf0e10cSrcweir 	m_pUnkDataObj->Release( );
324cdf0e10cSrcweir 
325cdf0e10cSrcweir 	// we need a helper variable because it's
326cdf0e10cSrcweir 	// not allowed to access a member variable
327cdf0e10cSrcweir 	// after an object is destroyed
328cdf0e10cSrcweir 	ULONG nRefCnt = InterlockedDecrement( &m_nRefCnt );
329cdf0e10cSrcweir 	if ( 0 == nRefCnt )
330cdf0e10cSrcweir 		delete this;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	return nRefCnt;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir //----------------------------------------------------------------------------
336cdf0e10cSrcweir // IEnumFORMATETC->Next
337cdf0e10cSrcweir //----------------------------------------------------------------------------
338cdf0e10cSrcweir 
Next(ULONG celt,LPFORMATETC rgelt,ULONG * pceltFetched)339cdf0e10cSrcweir STDMETHODIMP CEnumFormatEtc::Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir 	if ( ( 0 != celt ) && ( NULL == rgelt ) )
342cdf0e10cSrcweir 		return E_INVALIDARG;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	ULONG   ulFetched = 0;
345cdf0e10cSrcweir 	ULONG   ulToFetch = celt;
346cdf0e10cSrcweir 	HRESULT hr        = S_FALSE;
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	while( m_nCurrPos < 1 )
349cdf0e10cSrcweir 	{
350cdf0e10cSrcweir 		rgelt->cfFormat = CF_TEXT;
351cdf0e10cSrcweir 		rgelt->ptd      = NULL;
352cdf0e10cSrcweir 		rgelt->dwAspect = DVASPECT_CONTENT;
353cdf0e10cSrcweir 		rgelt->lindex   = -1;
354cdf0e10cSrcweir 		rgelt->tymed    = TYMED_HGLOBAL;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 		++m_nCurrPos;
357cdf0e10cSrcweir 		++rgelt;
358cdf0e10cSrcweir 		--ulToFetch;
359cdf0e10cSrcweir 		++ulFetched;
360cdf0e10cSrcweir 	}
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	if ( ulFetched == celt )
363cdf0e10cSrcweir 		hr = S_OK;
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	if ( NULL != pceltFetched )
366cdf0e10cSrcweir 	{
367cdf0e10cSrcweir 		*pceltFetched = ulFetched;
368cdf0e10cSrcweir 	}
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	return hr;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir 
373cdf0e10cSrcweir //----------------------------------------------------------------------------
374cdf0e10cSrcweir // IEnumFORMATETC->Skip
375cdf0e10cSrcweir //----------------------------------------------------------------------------
376cdf0e10cSrcweir 
Skip(ULONG celt)377cdf0e10cSrcweir STDMETHODIMP CEnumFormatEtc::Skip( ULONG celt )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir 	HRESULT hr = S_FALSE;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	/*
382cdf0e10cSrcweir 	if ( ( m_nCurrPos + celt ) < m_nClipFormats )
383cdf0e10cSrcweir 	{
384cdf0e10cSrcweir 		m_nCurrPos += celt;
385cdf0e10cSrcweir 		hr = S_OK;
386cdf0e10cSrcweir 	}
387cdf0e10cSrcweir 	*/
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	return hr;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir //----------------------------------------------------------------------------
393cdf0e10cSrcweir // IEnumFORMATETC->Reset
394cdf0e10cSrcweir //----------------------------------------------------------------------------
395cdf0e10cSrcweir 
Reset()396cdf0e10cSrcweir STDMETHODIMP CEnumFormatEtc::Reset( )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir 	m_nCurrPos = 0;
399cdf0e10cSrcweir 	return S_OK;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir //----------------------------------------------------------------------------
403cdf0e10cSrcweir // IEnumFORMATETC->Clone
404cdf0e10cSrcweir //----------------------------------------------------------------------------
405cdf0e10cSrcweir 
Clone(IEnumFORMATETC ** ppenum)406cdf0e10cSrcweir STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir 	OSL_ASSERT( NULL != ppenum );
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	if ( NULL == ppenum )
411cdf0e10cSrcweir 		return E_INVALIDARG;
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 	HRESULT hr = E_FAIL;
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 	*ppenum = NULL;
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 	CEnumFormatEtc* pCEnumFEtc = new CEnumFormatEtc( m_pUnkDataObj );
418cdf0e10cSrcweir 	if ( NULL != pCEnumFEtc )
419cdf0e10cSrcweir 	{
420cdf0e10cSrcweir 		pCEnumFEtc->m_nCurrPos = m_nCurrPos;
421cdf0e10cSrcweir 		*ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc );
422cdf0e10cSrcweir 		static_cast< LPUNKNOWN >( *ppenum )->AddRef( );
423cdf0e10cSrcweir 		hr = NOERROR;
424cdf0e10cSrcweir 	}
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	return hr;
427cdf0e10cSrcweir }
428