ole32: There's no need to recreate the static entry when parsing the CONTENTS stream.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2018-01-24 09:31:30 +00:00 committed by Alexandre Julliard
parent 57a5ab21f9
commit d5be8f57a1
2 changed files with 32 additions and 19 deletions

View File

@ -312,6 +312,29 @@ static DataCacheEntry *DataCache_GetEntryForFormatEtc(DataCache *This, const FOR
return NULL; 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 /* 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 * aren't and CACHE_S_NOTSUPPORTED if they are valid, but can't be rendered by
* DataCache_Draw */ * DataCache_Draw */
@ -1698,33 +1721,23 @@ static HRESULT parse_pres_streams( DataCache *cache, IStorage *stg )
return S_OK; return S_OK;
} }
static const FORMATETC static_dib_fmt = { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; static HRESULT parse_contents_stream( DataCache *cache, IStorage *stg )
static HRESULT parse_contents_stream( DataCache *This, IStorage *stg )
{ {
HRESULT hr; HRESULT hr;
STATSTG stat;
const FORMATETC *fmt;
IStream *stm; IStream *stm;
DataCacheEntry *cache_entry;
hr = open_pres_stream( stg, STREAM_NUMBER_CONTENTS, &stm ); hr = open_pres_stream( stg, STREAM_NUMBER_CONTENTS, &stm );
if (FAILED( hr )) return hr; if (FAILED( hr )) return hr;
hr = IStorage_Stat( stg, &stat, STATFLAG_NONAME ); hr = get_static_entry( cache, &cache_entry );
if (FAILED( hr )) goto done; if (hr == S_OK)
if (IsEqualCLSID( &stat.clsid, &CLSID_Picture_Dib ))
fmt = &static_dib_fmt;
else
{ {
FIXME("unsupported format %s\n", debugstr_guid( &stat.clsid )); cache_entry->load_stream_num = STREAM_NUMBER_CONTENTS;
hr = E_FAIL; cache_entry->save_stream_num = STREAM_NUMBER_CONTENTS;
goto done; cache_entry->dirty = FALSE;
} }
hr = add_cache_entry( This, fmt, 0, STREAM_NUMBER_CONTENTS );
done:
IStream_Release( stm ); IStream_Release( stm );
return hr; return hr;
} }

View File

@ -4450,7 +4450,6 @@ static void test_data_cache_contents(void)
ok(hr == S_OK, "unexpected %#x\n", hr); ok(hr == S_OK, "unexpected %#x\n", hr);
hr = IPersistStorage_IsDirty(stg); 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); ok(hr == S_FALSE, "%d: unexpected %#x\n", i, hr);
hr = IPersistStorage_Save(stg, doc2, FALSE); 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)) 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, ok(enumerated_streams == matched_streams, "%d out: enumerated %d != matched %d\n", i,
enumerated_streams, matched_streams); 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, 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); enumerated_streams, test_data[i].out->stream_count);