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