[PATCH v3 3/5] ole32: Add support for loading wmf from contents streams to data cache.

Sergio Gómez Del Real sdelreal at codeweavers.com
Thu Apr 5 08:05:47 CDT 2018


Signed-off-by: Sergio Gómez Del Real <sdelreal at codeweavers.com>
---
 dlls/ole32/datacache.c | 66 ++++++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 29 deletions(-)

diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index 2678c3ff06..1967f9dec0 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -609,6 +609,17 @@ static HRESULT synthesize_emf( HMETAFILEPICT data, STGMEDIUM *med )
     GlobalUnlock( data );
     return hr;
 }
+#include <pshpack2.h>
+struct meta_placeable
+{
+    DWORD key;
+    WORD hwmf;
+    WORD bounding_box[4];
+    WORD inch;
+    DWORD reserved;
+    WORD checksum;
+};
+#include <poppack.h>
 
 static HRESULT load_mf_pict( DataCacheEntry *cache_entry, IStream *stm )
 {
@@ -618,25 +629,24 @@ static HRESULT load_mf_pict( DataCacheEntry *cache_entry, IStream *stm )
     void *bits;
     METAFILEPICT *mfpict;
     HGLOBAL hmfpict;
-    PresentationDataHeader header;
-    CLIPFORMAT clipformat;
     static const LARGE_INTEGER offset_zero;
     ULONG read;
+    CLIPFORMAT cf[4];
+    PresentationDataHeader pres;
+    struct meta_placeable mf_place;
 
-    if (cache_entry->load_stream_num == STREAM_NUMBER_CONTENTS)
+    hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
+    if (FAILED( hr )) return hr;
+
+    if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
     {
-        FIXME( "Unimplemented for CONTENTS stream\n" );
-        return E_FAIL;
+        if (stat.cbSize.QuadPart < sizeof(pres) + sizeof(cf)) return E_FAIL;
+        hr = read_clipformat( stm, cf );
+        if (FAILED( hr )) return hr;
+        hr = IStream_Read( stm, &pres, sizeof(pres), &read );
     }
-
-    hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
-    if (FAILED( hr )) return hr;
-
-    hr = read_clipformat( stm, &clipformat );
-    if (FAILED( hr )) return hr;
-
-    hr = IStream_Read( stm, &header, sizeof(header), &read );
-    if (hr != S_OK || read != sizeof(header)) return E_FAIL;
+    else
+        hr = IStream_Read( stm, &mf_place, sizeof(mf_place), &read );
 
     hr = IStream_Seek( stm, offset_zero, STREAM_SEEK_CUR, &current_pos );
     if (FAILED( hr )) return hr;
@@ -659,10 +669,20 @@ static HRESULT load_mf_pict( DataCacheEntry *cache_entry, IStream *stm )
 
     if (SUCCEEDED( hr ))
     {
-        /* FIXME: get this from the stream */
         mfpict->mm = MM_ANISOTROPIC;
-        mfpict->xExt = header.dwObjectExtentX;
-        mfpict->yExt = header.dwObjectExtentY;
+        /* FIXME: get this from the stream */
+        if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
+        {
+            mfpict->xExt = pres.dwObjectExtentX;
+            mfpict->yExt = pres.dwObjectExtentY;
+        }
+        else
+        {
+            mfpict->xExt = ((mf_place.bounding_box[2] - mf_place.bounding_box[0])
+                            * 2540) / mf_place.inch;
+            mfpict->yExt = ((mf_place.bounding_box[3] - mf_place.bounding_box[1])
+                            * 2540) / mf_place.inch;
+        }
         mfpict->hMF = SetMetaFileBitsEx( stat.cbSize.u.LowPart, bits );
         if (!mfpict->hMF)
             hr = E_FAIL;
@@ -947,18 +967,6 @@ end:
     return hr;
 }
 
-#include <pshpack2.h>
-struct meta_placeable
-{
-    DWORD key;
-    WORD hwmf;
-    WORD bounding_box[4];
-    WORD inch;
-    DWORD reserved;
-    WORD checksum;
-};
-#include <poppack.h>
-
 static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream)
 {
     HRESULT hr = S_OK;
-- 
2.14.1




More information about the wine-devel mailing list