[PATCH 1/4] ole32: Implement the DiscardCache function in the data
cache.
Robert Shearman
rob at codeweavers.com
Mon Dec 4 09:51:05 CST 2006
---
dlls/ole32/datacache.c | 31 +++++++++++++++++++++++++++----
dlls/ole32/tests/ole2.c | 4 +---
2 files changed, 28 insertions(+), 7 deletions(-)
-------------- next part --------------
diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index b64143c..232abb8 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -732,6 +732,13 @@ static HRESULT DataCacheEntry_SetData(Da
&This->stgmedium, stgmedium);
}
+static inline HRESULT DataCacheEntry_DiscardData(DataCacheEntry *This)
+{
+ ReleaseStgMedium(&This->stgmedium);
+ This->data_cf = This->fmtetc.cfFormat;
+ return S_OK;
+}
+
/*********************************************************
* Method implementation for the non delegating IUnknown
* part of the DataCache class.
@@ -1327,7 +1334,7 @@ static HRESULT WINAPI DataCache_Load(
hr = DataCache_CreateEntry(This, &fmtetc, &cache_entry);
if (SUCCEEDED(hr))
{
- ReleaseStgMedium(&cache_entry->stgmedium);
+ DataCacheEntry_DiscardData(cache_entry);
if (cache_entry->storage) IStorage_Release(cache_entry->storage);
cache_entry->storage = pStg;
IStorage_AddRef(pStg);
@@ -2016,7 +2023,7 @@ static HRESULT WINAPI DataCache_UpdateCa
DWORD grfUpdf,
LPVOID pReserved)
{
- FIXME("stub\n");
+ FIXME("(%p, 0x%x, %p): stub\n", pDataObject, grfUpdf, pReserved);
return E_NOTIMPL;
}
@@ -2024,8 +2031,24 @@ static HRESULT WINAPI DataCache_DiscardC
IOleCache2* iface,
DWORD dwDiscardOptions)
{
- FIXME("stub\n");
- return E_NOTIMPL;
+ DataCache *This = impl_from_IOleCache2(iface);
+ DataCacheEntry *cache_entry;
+ HRESULT hr = S_OK;
+
+ TRACE("(%d)\n", dwDiscardOptions);
+
+ if (dwDiscardOptions == DISCARDCACHE_SAVEIFDIRTY)
+ hr = DataCache_Save((IPersistStorage *)&This->lpvtblIPersistStorage,
+ This->presentationStorage, TRUE);
+
+ LIST_FOR_EACH_ENTRY(cache_entry, &This->cache_list, DataCacheEntry, entry)
+ {
+ hr = DataCacheEntry_DiscardData(cache_entry);
+ if (FAILED(hr))
+ break;
+ }
+
+ return hr;
}
diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index 36341d5..24e981a 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -1261,9 +1261,7 @@ static void test_data_cache(void)
/* unload the cached storage object, causing it to be reloaded */
hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
- todo_wine {
ok_ole_success(hr, "IOleCache2_DiscardCache");
- }
hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
ok_ole_success(hr, "IViewObject_Draw");
@@ -1272,10 +1270,10 @@ static void test_data_cache(void)
ok_ole_success(hr, "IPersistStorage_HandsOffStorage");
hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
ok_ole_success(hr, "IViewObject_Draw");
- todo_wine {
hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
ok_ole_success(hr, "IOleCache2_DiscardCache");
hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
+ todo_wine {
ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
}
More information about the wine-patches
mailing list