]> git.saurik.com Git - wxWidgets.git/commitdiff
implement support for returning several elements at once from IEnumFORMATETC (part...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 9 Jul 2003 22:12:15 +0000 (22:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 9 Jul 2003 22:12:15 +0000 (22:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21818 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/ole/dataobj.cpp

index b554e126cd9def51095b65c5d85304ab9e6ea964..502137ce8f4cf87ab0cb98fd57576eeb4b8712dc 100644 (file)
@@ -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)