Commit 47967b7c authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32: Implement saving of view cache entries.

parent dfe813e3
......@@ -506,7 +506,9 @@ static HRESULT write_clipformat(IStream *stream, CLIPFORMAT clipformat)
HRESULT hr;
char format_name[256];
if (clipformat < 0xc000)
if (clipformat == 0)
length = 0;
else if (clipformat < 0xc000)
length = -1;
else
{
......@@ -515,8 +517,9 @@ static HRESULT write_clipformat(IStream *stream, CLIPFORMAT clipformat)
if (length) length++;
}
hr = IStream_Write(stream, &length, sizeof(length), NULL);
if (FAILED(hr))
if (FAILED(hr) || clipformat == 0)
return hr;
if (clipformat < 0xc000)
{
DWORD cf = clipformat;
......@@ -993,6 +996,19 @@ static HRESULT save_emf(DataCacheEntry *entry, BOOL contents, IStream *stream)
return hr;
}
static HRESULT save_view_cache(DataCacheEntry *entry, IStream *stream)
{
HRESULT hr;
PresentationDataHeader header;
init_stream_header(entry, &header);
hr = write_clipformat(stream, entry->fmtetc.cfFormat);
if (SUCCEEDED(hr))
hr = IStream_Write(stream, &header, FIELD_OFFSET(PresentationDataHeader, unknown7), NULL);
return hr;
}
static const WCHAR CONTENTS[] = {'C','O','N','T','E','N','T','S',0};
static HRESULT create_stream(DataCacheEntry *cache_entry, IStorage *storage,
BOOL contents, IStream **stream)
......@@ -1037,6 +1053,9 @@ static HRESULT DataCacheEntry_Save(DataCacheEntry *cache_entry, IStorage *storag
case CF_ENHMETAFILE:
hr = save_emf(cache_entry, contents, stream);
break;
case 0:
hr = save_view_cache(cache_entry, stream);
break;
default:
FIXME("got unsupported clipboard format %x\n", cache_entry->fmtetc.cfFormat);
}
......
......@@ -3986,13 +3986,18 @@ static void check_storage_contents(IStorage *stg, const struct storage_def *stg_
hr = IStorage_OpenStream(stg, stat.pwcsName, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
ok(hr == S_OK, "unexpected %#x\n", hr);
if (!memcmp(name, "\2OlePres", 7))
if (!memcmp(name, "\2OlePres", 8))
{
ULONG header_size = sizeof(header);
clipformat = read_clipformat(stream);
hr = IStream_Read(stream, &header, sizeof(header), &bytes);
if (clipformat == 0) /* view cache */
header_size = FIELD_OFFSET(PresentationDataHeader, unknown7);
hr = IStream_Read(stream, &header, header_size, &bytes);
ok(hr == S_OK, "unexpected %#x\n", hr);
ok(bytes >= 24, "read %u bytes\n", bytes);
ok(bytes == header_size, "read %u bytes, expected %u\n", bytes, header_size);
if (winetest_debug > 1)
trace("header: tdSize %#x, dvAspect %#x, lindex %#x, advf %#x, unknown7 %#x, dwObjectExtentX %#x, dwObjectExtentY %#x, dwSize %#x\n",
......@@ -4228,12 +4233,14 @@ static void test_data_cache_save_data(void)
{ CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
{ CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
{ 0, 0, DVASPECT_DOCPRINT, -1, TYMED_HGLOBAL },
},
3, 3, &CLSID_WineTest,
4, 3, &CLSID_WineTest,
{
&CLSID_WineTestOld, 3, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
&CLSID_WineTestOld, 4, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
{ "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, 0, NULL, 0 },
{ "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 } }
{ "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 },
{ "\2OlePres003", 0, DVASPECT_DOCPRINT, 0, NULL, 0 } }
}
},
/* without setting data */
......
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