[2/2] ole32: Relax media type check when loading CF_METAFILEPICT format from OLE storage.

Dmitry Timoshkov dmitry at baikal.ru
Mon Nov 2 03:01:23 CST 2015


This patch replaces "ole32: Accept TYMED_FILE as a possible source of
CF_METAFILEPICT format."

Microsoft Photo Editor 3.0 creates OLE storage documents with storage medium
type set to TYMED_FILE, this patch makes OleLoad() recognize such an object
as a valid CF_METAFILEPICT format, and OleDraw() later successfully paints
object contents on the screen.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/ole32/datacache.c  | 12 ++++++------
 dlls/ole32/tests/ole2.c |  6 ------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index 9284410..e93e867 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -282,10 +282,10 @@ static DataCacheEntry *DataCache_GetEntryForFormatEtc(DataCache *This, const FOR
 /* checks that the clipformat and tymed are valid and returns an error if they
 * aren't and CACHE_S_NOTSUPPORTED if they are valid, but can't be rendered by
 * DataCache_Draw */
-static HRESULT check_valid_clipformat_and_tymed(CLIPFORMAT cfFormat, DWORD tymed)
+static HRESULT check_valid_clipformat_and_tymed(CLIPFORMAT cfFormat, DWORD tymed, BOOL load)
 {
     if (!cfFormat || !tymed ||
-        (cfFormat == CF_METAFILEPICT && tymed == TYMED_MFPICT) ||
+        (cfFormat == CF_METAFILEPICT && (tymed == TYMED_MFPICT || load)) ||
         (cfFormat == CF_BITMAP && tymed == TYMED_GDI) ||
         (cfFormat == CF_DIB && tymed == TYMED_HGLOBAL) ||
         (cfFormat == CF_ENHMETAFILE && tymed == TYMED_ENHMF))
@@ -299,11 +299,11 @@ static HRESULT check_valid_clipformat_and_tymed(CLIPFORMAT cfFormat, DWORD tymed
     }
 }
 
-static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DataCacheEntry **cache_entry)
+static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DataCacheEntry **cache_entry, BOOL load)
 {
     HRESULT hr;
 
-    hr = check_valid_clipformat_and_tymed(formatetc->cfFormat, formatetc->tymed);
+    hr = check_valid_clipformat_and_tymed(formatetc->cfFormat, formatetc->tymed, load);
     if (FAILED(hr))
         return hr;
     if (hr == CACHE_S_FORMATETC_NOTSUPPORTED)
@@ -1259,7 +1259,7 @@ static HRESULT add_cache_entry( DataCache *This, const FORMATETC *fmt, IStream *
 
     cache_entry = DataCache_GetEntryForFormatEtc( This, fmt );
     if (!cache_entry)
-        hr = DataCache_CreateEntry( This, fmt, &cache_entry );
+        hr = DataCache_CreateEntry( This, fmt, &cache_entry, TRUE );
     if (SUCCEEDED( hr ))
     {
         DataCacheEntry_DiscardData( cache_entry );
@@ -2007,7 +2007,7 @@ static HRESULT WINAPI DataCache_Cache(
         return CACHE_S_SAMECACHE;
     }
 
-    hr = DataCache_CreateEntry(This, pformatetc, &cache_entry);
+    hr = DataCache_CreateEntry(This, pformatetc, &cache_entry, FALSE);
 
     if (SUCCEEDED(hr))
     {
diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index ed6157f..08253a1 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -1215,13 +1215,7 @@ static void test_OleLoad(IStorage *pStorage)
             hr = OleDraw(obj, DVASPECT_CONTENT, hdc, &rc);
             DeleteDC(hdc);
             if (fmt == CF_METAFILEPICT)
-            {
-            if (tymed == TYMED_HGLOBAL || tymed == TYMED_MFPICT)
                 ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, tymed = %u\n", hr, fmt, tymed);
-            else
-todo_wine
-                ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, tymed = %u\n", hr, fmt, tymed);
-            }
             else if (fmt == CF_ENHMETAFILE)
 todo_wine
                 ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, tymed = %u\n", hr, fmt, tymed);
-- 
2.6.2




More information about the wine-patches mailing list