From 1f1c42109dce7d0760966eb57127a0bb668d50f5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Jul 2003 22:12:15 +0000 Subject: [PATCH] implement support for returning several elements at once from IEnumFORMATETC (part of patch 649438) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21818 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/ole/dataobj.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index b554e126cd..502137ce8f 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -187,31 +187,27 @@ wxIEnumFORMATETC::wxIEnumFORMATETC(const wxDataFormat *formats, ULONG nCount) STDMETHODIMP wxIEnumFORMATETC::Next(ULONG celt, FORMATETC *rgelt, - ULONG *WXUNUSED(pceltFetched)) + ULONG *pceltFetched) { wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Next")); - if ( celt > 1 ) { - // we only return 1 element at a time - mainly because I'm too lazy to - // implement something which you're never asked for anyhow - return S_FALSE; - } - - if ( m_nCurrent < m_nCount ) { + ULONG numFetched = 0; + while (m_nCurrent < m_nCount && numFetched < celt) { FORMATETC format; format.cfFormat = m_formats[m_nCurrent++]; format.ptd = NULL; format.dwAspect = DVASPECT_CONTENT; format.lindex = -1; format.tymed = TYMED_HGLOBAL; - *rgelt = format; - return S_OK; - } - else { - // bad index - return S_FALSE; + *rgelt++ = format; + numFetched++; } + + if (pceltFetched) + *pceltFetched = numFetched; + + return numFetched == celt ? S_OK : S_FALSE; } STDMETHODIMP wxIEnumFORMATETC::Skip(ULONG celt)