Commit 12718fe0 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32: A presentation cache for DVASPECT_ICON must have format CF_METAFILEPICT.

parent 8d0a53e6
......@@ -322,19 +322,23 @@ static DataCacheEntry *DataCache_GetEntryForFormatEtc(DataCache *This, const FOR
/* 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 */
static HRESULT check_valid_clipformat_and_tymed(CLIPFORMAT cfFormat, DWORD tymed)
static HRESULT check_valid_formatetc( const FORMATETC *fmt )
{
if (!cfFormat || !tymed ||
(cfFormat == CF_METAFILEPICT && tymed == TYMED_MFPICT) ||
(cfFormat == CF_BITMAP && tymed == TYMED_GDI) ||
(cfFormat == CF_DIB && tymed == TYMED_HGLOBAL) ||
(cfFormat == CF_ENHMETAFILE && tymed == TYMED_ENHMF))
/* DVASPECT_ICON must be CF_METAFILEPICT */
if (fmt->dwAspect == DVASPECT_ICON && fmt->cfFormat != CF_METAFILEPICT)
return DV_E_FORMATETC;
if (!fmt->cfFormat || !fmt->tymed ||
(fmt->cfFormat == CF_METAFILEPICT && fmt->tymed == TYMED_MFPICT) ||
(fmt->cfFormat == CF_BITMAP && fmt->tymed == TYMED_GDI) ||
(fmt->cfFormat == CF_DIB && fmt->tymed == TYMED_HGLOBAL) ||
(fmt->cfFormat == CF_ENHMETAFILE && fmt->tymed == TYMED_ENHMF))
return S_OK;
else if (tymed == TYMED_HGLOBAL)
else if (fmt->tymed == TYMED_HGLOBAL)
return CACHE_S_FORMATETC_NOTSUPPORTED;
else
{
WARN("invalid clipformat/tymed combination: %d/%d\n", cfFormat, tymed);
WARN("invalid clipformat/tymed combination: %d/%d\n", fmt->cfFormat, fmt->tymed);
return DV_E_TYMED;
}
}
......@@ -368,7 +372,7 @@ static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc
DWORD id = automatic ? 1 : This->last_cache_id;
DataCacheEntry *entry;
hr = check_valid_clipformat_and_tymed(formatetc->cfFormat, formatetc->tymed);
hr = check_valid_formatetc( formatetc );
if (FAILED(hr))
return hr;
if (hr == CACHE_S_FORMATETC_NOTSUPPORTED)
......
......@@ -2309,6 +2309,29 @@ static void test_data_cache_cache(void)
hr = IOleCache2_Uncache( cache, view_caching[0].dwConnection );
ok( hr == S_OK, "got %08x\n", hr );
/* Only able to set cfFormat == CF_METAFILEPICT (or == 0, see above) for DVASPECT_ICON */
fmt.dwAspect = DVASPECT_ICON;
fmt.cfFormat = CF_DIB;
fmt.tymed = TYMED_HGLOBAL;
hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
fmt.cfFormat = CF_BITMAP;
fmt.tymed = TYMED_GDI;
hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
fmt.cfFormat = CF_ENHMETAFILE;
fmt.tymed = TYMED_ENHMF;
hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
fmt.cfFormat = CF_METAFILEPICT;
fmt.tymed = TYMED_MFPICT;
hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
ok( hr == S_OK, "got %08x\n", hr );
/* uncache everything */
hr = IOleCache2_Uncache( cache, conn );
ok( hr == S_OK, "got %08x\n", hr );
IDataObject_Release( data );
IOleCache2_Release( cache );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment