From d5be8f57a16dfb8ff5cdfba27f467b28c8766413 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 24 Jan 2018 09:31:30 +0000 Subject: [PATCH] ole32: There's no need to recreate the static entry when parsing the CONTENTS stream. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/ole32/datacache.c | 47 ++++++++++++++++++++++++++--------------- dlls/ole32/tests/ole2.c | 4 ++-- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c index ba253d9330b..c07633d960b 100644 --- a/dlls/ole32/datacache.c +++ b/dlls/ole32/datacache.c @@ -312,6 +312,29 @@ static DataCacheEntry *DataCache_GetEntryForFormatEtc(DataCache *This, const FOR return NULL; } +/* Returns the cache entry associated with a static CLSID. + This will be first in the list with connection id == 1 */ +static HRESULT get_static_entry( DataCache *cache, DataCacheEntry **cache_entry ) +{ + DataCacheEntry *entry; + struct list *head = list_head( &cache->cache_list ); + HRESULT hr = E_FAIL; + + *cache_entry = NULL; + + if (head) + { + entry = LIST_ENTRY( head, DataCacheEntry, entry ); + if (entry->id == 1) + { + *cache_entry = entry; + hr = S_OK; + } + } + + return hr; +} + /* 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 */ @@ -1698,33 +1721,23 @@ static HRESULT parse_pres_streams( DataCache *cache, IStorage *stg ) return S_OK; } -static const FORMATETC static_dib_fmt = { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - -static HRESULT parse_contents_stream( DataCache *This, IStorage *stg ) +static HRESULT parse_contents_stream( DataCache *cache, IStorage *stg ) { HRESULT hr; - STATSTG stat; - const FORMATETC *fmt; IStream *stm; + DataCacheEntry *cache_entry; hr = open_pres_stream( stg, STREAM_NUMBER_CONTENTS, &stm ); if (FAILED( hr )) return hr; - hr = IStorage_Stat( stg, &stat, STATFLAG_NONAME ); - if (FAILED( hr )) goto done; - - if (IsEqualCLSID( &stat.clsid, &CLSID_Picture_Dib )) - fmt = &static_dib_fmt; - else + hr = get_static_entry( cache, &cache_entry ); + if (hr == S_OK) { - FIXME("unsupported format %s\n", debugstr_guid( &stat.clsid )); - hr = E_FAIL; - goto done; + cache_entry->load_stream_num = STREAM_NUMBER_CONTENTS; + cache_entry->save_stream_num = STREAM_NUMBER_CONTENTS; + cache_entry->dirty = FALSE; } - hr = add_cache_entry( This, fmt, 0, STREAM_NUMBER_CONTENTS ); - -done: IStream_Release( stm ); return hr; } diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c index d83ca00a665..1a4fce5b06d 100644 --- a/dlls/ole32/tests/ole2.c +++ b/dlls/ole32/tests/ole2.c @@ -4450,7 +4450,6 @@ static void test_data_cache_contents(void) ok(hr == S_OK, "unexpected %#x\n", hr); hr = IPersistStorage_IsDirty(stg); -todo_wine_if(test_data[i].in == &stg_def_4 || test_data[i].in == &stg_def_8 || test_data[i].in == &stg_def_9) ok(hr == S_FALSE, "%d: unexpected %#x\n", i, hr); hr = IPersistStorage_Save(stg, doc2, FALSE); @@ -4463,7 +4462,8 @@ todo_wine_if(test_data[i].in == &stg_def_4 || test_data[i].in == &stg_def_8 || t todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_1 || test_data[i].in == &stg_def_2)) ok(enumerated_streams == matched_streams, "%d out: enumerated %d != matched %d\n", i, enumerated_streams, matched_streams); -todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_5)) +todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_4 || test_data[i].in == &stg_def_5 + || test_data[i].in == &stg_def_6)) ok(enumerated_streams == test_data[i].out->stream_count, "%d: saved streams %d != def streams %d\n", i, enumerated_streams, test_data[i].out->stream_count);