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"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-08-14 16:41:19 +02:00
|
|
|
#include "wine/unicode.h"
|
1999-03-23 14:48:56 +01:00
|
|
|
#include "ole2.h"
|
2002-12-19 02:09:40 +01:00
|
|
|
#include "moniker.h"
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2014-02-07 22:42:49 +01:00
|
|
|
#define BLOCK_TAB_SIZE 5 /* represent the first size table and its increment block size */
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* CompositeMoniker data structure */
|
|
|
|
typedef struct CompositeMonikerImpl{
|
2011-08-30 00:39:16 +02:00
|
|
|
IMoniker IMoniker_iface;
|
|
|
|
IROTData IROTData_iface;
|
|
|
|
IMarshal IMarshal_iface;
|
|
|
|
LONG ref;
|
2008-04-09 21:33:37 +02:00
|
|
|
IMoniker** tabMoniker; /* dynamic table containing all components (monikers) of this composite moniker */
|
1999-03-23 14:48:56 +01:00
|
|
|
ULONG tabSize; /* size of tabMoniker */
|
2011-08-30 00:39:16 +02:00
|
|
|
ULONG tabLastIndex; /* first free index in tabMoniker */
|
|
|
|
} 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
|
|
|
|
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);
|
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
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,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
|
|
|
}
|
|
|
|
|
2006-05-08 13:38:44 +02:00
|
|
|
static void CompositeMonikerImpl_ReleaseMonikersInTable(CompositeMonikerImpl *This)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
for (i = 0; i < This->tabLastIndex; i++)
|
|
|
|
IMoniker_Release(This->tabMoniker[i]);
|
|
|
|
|
|
|
|
This->tabLastIndex = 0;
|
|
|
|
}
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_Release
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
CompositeMonikerImpl_Release(IMoniker* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMoniker(iface);
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
2002-06-01 01:06:46 +02: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
|
|
|
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){
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* release all the components before destroying this object */
|
2006-05-08 13:38:44 +02:00
|
|
|
CompositeMonikerImpl_ReleaseMonikersInTable(This);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-03-28 12:01:45 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,This->tabMoniker);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_Load
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
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
|
|
|
HRESULT res;
|
2006-05-08 13:37:48 +02:00
|
|
|
DWORD moniker_count;
|
|
|
|
DWORD i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,pStm);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* this function call OleLoadFromStream function for each moniker within this object */
|
|
|
|
|
2006-05-08 13:37:48 +02:00
|
|
|
res=IStream_Read(pStm,&moniker_count,sizeof(DWORD),NULL);
|
|
|
|
if (res != S_OK)
|
|
|
|
{
|
|
|
|
ERR("couldn't reading moniker count from stream\n");
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_FAIL;
|
2006-05-08 13:37:48 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 13:38:44 +02:00
|
|
|
CompositeMonikerImpl_ReleaseMonikersInTable(This);
|
|
|
|
|
2006-05-08 13:37:48 +02:00
|
|
|
for (i = 0; i < moniker_count; i++)
|
|
|
|
{
|
1999-04-25 21:01:52 +02:00
|
|
|
res=OleLoadFromStream(pStm,&IID_IMoniker,(void**)&This->tabMoniker[This->tabLastIndex]);
|
1999-03-23 14:48:56 +01:00
|
|
|
if (FAILED(res))
|
2001-05-09 19:31:31 +02:00
|
|
|
{
|
2006-10-15 12:28:08 +02:00
|
|
|
ERR("couldn't load moniker from stream, res = 0x%08x\n", res);
|
1999-03-23 14:48:56 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* resize the table if needed */
|
|
|
|
if (++This->tabLastIndex==This->tabSize){
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
This->tabSize+=BLOCK_TAB_SIZE;
|
2013-06-27 23:36:54 +02:00
|
|
|
This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(This->tabMoniker[0]));
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (This->tabMoniker==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_Save
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty)
|
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
|
|
|
HRESULT res;
|
|
|
|
IEnumMoniker *enumMk;
|
|
|
|
IMoniker *pmk;
|
2006-05-08 13:37:48 +02:00
|
|
|
DWORD moniker_count = This->tabLastIndex;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* This function calls OleSaveToStream function for each moniker within
|
2001-10-22 21:04:32 +02:00
|
|
|
* this object.
|
2002-06-01 01:06:46 +02:00
|
|
|
* When I tested this function in windows, I usually found this constant
|
|
|
|
* at the beginning of the stream. I don't known why (there's no
|
2001-10-22 21:04:32 +02:00
|
|
|
* indication in the specification) !
|
|
|
|
*/
|
2006-05-08 13:37:48 +02:00
|
|
|
res=IStream_Write(pStm,&moniker_count,sizeof(moniker_count),NULL);
|
|
|
|
if (FAILED(res)) return res;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
IMoniker_Enum(iface,TRUE,&enumMk);
|
|
|
|
|
|
|
|
while(IEnumMoniker_Next(enumMk,1,&pmk,NULL)==S_OK){
|
|
|
|
|
|
|
|
res=OleSaveToStream((IPersistStream*)pmk,pStm);
|
|
|
|
|
|
|
|
IMoniker_Release(pmk);
|
|
|
|
|
|
|
|
if (FAILED(res)){
|
|
|
|
|
2006-05-08 13:37:48 +02:00
|
|
|
IEnumMoniker_Release(enumMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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);
|
|
|
|
|
2006-05-08 13:38:13 +02:00
|
|
|
pcbSize->QuadPart = ptmpSize.QuadPart + sizeof(CLSID);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_BindToObject
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
HRESULT res;
|
|
|
|
IRunningObjectTable *prot;
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker *tempMk,*antiMk,*rightMostMk;
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker *enumMoniker;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppvResult==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppvResult=0;
|
|
|
|
/* If pmkToLeft is NULL, this method looks for the moniker in the ROT, and if found, queries the retrieved */
|
|
|
|
/* object for the requested interface pointer. */
|
|
|
|
if(pmkToLeft==NULL){
|
|
|
|
|
|
|
|
res=IBindCtx_GetRunningObjectTable(pbc,&prot);
|
|
|
|
|
|
|
|
if (SUCCEEDED(res)){
|
|
|
|
|
2004-01-06 23:08:33 +01:00
|
|
|
/* if the requested class was loaded before ! we don't need to reload it */
|
1999-03-23 14:48:56 +01:00
|
|
|
res = IRunningObjectTable_GetObject(prot,iface,(IUnknown**)ppvResult);
|
|
|
|
|
|
|
|
if (res==S_OK)
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
/* If pmkToLeft is not NULL, the method recursively calls IMoniker::BindToObject on the rightmost */
|
|
|
|
/* component of the composite, passing the rest of the composite as the pmkToLeft parameter for that call */
|
|
|
|
|
|
|
|
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
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
res=CreateAntiMoniker(&antiMk);
|
|
|
|
res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
|
|
|
|
IMoniker_Release(antiMk);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
res=IMoniker_BindToObject(rightMostMk,pbc,tempMk,riid,ppvResult);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,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
|
|
|
{
|
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);
|
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
return IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,&tempMk, ppmkReduced);
|
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) &&
|
|
|
|
IMoniker_Reduce(rightMostMk,pbc,dwReduceHowFar,&tempMk,&leftReducedComposedMk)
|
1999-03-23 14:48:56 +01:00
|
|
|
)
|
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
return CreateGenericComposite(leftReducedComposedMk,rightMostReducedMk,ppmkReduced);
|
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.*/
|
|
|
|
|
|
|
|
IMoniker_AddRef(iface);
|
|
|
|
|
|
|
|
*ppmkReduced=iface;
|
|
|
|
|
|
|
|
return MK_S_REDUCED_TO_SELF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_ComposeWith
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
|
|
|
|
BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if ((ppmkComposite==NULL)||(pmkRight==NULL))
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppmkComposite=0;
|
|
|
|
|
|
|
|
/* If fOnlyIfNotGeneric is TRUE, this method sets *pmkComposite to NULL and returns MK_E_NEEDGENERIC; */
|
|
|
|
/* otherwise, the method returns the result of combining the two monikers by calling the */
|
|
|
|
/* CreateGenericComposite function */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (fOnlyIfNotGeneric)
|
|
|
|
return MK_E_NEEDGENERIC;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return CreateGenericComposite(iface,pmkRight,ppmkComposite);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_Enum
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
|
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,%d,%p)\n",iface,fForward,ppenumMoniker);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppenumMoniker == NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return EnumMonikerImpl_CreateEnumMoniker(This->tabMoniker,This->tabLastIndex,0,fForward,ppenumMoniker);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_IsEqual
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
IEnumMoniker *enumMoniker1,*enumMoniker2;
|
|
|
|
IMoniker *tempMk1,*tempMk2;
|
|
|
|
HRESULT res1,res2,res;
|
2009-08-29 14:23:48 +02:00
|
|
|
BOOL done;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (pmkOtherMoniker==NULL)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
/* This method returns S_OK if the components of both monikers are equal when compared in the */
|
|
|
|
/* left-to-right order.*/
|
|
|
|
IMoniker_Enum(pmkOtherMoniker,TRUE,&enumMoniker1);
|
|
|
|
|
|
|
|
if (enumMoniker1==NULL)
|
|
|
|
return S_FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_Enum(iface,TRUE,&enumMoniker2);
|
|
|
|
|
2009-08-29 14:23:48 +02:00
|
|
|
do {
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
|
|
|
|
res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if((res1==S_OK)&&(res2==S_OK)){
|
2009-08-29 14:23:48 +02:00
|
|
|
done = (res = IMoniker_IsEqual(tempMk1,tempMk2)) == S_FALSE;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2009-08-29 14:23:48 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
res = (res1==S_FALSE) && (res2==S_FALSE);
|
|
|
|
done = TRUE;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (res1==S_OK)
|
|
|
|
IMoniker_Release(tempMk1);
|
|
|
|
|
|
|
|
if (res2==S_OK)
|
|
|
|
IMoniker_Release(tempMk2);
|
2009-08-29 14:23:48 +02:00
|
|
|
} while (!done);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMoniker1);
|
|
|
|
IEnumMoniker_Release(enumMoniker2);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_Hash
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2005-05-23 11:52:13 +02:00
|
|
|
IEnumMoniker *enumMoniker;
|
|
|
|
IMoniker *tempMk;
|
|
|
|
HRESULT res;
|
|
|
|
DWORD tempHash;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n",iface,pdwHash);
|
|
|
|
|
|
|
|
if (pdwHash==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
res = IMoniker_Enum(iface,TRUE,&enumMoniker);
|
|
|
|
if(FAILED(res))
|
|
|
|
return res;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:04:41 +02:00
|
|
|
*pdwHash = 0;
|
|
|
|
|
2006-05-08 13:38:03 +02:00
|
|
|
while(IEnumMoniker_Next(enumMoniker,1,&tempMk,NULL)==S_OK){
|
2005-05-23 11:52:13 +02:00
|
|
|
res = IMoniker_Hash(tempMk, &tempHash);
|
|
|
|
if(FAILED(res))
|
|
|
|
break;
|
2006-05-08 13:42:16 +02:00
|
|
|
*pdwHash = *pdwHash ^ tempHash;
|
2005-05-23 11:52:13 +02:00
|
|
|
|
|
|
|
IMoniker_Release(tempMk);
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMoniker);
|
|
|
|
|
|
|
|
return res;
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_GetTimeOfLastChange
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft, FILETIME* pCompositeTime)
|
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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pCompositeTime);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (pCompositeTime==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* This method creates a composite of pmkToLeft (if non-NULL) and this moniker and uses the ROT to */
|
|
|
|
/* retrieve the time of last change. If the object is not in the ROT, the method recursively calls */
|
|
|
|
/* IMoniker::GetTimeOfLastChange on the rightmost component of the composite, passing the remainder */
|
|
|
|
/* of the composite as the pmkToLeft parameter for that call. */
|
2006-05-08 16:54:43 +02:00
|
|
|
if (pmkToLeft)
|
|
|
|
{
|
|
|
|
IRunningObjectTable* rot;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:43 +02:00
|
|
|
res = IMoniker_ComposeWith(pmkToLeft, iface, FALSE, &leftMk);
|
2015-03-13 09:32:47 +01:00
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:43 +02:00
|
|
|
res = IBindCtx_GetRunningObjectTable(pbc,&rot);
|
1999-03-23 14:48:56 +01:00
|
|
|
if (FAILED(res))
|
2006-05-08 16:54:43 +02:00
|
|
|
{
|
|
|
|
IMoniker_Release(leftMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
return res;
|
2006-05-08 16:54:43 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:43 +02:00
|
|
|
if (IRunningObjectTable_GetTimeOfLastChange(rot,leftMk,pCompositeTime)==S_OK)
|
|
|
|
{
|
|
|
|
IMoniker_Release(leftMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
return res;
|
2006-05-08 16:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
leftMk = iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:43 +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:43 +02:00
|
|
|
IEnumMoniker_Release(enumMoniker);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:43 +02:00
|
|
|
res = CreateAntiMoniker(&antiMk);
|
|
|
|
res = IMoniker_ComposeWith(leftMk, antiMk, 0, &tempMk);
|
|
|
|
IMoniker_Release(antiMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
res = IMoniker_GetTimeOfLastChange(rightMostMk, pbc, tempMk, pCompositeTime);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:43 +02:00
|
|
|
IMoniker_Release(tempMk);
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker_Release(rightMostMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 16:54:43 +02:00
|
|
|
if (pmkToLeft)
|
|
|
|
IMoniker_Release(leftMk);
|
|
|
|
|
|
|
|
return res;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_Inverse
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
HRESULT res;
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker *tempMk,*antiMk,*rightMostMk,*tempInvMk,*rightMostInvMk;
|
1999-03-23 14:48:56 +01:00
|
|
|
IEnumMoniker *enumMoniker;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,ppmk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppmk==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/* This method returns a composite moniker that consists of the inverses of each of the components */
|
|
|
|
/* of the original composite, stored in reverse order */
|
|
|
|
|
2015-03-13 09:47:55 +01:00
|
|
|
*ppmk = NULL;
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
res=CreateAntiMoniker(&antiMk);
|
2015-03-13 09:47:55 +01:00
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
res=IMoniker_ComposeWith(iface,antiMk,FALSE,&tempMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_Release(antiMk);
|
2015-03-13 09:47:55 +01:00
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (tempMk==NULL)
|
|
|
|
|
|
|
|
return IMoniker_Inverse(iface,ppmk);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker_Inverse(rightMostMk,&rightMostInvMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
CompositeMonikerImpl_Inverse(tempMk,&tempInvMk);
|
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
res=CreateGenericComposite(rightMostInvMk,tempInvMk,ppmk);
|
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
|
|
|
IMoniker_Release(tempInvMk);
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker_Release(rightMostInvMk);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_CommonPrefixWith
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_CommonPrefixWith(IMoniker* iface, IMoniker* pmkOther,
|
|
|
|
IMoniker** ppmkPrefix)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
DWORD mkSys;
|
|
|
|
HRESULT res1,res2;
|
|
|
|
IMoniker *tempMk1,*tempMk2,*mostLeftMk1,*mostLeftMk2;
|
|
|
|
IEnumMoniker *enumMoniker1,*enumMoniker2;
|
|
|
|
ULONG i,nbCommonMk=0;
|
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. */
|
|
|
|
|
|
|
|
if (ppmkPrefix==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppmkPrefix=0;
|
|
|
|
|
|
|
|
if (pmkOther==NULL)
|
|
|
|
return MK_E_NOPREFIX;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_IsSystemMoniker(pmkOther,&mkSys);
|
|
|
|
|
2011-04-13 00:42:36 +02:00
|
|
|
if(mkSys==MKSYS_GENERICCOMPOSITE){
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
IMoniker_Enum(iface,TRUE,&enumMoniker1);
|
|
|
|
IMoniker_Enum(pmkOther,TRUE,&enumMoniker2);
|
|
|
|
|
|
|
|
while(1){
|
|
|
|
|
|
|
|
res1=IEnumMoniker_Next(enumMoniker1,1,&mostLeftMk1,NULL);
|
|
|
|
res2=IEnumMoniker_Next(enumMoniker2,1,&mostLeftMk2,NULL);
|
|
|
|
|
|
|
|
if ((res1==S_FALSE) && (res2==S_FALSE)){
|
|
|
|
|
|
|
|
/* If the monikers are equal, the method returns MK_S_US and sets ppmkPrefix to this moniker.*/
|
|
|
|
*ppmkPrefix=iface;
|
|
|
|
IMoniker_AddRef(iface);
|
|
|
|
return MK_S_US;
|
|
|
|
}
|
|
|
|
else if ((res1==S_OK) && (res2==S_OK)){
|
|
|
|
|
|
|
|
if (IMoniker_IsEqual(mostLeftMk1,mostLeftMk2)==S_OK)
|
|
|
|
|
|
|
|
nbCommonMk++;
|
|
|
|
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (res1==S_OK){
|
|
|
|
|
|
|
|
/* If the other moniker is a prefix of this moniker, the method returns MK_S_HIM and sets */
|
|
|
|
/* ppmkPrefix to the other moniker. */
|
|
|
|
*ppmkPrefix=pmkOther;
|
|
|
|
return MK_S_HIM;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
/* If this moniker is a prefix of the other, this method returns MK_S_ME and sets ppmkPrefix */
|
|
|
|
/* to this moniker. */
|
|
|
|
*ppmkPrefix=iface;
|
|
|
|
return MK_S_ME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMoniker1);
|
|
|
|
IEnumMoniker_Release(enumMoniker2);
|
|
|
|
|
|
|
|
/* If there is no common prefix, this method returns MK_E_NOPREFIX and sets ppmkPrefix to NULL. */
|
|
|
|
if (nbCommonMk==0)
|
|
|
|
return MK_E_NOPREFIX;
|
|
|
|
|
|
|
|
IEnumMoniker_Reset(enumMoniker1);
|
|
|
|
|
|
|
|
IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
|
|
|
|
|
2008-04-09 21:33:37 +02:00
|
|
|
/* if we have more than one common moniker the result will be a composite moniker */
|
1999-03-23 14:48:56 +01:00
|
|
|
if (nbCommonMk>1){
|
|
|
|
|
|
|
|
/* initialize the common prefix moniker with the composite of two first moniker (from the left)*/
|
|
|
|
IEnumMoniker_Next(enumMoniker1,1,&tempMk2,NULL);
|
|
|
|
CreateGenericComposite(tempMk1,tempMk2,ppmkPrefix);
|
|
|
|
IMoniker_Release(tempMk1);
|
|
|
|
IMoniker_Release(tempMk2);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* compose all common monikers in a composite moniker */
|
|
|
|
for(i=0;i<nbCommonMk;i++){
|
|
|
|
|
|
|
|
IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
|
|
|
|
|
|
|
|
CreateGenericComposite(*ppmkPrefix,tempMk1,&tempMk2);
|
|
|
|
|
|
|
|
IMoniker_Release(*ppmkPrefix);
|
|
|
|
|
|
|
|
IMoniker_Release(tempMk1);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppmkPrefix=tempMk2;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else{
|
2008-04-09 21:33:37 +02:00
|
|
|
/* if we have only one common moniker the result will be a simple moniker which is the most-left one*/
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppmkPrefix=tempMk1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
/* If the other moniker is not a composite, the method simply compares it to the leftmost component
|
|
|
|
of this moniker.*/
|
|
|
|
|
|
|
|
IMoniker_Enum(iface,TRUE,&enumMoniker1);
|
|
|
|
|
|
|
|
IEnumMoniker_Next(enumMoniker1,1,&mostLeftMk1,NULL);
|
|
|
|
|
|
|
|
if (IMoniker_IsEqual(pmkOther,mostLeftMk1)==S_OK){
|
|
|
|
|
|
|
|
*ppmkPrefix=pmkOther;
|
|
|
|
|
|
|
|
return MK_S_HIM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return MK_E_NOPREFIX;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_GetDisplayName
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
ULONG lengthStr=1;
|
|
|
|
IEnumMoniker *enumMoniker;
|
|
|
|
IMoniker* tempMk;
|
|
|
|
LPOLESTR tempStr;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppszDisplayName==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (*ppszDisplayName==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/* This method returns the concatenation of the display names returned by each component moniker of */
|
|
|
|
/* the composite */
|
|
|
|
|
|
|
|
**ppszDisplayName=0;
|
|
|
|
|
|
|
|
IMoniker_Enum(iface,TRUE,&enumMoniker);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
while(IEnumMoniker_Next(enumMoniker,1,&tempMk,NULL)==S_OK){
|
|
|
|
|
|
|
|
IMoniker_GetDisplayName(tempMk,pbc,NULL,&tempStr);
|
|
|
|
|
|
|
|
lengthStr+=lstrlenW(tempStr);
|
|
|
|
|
|
|
|
*ppszDisplayName=CoTaskMemRealloc(*ppszDisplayName,lengthStr * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (*ppszDisplayName==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2000-08-14 16:41:19 +02:00
|
|
|
strcatW(*ppszDisplayName,tempStr);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
CoTaskMemFree(tempStr);
|
|
|
|
IMoniker_Release(tempMk);
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMoniker);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CompositeMoniker_ParseDisplayName
|
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
CompositeMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten,
|
|
|
|
IMoniker** ppmkOut)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
IEnumMoniker *enumMoniker;
|
2016-04-15 14:28:08 +02:00
|
|
|
IMoniker *tempMk,*rightMostMk,*antiMk;
|
1999-03-23 14:48:56 +01:00
|
|
|
/* This method recursively calls IMoniker::ParseDisplayName on the rightmost component of the composite,*/
|
|
|
|
/* passing everything else as the pmkToLeft parameter for that call. */
|
|
|
|
|
2001-04-20 20:36:05 +02:00
|
|
|
/* get the most 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);
|
|
|
|
|
2001-04-20 20:36:05 +02:00
|
|
|
/* get the left moniker */
|
1999-03-23 14:48:56 +01:00
|
|
|
CreateAntiMoniker(&antiMk);
|
|
|
|
IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
|
|
|
|
IMoniker_Release(antiMk);
|
|
|
|
|
2016-04-15 14:28:08 +02:00
|
|
|
return IMoniker_ParseDisplayName(rightMostMk,pbc,tempMk,pszDisplayName,pchEaten,ppmkOut);
|
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
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",iface,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
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2006-05-08 13:37:25 +02:00
|
|
|
* CompositeMonikerIROTData_GetComparisonData
|
1999-03-23 14:48:56 +01:00
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
static HRESULT WINAPI
|
2006-05-08 13:37:25 +02:00
|
|
|
CompositeMonikerROTDataImpl_GetComparisonData(IROTData* iface,
|
2005-03-28 12:01:45 +02:00
|
|
|
BYTE* pbData, ULONG cbMax, ULONG* pcbData)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IROTData(iface);
|
2006-05-08 13:37:25 +02:00
|
|
|
IEnumMoniker *pEnumMk;
|
|
|
|
IMoniker *pmk;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p, %u, %p)\n", pbData, cbMax, pcbData);
|
2006-05-08 13:37:25 +02:00
|
|
|
|
|
|
|
*pcbData = sizeof(CLSID);
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
hr = IMoniker_Enum(&This->IMoniker_iface, TRUE, &pEnumMk);
|
2006-05-08 13:37:25 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
while(IEnumMoniker_Next(pEnumMk, 1, &pmk, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
IROTData *pROTData;
|
|
|
|
hr = IMoniker_QueryInterface(pmk, &IID_IROTData, (void **)&pROTData);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("moniker doesn't support IROTData interface\n");
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ULONG cbData;
|
|
|
|
hr = IROTData_GetComparisonData(pROTData, NULL, 0, &cbData);
|
|
|
|
IROTData_Release(pROTData);
|
|
|
|
if (SUCCEEDED(hr) || (hr == E_OUTOFMEMORY))
|
|
|
|
{
|
|
|
|
*pcbData += cbData;
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else
|
2006-10-15 12:28:08 +02:00
|
|
|
ERR("IROTData_GetComparisonData failed with error 0x%08x\n", hr);
|
2006-05-08 13:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IMoniker_Release(pmk);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(pEnumMk);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cbMax < *pcbData)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
IEnumMoniker_Reset(pEnumMk);
|
|
|
|
|
|
|
|
memcpy(pbData, &CLSID_CompositeMoniker, sizeof(CLSID));
|
|
|
|
pbData += sizeof(CLSID);
|
|
|
|
cbMax -= sizeof(CLSID);
|
|
|
|
|
|
|
|
while (IEnumMoniker_Next(pEnumMk, 1, &pmk, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
IROTData *pROTData;
|
|
|
|
hr = IMoniker_QueryInterface(pmk, &IID_IROTData, (void **)&pROTData);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("moniker doesn't support IROTData interface\n");
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ULONG cbData;
|
|
|
|
hr = IROTData_GetComparisonData(pROTData, pbData, cbMax, &cbData);
|
|
|
|
IROTData_Release(pROTData);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
pbData += cbData;
|
|
|
|
cbMax -= cbData;
|
|
|
|
}
|
|
|
|
else
|
2006-10-15 12:28:08 +02:00
|
|
|
ERR("IROTData_GetComparisonData failed with error 0x%08x\n", hr);
|
2006-05-08 13:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IMoniker_Release(pmk);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(pEnumMk);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(pEnumMk);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
IEnumMoniker *pEnumMk;
|
|
|
|
IMoniker *pmk;
|
|
|
|
HRESULT hr;
|
|
|
|
ULARGE_INTEGER size;
|
|
|
|
|
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);
|
|
|
|
|
2006-05-08 13:43:20 +02:00
|
|
|
*pSize = 0x10; /* to match native */
|
2006-05-08 13:38:55 +02:00
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
hr = IMoniker_Enum(&This->IMoniker_iface, TRUE, &pEnumMk);
|
2006-05-08 13:38:55 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
hr = IMoniker_GetSizeMax(&This->IMoniker_iface, &size);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
|
|
|
while (IEnumMoniker_Next(pEnumMk, 1, &pmk, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
ULONG size;
|
|
|
|
|
|
|
|
hr = CoGetMarshalSizeMax(&size, &IID_IMoniker, (IUnknown *)pmk, dwDestContext, pvDestContext, mshlflags);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
*pSize += size;
|
|
|
|
|
|
|
|
IMoniker_Release(pmk);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(pEnumMk);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(pEnumMk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_MarshalInterface(IMarshal *iface, IStream *pStm,
|
2006-05-08 13:38:55 +02:00
|
|
|
REFIID riid, void* pv, DWORD dwDestContext,
|
|
|
|
void* pvDestContext, DWORD mshlflags)
|
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
IEnumMoniker *pEnumMk;
|
|
|
|
IMoniker *pmk;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG i = 0;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p, %s, %p, %x, %p, %x)\n", pStm, debugstr_guid(riid), pv,
|
2006-05-08 13:38:55 +02:00
|
|
|
dwDestContext, pvDestContext, mshlflags);
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
hr = IMoniker_Enum(&This->IMoniker_iface, TRUE, &pEnumMk);
|
2006-05-08 13:38:55 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
while (IEnumMoniker_Next(pEnumMk, 1, &pmk, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
hr = CoMarshalInterface(pStm, &IID_IMoniker, (IUnknown *)pmk, dwDestContext, pvDestContext, mshlflags);
|
|
|
|
|
|
|
|
IMoniker_Release(pmk);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(pEnumMk);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != 2)
|
2006-10-15 12:28:08 +02:00
|
|
|
FIXME("moniker count of %d not supported\n", i);
|
2006-05-08 13:38:55 +02:00
|
|
|
|
|
|
|
IEnumMoniker_Release(pEnumMk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerMarshalImpl_UnmarshalInterface(IMarshal *iface, IStream *pStm,
|
|
|
|
REFIID riid, void **ppv)
|
2006-05-08 13:38:55 +02:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl *This = impl_from_IMarshal(iface);
|
2006-05-08 13:38:55 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", pStm, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
CompositeMonikerImpl_ReleaseMonikersInTable(This);
|
|
|
|
|
|
|
|
/* resize the table if needed */
|
|
|
|
if (This->tabLastIndex + 2 > This->tabSize)
|
|
|
|
{
|
|
|
|
This->tabSize += max(BLOCK_TAB_SIZE, 2);
|
2013-06-27 23:36:54 +02:00
|
|
|
This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(This->tabMoniker[0]));
|
2006-05-08 13:38:55 +02:00
|
|
|
|
|
|
|
if (This->tabMoniker==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoUnmarshalInterface(pStm, &IID_IMoniker, (void**)&This->tabMoniker[This->tabLastIndex]);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2006-10-15 12:28:08 +02:00
|
|
|
ERR("couldn't unmarshal moniker, hr = 0x%08x\n", hr);
|
2006-05-08 13:38:55 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
This->tabLastIndex++;
|
|
|
|
hr = CoUnmarshalInterface(pStm, &IID_IMoniker, (void**)&This->tabMoniker[This->tabLastIndex]);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2006-10-15 12:28:08 +02:00
|
|
|
ERR("couldn't unmarshal moniker, hr = 0x%08x\n", hr);
|
2006-05-08 13:38:55 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
This->tabLastIndex++;
|
|
|
|
|
2011-08-30 00:39:16 +02:00
|
|
|
return IMoniker_QueryInterface(&This->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
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,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-03-28 12:01:45 +02:00
|
|
|
/********************************************************************************/
|
|
|
|
/* Virtual function table for the IROTData class */
|
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
|
|
|
|
};
|
|
|
|
|
2005-03-28 12:01:45 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Composite-Moniker_Construct (local function)
|
|
|
|
*******************************************************************************/
|
|
|
|
static HRESULT
|
2011-08-30 00:39:16 +02:00
|
|
|
CompositeMonikerImpl_Construct(IMoniker **ppMoniker, IMoniker *pmkFirst, IMoniker *pmkRest)
|
2005-03-28 12:01:45 +02:00
|
|
|
{
|
|
|
|
DWORD mkSys;
|
|
|
|
IEnumMoniker *enumMoniker;
|
|
|
|
IMoniker *tempMk;
|
|
|
|
HRESULT res;
|
2006-05-08 13:40:52 +02:00
|
|
|
CompositeMonikerImpl *This;
|
2016-04-14 06:56:49 +02:00
|
|
|
int i;
|
2006-05-08 13:40:52 +02:00
|
|
|
|
2006-05-08 16:54:52 +02:00
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
2006-05-08 13:40:52 +02:00
|
|
|
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n",This,pmkFirst,pmkRest);
|
|
|
|
|
|
|
|
/* Initialize the virtual function table. */
|
2011-08-30 00:39:16 +02:00
|
|
|
This->IMoniker_iface.lpVtbl = &VT_CompositeMonikerImpl;
|
|
|
|
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
|
|
|
|
This->IMarshal_iface.lpVtbl = &VT_MarshalImpl;
|
2006-05-08 16:54:52 +02:00
|
|
|
This->ref = 1;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
|
|
|
This->tabSize=BLOCK_TAB_SIZE;
|
|
|
|
This->tabLastIndex=0;
|
|
|
|
|
2013-06-27 23:36:54 +02:00
|
|
|
This->tabMoniker=HeapAlloc(GetProcessHeap(),0,This->tabSize*sizeof(This->tabMoniker[0]));
|
2007-09-01 16:36:11 +02:00
|
|
|
if (This->tabMoniker==NULL) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2005-03-28 12:01:45 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2007-09-01 16:36:11 +02:00
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2006-05-08 13:40:52 +02:00
|
|
|
if (!pmkFirst && !pmkRest)
|
2006-05-08 16:54:52 +02:00
|
|
|
{
|
2011-08-30 00:39:16 +02:00
|
|
|
*ppMoniker = &This->IMoniker_iface;
|
2006-05-08 13:40:52 +02:00
|
|
|
return S_OK;
|
2006-05-08 16:54:52 +02:00
|
|
|
}
|
2006-05-08 13:40:52 +02:00
|
|
|
|
2005-03-28 12:01:45 +02:00
|
|
|
IMoniker_IsSystemMoniker(pmkFirst,&mkSys);
|
|
|
|
|
|
|
|
/* put the first moniker contents in the beginning of the table */
|
|
|
|
if (mkSys!=MKSYS_GENERICCOMPOSITE){
|
|
|
|
|
|
|
|
This->tabMoniker[(This->tabLastIndex)++]=pmkFirst;
|
|
|
|
IMoniker_AddRef(pmkFirst);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
|
|
IMoniker_Enum(pmkFirst,TRUE,&enumMoniker);
|
|
|
|
|
|
|
|
while(IEnumMoniker_Next(enumMoniker,1,&This->tabMoniker[This->tabLastIndex],NULL)==S_OK){
|
|
|
|
|
|
|
|
|
|
|
|
if (++This->tabLastIndex==This->tabSize){
|
2016-04-14 06:56:49 +02:00
|
|
|
IMoniker **tab_moniker = This->tabMoniker;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
|
|
|
This->tabSize+=BLOCK_TAB_SIZE;
|
2016-03-30 02:31:15 +02:00
|
|
|
This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(This->tabMoniker[0]));
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2007-10-01 21:17:29 +02:00
|
|
|
if (This->tabMoniker==NULL){
|
2016-04-14 06:56:49 +02:00
|
|
|
for (i = 0; i < This->tabLastIndex; i++)
|
|
|
|
IMoniker_Release(tab_moniker[i]);
|
2007-10-01 21:17:29 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, tab_moniker);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2005-03-28 12:01:45 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2007-10-01 21:17:29 +02:00
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMoniker);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put the rest moniker contents after the first one and make simplification if needed */
|
|
|
|
|
|
|
|
IMoniker_IsSystemMoniker(pmkRest,&mkSys);
|
|
|
|
|
|
|
|
if (mkSys!=MKSYS_GENERICCOMPOSITE){
|
|
|
|
|
|
|
|
/* add a simple moniker to the moniker table */
|
|
|
|
|
|
|
|
res=IMoniker_ComposeWith(This->tabMoniker[This->tabLastIndex-1],pmkRest,TRUE,&tempMk);
|
|
|
|
|
|
|
|
if (res==MK_E_NEEDGENERIC){
|
|
|
|
|
|
|
|
/* there's no simplification in this case */
|
|
|
|
This->tabMoniker[This->tabLastIndex]=pmkRest;
|
|
|
|
|
|
|
|
This->tabLastIndex++;
|
|
|
|
|
|
|
|
IMoniker_AddRef(pmkRest);
|
|
|
|
}
|
|
|
|
else if (tempMk==NULL){
|
|
|
|
|
|
|
|
/* we have an antimoniker after a simple moniker so we can make a simplification in this case */
|
|
|
|
IMoniker_Release(This->tabMoniker[This->tabLastIndex-1]);
|
|
|
|
|
|
|
|
This->tabLastIndex--;
|
|
|
|
}
|
|
|
|
else if (SUCCEEDED(res)){
|
|
|
|
|
|
|
|
/* the non-generic composition was successful so we can make a simplification in this case */
|
|
|
|
IMoniker_Release(This->tabMoniker[This->tabLastIndex-1]);
|
|
|
|
|
|
|
|
This->tabMoniker[This->tabLastIndex-1]=tempMk;
|
2016-04-14 06:56:49 +02:00
|
|
|
} else{
|
|
|
|
for (i = 0; i < This->tabLastIndex; i++)
|
|
|
|
IMoniker_Release(This->tabMoniker[i]);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->tabMoniker);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2005-03-28 12:01:45 +02:00
|
|
|
return res;
|
2016-04-14 06:56:49 +02:00
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
|
|
|
|
/* resize tabMoniker if needed */
|
|
|
|
if (This->tabLastIndex==This->tabSize){
|
2016-04-14 06:56:49 +02:00
|
|
|
IMoniker **tab_moniker = This->tabMoniker;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
|
|
|
This->tabSize+=BLOCK_TAB_SIZE;
|
|
|
|
|
|
|
|
This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
|
|
|
|
|
2007-10-01 21:17:29 +02:00
|
|
|
if (This->tabMoniker==NULL){
|
2016-04-14 06:56:49 +02:00
|
|
|
for (i = 0; i < This->tabLastIndex; i++)
|
|
|
|
IMoniker_Release(tab_moniker[i]);
|
2007-10-01 21:17:29 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, tab_moniker);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
|
|
/* add a composite moniker to the moniker table (do the same thing
|
|
|
|
* for each moniker within the composite moniker as a simple moniker
|
|
|
|
* (see above for how to add a simple moniker case) )
|
|
|
|
*/
|
|
|
|
IMoniker_Enum(pmkRest,TRUE,&enumMoniker);
|
|
|
|
|
|
|
|
while(IEnumMoniker_Next(enumMoniker,1,&This->tabMoniker[This->tabLastIndex],NULL)==S_OK){
|
|
|
|
|
|
|
|
res=IMoniker_ComposeWith(This->tabMoniker[This->tabLastIndex-1],This->tabMoniker[This->tabLastIndex],TRUE,&tempMk);
|
|
|
|
|
|
|
|
if (res==MK_E_NEEDGENERIC){
|
|
|
|
|
|
|
|
This->tabLastIndex++;
|
|
|
|
}
|
|
|
|
else if (tempMk==NULL){
|
|
|
|
|
|
|
|
IMoniker_Release(This->tabMoniker[This->tabLastIndex-1]);
|
|
|
|
IMoniker_Release(This->tabMoniker[This->tabLastIndex]);
|
|
|
|
This->tabLastIndex--;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
|
|
IMoniker_Release(This->tabMoniker[This->tabLastIndex-1]);
|
|
|
|
|
|
|
|
This->tabMoniker[This->tabLastIndex-1]=tempMk;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->tabLastIndex==This->tabSize){
|
2016-04-14 06:56:49 +02:00
|
|
|
IMoniker **tab_moniker = This->tabMoniker;
|
2005-03-28 12:01:45 +02:00
|
|
|
|
|
|
|
This->tabSize+=BLOCK_TAB_SIZE;
|
|
|
|
|
2013-06-27 23:36:54 +02:00
|
|
|
This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(This->tabMoniker[0]));
|
2005-03-28 12:01:45 +02:00
|
|
|
|
2007-10-01 21:17:29 +02:00
|
|
|
if (This->tabMoniker==NULL){
|
2016-04-14 06:56:49 +02:00
|
|
|
for (i = 0; i < This->tabLastIndex; i++)
|
|
|
|
IMoniker_Release(tab_moniker[i]);
|
2007-10-01 21:17:29 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, tab_moniker);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2005-03-28 12:01:45 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2007-10-01 21:17:29 +02:00
|
|
|
}
|
2005-03-28 12:01:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(enumMoniker);
|
|
|
|
}
|
|
|
|
|
2006-05-08 16:54:52 +02:00
|
|
|
/* only one moniker, then just return it */
|
|
|
|
if (This->tabLastIndex == 1)
|
|
|
|
{
|
|
|
|
*ppMoniker = This->tabMoniker[0];
|
|
|
|
IMoniker_AddRef(*ppMoniker);
|
2011-08-30 00:39:16 +02:00
|
|
|
IMoniker_Release(&This->IMoniker_iface);
|
2006-05-08 16:54:52 +02:00
|
|
|
}
|
|
|
|
else
|
2011-08-30 00:39:16 +02:00
|
|
|
*ppMoniker = &This->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
|
|
|
******************************************************************************/
|
2005-03-28 12:01:45 +02:00
|
|
|
HRESULT WINAPI
|
2011-08-30 00:39:16 +02:00
|
|
|
CreateGenericComposite(IMoniker *pmkFirst, IMoniker *pmkRest, IMoniker **ppmkComposite)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2006-05-08 16:54:52 +02:00
|
|
|
IMoniker* moniker = 0;
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",pmkFirst,pmkRest,ppmkComposite);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppmkComposite==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppmkComposite=0;
|
|
|
|
|
|
|
|
if (pmkFirst==NULL && pmkRest!=NULL){
|
|
|
|
|
|
|
|
*ppmkComposite=pmkRest;
|
2014-03-10 18:27:12 +01:00
|
|
|
IMoniker_AddRef(pmkRest);
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (pmkFirst!=NULL && pmkRest==NULL){
|
|
|
|
*ppmkComposite=pmkFirst;
|
2014-03-10 18:27:12 +01:00
|
|
|
IMoniker_AddRef(pmkFirst);
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (pmkFirst==NULL && pmkRest==NULL)
|
|
|
|
return S_OK;
|
|
|
|
|
2006-05-08 16:54:52 +02:00
|
|
|
hr = CompositeMonikerImpl_Construct(&moniker,pmkFirst,pmkRest);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2006-05-08 13:40:52 +02:00
|
|
|
if (FAILED(hr))
|
1999-03-23 14:48:56 +01:00
|
|
|
return hr;
|
|
|
|
|
2006-05-08 16:54:52 +02:00
|
|
|
hr = IMoniker_QueryInterface(moniker,&IID_IMoniker,(void**)ppmkComposite);
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
|
|
|
|
return hr;
|
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
|
|
|
|
2012-08-13 11:40:33 +02:00
|
|
|
static HRESULT WINAPI CompositeMonikerCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
2006-05-08 13:41:06 +02:00
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
2012-08-13 11:40:33 +02:00
|
|
|
IClassFactory_AddRef(iface);
|
2006-05-08 13:41:06 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CompositeMonikerCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 2; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CompositeMonikerCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 1; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeMonikerCF_CreateInstance(LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
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;
|
|
|
|
|
2006-05-08 16:54:52 +02:00
|
|
|
hr = CompositeMonikerImpl_Construct(&pMoniker, NULL, NULL);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeMonikerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
|
|
|
|
{
|
|
|
|
FIXME("(%d), stub!\n",fLock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl CompositeMonikerCFVtbl =
|
|
|
|
{
|
|
|
|
CompositeMonikerCF_QueryInterface,
|
|
|
|
CompositeMonikerCF_AddRef,
|
|
|
|
CompositeMonikerCF_Release,
|
|
|
|
CompositeMonikerCF_CreateInstance,
|
|
|
|
CompositeMonikerCF_LockServer
|
|
|
|
};
|
|
|
|
static const IClassFactoryVtbl *CompositeMonikerCF = &CompositeMonikerCFVtbl;
|
|
|
|
|
|
|
|
HRESULT CompositeMonikerCF_Create(REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
return IClassFactory_QueryInterface((IClassFactory *)&CompositeMonikerCF, riid, ppv);
|
|
|
|
}
|