Commit 6235ac9f authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ole32: Implement the DiscardCache function in the data cache.

parent 9108eede
...@@ -732,6 +732,13 @@ static HRESULT DataCacheEntry_SetData(DataCacheEntry *This, ...@@ -732,6 +732,13 @@ static HRESULT DataCacheEntry_SetData(DataCacheEntry *This,
&This->stgmedium, stgmedium); &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 * Method implementation for the non delegating IUnknown
* part of the DataCache class. * part of the DataCache class.
...@@ -1327,7 +1334,7 @@ static HRESULT WINAPI DataCache_Load( ...@@ -1327,7 +1334,7 @@ static HRESULT WINAPI DataCache_Load(
hr = DataCache_CreateEntry(This, &fmtetc, &cache_entry); hr = DataCache_CreateEntry(This, &fmtetc, &cache_entry);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
ReleaseStgMedium(&cache_entry->stgmedium); DataCacheEntry_DiscardData(cache_entry);
if (cache_entry->storage) IStorage_Release(cache_entry->storage); if (cache_entry->storage) IStorage_Release(cache_entry->storage);
cache_entry->storage = pStg; cache_entry->storage = pStg;
IStorage_AddRef(pStg); IStorage_AddRef(pStg);
...@@ -2016,7 +2023,7 @@ static HRESULT WINAPI DataCache_UpdateCache( ...@@ -2016,7 +2023,7 @@ static HRESULT WINAPI DataCache_UpdateCache(
DWORD grfUpdf, DWORD grfUpdf,
LPVOID pReserved) LPVOID pReserved)
{ {
FIXME("stub\n"); FIXME("(%p, 0x%x, %p): stub\n", pDataObject, grfUpdf, pReserved);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -2024,8 +2031,24 @@ static HRESULT WINAPI DataCache_DiscardCache( ...@@ -2024,8 +2031,24 @@ static HRESULT WINAPI DataCache_DiscardCache(
IOleCache2* iface, IOleCache2* iface,
DWORD dwDiscardOptions) DWORD dwDiscardOptions)
{ {
FIXME("stub\n"); DataCache *This = impl_from_IOleCache2(iface);
return E_NOTIMPL; 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;
} }
......
...@@ -1261,9 +1261,7 @@ static void test_data_cache(void) ...@@ -1261,9 +1261,7 @@ static void test_data_cache(void)
/* unload the cached storage object, causing it to be reloaded */ /* unload the cached storage object, causing it to be reloaded */
hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE); hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
todo_wine {
ok_ole_success(hr, "IOleCache2_DiscardCache"); ok_ole_success(hr, "IOleCache2_DiscardCache");
}
hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef); hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
ok_ole_success(hr, "IViewObject_Draw"); ok_ole_success(hr, "IViewObject_Draw");
...@@ -1272,10 +1270,10 @@ static void test_data_cache(void) ...@@ -1272,10 +1270,10 @@ static void test_data_cache(void)
ok_ole_success(hr, "IPersistStorage_HandsOffStorage"); ok_ole_success(hr, "IPersistStorage_HandsOffStorage");
hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef); hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
ok_ole_success(hr, "IViewObject_Draw"); ok_ole_success(hr, "IViewObject_Draw");
todo_wine {
hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE); hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
ok_ole_success(hr, "IOleCache2_DiscardCache"); ok_ole_success(hr, "IOleCache2_DiscardCache");
hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef); 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); ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
} }
......
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