Commit cdf51b39 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32: Fix CommonPrefixWith() for antimoniker, when other is also antimoniker.

parent 31f5f9da
......@@ -400,25 +400,32 @@ AntiMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
/******************************************************************************
* AntiMoniker_CommonPrefixWith
******************************************************************************/
static HRESULT WINAPI
AntiMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
static HRESULT WINAPI AntiMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *other, IMoniker **prefix)
{
DWORD mkSys;
IMoniker_IsSystemMoniker(pmkOther,&mkSys);
if(mkSys==MKSYS_ANTIMONIKER){
IMoniker_AddRef(iface);
*ppmkPrefix=iface;
AntiMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
HRESULT hr;
IMoniker_AddRef(iface);
TRACE("%p, %p, %p.\n", iface, other, prefix);
return MK_S_US;
other_moniker = unsafe_impl_from_IMoniker(other);
if (other_moniker)
{
if (moniker->count <= other_moniker->count)
{
*prefix = iface;
hr = moniker->count == other_moniker->count ? MK_S_US : MK_S_ME;
}
else
{
*prefix = other;
hr = MK_S_HIM;
}
IMoniker_AddRef(*prefix);
return hr;
}
else
return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
return MonikerCommonPrefixWith(iface, other, prefix);
}
/******************************************************************************
......
......@@ -2430,8 +2430,6 @@ todo_wine
hr = IMoniker_IsEqual(moniker, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
IStream_Release(stream);
/* Reduce() */
hr = IMoniker_Reduce(moniker, NULL, MKRREDUCE_ALL, NULL, &reduced);
ok(hr == MK_S_REDUCED_TO_SELF, "Unexpected hr %#x.\n", hr);
......@@ -2453,6 +2451,70 @@ todo_wine
todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
/* CommonPrefixWith() */
stream_write_dword(stream, 0);
hr = IMoniker_Load(moniker, stream);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &moniker3);
ok(hr == MK_S_ME, "Unexpected hr %#x.\n", hr);
ok(moniker3 == moniker, "Unexpected prefix moniker.\n");
IMoniker_Release(moniker3);
hr = IMoniker_CommonPrefixWith(moniker2, moniker, &moniker3);
ok(hr == MK_S_HIM, "Unexpected hr %#x.\n", hr);
ok(moniker3 == moniker, "Unexpected prefix moniker.\n");
IMoniker_Release(moniker3);
stream_write_dword(stream, 10);
hr = IMoniker_Load(moniker, stream);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
stream_write_dword(stream, 5);
hr = IMoniker_Load(moniker2, stream);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &moniker3);
ok(hr == MK_S_HIM, "Unexpected hr %#x.\n", hr);
ok(moniker3 == moniker2, "Unexpected prefix moniker.\n");
IMoniker_Release(moniker3);
hr = IMoniker_CommonPrefixWith(moniker2, moniker, &moniker3);
ok(hr == MK_S_ME, "Unexpected hr %#x.\n", hr);
ok(moniker3 == moniker2, "Unexpected prefix moniker.\n");
IMoniker_Release(moniker3);
/* Now same length, 0 or 2 */
stream_write_dword(stream, 0);
hr = IMoniker_Load(moniker, stream);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
stream_write_dword(stream, 0);
hr = IMoniker_Load(moniker2, stream);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &moniker3);
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
ok(moniker3 == moniker, "Unexpected prefix moniker.\n");
IMoniker_Release(moniker3);
stream_write_dword(stream, 2);
hr = IMoniker_Load(moniker, stream);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
stream_write_dword(stream, 2);
hr = IMoniker_Load(moniker2, stream);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &moniker3);
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
ok(moniker3 == moniker, "Unexpected prefix moniker.\n");
IMoniker_Release(moniker3);
IStream_Release(stream);
IBindCtx_Release(bindctx);
IMoniker_Release(moniker);
IMoniker_Release(moniker2);
......
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