Andrew Eikum : ole32: Create a FORMATETC if one is not given in OleCreate.

Alexandre Julliard julliard at winehq.org
Tue Sep 28 11:13:41 CDT 2010


Module: wine
Branch: master
Commit: 91d91afb7d0f1806b1e79f2d45d9fa62df186048
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=91d91afb7d0f1806b1e79f2d45d9fa62df186048

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Fri Sep 24 10:53:32 2010 -0500

ole32: Create a FORMATETC if one is not given in OleCreate.

---

 dlls/ole32/ole2.c       |   14 +++++++++++++-
 dlls/ole32/tests/ole2.c |   25 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c
index 84bf174..2b301e4 100644
--- a/dlls/ole32/ole2.c
+++ b/dlls/ole32/ole2.c
@@ -2530,7 +2530,19 @@ HRESULT WINAPI OleCreate(
             if (SUCCEEDED(hres2))
             {
                 DWORD dwConnection;
-                hres = IOleCache_Cache(pOleCache, pFormatEtc, ADVF_PRIMEFIRST, &dwConnection);
+                FORMATETC *pfe;
+                if (renderopt == OLERENDER_DRAW && !pFormatEtc) {
+                    pfe = HeapAlloc(GetProcessHeap(), 0, sizeof(FORMATETC));
+                    pfe->cfFormat = 0;
+                    pfe->ptd = NULL;
+                    pfe->dwAspect = DVASPECT_CONTENT;
+                    pfe->lindex = -1;
+                    pfe->tymed = TYMED_NULL;
+                }else
+                    pfe = pFormatEtc;
+                hres = IOleCache_Cache(pOleCache, pfe, ADVF_PRIMEFIRST, &dwConnection);
+                if (!pFormatEtc && pfe)
+                    HeapFree(GetProcessHeap(), 0, pfe);
                 IOleCache_Release(pOleCache);
             }
         }
diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index 48584a1..3db2cb5 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -53,6 +53,7 @@ struct expected_method
 };
 
 static const struct expected_method *expected_method_list;
+static FORMATETC *g_expected_fetc = NULL;
 
 BOOL g_showRunnable = TRUE;
 BOOL g_isRunning = TRUE;
@@ -496,6 +497,22 @@ static HRESULT WINAPI OleObjectCache_Cache
 )
 {
     CHECK_EXPECTED_METHOD("OleObjectCache_Cache");
+    if (g_expected_fetc) {
+        ok(pformatetc != NULL, "pformatetc should not be NULL\n");
+        if (pformatetc) {
+            ok(pformatetc->cfFormat == g_expected_fetc->cfFormat,
+                    "cfFormat: %x\n", pformatetc->cfFormat);
+            ok((pformatetc->ptd != NULL) == (g_expected_fetc->ptd != NULL),
+                    "ptd: %p\n", pformatetc->ptd);
+            ok(pformatetc->dwAspect == g_expected_fetc->dwAspect,
+                    "dwAspect: %x\n", pformatetc->dwAspect);
+            ok(pformatetc->lindex == g_expected_fetc->lindex,
+                    "lindex: %x\n", pformatetc->lindex);
+            ok(pformatetc->tymed == g_expected_fetc->tymed,
+                    "tymed: %x\n", pformatetc->tymed);
+        }
+    } else
+        ok(pformatetc == NULL, "pformatetc should be NULL\n");
     return S_OK;
 }
 
@@ -796,6 +813,12 @@ static void test_OleCreate(IStorage *pStorage)
         { NULL, 0 }
     };
 
+    g_expected_fetc = &formatetc;
+    formatetc.cfFormat = 0;
+    formatetc.ptd = NULL;
+    formatetc.dwAspect = DVASPECT_CONTENT;
+    formatetc.lindex = -1;
+    formatetc.tymed = TYMED_NULL;
     runnable = &OleObjectRunnable;
     cache = &OleObjectCache;
     expected_method_list = methods_olerender_none;
@@ -836,6 +859,8 @@ static void test_OleCreate(IStorage *pStorage)
     IOleObject_Release(pObject);
     CHECK_NO_EXTRA_METHODS();
 
+    formatetc.cfFormat = 0;
+    formatetc.tymed = TYMED_NULL;
     runnable = NULL;
     expected_method_list = methods_olerender_draw_no_runnable;
     trace("OleCreate with OLERENDER_DRAW (no IRunnableObject):\n");




More information about the wine-cvs mailing list