1999-01-28 18:56:14 +01:00
|
|
|
/***************************************************************************************
|
|
|
|
* ItemMonikers implementation
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-01-28 18:56:14 +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-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-10-07 05:06:48 +02:00
|
|
|
|
1999-01-28 18:56:14 +01:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "winbase.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2000-11-28 23:40:56 +01:00
|
|
|
#include "winnls.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "ole2.h"
|
2000-08-14 16:41:19 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-12-19 02:09:40 +01:00
|
|
|
#include "moniker.h"
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2002-12-19 02:09:40 +01:00
|
|
|
const CLSID CLSID_ItemMoniker = {
|
|
|
|
0x304, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}
|
|
|
|
};
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* ItemMoniker data structure */
|
1999-01-28 18:56:14 +01:00
|
|
|
typedef struct ItemMonikerImpl{
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
|
1999-03-23 14:48:56 +01:00
|
|
|
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
|
|
|
|
*/
|
2005-06-06 21:50:35 +02:00
|
|
|
const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
ULONG ref; /* reference counter for this object */
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
LPOLESTR itemName; /* item name identified by this ItemMoniker */
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
LPOLESTR itemDelimiter; /* Delimiter string */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-05-19 16:22:14 +02:00
|
|
|
IUnknown *pMarshal; /* custom marshaler */
|
1999-01-28 18:56:14 +01:00
|
|
|
} ItemMonikerImpl;
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/********************************************************************************/
|
|
|
|
/* ItemMoniker prototype functions : */
|
|
|
|
|
|
|
|
/* IUnknown prototype functions */
|
1999-02-18 14:26:22 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject);
|
|
|
|
static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface);
|
|
|
|
static ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* IPersist prototype functions */
|
1999-07-31 15:13:23 +02:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_GetClassID(IMoniker* iface, CLSID *pClassID);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* IPersistStream prototype functions */
|
1999-02-18 14:26:22 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface);
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface, IStream* pStm);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty);
|
1999-02-18 14:26:22 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* IMoniker prototype functions */
|
1999-02-18 14:26:22 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced);
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker);
|
1999-02-18 14:26:22 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pItemTime);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath);
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName);
|
|
|
|
static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut);
|
1999-02-18 14:26:22 +01:00
|
|
|
static HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys);
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Local function used by ItemMoniker implementation */
|
|
|
|
HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* iface, LPCOLESTR lpszDelim,LPCOLESTR lpszPathName);
|
|
|
|
HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
|
|
|
|
|
|
|
|
/********************************************************************************/
|
|
|
|
/* IROTData prototype functions */
|
1999-02-18 14:26:22 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* IUnknown prototype functions */
|
|
|
|
static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData* iface,REFIID riid,VOID** ppvObject);
|
|
|
|
static ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData* iface);
|
|
|
|
static ULONG WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface);
|
|
|
|
|
|
|
|
/* IROTData prototype function */
|
2005-05-18 20:28:15 +02:00
|
|
|
static HRESULT WINAPI ItemMonikerROTDataImpl_GetComparisonData(IROTData* iface,BYTE* pbData,ULONG cbMax,ULONG* pcbData);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/********************************************************************************/
|
2001-02-28 06:31:02 +01:00
|
|
|
/* Virtual function table for the ItemMonikerImpl class which include IPersist,*/
|
1999-03-23 14:48:56 +01:00
|
|
|
/* IPersistStream and IMoniker functions. */
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IMonikerVtbl VT_ItemMonikerImpl =
|
1999-01-28 18:56:14 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
ItemMonikerImpl_QueryInterface,
|
|
|
|
ItemMonikerImpl_AddRef,
|
|
|
|
ItemMonikerImpl_Release,
|
|
|
|
ItemMonikerImpl_GetClassID,
|
|
|
|
ItemMonikerImpl_IsDirty,
|
|
|
|
ItemMonikerImpl_Load,
|
|
|
|
ItemMonikerImpl_Save,
|
|
|
|
ItemMonikerImpl_GetSizeMax,
|
|
|
|
ItemMonikerImpl_BindToObject,
|
|
|
|
ItemMonikerImpl_BindToStorage,
|
|
|
|
ItemMonikerImpl_Reduce,
|
|
|
|
ItemMonikerImpl_ComposeWith,
|
|
|
|
ItemMonikerImpl_Enum,
|
|
|
|
ItemMonikerImpl_IsEqual,
|
|
|
|
ItemMonikerImpl_Hash,
|
|
|
|
ItemMonikerImpl_IsRunning,
|
|
|
|
ItemMonikerImpl_GetTimeOfLastChange,
|
|
|
|
ItemMonikerImpl_Inverse,
|
|
|
|
ItemMonikerImpl_CommonPrefixWith,
|
|
|
|
ItemMonikerImpl_RelativePathTo,
|
|
|
|
ItemMonikerImpl_GetDisplayName,
|
|
|
|
ItemMonikerImpl_ParseDisplayName,
|
|
|
|
ItemMonikerImpl_IsSystemMoniker
|
1999-01-28 18:56:14 +01:00
|
|
|
};
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/********************************************************************************/
|
|
|
|
/* Virtual function table for the IROTData class. */
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IROTDataVtbl VT_ROTDataImpl =
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
ItemMonikerROTDataImpl_QueryInterface,
|
|
|
|
ItemMonikerROTDataImpl_AddRef,
|
|
|
|
ItemMonikerROTDataImpl_Release,
|
2005-05-18 20:28:15 +02:00
|
|
|
ItemMonikerROTDataImpl_GetComparisonData
|
1999-03-23 14:48:56 +01:00
|
|
|
};
|
|
|
|
|
1999-01-28 18:56:14 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* ItemMoniker_QueryInterface
|
|
|
|
*******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Perform a sanity check on the parameters.*/
|
|
|
|
if ( (This==0) || (ppvObject==0) )
|
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Initialize the return parameter */
|
1999-01-28 18:56:14 +01:00
|
|
|
*ppvObject = 0;
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* 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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
else if (IsEqualIID(&IID_IROTData, riid))
|
|
|
|
*ppvObject = (IROTData*)&(This->lpvtbl2);
|
2005-05-19 16:22:14 +02:00
|
|
|
else if (IsEqualIID(&IID_IMarshal, riid))
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
if (!This->pMarshal)
|
|
|
|
hr = MonikerMarshal_Create(iface, &This->pMarshal);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
|
|
|
return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
|
|
|
|
}
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Check that we obtained an interface.*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
return E_NOINTERFACE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Query Interface always increases the reference count by one when it is successful */
|
1999-02-18 14:26:22 +01:00
|
|
|
ItemMonikerImpl_AddRef(iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-02-18 14:26:22 +01:00
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_AddRef
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_Release
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* destroy the object if there's no more reference on it */
|
2004-09-24 03:16:53 +02:00
|
|
|
if (ref == 0) ItemMonikerImpl_Destroy(This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_GetClassID
|
|
|
|
******************************************************************************/
|
1999-07-31 15:13:23 +02:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
2005-02-18 21:13:23 +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_ItemMoniker;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_IsDirty
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface)
|
1999-01-28 18:56:14 +01:00
|
|
|
{
|
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-02-18 14:26:22 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_FALSE;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_Load
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
1999-01-28 18:56:14 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT res;
|
2000-11-28 23:40:56 +01:00
|
|
|
DWORD delimiterLength,nameLength,lenW;
|
1999-03-23 14:48:56 +01:00
|
|
|
CHAR *itemNameA,*itemDelimiterA;
|
|
|
|
ULONG bread;
|
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("\n");
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* for more details about data read by this function see coments of ItemMonikerImpl_Save function */
|
|
|
|
|
|
|
|
/* read item delimiter string length + 1 */
|
|
|
|
res=IStream_Read(pStm,&delimiterLength,sizeof(DWORD),&bread);
|
|
|
|
if (bread != sizeof(DWORD))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/* read item delimiter string */
|
2000-11-28 23:40:56 +01:00
|
|
|
if (!(itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength)))
|
|
|
|
return E_OUTOFMEMORY;
|
1999-03-23 14:48:56 +01:00
|
|
|
res=IStream_Read(pStm,itemDelimiterA,delimiterLength,&bread);
|
|
|
|
if (bread != delimiterLength)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, itemDelimiterA );
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_FAIL;
|
2000-11-28 23:40:56 +01:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2000-11-28 23:40:56 +01:00
|
|
|
lenW = MultiByteToWideChar( CP_ACP, 0, itemDelimiterA, -1, NULL, 0 );
|
|
|
|
This->itemDelimiter=HeapReAlloc(GetProcessHeap(),0,This->itemDelimiter,lenW*sizeof(WCHAR));
|
1999-03-23 14:48:56 +01:00
|
|
|
if (!This->itemDelimiter)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, itemDelimiterA );
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2000-11-28 23:40:56 +01:00
|
|
|
}
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, itemDelimiterA, -1, This->itemDelimiter, lenW );
|
|
|
|
HeapFree( GetProcessHeap(), 0, itemDelimiterA );
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* read item name string length + 1*/
|
|
|
|
res=IStream_Read(pStm,&nameLength,sizeof(DWORD),&bread);
|
|
|
|
if (bread != sizeof(DWORD))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/* read item name string */
|
2000-11-28 23:40:56 +01:00
|
|
|
if (!(itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength)))
|
|
|
|
return E_OUTOFMEMORY;
|
1999-03-23 14:48:56 +01:00
|
|
|
res=IStream_Read(pStm,itemNameA,nameLength,&bread);
|
|
|
|
if (bread != nameLength)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, itemNameA );
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_FAIL;
|
2000-11-28 23:40:56 +01:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2000-11-28 23:40:56 +01:00
|
|
|
lenW = MultiByteToWideChar( CP_ACP, 0, itemNameA, -1, NULL, 0 );
|
|
|
|
This->itemName=HeapReAlloc(GetProcessHeap(),0,This->itemName,lenW*sizeof(WCHAR));
|
1999-03-23 14:48:56 +01:00
|
|
|
if (!This->itemName)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, itemNameA );
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2000-11-28 23:40:56 +01:00
|
|
|
}
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, itemNameA, -1, This->itemName, lenW );
|
|
|
|
HeapFree( GetProcessHeap(), 0, itemNameA );
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-02-18 14:26:22 +01:00
|
|
|
* ItemMoniker_Save
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface,
|
|
|
|
IStream* pStm,/* pointer to the stream where the object is to be saved */
|
|
|
|
BOOL fClearDirty)/* Specifies whether to clear the dirty flag */
|
1999-01-28 18:56:14 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT res;
|
|
|
|
CHAR *itemNameA,*itemDelimiterA;
|
|
|
|
|
2003-06-18 05:30:39 +02:00
|
|
|
/* data written by this function are : 1) DWORD : size of item delimiter string ('\0' included ) */
|
1999-03-23 14:48:56 +01:00
|
|
|
/* 2) String (type A): item delimiter string ('\0' included) */
|
|
|
|
/* 3) DWORD : size of item name string ('\0' included) */
|
|
|
|
/* 4) String (type A): item name string ('\0' included) */
|
|
|
|
|
2000-11-28 23:40:56 +01:00
|
|
|
DWORD nameLength = WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, NULL, 0, NULL, NULL);
|
|
|
|
DWORD delimiterLength = WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, NULL, 0, NULL, NULL);
|
1999-03-23 14:48:56 +01:00
|
|
|
itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength);
|
|
|
|
itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength);
|
2000-11-28 23:40:56 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, itemNameA, nameLength, NULL, NULL);
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, itemDelimiterA, delimiterLength, NULL, NULL);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("%p, %s\n", pStm, fClearDirty ? "TRUE" : "FALSE");
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
res=IStream_Write(pStm,&delimiterLength,sizeof(DWORD),NULL);
|
|
|
|
res=IStream_Write(pStm,itemDelimiterA,delimiterLength * sizeof(CHAR),NULL);
|
|
|
|
res=IStream_Write(pStm,&nameLength,sizeof(DWORD),NULL);
|
|
|
|
res=IStream_Write(pStm,itemNameA,nameLength * sizeof(CHAR),NULL);
|
|
|
|
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_GetSizeMax
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface,
|
|
|
|
ULARGE_INTEGER* pcbSize)/* Pointer to size of stream needed to save object */
|
1999-01-28 18:56:14 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
DWORD delimiterLength=lstrlenW(This->itemDelimiter)+1;
|
|
|
|
DWORD nameLength=lstrlenW(This->itemName)+1;
|
1999-02-18 14:26:22 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,pcbSize);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 12:27:42 +02:00
|
|
|
if (!pcbSize)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/* for more details see ItemMonikerImpl_Save coments */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
pcbSize->u.LowPart = sizeof(DWORD) + /* DWORD which contains delimiter length */
|
2005-05-23 12:27:42 +02:00
|
|
|
delimiterLength*4 + /* item delimiter string */
|
2001-02-28 06:31:02 +01:00
|
|
|
sizeof(DWORD) + /* DWORD which contains item name length */
|
2005-05-23 12:27:42 +02:00
|
|
|
nameLength*4 + /* item name string */
|
|
|
|
18; /* strange, but true */
|
2004-01-23 02:51:33 +01:00
|
|
|
pcbSize->u.HighPart=0;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* ItemMoniker_Construct (local function)
|
1999-01-28 18:56:14 +01:00
|
|
|
*******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem)
|
|
|
|
{
|
|
|
|
|
2000-10-28 02:31:09 +02:00
|
|
|
int sizeStr1=lstrlenW(lpszItem), sizeStr2;
|
|
|
|
static const OLECHAR emptystr[1];
|
|
|
|
LPCOLESTR delim;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszDelim),debugstr_w(lpszItem));
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Initialize the virtual fgunction table. */
|
|
|
|
This->lpvtbl1 = &VT_ItemMonikerImpl;
|
|
|
|
This->lpvtbl2 = &VT_ROTDataImpl;
|
|
|
|
This->ref = 0;
|
2005-05-19 16:22:14 +02:00
|
|
|
This->pMarshal = NULL;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1));
|
2000-10-28 02:31:09 +02:00
|
|
|
if (!This->itemName)
|
|
|
|
return E_OUTOFMEMORY;
|
2002-07-16 03:43:24 +02:00
|
|
|
lstrcpyW(This->itemName,lpszItem);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2000-10-28 02:31:09 +02:00
|
|
|
if (!lpszDelim)
|
|
|
|
FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2000-10-28 02:31:09 +02:00
|
|
|
delim = lpszDelim ? lpszDelim : emptystr;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2002-07-16 03:43:24 +02:00
|
|
|
sizeStr2=lstrlenW(delim);
|
2000-10-28 02:31:09 +02:00
|
|
|
This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1));
|
|
|
|
if (!This->itemDelimiter) {
|
|
|
|
HeapFree(GetProcessHeap(),0,This->itemName);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2002-07-16 03:43:24 +02:00
|
|
|
lstrcpyW(This->itemDelimiter,delim);
|
1999-01-28 18:56:14 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* ItemMoniker_Destroy (local function)
|
1999-01-28 18:56:14 +01:00
|
|
|
*******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* This)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-19 16:22:14 +02:00
|
|
|
if (This->pMarshal) IUnknown_Release(This->pMarshal);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This->itemName);
|
|
|
|
HeapFree(GetProcessHeap(),0,This->itemDelimiter);
|
1999-03-23 14:48:56 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_BindToObject
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvResult)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT res;
|
|
|
|
IID refid=IID_IOleItemContainer;
|
|
|
|
IOleItemContainer *poic=0;
|
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if(ppvResult ==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(pmkToLeft==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppvResult=0;
|
|
|
|
|
2004-05-21 22:52:57 +02:00
|
|
|
res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&refid,(void**)&poic);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(res)){
|
|
|
|
|
|
|
|
res=IOleItemContainer_GetObject(poic,This->itemName,BINDSPEED_MODERATE,pbc,riid,ppvResult);
|
|
|
|
|
|
|
|
IOleItemContainer_Release(poic);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_BindToStorage
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvResult)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT res;
|
|
|
|
IOleItemContainer *poic=0;
|
|
|
|
|
2005-02-18 21:13:23 +01: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;
|
|
|
|
|
|
|
|
if(pmkToLeft==NULL)
|
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-05-21 22:52:57 +02:00
|
|
|
res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(res)){
|
|
|
|
|
|
|
|
res=IOleItemContainer_GetObjectStorage(poic,This->itemName,pbc,riid,ppvResult);
|
|
|
|
|
|
|
|
IOleItemContainer_Release(poic);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_Reduce
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
DWORD dwReduceHowFar,
|
|
|
|
IMoniker** ppmkToLeft,
|
|
|
|
IMoniker** ppmkReduced)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%ld,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (ppmkReduced==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
ItemMonikerImpl_AddRef(iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppmkReduced=iface;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return MK_S_REDUCED_TO_SELF;
|
|
|
|
}
|
1999-01-28 18:56:14 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_ComposeWith
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface,
|
|
|
|
IMoniker* pmkRight,
|
|
|
|
BOOL fOnlyIfNotGeneric,
|
1999-02-18 14:26:22 +01:00
|
|
|
IMoniker** ppmkComposite)
|
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT res=S_OK;
|
|
|
|
DWORD mkSys,mkSys2;
|
|
|
|
IEnumMoniker* penumMk=0;
|
|
|
|
IMoniker *pmostLeftMk=0;
|
|
|
|
IMoniker* tempMkComposite=0;
|
1999-01-28 18:56:14 +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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_IsSystemMoniker(pmkRight,&mkSys);
|
|
|
|
|
|
|
|
/* If pmkRight is an anti-moniker, the returned moniker is NULL */
|
|
|
|
if(mkSys==MKSYS_ANTIMONIKER)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
else
|
|
|
|
/* if pmkRight is a composite whose leftmost component is an anti-moniker, */
|
|
|
|
/* the returned moniker is the composite after the leftmost anti-moniker is removed. */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if(mkSys==MKSYS_GENERICCOMPOSITE){
|
|
|
|
|
|
|
|
res=IMoniker_Enum(pmkRight,TRUE,&penumMk);
|
|
|
|
|
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
res=IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL);
|
|
|
|
|
|
|
|
IMoniker_IsSystemMoniker(pmostLeftMk,&mkSys2);
|
|
|
|
|
|
|
|
if(mkSys2==MKSYS_ANTIMONIKER){
|
|
|
|
|
|
|
|
IMoniker_Release(pmostLeftMk);
|
|
|
|
|
|
|
|
tempMkComposite=iface;
|
|
|
|
IMoniker_AddRef(iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
while(IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL)==S_OK){
|
|
|
|
|
|
|
|
res=CreateGenericComposite(tempMkComposite,pmostLeftMk,ppmkComposite);
|
|
|
|
|
|
|
|
IMoniker_Release(tempMkComposite);
|
|
|
|
IMoniker_Release(pmostLeftMk);
|
|
|
|
|
|
|
|
tempMkComposite=*ppmkComposite;
|
|
|
|
IMoniker_AddRef(tempMkComposite);
|
2001-09-11 02:32:32 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return CreateGenericComposite(iface,pmkRight,ppmkComposite);
|
|
|
|
}
|
|
|
|
/* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic
|
|
|
|
composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns
|
|
|
|
a NULL moniker and a return value of MK_E_NEEDGENERIC */
|
|
|
|
else
|
|
|
|
if (!fOnlyIfNotGeneric)
|
|
|
|
return CreateGenericComposite(iface,pmkRight,ppmkComposite);
|
|
|
|
|
|
|
|
else
|
|
|
|
return MK_E_NEEDGENERIC;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_Enum
|
|
|
|
******************************************************************************/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (ppenumMoniker == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppenumMoniker = NULL;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_IsEqual
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
|
|
|
|
{
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
CLSID clsid;
|
|
|
|
LPOLESTR dispName1,dispName2;
|
|
|
|
IBindCtx* bind;
|
2002-07-16 03:43:24 +02:00
|
|
|
HRESULT res = S_FALSE;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2002-07-16 03:43:24 +02:00
|
|
|
if (!pmkOtherMoniker) return S_FALSE;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-07-16 03:43:24 +02:00
|
|
|
/* check if both are ItemMoniker */
|
|
|
|
if(FAILED (IMoniker_GetClassID(pmkOtherMoniker,&clsid))) return S_FALSE;
|
|
|
|
if(!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) return S_FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-07-16 03:43:24 +02:00
|
|
|
/* check if both displaynames are the same */
|
|
|
|
if(SUCCEEDED ((res = CreateBindCtx(0,&bind)))) {
|
|
|
|
if(SUCCEEDED (IMoniker_GetDisplayName(iface,bind,NULL,&dispName1))) {
|
|
|
|
if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2))) {
|
|
|
|
if(lstrcmpW(dispName1,dispName2)==0) res = S_OK;
|
|
|
|
CoTaskMemFree(dispName2);
|
|
|
|
}
|
|
|
|
CoTaskMemFree(dispName1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_Hash
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
int h = 0,i,skip,len;
|
|
|
|
int off = 0;
|
|
|
|
LPOLESTR val;
|
|
|
|
|
|
|
|
if (pdwHash==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
val = This->itemName;
|
|
|
|
len = lstrlenW(val);
|
|
|
|
|
|
|
|
if (len < 16) {
|
|
|
|
for (i = len ; i > 0; i--) {
|
|
|
|
h = (h * 37) + val[off++];
|
2001-09-11 02:32:32 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
} else {
|
|
|
|
/* only sample some characters */
|
|
|
|
skip = len / 8;
|
|
|
|
for (i = len ; i > 0; i -= skip, off += skip) {
|
|
|
|
h = (h * 39) + val[off];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdwHash=h;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_IsRunning
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
1999-02-18 14:26:22 +01:00
|
|
|
IMoniker* pmkNewlyRunning)
|
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
IRunningObjectTable* rot;
|
|
|
|
HRESULT res;
|
|
|
|
IOleItemContainer *poic=0;
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
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 NULL, this method returns TRUE if pmkNewlyRunning is non-NULL and is equal to this */
|
|
|
|
/* moniker. Otherwise, the method checks the ROT to see whether this moniker is running. */
|
|
|
|
if (pmkToLeft==NULL)
|
|
|
|
if ((pmkNewlyRunning!=NULL)&&(IMoniker_IsEqual(pmkNewlyRunning,iface)==S_OK))
|
|
|
|
return S_OK;
|
|
|
|
else {
|
|
|
|
if (pbc==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
res=IBindCtx_GetRunningObjectTable(pbc,&rot);
|
|
|
|
|
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
res = IRunningObjectTable_IsRunning(rot,iface);
|
|
|
|
|
|
|
|
IRunningObjectTable_Release(rot);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
|
|
/* If pmkToLeft is non-NULL, the method calls IMoniker::BindToObject on the pmkToLeft parameter, */
|
|
|
|
/* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/
|
|
|
|
/* passing the string contained within this moniker. */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-05-21 22:52:57 +02:00
|
|
|
res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(res)){
|
|
|
|
|
|
|
|
res=IOleItemContainer_IsRunning(poic,This->itemName);
|
|
|
|
|
|
|
|
IOleItemContainer_Release(poic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_GetTimeOfLastChange
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
FILETIME* pItemTime)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
IRunningObjectTable* rot;
|
|
|
|
HRESULT res;
|
|
|
|
IMoniker *compositeMk;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pItemTime);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (pItemTime==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* If pmkToLeft is NULL, this method returns MK_E_NOTBINDABLE */
|
|
|
|
if (pmkToLeft==NULL)
|
|
|
|
|
|
|
|
return MK_E_NOTBINDABLE;
|
|
|
|
else {
|
|
|
|
|
|
|
|
/* Otherwise, the method creates a composite of pmkToLeft and this moniker and uses the ROT to access */
|
|
|
|
/* the time of last change. If the object is not in the ROT, the method calls */
|
|
|
|
/* IMoniker::GetTimeOfLastChange on the pmkToLeft parameter. */
|
|
|
|
|
|
|
|
res=CreateGenericComposite(pmkToLeft,iface,&compositeMk);
|
|
|
|
|
|
|
|
res=IBindCtx_GetRunningObjectTable(pbc,&rot);
|
|
|
|
|
|
|
|
if (IRunningObjectTable_GetTimeOfLastChange(rot,compositeMk,pItemTime)!=S_OK)
|
|
|
|
|
|
|
|
res=IMoniker_GetTimeOfLastChange(pmkToLeft,pbc,NULL,pItemTime);
|
|
|
|
|
|
|
|
IMoniker_Release(compositeMk);
|
2001-09-11 02:32:32 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_Inverse
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",iface,ppmk);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (ppmk==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
return CreateAntiMoniker(ppmk);
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_CommonPrefixWith
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
DWORD mkSys;
|
2005-02-18 21:13:23 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pmkOther, ppmkPrefix);
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_IsSystemMoniker(pmkOther,&mkSys);
|
|
|
|
/* If the other moniker is an item moniker that is equal to this moniker, this method sets *ppmkPrefix */
|
|
|
|
/* to this moniker and returns MK_S_US */
|
|
|
|
|
|
|
|
if((mkSys==MKSYS_ITEMMONIKER) && (IMoniker_IsEqual(iface,pmkOther)==S_OK) ){
|
|
|
|
|
|
|
|
*ppmkPrefix=iface;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
IMoniker_AddRef(iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return MK_S_US;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
|
|
|
|
/* the case where the other moniker is a generic composite. */
|
|
|
|
return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_RelativePathTo
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (ppmkRelPath==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppmkRelPath=0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return MK_E_NOTBINDABLE;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_GetDisplayName
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
1999-02-26 12:11:13 +01:00
|
|
|
LPOLESTR *ppszDisplayName)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (pmkToLeft!=NULL){
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)*(lstrlenW(This->itemDelimiter)+lstrlenW(This->itemName)+1));
|
|
|
|
|
|
|
|
if (*ppszDisplayName==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2002-07-16 03:43:24 +02:00
|
|
|
lstrcpyW(*ppszDisplayName,This->itemDelimiter);
|
|
|
|
lstrcatW(*ppszDisplayName,This->itemName);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("-- %s\n", debugstr_w(*ppszDisplayName));
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMoniker_ParseDisplayName
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
LPOLESTR pszDisplayName,
|
|
|
|
ULONG* pchEaten,
|
|
|
|
IMoniker** ppmkOut)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
IOleItemContainer* poic=0;
|
|
|
|
IParseDisplayName* ppdn=0;
|
|
|
|
LPOLESTR displayName;
|
|
|
|
HRESULT res;
|
2004-09-09 23:03:58 +02:00
|
|
|
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("%s\n", debugstr_w(pszDisplayName));
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* If pmkToLeft is NULL, this method returns MK_E_SYNTAX */
|
|
|
|
if (pmkToLeft==NULL)
|
|
|
|
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
|
|
|
|
else{
|
|
|
|
/* Otherwise, the method calls IMoniker::BindToObject on the pmkToLeft parameter, requesting an */
|
2001-09-11 02:32:32 +02:00
|
|
|
/* IParseDisplayName interface pointer to the object identified by the moniker, and passes the display */
|
|
|
|
/* name to IParseDisplayName::ParseDisplayName */
|
2004-05-21 22:52:57 +02:00
|
|
|
res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(res)){
|
|
|
|
|
2004-05-21 22:52:57 +02:00
|
|
|
res=IOleItemContainer_GetObject(poic,This->itemName,BINDSPEED_MODERATE,pbc,&IID_IParseDisplayName,(void**)&ppdn);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
res=IMoniker_GetDisplayName(iface,pbc,NULL,&displayName);
|
|
|
|
|
|
|
|
res=IParseDisplayName_ParseDisplayName(ppdn,pbc,displayName,pchEaten,ppmkOut);
|
|
|
|
|
|
|
|
IOleItemContainer_Release(poic);
|
|
|
|
IParseDisplayName_Release(ppdn);
|
|
|
|
}
|
2001-09-11 02:32:32 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-04-20 20:36:05 +02:00
|
|
|
* ItemMoniker_IsSystemMoniker
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
|
|
|
|
{
|
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_ITEMMONIKER;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* ItemMonikerIROTData_QueryInterface
|
|
|
|
*******************************************************************************/
|
|
|
|
HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
|
|
|
|
{
|
|
|
|
|
|
|
|
ICOM_THIS_From_IROTData(IMoniker, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return ItemMonikerImpl_QueryInterface(This, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ItemMonikerIROTData_AddRef
|
|
|
|
*/
|
|
|
|
ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS_From_IROTData(IMoniker, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return ItemMonikerImpl_AddRef(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ItemMonikerIROTData_Release
|
|
|
|
*/
|
|
|
|
ULONG WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS_From_IROTData(IMoniker, 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
|
|
|
|
|
|
|
return ItemMonikerImpl_Release(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ItemMonikerIROTData_GetComparaisonData
|
|
|
|
******************************************************************************/
|
2005-05-18 20:28:15 +02:00
|
|
|
HRESULT WINAPI ItemMonikerROTDataImpl_GetComparisonData(IROTData* iface,
|
1999-03-23 14:48:56 +01:00
|
|
|
BYTE* pbData,
|
|
|
|
ULONG cbMax,
|
|
|
|
ULONG* pcbData)
|
|
|
|
{
|
2005-05-18 20:28:15 +02:00
|
|
|
ICOM_THIS_From_IROTData(IMoniker, iface);
|
|
|
|
ItemMonikerImpl *This1 = (ItemMonikerImpl *)This;
|
|
|
|
int len = (strlenW(This1->itemName)+1);
|
|
|
|
int i;
|
|
|
|
LPWSTR pszItemName;
|
|
|
|
LPWSTR pszItemDelimiter;
|
|
|
|
|
|
|
|
TRACE("(%p, %lu, %p)\n", pbData, cbMax, pcbData);
|
|
|
|
|
|
|
|
*pcbData = sizeof(CLSID) + sizeof(WCHAR) + len * sizeof(WCHAR);
|
|
|
|
if (cbMax < *pcbData)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/* write CLSID */
|
|
|
|
memcpy(pbData, &CLSID_ItemMoniker, sizeof(CLSID));
|
|
|
|
/* write delimiter */
|
|
|
|
pszItemDelimiter = (LPWSTR)(pbData+sizeof(CLSID));
|
|
|
|
*pszItemDelimiter = *This1->itemDelimiter;
|
|
|
|
/* write name */
|
|
|
|
pszItemName = pszItemDelimiter + 1;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
pszItemName[i] = toupperW(This1->itemName[i]);
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* CreateItemMoniker [OLE32.@]
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONIKER * ppmk)
|
1999-01-28 18:56:14 +01:00
|
|
|
{
|
2005-02-18 21:13:23 +01:00
|
|
|
ItemMonikerImpl* newItemMoniker;
|
|
|
|
HRESULT hr;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
TRACE("(%s,%s,%p)\n",debugstr_w(lpszDelim),debugstr_w(lpszItem),ppmk);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl));
|
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
if (!newItemMoniker)
|
1999-01-28 18:56:14 +01:00
|
|
|
return STG_E_INSUFFICIENTMEMORY;
|
|
|
|
|
|
|
|
hr = ItemMonikerImpl_Construct(newItemMoniker,lpszDelim,lpszItem);
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (FAILED(hr)){
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,newItemMoniker);
|
1999-01-28 18:56:14 +01:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2005-02-18 21:13:23 +01:00
|
|
|
return ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker,&IID_IMoniker,(void**)ppmk);
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
2005-05-19 16:22:14 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI ItemMonikerCF_QueryInterface(LPCLASSFACTORY iface,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ItemMonikerCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 2; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ItemMonikerCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 1; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ItemMonikerCF_CreateInstance(LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
ItemMonikerImpl* newItemMoniker;
|
|
|
|
HRESULT hr;
|
|
|
|
static const WCHAR wszEmpty[] = { 0 };
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (pUnk)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl));
|
|
|
|
if (!newItemMoniker)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = ItemMonikerImpl_Construct(newItemMoniker, wszEmpty, wszEmpty);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker, riid, ppv);
|
|
|
|
if (FAILED(hr))
|
|
|
|
HeapFree(GetProcessHeap(),0,newItemMoniker);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ItemMonikerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
|
|
|
|
{
|
|
|
|
FIXME("(%d), stub!\n",fLock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl ItemMonikerCFVtbl =
|
|
|
|
{
|
|
|
|
ItemMonikerCF_QueryInterface,
|
|
|
|
ItemMonikerCF_AddRef,
|
|
|
|
ItemMonikerCF_Release,
|
|
|
|
ItemMonikerCF_CreateInstance,
|
|
|
|
ItemMonikerCF_LockServer
|
|
|
|
};
|
|
|
|
static const IClassFactoryVtbl *ItemMonikerCF = &ItemMonikerCFVtbl;
|
|
|
|
|
|
|
|
HRESULT ItemMonikerCF_Create(REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
return IClassFactory_QueryInterface((IClassFactory *)&ItemMonikerCF, riid, ppv);
|
|
|
|
}
|