[PATCH v4 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 18:30:36 CDT 2018
Signed-off-by: Sergio Gómez Del Real <sdelreal at codeweavers.com>
---
dlls/ole32/datacache.c | 68 +++++++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 29 deletions(-)
diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index ec80e6091d..763d01a3c5 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -570,6 +570,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 )
{
@@ -579,29 +590,30 @@ 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;
-
- if (cache_entry->load_stream_num == STREAM_NUMBER_CONTENTS)
- {
- FIXME( "Unimplemented for CONTENTS stream\n" );
- return E_FAIL;
- }
+ CLIPFORMAT cf;
+ PresentationDataHeader pres;
+ struct meta_placeable mf_place;
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;
+ if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
+ {
+ hr = read_clipformat( stm, &cf );
+ if (FAILED( hr )) return hr;
+ hr = IStream_Read( stm, &pres, sizeof(pres), &read );
+ if (FAILED( hr ) || read != sizeof(pres)) return E_FAIL;
+ }
+ else
+ {
+ hr = IStream_Read( stm, &mf_place, sizeof(mf_place), &read );
+ if (FAILED( hr ) || read != sizeof(mf_place)) return E_FAIL;
+ }
hr = IStream_Seek( stm, offset_zero, STREAM_SEEK_CUR, ¤t_pos );
if (FAILED( hr )) return hr;
-
stat.cbSize.QuadPart -= current_pos.QuadPart;
hmfpict = GlobalAlloc( GMEM_MOVEABLE, sizeof(METAFILEPICT) );
@@ -620,10 +632,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;
@@ -913,18 +935,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