[PATCH v5 3/5] ole32: Add support for loading wmf from contents streams to data cache.
Huw Davies
huw at codeweavers.com
Mon Apr 9 03:10:27 CDT 2018
On Fri, Apr 06, 2018 at 08:54:40AM -0500, Sergio Gómez Del Real wrote:
> Signed-off-by: Sergio Gómez Del Real <sdelreal at codeweavers.com>
> ---
> dlls/ole32/datacache.c | 70 ++++++++++++++++++++++++++++----------------------
> 1 file changed, 40 insertions(+), 30 deletions(-)
>
> diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
> index 7c1f9677cb..028c0a1daa 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;
Again, I'm not sure the variable renames are worth the extra noise
here.
> 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 (hr != S_OK) return hr;
> + hr = IStream_Read( stm, &pres, sizeof(pres), &read );
> + if (hr != S_OK) return E_FAIL;
Propagate hr.
> + }
> + else
> + {
> + hr = IStream_Read( stm, &mf_place, sizeof(mf_place), &read );
> + if (hr != S_OK) return E_FAIL;
And here.
> + }
>
> 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) );
> @@ -616,14 +628,24 @@ static HRESULT load_mf_pict( DataCacheEntry *cache_entry, IStream *stm )
> }
>
> hr = IStream_Read( stm, bits, stat.cbSize.u.LowPart, &read );
> - if (hr != S_OK || read != stat.cbSize.u.LowPart) hr = E_FAIL;
> + if (hr != S_OK) hr = E_FAIL;
And here.
>
> 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;
> @@ -912,18 +934,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