Huw Davies : ole32: Implement saving of view cache entries.
Alexandre Julliard
julliard at winehq.org
Mon Jan 22 15:34:54 CST 2018
Module: wine
Branch: master
Commit: 47967b7c0871c409c49ca93b308335fdb20d684c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=47967b7c0871c409c49ca93b308335fdb20d684c
Author: Huw Davies <huw at codeweavers.com>
Date: Mon Jan 22 08:54:11 2018 +0000
ole32: Implement saving of view cache entries.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ole32/datacache.c | 23 +++++++++++++++++++++--
dlls/ole32/tests/ole2.c | 19 +++++++++++++------
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index 4ba0826..e2ff928 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -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);
}
diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index fe45c6a..7fcb1aa 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -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 */
More information about the wine-cvs
mailing list