2003-01-03 20:12:55 +01:00
|
|
|
/*
|
2005-03-28 12:01:45 +02:00
|
|
|
* CompositeMonikers implementation
|
1999-03-23 14:48:56 +01:00
|
|
|
*
|
2005-03-28 12:01:45 +02:00
|
|
|
* Copyright 1999 Noomen Hamza
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-01-03 20:12:55 +01:00
|
|
|
*/
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2003-01-07 21:36:20 +01:00
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-08-18 20:35:57 +02:00
|
|
|
#include "winbase.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
1999-03-23 14:48:56 +01:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "ole2.h"
|
2002-12-19 02:09:40 +01:00
|
|
|
#include "moniker.h"
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/heap.h"
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
typedef struct CompositeMonikerImpl
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
IMoniker IMoniker_iface;
|
|
|
|
IROTData IROTData_iface;
|
|
|
|
IMarshal IMarshal_iface;
|
|
|
|
LONG ref;
|
2021-09-21 14:05:08 +02:00
|
|
|
|
|
|
|
IMoniker *left;
|
|
|
|
IMoniker *right;
|
|
|
|
unsigned int comp_count;
|
2011-08-30 00:39:16 +02:00
|
|
|
} CompositeMonikerImpl;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static inline CompositeMonikerImpl *impl_from_IMoniker(IMoniker *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, CompositeMonikerImpl, IMoniker_iface);
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static const IMonikerVtbl VT_CompositeMonikerImpl;
|
|
|
|
|
|
|
|
static CompositeMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface)
|
|
|
|
{
|
|
|
|
if (iface->lpVtbl != &VT_CompositeMonikerImpl)
|
|
|
|
return NULL;
|
|
|
|
return CONTAINING_RECORD(iface, CompositeMonikerImpl, IMoniker_iface);
|
|
|
|
}
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static inline CompositeMonikerImpl *impl_from_IROTData(IROTData *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, CompositeMonikerImpl, IROTData_iface);
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static inline CompositeMonikerImpl *impl_from_IMarshal(IMarshal *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, CompositeMonikerImpl, IMarshal_iface);
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* EnumMoniker data structure */
|
|
|
|
typedef struct EnumMonikerImpl{
|
2011-08-30 00:39:16 +02:00
|
|
|
IEnumMoniker IEnumMoniker_iface;
|
|
|
|
LONG ref;
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker** tabMoniker; /* dynamic table containing the enumerated monikers */
|
|
|
|
ULONG tabSize; /* size of tabMoniker */
|
|
|
|
ULONG currentPos; /* index pointer on the current moniker */
|
|
|
|
} EnumMonikerImpl;
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static inline EnumMonikerImpl *impl_from_IEnumMoniker(IEnumMoniker *iface)
|
2005-07-27 13:10:52 +02:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
static HRESULT EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,ULONG tabSize,ULONG currentPos,BOOL leftToRight,IEnumMoniker ** ppmk);
|
2021-09-23 12:53:11 +02:00
|
|
|
static HRESULT composite_get_rightmost(CompositeMonikerImpl *composite, IMoniker **left, IMoniker **rightmost);
|
2021-09-27 14:31:38 +02:00
|
|
|
static HRESULT composite_get_leftmost(CompositeMonikerImpl *composite, IMoniker **leftmost);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* CompositeMoniker_QueryInterface
|
|
|
|
*******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2016-09-15 23:15:59 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* Perform a sanity check on the parameters.*/
|
2010-07-21 12:15:10 +02:00
|
|
|
if ( ppvObject==0 )
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Initialize the return parameter */
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
|
|
|
/* Compare the riid with the interface IDs implemented by this object.*/
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) ||
|
|
|
|
IsEqualIID(&IID_IPersist, riid) ||
|
|
|
|
IsEqualIID(&IID_IPersistStream, riid) ||
|
|
|
|
IsEqualIID(&IID_IMoniker, riid)
|
|
|
|
)
|
|
|
|
*ppvObject = iface;
|
|
|
|
else if (IsEqualIID(&IID_IROTData, riid))
|
2011-08-30 00:39:16 +02:00
|
|
|
*ppvObject = &This->IROTData_iface;
|
2006-05-08 13:38:55 +02:00
|
|
|
else if (IsEqualIID(&IID_IMarshal, riid))
|
2011-08-30 00:39:16 +02:00
|
|
|
*ppvObject = &This->IMarshal_iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* Check that we obtained an interface.*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
/* Query Interface always increases the reference count by one when it is successful */
|
2005-03-28 12:01:45 +02:00
|
|
|
IMoniker_AddRef(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_AddRef
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
CompositeMonikerImpl_AddRef(IMoniker* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static ULONG WINAPI CompositeMonikerImpl_Release(IMoniker* iface)
|
2006-05-08 13:38:44 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&moniker->ref);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, refcount %u\n", iface, refcount);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
if (moniker->left) IMoniker_Release(moniker->left);
|
|
|
|
if (moniker->right) IMoniker_Release(moniker->right);
|
|
|
|
heap_free(moniker);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
|
|
|
|
return refcount;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_GetClassID
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2006-01-06 21:08:09 +01:00
|
|
|
TRACE("(%p,%p)\n",iface,pClassID);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (pClassID==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*pClassID = CLSID_CompositeMoniker;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_IsDirty
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_IsDirty(IMoniker* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
/* Note that the OLE-provided implementations of the IPersistStream::IsDirty
|
|
|
|
method in the OLE-provided moniker interfaces always return S_FALSE because
|
|
|
|
their internal state never changes. */
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_Load(IMoniker *iface, IStream *stream)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
IMoniker *last, *m, *c;
|
|
|
|
DWORD i, count;
|
|
|
|
HRESULT hr;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, %p\n", iface, stream);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (moniker->comp_count)
|
|
|
|
return E_UNEXPECTED;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
hr = IStream_Read(stream, &count, sizeof(DWORD), NULL);
|
|
|
|
if (hr != S_OK)
|
2006-05-08 13:37:48 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
WARN("Failed to read component count, hr %#x.\n", hr);
|
|
|
|
return hr;
|
2006-05-08 13:37:48 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (count < 2)
|
|
|
|
{
|
|
|
|
WARN("Unexpected component count %u.\n", count);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = OleLoadFromStream(stream, &IID_IMoniker, (void **)&last)))
|
|
|
|
return hr;
|
2006-05-08 13:38:44 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
for (i = 1; i < count - 1; ++i)
|
2006-05-08 13:37:48 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = OleLoadFromStream(stream, &IID_IMoniker, (void **)&m)))
|
2001-05-09 19:31:31 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
WARN("Failed to initialize component %u, hr %#x.\n", i, hr);
|
|
|
|
IMoniker_Release(last);
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
hr = CreateGenericComposite(last, m, &c);
|
|
|
|
IMoniker_Release(last);
|
|
|
|
IMoniker_Release(m);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
last = c;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = OleLoadFromStream(stream, &IID_IMoniker, (void **)&m)))
|
|
|
|
{
|
|
|
|
IMoniker_Release(last);
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
moniker->left = last;
|
|
|
|
moniker->right = m;
|
|
|
|
moniker->comp_count = count;
|
|
|
|
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT composite_save_components(IMoniker *moniker, IStream *stream)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *comp_moniker;
|
|
|
|
HRESULT hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if ((comp_moniker = unsafe_impl_from_IMoniker(moniker)))
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(hr = composite_save_components(comp_moniker->left, stream)))
|
|
|
|
hr = composite_save_components(comp_moniker->right, stream);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = OleSaveToStream((IPersistStream *)moniker, stream);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return hr;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_Save(IMoniker *iface, IStream *stream, BOOL clear_dirty)
|
|
|
|
{
|
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
HRESULT hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, %p, %d\n", iface, stream, clear_dirty);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!moniker->comp_count)
|
|
|
|
return E_UNEXPECTED;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
hr = IStream_Write(stream, &moniker->comp_count, sizeof(moniker->comp_count), NULL);
|
|
|
|
if (FAILED(hr)) return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return composite_save_components(iface, stream);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_GetSizeMax
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_GetSizeMax(IMoniker* iface,ULARGE_INTEGER* pcbSize)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
IEnumMoniker *enumMk;
|
|
|
|
IMoniker *pmk;
|
|
|
|
ULARGE_INTEGER ptmpSize;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* The sizeMax of this object is calculated by calling GetSizeMax on
|
2001-10-22 21:04:32 +02:00
|
|
|
* each moniker within this object then summing all returned values
|
|
|
|
*/
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,pcbSize);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-04-07 12:20:09 +02:00
|
|
|
if (!pcbSize)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_POINTER;
|
|
|
|
|
2006-05-08 13:38:13 +02:00
|
|
|
pcbSize->QuadPart = sizeof(DWORD);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
IMoniker_Enum(iface,TRUE,&enumMk);
|
|
|
|
|
2006-05-08 13:38:13 +02:00
|
|
|
while(IEnumMoniker_Next(enumMk,1,&pmk,NULL)==S_OK){
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
IMoniker_GetSizeMax(pmk,&ptmpSize);
|
|
|
|
|
|
|
|
IMoniker_Release(pmk);
|
|
|
|
|
2019-12-13 11:06:55 +01:00
|
|
|
pcbSize->QuadPart += ptmpSize.QuadPart + sizeof(CLSID);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
static HRESULT compose_with(IMoniker *left, IMoniker *right, IMoniker **c)
|
|
|
|
{
|
|
|
|
HRESULT hr = IMoniker_ComposeWith(left, right, TRUE, c);
|
|
|
|
if (FAILED(hr) && hr != MK_E_NEEDGENERIC) return hr;
|
|
|
|
return CreateGenericComposite(left, right, c);
|
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:07 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_BindToObject(IMoniker *iface, IBindCtx *pbc,
|
2021-09-28 14:56:32 +02:00
|
|
|
IMoniker *toleft, REFIID riid, void **result)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-28 14:56:32 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
IMoniker *left, *rightmost, *c;
|
2021-09-21 14:05:07 +02:00
|
|
|
IRunningObjectTable *rot;
|
|
|
|
IUnknown *object;
|
|
|
|
HRESULT hr;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
TRACE("%p, %p, %p, %s, %p.\n", iface, pbc, toleft, debugstr_guid(riid), result);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:07 +02:00
|
|
|
if (!result)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-21 14:05:07 +02:00
|
|
|
*result = NULL;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
if (!toleft)
|
2021-09-21 14:05:07 +02:00
|
|
|
{
|
|
|
|
hr = IBindCtx_GetRunningObjectTable(pbc, &rot);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IRunningObjectTable_GetObject(rot, iface, &object);
|
|
|
|
IRunningObjectTable_Release(rot);
|
|
|
|
if (FAILED(hr)) return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:07 +02:00
|
|
|
hr = IUnknown_QueryInterface(object, riid, result);
|
|
|
|
IUnknown_Release(object);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
/* Try to bind rightmost component with (toleft, composite->left) composite at its left side */
|
|
|
|
if (FAILED(hr = composite_get_rightmost(moniker, &left, &rightmost)))
|
|
|
|
return hr;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
hr = compose_with(toleft, left, &c);
|
|
|
|
IMoniker_Release(left);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IMoniker_BindToObject(rightmost, pbc, c, riid, result);
|
|
|
|
IMoniker_Release(c);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-28 14:56:32 +02:00
|
|
|
IMoniker_Release(rightmost);
|
|
|
|
|
2021-09-21 14:05:07 +02:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_BindToStorage
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
HRESULT res;
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker *tempMk,*antiMk,*rightMostMk,*leftMk;
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker *enumMoniker;
|
|
|
|
|
2016-09-15 23:15:59 +02:00
|
|
|
TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
*ppvResult=0;
|
|
|
|
|
|
|
|
/* This method recursively calls BindToStorage on the rightmost component of the composite, */
|
|
|
|
/* passing the rest of the composite as the pmkToLeft parameter for that call. */
|
|
|
|
|
2006-05-08 16:54:34 +02:00
|
|
|
if (pmkToLeft)
|
|
|
|
{
|
|
|
|
res = IMoniker_ComposeWith(pmkToLeft, iface, FALSE, &leftMk);
|
|
|
|
if (FAILED(res)) return res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
leftMk = iface;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-05-08 16:54:34 +02:00
|
|
|
IMoniker_Enum(iface, FALSE, &enumMoniker);
|
2016-04-15 14:28:08 +02:00
|
|
|
IEnumMoniker_Next(enumMoniker, 1, &rightMostMk, NULL);
|
2006-05-08 16:54:34 +02:00
|
|
|
IEnumMoniker_Release(enumMoniker);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-05-08 16:54:34 +02:00
|
|
|
res = CreateAntiMoniker(&antiMk);
|
|
|
|
if (FAILED(res)) return res;
|
|
|
|
res = IMoniker_ComposeWith(leftMk, antiMk, 0, &tempMk);
|
|
|
|
if (FAILED(res)) return res;
|
|
|
|
IMoniker_Release(antiMk);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
res = IMoniker_BindToStorage(rightMostMk, pbc, tempMk, riid, ppvResult);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:34 +02:00
|
|
|
IMoniker_Release(tempMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker_Release(rightMostMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:34 +02:00
|
|
|
if (pmkToLeft)
|
|
|
|
IMoniker_Release(leftMk);
|
|
|
|
|
|
|
|
return res;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_Reduce
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar,
|
|
|
|
IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2019-01-30 11:35:23 +01:00
|
|
|
HRESULT res;
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker *tempMk,*antiMk,*rightMostMk,*leftReducedComposedMk,*rightMostReducedMk;
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker *enumMoniker;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p,%p,%d,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppmkReduced==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/* This method recursively calls Reduce for each of its component monikers. */
|
|
|
|
|
|
|
|
if (ppmkToLeft==NULL){
|
|
|
|
|
|
|
|
IMoniker_Enum(iface,FALSE,&enumMoniker);
|
2016-04-15 14:28:08 +02:00
|
|
|
IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL);
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker_Release(enumMoniker);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-04-24 14:11:58 +02:00
|
|
|
CreateAntiMoniker(&antiMk);
|
|
|
|
IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_Release(antiMk);
|
|
|
|
|
2019-01-30 11:35:23 +01:00
|
|
|
res = IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,&tempMk, ppmkReduced);
|
|
|
|
IMoniker_Release(tempMk);
|
|
|
|
IMoniker_Release(rightMostMk);
|
|
|
|
|
|
|
|
return res;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
else if (*ppmkToLeft==NULL)
|
|
|
|
|
|
|
|
return IMoniker_Reduce(iface,pbc,dwReduceHowFar,NULL,ppmkReduced);
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
2001-04-20 20:36:05 +02:00
|
|
|
/* separate the composite moniker in to left and right moniker */
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_Enum(iface,FALSE,&enumMoniker);
|
2016-04-15 14:28:08 +02:00
|
|
|
IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL);
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker_Release(enumMoniker);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-04-24 14:11:58 +02:00
|
|
|
CreateAntiMoniker(&antiMk);
|
|
|
|
IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_Release(antiMk);
|
|
|
|
|
|
|
|
/* If any of the components reduces itself, the method returns S_OK and passes back a composite */
|
|
|
|
/* of the reduced components */
|
2016-04-15 14:28:08 +02:00
|
|
|
if (IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,NULL,&rightMostReducedMk) &&
|
2019-01-30 11:35:23 +01:00
|
|
|
IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,&tempMk,&leftReducedComposedMk) ){
|
|
|
|
IMoniker_Release(tempMk);
|
|
|
|
IMoniker_Release(rightMostMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
return CreateGenericComposite(leftReducedComposedMk,rightMostReducedMk,ppmkReduced);
|
2019-01-30 11:35:23 +01:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
else{
|
|
|
|
/* If no reduction occurred, the method passes back the same moniker and returns MK_S_REDUCED_TO_SELF.*/
|
2019-01-30 11:35:23 +01:00
|
|
|
IMoniker_Release(tempMk);
|
|
|
|
IMoniker_Release(rightMostMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
IMoniker_AddRef(iface);
|
|
|
|
|
|
|
|
*ppmkReduced=iface;
|
|
|
|
|
|
|
|
return MK_S_REDUCED_TO_SELF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-27 14:31:40 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_ComposeWith(IMoniker *iface, IMoniker *right,
|
|
|
|
BOOL only_if_not_generic, IMoniker **composite)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-27 14:31:40 +02:00
|
|
|
TRACE("%p, %p, %d, %p.\n", iface, right, only_if_not_generic, composite);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-27 14:31:40 +02:00
|
|
|
*composite = NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-27 14:31:40 +02:00
|
|
|
return only_if_not_generic ? MK_E_NEEDGENERIC : CreateGenericComposite(iface, right, composite);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static void composite_get_components(IMoniker *moniker, IMoniker **components, unsigned int *index)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *comp_moniker;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if ((comp_moniker = unsafe_impl_from_IMoniker(moniker)))
|
|
|
|
{
|
|
|
|
composite_get_components(comp_moniker->left, components, index);
|
|
|
|
composite_get_components(comp_moniker->right, components, index);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
components[*index] = moniker;
|
|
|
|
(*index)++;
|
|
|
|
}
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
static HRESULT composite_get_components_alloc(CompositeMonikerImpl *moniker, IMoniker ***components)
|
|
|
|
{
|
|
|
|
unsigned int index;
|
|
|
|
|
|
|
|
if (!(*components = heap_alloc(moniker->comp_count * sizeof(**components))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
composite_get_components(&moniker->IMoniker_iface, *components, &index);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_Enum(IMoniker *iface, BOOL forward, IEnumMoniker **ppenumMoniker)
|
|
|
|
{
|
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
IMoniker **monikers;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p, %d, %p\n", iface, forward, ppenumMoniker);
|
|
|
|
|
|
|
|
if (!ppenumMoniker)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if (FAILED(hr = composite_get_components_alloc(moniker, &monikers)))
|
|
|
|
return hr;
|
2021-09-21 14:05:08 +02:00
|
|
|
|
|
|
|
hr = EnumMonikerImpl_CreateEnumMoniker(monikers, moniker->comp_count, 0, forward, ppenumMoniker);
|
|
|
|
heap_free(monikers);
|
|
|
|
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-27 14:31:39 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
|
|
|
|
IMoniker **components, **other_components;
|
|
|
|
unsigned int i;
|
|
|
|
HRESULT hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
TRACE("%p, %p.\n", iface, other);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
if (!other)
|
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
if (!(other_moniker = unsafe_impl_from_IMoniker(other)))
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
if (moniker->comp_count != other_moniker->comp_count)
|
|
|
|
return S_FALSE;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
if (FAILED(hr = composite_get_components_alloc(moniker, &components))) return hr;
|
|
|
|
if (FAILED(hr = composite_get_components_alloc(other_moniker, &other_components)))
|
|
|
|
{
|
|
|
|
heap_free(components);
|
|
|
|
return hr;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
for (i = 0; i < moniker->comp_count; ++i)
|
|
|
|
{
|
|
|
|
if ((hr = IMoniker_IsEqual(components[i], other_components[i]) != S_OK))
|
|
|
|
break;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
heap_free(other_components);
|
|
|
|
heap_free(components);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:39 +02:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_Hash(IMoniker *iface, DWORD *hash)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
DWORD left_hash, right_hash;
|
|
|
|
HRESULT hr;
|
2005-05-23 11:52:13 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, %p\n", iface, hash);
|
2005-05-23 11:52:13 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!hash)
|
2005-05-23 11:52:13 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!moniker->comp_count)
|
|
|
|
return E_UNEXPECTED;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
*hash = 0;
|
2006-05-08 16:04:41 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = IMoniker_Hash(moniker->left, &left_hash))) return hr;
|
|
|
|
if (FAILED(hr = IMoniker_Hash(moniker->right, &right_hash))) return hr;
|
2005-05-23 11:52:13 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
*hash = left_hash ^ right_hash;
|
2005-05-23 11:52:13 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_IsRunning
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
IRunningObjectTable* rot;
|
|
|
|
HRESULT res;
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker *tempMk,*antiMk,*rightMostMk;
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker *enumMoniker;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* If pmkToLeft is non-NULL, this method composes pmkToLeft with this moniker and calls IsRunning on the result.*/
|
|
|
|
if (pmkToLeft!=NULL){
|
|
|
|
|
|
|
|
CreateGenericComposite(pmkToLeft,iface,&tempMk);
|
|
|
|
|
|
|
|
res = IMoniker_IsRunning(tempMk,pbc,NULL,pmkNewlyRunning);
|
|
|
|
|
|
|
|
IMoniker_Release(tempMk);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* If pmkToLeft is NULL, this method returns S_OK if pmkNewlyRunning is non-NULL and is equal */
|
|
|
|
/* to this moniker */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (pmkNewlyRunning!=NULL)
|
|
|
|
|
|
|
|
if (IMoniker_IsEqual(iface,pmkNewlyRunning)==S_OK)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
if (pbc==NULL)
|
2010-03-02 00:15:11 +01:00
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* If pmkToLeft and pmkNewlyRunning are both NULL, this method checks the ROT to see whether */
|
|
|
|
/* the moniker is running. If so, the method returns S_OK; otherwise, it recursively calls */
|
|
|
|
/* IMoniker::IsRunning on the rightmost component of the composite, passing the remainder of */
|
|
|
|
/* the composite as the pmkToLeft parameter for that call. */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
res=IBindCtx_GetRunningObjectTable(pbc,&rot);
|
|
|
|
|
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
res = IRunningObjectTable_IsRunning(rot,iface);
|
|
|
|
IRunningObjectTable_Release(rot);
|
|
|
|
|
|
|
|
if(res==S_OK)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
IMoniker_Enum(iface,FALSE,&enumMoniker);
|
2016-04-15 14:28:08 +02:00
|
|
|
IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL);
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker_Release(enumMoniker);
|
|
|
|
|
|
|
|
res=CreateAntiMoniker(&antiMk);
|
|
|
|
res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
|
|
|
|
IMoniker_Release(antiMk);
|
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
res=IMoniker_IsRunning(rightMostMk,pbc,tempMk,pmkNewlyRunning);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
IMoniker_Release(tempMk);
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker_Release(rightMostMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
|
|
|
|
IMoniker *toleft, FILETIME *changetime)
|
|
|
|
{
|
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
IMoniker *left, *rightmost, *composed_left = NULL, *running = NULL;
|
|
|
|
IRunningObjectTable *rot;
|
|
|
|
HRESULT hr;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
TRACE("%p, %p, %p, %p.\n", iface, pbc, toleft, changetime);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
if (!changetime || !pbc)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
if (FAILED(hr = composite_get_rightmost(moniker, &left, &rightmost)))
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
if (toleft)
|
|
|
|
{
|
|
|
|
/* Compose (toleft, left) and check that against rightmost */
|
|
|
|
if (SUCCEEDED(hr = compose_with(toleft, left, &composed_left)) && composed_left)
|
|
|
|
hr = compose_with(composed_left, rightmost, &running);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
composed_left = left;
|
|
|
|
IMoniker_AddRef(composed_left);
|
|
|
|
running = iface;
|
|
|
|
IMoniker_AddRef(running);
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(hr = IBindCtx_GetRunningObjectTable(pbc, &rot)))
|
2006-05-08 16:54:43 +02:00
|
|
|
{
|
2021-09-23 12:53:12 +02:00
|
|
|
if (IRunningObjectTable_GetTimeOfLastChange(rot, running, changetime) != S_OK)
|
|
|
|
hr = IMoniker_GetTimeOfLastChange(rightmost, pbc, composed_left, changetime);
|
|
|
|
IRunningObjectTable_Release(rot);
|
2006-05-08 16:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
if (composed_left)
|
|
|
|
IMoniker_Release(composed_left);
|
|
|
|
if (running)
|
|
|
|
IMoniker_Release(running);
|
|
|
|
IMoniker_Release(rightmost);
|
|
|
|
IMoniker_Release(left);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:12 +02:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_Inverse(IMoniker *iface, IMoniker **inverse)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-28 14:56:27 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
IMoniker *right_inverted, *left_inverted;
|
|
|
|
HRESULT hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
TRACE("%p, %p.\n", iface, inverse);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
if (!inverse)
|
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
*inverse = NULL;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
if (FAILED(hr = IMoniker_Inverse(moniker->right, &right_inverted))) return hr;
|
|
|
|
if (FAILED(hr = IMoniker_Inverse(moniker->left, &left_inverted)))
|
|
|
|
{
|
|
|
|
IMoniker_Release(right_inverted);
|
|
|
|
return hr;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
hr = CreateGenericComposite(right_inverted, left_inverted, inverse);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
IMoniker_Release(left_inverted);
|
|
|
|
IMoniker_Release(right_inverted);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-28 14:56:27 +02:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *other,
|
|
|
|
IMoniker **prefix)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-27 14:31:38 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
|
|
|
|
unsigned int i, count, prefix_len = 0;
|
|
|
|
IMoniker *leftmost;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p.\n", iface, other, prefix);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* If the other moniker is a composite, this method compares the components of each composite from left */
|
|
|
|
/* to right. The returned common prefix moniker might also be a composite moniker, depending on how many */
|
|
|
|
/* of the leftmost components were common to both monikers. */
|
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if (prefix)
|
|
|
|
*prefix = NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if (!other || !prefix)
|
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if ((other_moniker = unsafe_impl_from_IMoniker(other)))
|
|
|
|
{
|
|
|
|
IMoniker **components, **other_components, **prefix_components;
|
|
|
|
IMoniker *last, *c;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if (FAILED(hr = composite_get_components_alloc(moniker, &components))) return hr;
|
|
|
|
if (FAILED(hr = composite_get_components_alloc(other_moniker, &other_components)))
|
|
|
|
{
|
|
|
|
heap_free(components);
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
count = min(moniker->comp_count, other_moniker->comp_count);
|
|
|
|
if (!(prefix_components = heap_calloc(count, sizeof(*prefix_components))))
|
|
|
|
{
|
|
|
|
heap_free(components);
|
|
|
|
heap_free(other_components);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
/* Collect prefix components */
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
IMoniker *p;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if (FAILED(hr = IMoniker_CommonPrefixWith(components[i], other_components[i], &p)))
|
|
|
|
break;
|
|
|
|
prefix_components[prefix_len++] = p;
|
|
|
|
/* S_OK means that prefix was found and is neither of tested monikers */
|
|
|
|
if (hr == S_OK) break;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
heap_free(components);
|
|
|
|
heap_free(other_components);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if (!prefix_len) return MK_E_NOPREFIX;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
last = prefix_components[0];
|
|
|
|
for (i = 1; i < prefix_len; ++i)
|
|
|
|
{
|
|
|
|
hr = CreateGenericComposite(last, prefix_components[i], &c);
|
|
|
|
IMoniker_Release(last);
|
|
|
|
IMoniker_Release(prefix_components[i]);
|
|
|
|
if (FAILED(hr)) break;
|
|
|
|
last = c;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2021-09-27 14:31:38 +02:00
|
|
|
heap_free(prefix_components);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
*prefix = last;
|
|
|
|
if (IMoniker_IsEqual(iface, *prefix) == S_OK)
|
|
|
|
hr = MK_S_US;
|
|
|
|
else if (prefix_len < count)
|
|
|
|
hr = S_OK;
|
|
|
|
else
|
|
|
|
hr = prefix_len == moniker->comp_count ? MK_S_ME : MK_S_HIM;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
return hr;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
/* For non-composite, compare to leftmost component */
|
|
|
|
if (SUCCEEDED(hr = composite_get_leftmost(moniker, &leftmost)))
|
|
|
|
{
|
|
|
|
if ((hr = IMoniker_IsEqual(leftmost, other)) == S_OK)
|
|
|
|
{
|
|
|
|
*prefix = leftmost;
|
|
|
|
IMoniker_AddRef(*prefix);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2021-09-27 14:31:38 +02:00
|
|
|
|
|
|
|
hr = hr == S_OK ? MK_S_HIM : MK_E_NOPREFIX;
|
|
|
|
IMoniker_Release(leftmost);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2021-09-27 14:31:38 +02:00
|
|
|
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/***************************************************************************************************
|
|
|
|
* GetAfterCommonPrefix (local function)
|
|
|
|
* This function returns a moniker that consist of the remainder when the common prefix is removed
|
|
|
|
***************************************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static VOID GetAfterCommonPrefix(IMoniker* pGenMk,IMoniker* commonMk,IMoniker** restMk)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
IMoniker *tempMk,*tempMk1,*tempMk2;
|
|
|
|
IEnumMoniker *enumMoniker1,*enumMoniker2,*enumMoniker3;
|
|
|
|
ULONG nbRestMk=0;
|
|
|
|
DWORD mkSys;
|
|
|
|
HRESULT res1,res2;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*restMk=0;
|
|
|
|
|
|
|
|
/* to create an enumerator for pGenMk with current position pointed on the first element after common */
|
2001-04-20 20:36:05 +02:00
|
|
|
/* prefix: enum the two monikers (left-right) then compare these enumerations (left-right) and stop */
|
1999-03-23 14:48:56 +01:00
|
|
|
/* on the first difference. */
|
|
|
|
IMoniker_Enum(pGenMk,TRUE,&enumMoniker1);
|
|
|
|
|
|
|
|
IMoniker_IsSystemMoniker(commonMk,&mkSys);
|
|
|
|
|
|
|
|
if (mkSys==MKSYS_GENERICCOMPOSITE){
|
|
|
|
|
|
|
|
IMoniker_Enum(commonMk,TRUE,&enumMoniker2);
|
|
|
|
while(1){
|
|
|
|
|
|
|
|
res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
|
|
|
|
res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL);
|
|
|
|
|
|
|
|
if ((res1==S_FALSE)||(res2==S_FALSE)){
|
|
|
|
|
|
|
|
if (res1==S_OK)
|
|
|
|
|
|
|
|
nbRestMk++;
|
|
|
|
|
|
|
|
IMoniker_Release(tempMk1);
|
2009-08-29 14:23:48 +02:00
|
|
|
IMoniker_Release(tempMk2);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMoniker_Release(tempMk1);
|
2009-08-29 14:23:48 +02:00
|
|
|
IMoniker_Release(tempMk2);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
|
|
|
|
IMoniker_Release(tempMk1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* count the number of elements in the enumerator after the common prefix */
|
|
|
|
IEnumMoniker_Clone(enumMoniker1,&enumMoniker3);
|
|
|
|
|
|
|
|
for(;IEnumMoniker_Next(enumMoniker3,1,&tempMk,NULL)==S_OK;nbRestMk++)
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
IMoniker_Release(tempMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (nbRestMk==0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* create a generic composite moniker with monikers located after the common prefix */
|
|
|
|
IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
|
|
|
|
|
|
|
|
if (nbRestMk==1){
|
|
|
|
|
|
|
|
*restMk= tempMk1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
IEnumMoniker_Next(enumMoniker1,1,&tempMk2,NULL);
|
|
|
|
|
|
|
|
CreateGenericComposite(tempMk1,tempMk2,restMk);
|
|
|
|
|
|
|
|
IMoniker_Release(tempMk1);
|
|
|
|
|
|
|
|
IMoniker_Release(tempMk2);
|
|
|
|
|
|
|
|
while(IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL)==S_OK){
|
|
|
|
|
|
|
|
CreateGenericComposite(*restMk,tempMk1,&tempMk2);
|
|
|
|
|
|
|
|
IMoniker_Release(tempMk1);
|
|
|
|
|
|
|
|
IMoniker_Release(*restMk);
|
|
|
|
|
|
|
|
*restMk=tempMk2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_RelativePathTo
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmkOther,
|
|
|
|
IMoniker** ppmkRelPath)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
HRESULT res;
|
|
|
|
IMoniker *restOtherMk=0,*restThisMk=0,*invRestThisMk=0,*commonMk=0;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",iface,pmkOther,ppmkRelPath);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppmkRelPath==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppmkRelPath=0;
|
|
|
|
|
|
|
|
/* This method finds the common prefix of the two monikers and creates two monikers that consist */
|
|
|
|
/* of the remainder when the common prefix is removed. Then it creates the inverse for the remainder */
|
|
|
|
/* of this moniker and composes the remainder of the other moniker on the right of it. */
|
|
|
|
|
|
|
|
/* finds the common prefix of the two monikers */
|
2002-06-01 01:06:46 +02:00
|
|
|
res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* if there's no common prefix or the two moniker are equal the relative is the other moniker */
|
|
|
|
if ((res== MK_E_NOPREFIX)||(res==MK_S_US)){
|
|
|
|
|
|
|
|
*ppmkRelPath=pmkOther;
|
|
|
|
IMoniker_AddRef(pmkOther);
|
|
|
|
return MK_S_HIM;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetAfterCommonPrefix(iface,commonMk,&restThisMk);
|
|
|
|
GetAfterCommonPrefix(pmkOther,commonMk,&restOtherMk);
|
|
|
|
|
|
|
|
/* if other is a prefix of this moniker the relative path is the inverse of the remainder path of this */
|
|
|
|
/* moniker when the common prefix is removed */
|
|
|
|
if (res==MK_S_HIM){
|
|
|
|
|
|
|
|
IMoniker_Inverse(restThisMk,ppmkRelPath);
|
|
|
|
IMoniker_Release(restThisMk);
|
|
|
|
}
|
|
|
|
/* if this moniker is a prefix of other moniker the relative path is the remainder path of other moniker */
|
|
|
|
/* when the common prefix is removed */
|
|
|
|
else if (res==MK_S_ME){
|
|
|
|
|
|
|
|
*ppmkRelPath=restOtherMk;
|
|
|
|
IMoniker_AddRef(restOtherMk);
|
|
|
|
}
|
|
|
|
/* the relative path is the inverse for the remainder of this moniker and the remainder of the other */
|
|
|
|
/* moniker on the right of it. */
|
|
|
|
else if (res==S_OK){
|
|
|
|
|
|
|
|
IMoniker_Inverse(restThisMk,&invRestThisMk);
|
|
|
|
IMoniker_Release(restThisMk);
|
|
|
|
CreateGenericComposite(invRestThisMk,restOtherMk,ppmkRelPath);
|
|
|
|
IMoniker_Release(invRestThisMk);
|
|
|
|
IMoniker_Release(restOtherMk);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
|
|
|
|
IMoniker *pmkToLeft, LPOLESTR *displayname)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
WCHAR *left_name = NULL, *right_name = NULL;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, %p, %p, %p\n", iface, pbc, pmkToLeft, displayname);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!displayname)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!moniker->comp_count)
|
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
IMoniker_GetDisplayName(moniker->left, pbc, NULL, &left_name);
|
|
|
|
IMoniker_GetDisplayName(moniker->right, pbc, NULL, &right_name);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!(*displayname = CoTaskMemAlloc((lstrlenW(left_name) + lstrlenW(right_name) + 1) * sizeof(WCHAR))))
|
|
|
|
{
|
|
|
|
CoTaskMemFree(left_name);
|
|
|
|
CoTaskMemFree(right_name);
|
|
|
|
return E_OUTOFMEMORY;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
lstrcpyW(*displayname, left_name);
|
|
|
|
lstrcatW(*displayname, right_name);
|
|
|
|
|
|
|
|
CoTaskMemFree(left_name);
|
|
|
|
CoTaskMemFree(right_name);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-23 12:53:11 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerImpl_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
|
|
|
|
IMoniker *pmkToLeft, LPOLESTR name, ULONG *eaten, IMoniker **result)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-23 12:53:11 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
|
|
|
|
IMoniker *left, *rightmost;
|
|
|
|
HRESULT hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:11 +02:00
|
|
|
TRACE("%p, %p, %p, %s, %p, %p.\n", iface, pbc, pmkToLeft, debugstr_w(name), eaten, result);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:11 +02:00
|
|
|
if (!pbc)
|
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-23 12:53:11 +02:00
|
|
|
if (FAILED(hr = composite_get_rightmost(moniker, &left, &rightmost)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* Let rightmost component parse the name, using what's left of the composite as a left side. */
|
|
|
|
hr = IMoniker_ParseDisplayName(rightmost, pbc, left, name, eaten, result);
|
|
|
|
|
|
|
|
IMoniker_Release(left);
|
|
|
|
IMoniker_Release(rightmost);
|
|
|
|
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-04-20 20:36:05 +02:00
|
|
|
* CompositeMoniker_IsSystemMoniker
|
1999-03-23 14:48:56 +01:00
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,pwdMksys);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (!pwdMksys)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
(*pwdMksys)=MKSYS_GENERICCOMPOSITE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* CompositeMonikerIROTData_QueryInterface
|
|
|
|
*******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,
|
|
|
|
VOID** ppvObject)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IROTData(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2016-09-15 23:15:59 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",iface,debugstr_guid(riid),ppvObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return CompositeMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CompositeMonikerIROTData_AddRef
|
|
|
|
*/
|
2005-03-28 12:01:45 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
CompositeMonikerROTDataImpl_AddRef(IROTData *iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IROTData(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return IMoniker_AddRef(&This->IMoniker_iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CompositeMonikerIROTData_Release
|
|
|
|
*/
|
2005-03-28 12:01:45 +02:00
|
|
|
static ULONG WINAPI CompositeMonikerROTDataImpl_Release(IROTData* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IROTData(iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return IMoniker_Release(&This->IMoniker_iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT composite_get_moniker_comparison_data(IMoniker *moniker,
|
|
|
|
BYTE *data, ULONG max_len, ULONG *ret_len)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
IROTData *rot_data;
|
2006-05-08 13:37:25 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = IMoniker_QueryInterface(moniker, &IID_IROTData, (void **)&rot_data)))
|
2006-05-08 13:37:25 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
WARN("Failed to get IROTData for component moniker, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
hr = IROTData_GetComparisonData(rot_data, data, max_len, ret_len);
|
|
|
|
IROTData_Release(rot_data);
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerROTDataImpl_GetComparisonData(IROTData *iface,
|
|
|
|
BYTE *data, ULONG max_len, ULONG *ret_len)
|
|
|
|
{
|
|
|
|
CompositeMonikerImpl *moniker = impl_from_IROTData(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG len;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %u, %p\n", iface, data, max_len, ret_len);
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!moniker->comp_count)
|
|
|
|
return E_UNEXPECTED;
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
/* Get required size first */
|
|
|
|
*ret_len = sizeof(CLSID);
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
len = 0;
|
|
|
|
hr = composite_get_moniker_comparison_data(moniker->left, NULL, 0, &len);
|
|
|
|
if (SUCCEEDED(hr) || hr == E_OUTOFMEMORY)
|
|
|
|
*ret_len += len;
|
|
|
|
else
|
2006-05-08 13:37:25 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
WARN("Failed to get comparison data length for left component, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
len = 0;
|
|
|
|
hr = composite_get_moniker_comparison_data(moniker->right, NULL, 0, &len);
|
|
|
|
if (SUCCEEDED(hr) || hr == E_OUTOFMEMORY)
|
|
|
|
*ret_len += len;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Failed to get comparison data length for right component, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (max_len < *ret_len)
|
|
|
|
return E_OUTOFMEMORY;
|
2006-05-08 13:37:25 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
memcpy(data, &CLSID_CompositeMoniker, sizeof(CLSID));
|
|
|
|
data += sizeof(CLSID);
|
|
|
|
max_len -= sizeof(CLSID);
|
|
|
|
if (FAILED(hr = composite_get_moniker_comparison_data(moniker->left, data, max_len, &len)))
|
|
|
|
{
|
|
|
|
WARN("Failed to get comparison data for left component, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
data += len;
|
|
|
|
max_len -= len;
|
|
|
|
if (FAILED(hr = composite_get_moniker_comparison_data(moniker->right, data, max_len, &len)))
|
|
|
|
{
|
|
|
|
WARN("Failed to get comparison data for right component, hr %#x.\n", hr);
|
|
|
|
return hr;
|
2006-05-08 13:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2006-05-08 13:38:55 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_QueryInterface(IMarshal *iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%s,%p)\n",iface,debugstr_guid(riid),ppv);
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return CompositeMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppv);
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CompositeMonikerMarshalImpl_AddRef(IMarshal *iface)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",iface);
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return CompositeMonikerImpl_AddRef(&This->IMoniker_iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CompositeMonikerMarshalImpl_Release(IMarshal *iface)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",iface);
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return CompositeMonikerImpl_Release(&This->IMoniker_iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_GetUnmarshalClass(
|
2011-08-30 00:39:16 +02:00
|
|
|
IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext,
|
2006-05-08 13:38:55 +02:00
|
|
|
void* pvDestContext, DWORD mshlflags, CLSID* pCid)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid), pv,
|
2006-05-08 13:38:55 +02:00
|
|
|
dwDestContext, pvDestContext, mshlflags, pCid);
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return IMoniker_GetClassID(&This->IMoniker_iface, pCid);
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_GetMarshalSizeMax(
|
2011-08-30 00:39:16 +02:00
|
|
|
IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext,
|
2006-05-08 13:38:55 +02:00
|
|
|
void* pvDestContext, DWORD mshlflags, DWORD* pSize)
|
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
HRESULT hr;
|
2021-09-21 14:05:08 +02:00
|
|
|
ULONG size;
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid), pv,
|
2006-05-08 13:38:55 +02:00
|
|
|
dwDestContext, pvDestContext, mshlflags, pSize);
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!moniker->comp_count)
|
|
|
|
return E_UNEXPECTED;
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
*pSize = 0x10; /* to match native */
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = CoGetMarshalSizeMax(&size, &IID_IMoniker, (IUnknown *)moniker->left, dwDestContext,
|
|
|
|
pvDestContext, mshlflags)))
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
return hr;
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
*pSize += size;
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = CoGetMarshalSizeMax(&size, &IID_IMoniker, (IUnknown *)moniker->right, dwDestContext,
|
|
|
|
pvDestContext, mshlflags)))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
*pSize += size;
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return hr;
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_MarshalInterface(IMarshal *iface, IStream *stream,
|
|
|
|
REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD flags)
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, %p, %s, %p, %x, %p, %#x\n", iface, stream, debugstr_guid(riid), pv, dwDestContext, pvDestContext, flags);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!moniker->comp_count)
|
|
|
|
return E_UNEXPECTED;
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = CoMarshalInterface(stream, &IID_IMoniker, (IUnknown *)moniker->left, dwDestContext, pvDestContext, flags)))
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
WARN("Failed to marshal left component, hr %#x.\n", hr);
|
|
|
|
return hr;
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = CoMarshalInterface(stream, &IID_IMoniker, (IUnknown *)moniker->right, dwDestContext, pvDestContext, flags)))
|
|
|
|
WARN("Failed to marshal right component, hr %#x.\n", hr);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return hr;
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_UnmarshalInterface(IMarshal *iface, IStream *stream,
|
|
|
|
REFIID riid, void **ppv)
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
CompositeMonikerImpl *moniker = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, %p, %s, %p\n", iface, stream, debugstr_guid(riid), ppv);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (moniker->left)
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
IMoniker_Release(moniker->left);
|
|
|
|
moniker->left = NULL;
|
|
|
|
}
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (moniker->right)
|
|
|
|
{
|
|
|
|
IMoniker_Release(moniker->right);
|
|
|
|
moniker->right = NULL;
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = CoUnmarshalInterface(stream, &IID_IMoniker, (void **)&moniker->left)))
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
WARN("Failed to unmarshal left moniker, hr %#x.\n", hr);
|
2006-05-08 13:38:55 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = CoUnmarshalInterface(stream, &IID_IMoniker, (void **)&moniker->right)))
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
WARN("Failed to unmarshal right moniker, hr %#x.\n", hr);
|
2006-05-08 13:38:55 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return IMoniker_QueryInterface(&moniker->IMoniker_iface, riid, ppv);
|
2006-05-08 13:38:55 +02:00
|
|
|
}
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_ReleaseMarshalData(IMarshal *iface, IStream *pStm)
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pStm);
|
|
|
|
/* can't release a state-based marshal as nothing on server side to
|
|
|
|
* release */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_DisconnectObject(IMarshal *iface,
|
|
|
|
DWORD dwReserved)
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(0x%x)\n", dwReserved);
|
2006-05-08 13:38:55 +02:00
|
|
|
/* can't disconnect a state-based marshal as nothing on server side to
|
|
|
|
* disconnect from */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_QueryInterface
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
EnumMonikerImpl_QueryInterface(IEnumMoniker* iface,REFIID riid,void** ppvObject)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2016-09-15 23:15:59 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* Perform a sanity check on the parameters.*/
|
2010-07-21 12:15:10 +02:00
|
|
|
if ( ppvObject==0 )
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Initialize the return parameter */
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
|
|
|
/* Compare the riid with the interface IDs implemented by this object.*/
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IEnumMoniker, riid))
|
|
|
|
*ppvObject = iface;
|
|
|
|
|
|
|
|
/* Check that we obtained an interface.*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
/* Query Interface always increases the reference count by one when it is successful */
|
2005-03-28 12:01:45 +02:00
|
|
|
IEnumMoniker_AddRef(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_AddRef
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
EnumMonikerImpl_AddRef(IEnumMoniker* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_Release
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
EnumMonikerImpl_Release(IEnumMoniker* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG i;
|
|
|
|
ULONG ref;
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2013-11-20 23:39:28 +01:00
|
|
|
/* destroy the object if there are no more references to it */
|
2004-09-24 03:16:53 +02:00
|
|
|
if (ref == 0) {
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
for(i=0;i<This->tabSize;i++)
|
|
|
|
IMoniker_Release(This->tabMoniker[i]);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,This->tabMoniker);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_Next
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
EnumMonikerImpl_Next(IEnumMoniker* iface,ULONG celt, IMoniker** rgelt,
|
|
|
|
ULONG* pceltFethed)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
/* retrieve the requested number of moniker from the current position */
|
|
|
|
for(i=0;((This->currentPos < This->tabSize) && (i < celt));i++)
|
2006-05-08 13:38:34 +02:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
rgelt[i]=This->tabMoniker[This->currentPos++];
|
2006-05-08 13:38:34 +02:00
|
|
|
IMoniker_AddRef(rgelt[i]);
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (pceltFethed!=NULL)
|
|
|
|
*pceltFethed= i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (i==celt)
|
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_Skip
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
EnumMonikerImpl_Skip(IEnumMoniker* iface,ULONG celt)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if ((This->currentPos+celt) >= This->tabSize)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
This->currentPos+=celt;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_Reset
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
EnumMonikerImpl_Reset(IEnumMoniker* iface)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
This->currentPos=0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_Clone
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
EnumMonikerImpl_Clone(IEnumMoniker* iface,IEnumMoniker** ppenum)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return EnumMonikerImpl_CreateEnumMoniker(This->tabMoniker,This->tabSize,This->currentPos,TRUE,ppenum);
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IEnumMonikerVtbl VT_EnumMonikerImpl =
|
2005-03-28 12:01:45 +02:00
|
|
|
{
|
|
|
|
EnumMonikerImpl_QueryInterface,
|
|
|
|
EnumMonikerImpl_AddRef,
|
|
|
|
EnumMonikerImpl_Release,
|
|
|
|
EnumMonikerImpl_Next,
|
|
|
|
EnumMonikerImpl_Skip,
|
|
|
|
EnumMonikerImpl_Reset,
|
|
|
|
EnumMonikerImpl_Clone
|
|
|
|
};
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* EnumMonikerImpl_CreateEnumMoniker
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT
|
|
|
|
EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker, ULONG tabSize,
|
2013-02-21 23:30:15 +01:00
|
|
|
ULONG currentPos, BOOL leftToRight, IEnumMoniker ** ppmk)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
EnumMonikerImpl* newEnumMoniker;
|
2013-02-21 23:30:15 +01:00
|
|
|
ULONG i;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2003-09-30 02:24:08 +02:00
|
|
|
if (currentPos > tabSize)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
newEnumMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl));
|
|
|
|
|
|
|
|
if (newEnumMoniker == 0)
|
|
|
|
return STG_E_INSUFFICIENTMEMORY;
|
|
|
|
|
|
|
|
/* Initialize the virtual function table. */
|
2011-08-30 00:39:16 +02:00
|
|
|
newEnumMoniker->IEnumMoniker_iface.lpVtbl = &VT_EnumMonikerImpl;
|
2006-05-08 13:44:37 +02:00
|
|
|
newEnumMoniker->ref = 1;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
newEnumMoniker->tabSize=tabSize;
|
|
|
|
newEnumMoniker->currentPos=currentPos;
|
|
|
|
|
2013-06-27 23:36:54 +02:00
|
|
|
newEnumMoniker->tabMoniker=HeapAlloc(GetProcessHeap(),0,tabSize*sizeof(newEnumMoniker->tabMoniker[0]));
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2003-09-30 02:24:08 +02:00
|
|
|
if (newEnumMoniker->tabMoniker==NULL) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, newEnumMoniker);
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2003-09-30 02:24:08 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2013-02-21 23:30:15 +01:00
|
|
|
if (leftToRight)
|
1999-03-23 14:48:56 +01:00
|
|
|
for (i=0;i<tabSize;i++){
|
|
|
|
|
|
|
|
newEnumMoniker->tabMoniker[i]=tabMoniker[i];
|
|
|
|
IMoniker_AddRef(tabMoniker[i]);
|
|
|
|
}
|
|
|
|
else
|
2013-02-21 23:30:15 +01:00
|
|
|
for (i = tabSize; i > 0; i--){
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2013-02-21 23:30:15 +01:00
|
|
|
newEnumMoniker->tabMoniker[tabSize-i]=tabMoniker[i - 1];
|
|
|
|
IMoniker_AddRef(tabMoniker[i - 1]);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
*ppmk=&newEnumMoniker->IEnumMoniker_iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-03-28 12:01:45 +02:00
|
|
|
/********************************************************************************/
|
|
|
|
/* Virtual function table for the CompositeMonikerImpl class which includes */
|
|
|
|
/* IPersist, IPersistStream and IMoniker functions. */
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IMonikerVtbl VT_CompositeMonikerImpl =
|
2005-03-28 12:01:45 +02:00
|
|
|
{
|
|
|
|
CompositeMonikerImpl_QueryInterface,
|
|
|
|
CompositeMonikerImpl_AddRef,
|
|
|
|
CompositeMonikerImpl_Release,
|
|
|
|
CompositeMonikerImpl_GetClassID,
|
|
|
|
CompositeMonikerImpl_IsDirty,
|
|
|
|
CompositeMonikerImpl_Load,
|
|
|
|
CompositeMonikerImpl_Save,
|
|
|
|
CompositeMonikerImpl_GetSizeMax,
|
|
|
|
CompositeMonikerImpl_BindToObject,
|
|
|
|
CompositeMonikerImpl_BindToStorage,
|
|
|
|
CompositeMonikerImpl_Reduce,
|
|
|
|
CompositeMonikerImpl_ComposeWith,
|
|
|
|
CompositeMonikerImpl_Enum,
|
|
|
|
CompositeMonikerImpl_IsEqual,
|
|
|
|
CompositeMonikerImpl_Hash,
|
|
|
|
CompositeMonikerImpl_IsRunning,
|
|
|
|
CompositeMonikerImpl_GetTimeOfLastChange,
|
|
|
|
CompositeMonikerImpl_Inverse,
|
|
|
|
CompositeMonikerImpl_CommonPrefixWith,
|
|
|
|
CompositeMonikerImpl_RelativePathTo,
|
|
|
|
CompositeMonikerImpl_GetDisplayName,
|
|
|
|
CompositeMonikerImpl_ParseDisplayName,
|
|
|
|
CompositeMonikerImpl_IsSystemMoniker
|
|
|
|
};
|
|
|
|
|
|
|
|
/********************************************************************************/
|
|
|
|
/* Virtual function table for the IROTData class. */
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IROTDataVtbl VT_ROTDataImpl =
|
2005-03-28 12:01:45 +02:00
|
|
|
{
|
|
|
|
CompositeMonikerROTDataImpl_QueryInterface,
|
|
|
|
CompositeMonikerROTDataImpl_AddRef,
|
|
|
|
CompositeMonikerROTDataImpl_Release,
|
2006-05-08 13:37:25 +02:00
|
|
|
CompositeMonikerROTDataImpl_GetComparisonData
|
2005-03-28 12:01:45 +02:00
|
|
|
};
|
|
|
|
|
2006-05-08 13:38:55 +02:00
|
|
|
static const IMarshalVtbl VT_MarshalImpl =
|
|
|
|
{
|
|
|
|
CompositeMonikerMarshalImpl_QueryInterface,
|
|
|
|
CompositeMonikerMarshalImpl_AddRef,
|
|
|
|
CompositeMonikerMarshalImpl_Release,
|
|
|
|
CompositeMonikerMarshalImpl_GetUnmarshalClass,
|
|
|
|
CompositeMonikerMarshalImpl_GetMarshalSizeMax,
|
|
|
|
CompositeMonikerMarshalImpl_MarshalInterface,
|
|
|
|
CompositeMonikerMarshalImpl_UnmarshalInterface,
|
|
|
|
CompositeMonikerMarshalImpl_ReleaseMarshalData,
|
|
|
|
CompositeMonikerMarshalImpl_DisconnectObject
|
|
|
|
};
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
struct comp_node
|
2005-03-28 12:01:45 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
IMoniker *moniker;
|
|
|
|
struct comp_node *parent;
|
|
|
|
struct comp_node *left;
|
|
|
|
struct comp_node *right;
|
|
|
|
};
|
2006-05-08 13:40:52 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT moniker_get_tree_representation(IMoniker *moniker, struct comp_node *parent,
|
|
|
|
struct comp_node **ret)
|
|
|
|
{
|
|
|
|
CompositeMonikerImpl *comp_moniker;
|
|
|
|
struct comp_node *node;
|
2006-05-08 13:40:52 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!(node = heap_alloc_zero(sizeof(*node))))
|
2006-05-08 13:40:52 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2021-09-21 14:05:08 +02:00
|
|
|
node->parent = parent;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if ((comp_moniker = unsafe_impl_from_IMoniker(moniker)))
|
2006-05-08 16:54:52 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
moniker_get_tree_representation(comp_moniker->left, node, &node->left);
|
|
|
|
moniker_get_tree_representation(comp_moniker->right, node, &node->right);
|
2006-05-08 16:54:52 +02:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
node->moniker = moniker;
|
|
|
|
IMoniker_AddRef(node->moniker);
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
*ret = node;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static struct comp_node *moniker_tree_get_rightmost(struct comp_node *root)
|
|
|
|
{
|
|
|
|
if (!root->left && !root->right) return root->moniker ? root : NULL;
|
|
|
|
while (root->right) root = root->right;
|
|
|
|
return root;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static struct comp_node *moniker_tree_get_leftmost(struct comp_node *root)
|
|
|
|
{
|
|
|
|
if (!root->left && !root->right) return root->moniker ? root : NULL;
|
|
|
|
while (root->left) root = root->left;
|
|
|
|
return root;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static void moniker_tree_node_release(struct comp_node *node)
|
|
|
|
{
|
|
|
|
if (node->moniker)
|
|
|
|
IMoniker_Release(node->moniker);
|
|
|
|
heap_free(node);
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static void moniker_tree_release(struct comp_node *node)
|
|
|
|
{
|
|
|
|
if (node->left)
|
|
|
|
moniker_tree_node_release(node->left);
|
|
|
|
if (node->right)
|
|
|
|
moniker_tree_node_release(node->right);
|
|
|
|
moniker_tree_node_release(node);
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static void moniker_tree_replace_node(struct comp_node *node, struct comp_node *replace_with)
|
|
|
|
{
|
|
|
|
if (node->parent)
|
|
|
|
{
|
|
|
|
if (node->parent->left == node) node->parent->left = replace_with;
|
|
|
|
else node->parent->right = replace_with;
|
|
|
|
replace_with->parent = node->parent;
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
else if (replace_with->moniker)
|
|
|
|
{
|
|
|
|
/* Replacing root with non-composite */
|
|
|
|
node->moniker = replace_with->moniker;
|
|
|
|
IMoniker_AddRef(node->moniker);
|
|
|
|
node->left = node->right = NULL;
|
|
|
|
moniker_tree_node_release(replace_with);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Attaching composite branches to the root */
|
|
|
|
node->left = replace_with->left;
|
|
|
|
node->right = replace_with->right;
|
|
|
|
moniker_tree_node_release(replace_with);
|
|
|
|
}
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static void moniker_tree_discard(struct comp_node *node, BOOL left)
|
|
|
|
{
|
|
|
|
if (node->parent)
|
|
|
|
{
|
|
|
|
moniker_tree_replace_node(node->parent, left ? node->parent->left : node->parent->right);
|
|
|
|
moniker_tree_node_release(node);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IMoniker_Release(node->moniker);
|
|
|
|
node->moniker = NULL;
|
|
|
|
}
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT moniker_create_from_tree(const struct comp_node *root, unsigned int *count, IMoniker **moniker)
|
|
|
|
{
|
|
|
|
IMoniker *left_moniker, *right_moniker;
|
|
|
|
HRESULT hr;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
*moniker = NULL;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
/* Non-composite node */
|
|
|
|
if (!root->left && !root->right)
|
|
|
|
{
|
|
|
|
(*count)++;
|
|
|
|
*moniker = root->moniker;
|
|
|
|
if (*moniker) IMoniker_AddRef(*moniker);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = moniker_create_from_tree(root->left, count, &left_moniker))) return hr;
|
|
|
|
if (FAILED(hr = moniker_create_from_tree(root->right, count, &right_moniker)))
|
|
|
|
{
|
|
|
|
IMoniker_Release(left_moniker);
|
|
|
|
return hr;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
hr = CreateGenericComposite(left_moniker, right_moniker, moniker);
|
|
|
|
IMoniker_Release(left_moniker);
|
|
|
|
IMoniker_Release(right_moniker);
|
|
|
|
return hr;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static void moniker_get_tree_comp_count(const struct comp_node *root, unsigned int *count)
|
|
|
|
{
|
|
|
|
if (!root->left && !root->right)
|
|
|
|
{
|
|
|
|
(*count)++;
|
|
|
|
return;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
moniker_get_tree_comp_count(root->left, count);
|
|
|
|
moniker_get_tree_comp_count(root->right, count);
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-23 12:53:11 +02:00
|
|
|
static HRESULT composite_get_rightmost(CompositeMonikerImpl *composite, IMoniker **left, IMoniker **rightmost)
|
|
|
|
{
|
|
|
|
struct comp_node *root, *node;
|
|
|
|
unsigned int count;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Shortcut for trivial case when right component is non-composite */
|
|
|
|
if (!unsafe_impl_from_IMoniker(composite->right))
|
|
|
|
{
|
|
|
|
*left = composite->left;
|
|
|
|
IMoniker_AddRef(*left);
|
|
|
|
*rightmost = composite->right;
|
|
|
|
IMoniker_AddRef(*rightmost);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*left = *rightmost = NULL;
|
|
|
|
|
|
|
|
if (FAILED(hr = moniker_get_tree_representation(&composite->IMoniker_iface, NULL, &root)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (!(node = moniker_tree_get_rightmost(root)))
|
|
|
|
{
|
|
|
|
WARN("Couldn't get right most component.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*rightmost = node->moniker;
|
|
|
|
IMoniker_AddRef(*rightmost);
|
|
|
|
moniker_tree_discard(node, TRUE);
|
|
|
|
|
|
|
|
hr = moniker_create_from_tree(root, &count, left);
|
|
|
|
moniker_tree_release(root);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMoniker_Release(*rightmost);
|
|
|
|
*rightmost = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2021-09-27 14:31:38 +02:00
|
|
|
static HRESULT composite_get_leftmost(CompositeMonikerImpl *composite, IMoniker **leftmost)
|
|
|
|
{
|
|
|
|
struct comp_node *root, *node;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!unsafe_impl_from_IMoniker(composite->left))
|
|
|
|
{
|
|
|
|
*leftmost = composite->left;
|
|
|
|
IMoniker_AddRef(*leftmost);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = moniker_get_tree_representation(&composite->IMoniker_iface, NULL, &root)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (!(node = moniker_tree_get_leftmost(root)))
|
|
|
|
{
|
|
|
|
WARN("Couldn't get right most component.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*leftmost = node->moniker;
|
|
|
|
IMoniker_AddRef(*leftmost);
|
|
|
|
|
|
|
|
moniker_tree_release(root);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT moniker_simplify_composition(IMoniker *left, IMoniker *right,
|
|
|
|
unsigned int *count, IMoniker **new_left, IMoniker **new_right)
|
|
|
|
{
|
|
|
|
struct comp_node *left_tree, *right_tree;
|
|
|
|
unsigned int modified = 0;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
IMoniker *c;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
*count = 0;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
moniker_get_tree_representation(left, NULL, &left_tree);
|
|
|
|
moniker_get_tree_representation(right, NULL, &right_tree);
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
/* Simplify by composing trees together, in a non-generic way. */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
struct comp_node *l, *r;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!(l = moniker_tree_get_rightmost(left_tree))) break;
|
|
|
|
if (!(r = moniker_tree_get_leftmost(right_tree))) break;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
c = NULL;
|
|
|
|
if (FAILED(IMoniker_ComposeWith(l->moniker, r->moniker, TRUE, &c))) break;
|
|
|
|
modified++;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (c)
|
|
|
|
{
|
|
|
|
/* Replace with composed moniker on the left side */
|
|
|
|
IMoniker_Release(l->moniker);
|
|
|
|
l->moniker = c;
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
else
|
|
|
|
moniker_tree_discard(l, TRUE);
|
|
|
|
moniker_tree_discard(r, FALSE);
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!modified)
|
|
|
|
{
|
|
|
|
*new_left = left;
|
|
|
|
IMoniker_AddRef(*new_left);
|
|
|
|
*new_right = right;
|
|
|
|
IMoniker_AddRef(*new_right);
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
moniker_get_tree_comp_count(left_tree, count);
|
|
|
|
moniker_get_tree_comp_count(right_tree, count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = moniker_create_from_tree(left_tree, count, new_left);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = moniker_create_from_tree(right_tree, count, new_right);
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
moniker_tree_release(left_tree);
|
|
|
|
moniker_tree_release(right_tree);
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (*new_left) IMoniker_Release(*new_left);
|
|
|
|
if (*new_right) IMoniker_Release(*new_right);
|
|
|
|
*new_left = *new_right = NULL;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
static HRESULT create_composite(IMoniker *left, IMoniker *right, IMoniker **moniker)
|
|
|
|
{
|
|
|
|
IMoniker *new_left, *new_right;
|
|
|
|
CompositeMonikerImpl *object;
|
|
|
|
HRESULT hr;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
*moniker = NULL;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
object->IMoniker_iface.lpVtbl = &VT_CompositeMonikerImpl;
|
|
|
|
object->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
|
|
|
|
object->IMarshal_iface.lpVtbl = &VT_MarshalImpl;
|
|
|
|
object->ref = 1;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
/* Uninitialized moniker created by object activation */
|
|
|
|
if (!left && !right)
|
|
|
|
{
|
|
|
|
*moniker = &object->IMoniker_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (FAILED(hr = moniker_simplify_composition(left, right, &object->comp_count, &new_left, &new_right)))
|
|
|
|
{
|
|
|
|
IMoniker_Release(&object->IMoniker_iface);
|
|
|
|
return hr;
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!new_left || !new_right)
|
2006-05-08 16:54:52 +02:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
*moniker = new_left ? new_left : new_right;
|
|
|
|
IMoniker_Release(&object->IMoniker_iface);
|
|
|
|
return S_OK;
|
2006-05-08 16:54:52 +02:00
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
|
|
|
|
object->left = new_left;
|
|
|
|
object->right = new_right;
|
|
|
|
|
|
|
|
*moniker = &object->IMoniker_iface;
|
2006-05-08 16:54:52 +02:00
|
|
|
|
2005-03-28 12:01:45 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/******************************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* CreateGenericComposite [OLE32.@]
|
1999-03-23 14:48:56 +01:00
|
|
|
******************************************************************************/
|
2021-09-21 14:05:08 +02:00
|
|
|
HRESULT WINAPI CreateGenericComposite(IMoniker *left, IMoniker *right, IMoniker **composite)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2021-09-21 14:05:08 +02:00
|
|
|
TRACE("%p, %p, %p\n", left, right, composite);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!composite)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
if (!left && right)
|
|
|
|
{
|
|
|
|
*composite = right;
|
|
|
|
IMoniker_AddRef(*composite);
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
else if (left && !right)
|
|
|
|
{
|
|
|
|
*composite = left;
|
|
|
|
IMoniker_AddRef(*composite);
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2021-09-21 14:05:08 +02:00
|
|
|
else if (!left && !right)
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
return create_composite(left, right, composite);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* MonikerCommonPrefixWith [OLE32.@]
|
1999-03-23 14:48:56 +01:00
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
HRESULT WINAPI
|
|
|
|
MonikerCommonPrefixWith(IMoniker* pmkThis,IMoniker* pmkOther,IMoniker** ppmkCommon)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("(),stub!\n");
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2006-05-08 13:41:06 +02:00
|
|
|
|
2017-02-21 13:19:39 +01:00
|
|
|
HRESULT WINAPI CompositeMoniker_CreateInstance(IClassFactory *iface,
|
|
|
|
IUnknown *pUnk, REFIID riid, void **ppv)
|
2006-05-08 13:41:06 +02:00
|
|
|
{
|
2006-05-08 16:54:52 +02:00
|
|
|
IMoniker* pMoniker;
|
2006-05-08 13:41:06 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (pUnk)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2021-09-21 14:05:08 +02:00
|
|
|
hr = create_composite(NULL, NULL, &pMoniker);
|
2006-05-08 13:41:06 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
2006-05-08 16:54:52 +02:00
|
|
|
{
|
|
|
|
hr = IMoniker_QueryInterface(pMoniker, riid, ppv);
|
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
}
|
2006-05-08 13:41:06 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|