1 /***************************************************************************************
2 * ItemMonikers implementation
4 * Copyright 1999 Noomen Hamza
5 ***************************************************************************************/
15 #include "wine/obj_inplace.h"
17 DEFAULT_DEBUG_CHANNEL(ole
)
19 /* ItemMoniker data structure */
20 typedef struct ItemMonikerImpl
{
22 ICOM_VTABLE(IMoniker
)* lpvtbl1
; /* VTable relative to the IMoniker interface.*/
24 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
25 * two monikers are equal. That's whay IROTData interface is implemented by monikers.
27 ICOM_VTABLE(IROTData
)* lpvtbl2
; /* VTable relative to the IROTData interface.*/
29 ULONG ref
; /* reference counter for this object */
31 LPOLESTR itemName
; /* item name identified by this ItemMoniker */
33 LPOLESTR itemDelimiter
; /* Delimiter string */
37 /********************************************************************************/
38 /* ItemMoniker prototype functions : */
40 /* IUnknown prototype functions */
41 static HRESULT WINAPI
ItemMonikerImpl_QueryInterface(IMoniker
* iface
,REFIID riid
,void** ppvObject
);
42 static ULONG WINAPI
ItemMonikerImpl_AddRef(IMoniker
* iface
);
43 static ULONG WINAPI
ItemMonikerImpl_Release(IMoniker
* iface
);
45 /* IPersist prototype functions */
46 static HRESULT WINAPI
ItemMonikerImpl_GetClassID(const IMoniker
* iface
, CLSID
*pClassID
);
48 /* IPersistStream prototype functions */
49 static HRESULT WINAPI
ItemMonikerImpl_IsDirty(IMoniker
* iface
);
50 static HRESULT WINAPI
ItemMonikerImpl_Load(IMoniker
* iface
, IStream
* pStm
);
51 static HRESULT WINAPI
ItemMonikerImpl_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
);
52 static HRESULT WINAPI
ItemMonikerImpl_GetSizeMax(IMoniker
* iface
, ULARGE_INTEGER
* pcbSize
);
54 /* IMoniker prototype functions */
55 static HRESULT WINAPI
ItemMonikerImpl_BindToObject(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, REFIID riid
, VOID
** ppvResult
);
56 static HRESULT WINAPI
ItemMonikerImpl_BindToStorage(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, REFIID riid
, VOID
** ppvResult
);
57 static HRESULT WINAPI
ItemMonikerImpl_Reduce(IMoniker
* iface
,IBindCtx
* pbc
, DWORD dwReduceHowFar
,IMoniker
** ppmkToLeft
, IMoniker
** ppmkReduced
);
58 static HRESULT WINAPI
ItemMonikerImpl_ComposeWith(IMoniker
* iface
,IMoniker
* pmkRight
,BOOL fOnlyIfNotGeneric
, IMoniker
** ppmkComposite
);
59 static HRESULT WINAPI
ItemMonikerImpl_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
);
60 static HRESULT WINAPI
ItemMonikerImpl_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
);
61 static HRESULT WINAPI
ItemMonikerImpl_Hash(IMoniker
* iface
,DWORD
* pdwHash
);
62 static HRESULT WINAPI
ItemMonikerImpl_IsRunning(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, IMoniker
* pmkNewlyRunning
);
63 static HRESULT WINAPI
ItemMonikerImpl_GetTimeOfLastChange(IMoniker
* iface
, IBindCtx
* pbc
, IMoniker
* pmkToLeft
, FILETIME
* pItemTime
);
64 static HRESULT WINAPI
ItemMonikerImpl_Inverse(IMoniker
* iface
,IMoniker
** ppmk
);
65 static HRESULT WINAPI
ItemMonikerImpl_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
, IMoniker
** ppmkPrefix
);
66 static HRESULT WINAPI
ItemMonikerImpl_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
);
67 static HRESULT WINAPI
ItemMonikerImpl_GetDisplayName(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, LPOLESTR
*ppszDisplayName
);
68 static HRESULT WINAPI
ItemMonikerImpl_ParseDisplayName(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, LPOLESTR pszDisplayName
, ULONG
* pchEaten
, IMoniker
** ppmkOut
);
69 static HRESULT WINAPI
ItemMonikerImpl_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
);
71 /* Local function used by ItemMoniker implementation */
72 HRESULT WINAPI
ItemMonikerImpl_Construct(ItemMonikerImpl
* iface
, LPCOLESTR lpszDelim
,LPCOLESTR lpszPathName
);
73 HRESULT WINAPI
ItemMonikerImpl_Destroy(ItemMonikerImpl
* iface
);
75 /********************************************************************************/
76 /* IROTData prototype functions */
78 /* IUnknown prototype functions */
79 static HRESULT WINAPI
ItemMonikerROTDataImpl_QueryInterface(IROTData
* iface
,REFIID riid
,VOID
** ppvObject
);
80 static ULONG WINAPI
ItemMonikerROTDataImpl_AddRef(IROTData
* iface
);
81 static ULONG WINAPI
ItemMonikerROTDataImpl_Release(IROTData
* iface
);
83 /* IROTData prototype function */
84 static HRESULT WINAPI
ItemMonikerROTDataImpl_GetComparaisonData(IROTData
* iface
,BYTE
* pbData
,ULONG cbMax
,ULONG
* pcbData
);
86 /********************************************************************************/
87 /* Virtual function table for the ItemMonikerImpl class witch include Ipersist,*/
88 /* IPersistStream and IMoniker functions. */
89 static ICOM_VTABLE(IMoniker
) VT_ItemMonikerImpl
=
91 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
92 ItemMonikerImpl_QueryInterface
,
93 ItemMonikerImpl_AddRef
,
94 ItemMonikerImpl_Release
,
95 ItemMonikerImpl_GetClassID
,
96 ItemMonikerImpl_IsDirty
,
99 ItemMonikerImpl_GetSizeMax
,
100 ItemMonikerImpl_BindToObject
,
101 ItemMonikerImpl_BindToStorage
,
102 ItemMonikerImpl_Reduce
,
103 ItemMonikerImpl_ComposeWith
,
104 ItemMonikerImpl_Enum
,
105 ItemMonikerImpl_IsEqual
,
106 ItemMonikerImpl_Hash
,
107 ItemMonikerImpl_IsRunning
,
108 ItemMonikerImpl_GetTimeOfLastChange
,
109 ItemMonikerImpl_Inverse
,
110 ItemMonikerImpl_CommonPrefixWith
,
111 ItemMonikerImpl_RelativePathTo
,
112 ItemMonikerImpl_GetDisplayName
,
113 ItemMonikerImpl_ParseDisplayName
,
114 ItemMonikerImpl_IsSystemMoniker
117 /********************************************************************************/
118 /* Virtual function table for the IROTData class. */
119 static ICOM_VTABLE(IROTData
) VT_ROTDataImpl
=
121 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
122 ItemMonikerROTDataImpl_QueryInterface
,
123 ItemMonikerROTDataImpl_AddRef
,
124 ItemMonikerROTDataImpl_Release
,
125 ItemMonikerROTDataImpl_GetComparaisonData
128 /*******************************************************************************
129 * ItemMoniker_QueryInterface
130 *******************************************************************************/
131 HRESULT WINAPI
ItemMonikerImpl_QueryInterface(IMoniker
* iface
,REFIID riid
,void** ppvObject
)
133 ICOM_THIS(ItemMonikerImpl
,iface
);
135 TRACE(ole
,"(%p,%p,%p)\n",This
,riid
,ppvObject
);
137 /* Perform a sanity check on the parameters.*/
138 if ( (This
==0) || (ppvObject
==0) )
141 /* Initialize the return parameter */
144 /* Compare the riid with the interface IDs implemented by this object.*/
145 if (IsEqualIID(&IID_IUnknown
, riid
) ||
146 IsEqualIID(&IID_IPersist
, riid
) ||
147 IsEqualIID(&IID_IPersistStream
, riid
) ||
148 IsEqualIID(&IID_IMoniker
, riid
)
152 else if (IsEqualIID(&IID_IROTData
, riid
))
153 *ppvObject
= (IROTData
*)&(This
->lpvtbl2
);
155 /* Check that we obtained an interface.*/
157 return E_NOINTERFACE
;
159 /* Query Interface always increases the reference count by one when it is successful */
160 ItemMonikerImpl_AddRef(iface
);
165 /******************************************************************************
167 ******************************************************************************/
168 ULONG WINAPI
ItemMonikerImpl_AddRef(IMoniker
* iface
)
170 ICOM_THIS(ItemMonikerImpl
,iface
);
172 TRACE(ole
,"(%p)\n",This
);
174 return ++(This
->ref
);
177 /******************************************************************************
178 * ItemMoniker_Release
179 ******************************************************************************/
180 ULONG WINAPI
ItemMonikerImpl_Release(IMoniker
* iface
)
182 ICOM_THIS(ItemMonikerImpl
,iface
);
184 TRACE(ole
,"(%p)\n",This
);
188 /* destroy the object if there's no more reference on it */
191 ItemMonikerImpl_Destroy(This
);
198 /******************************************************************************
199 * ItemMoniker_GetClassID
200 ******************************************************************************/
201 HRESULT WINAPI
ItemMonikerImpl_GetClassID(const IMoniker
* iface
,CLSID
*pClassID
)
203 TRACE(ole
,"(%p,%p),stub!\n",iface
,pClassID
);
208 *pClassID
= CLSID_ItemMoniker
;
213 /******************************************************************************
214 * ItemMoniker_IsDirty
215 ******************************************************************************/
216 HRESULT WINAPI
ItemMonikerImpl_IsDirty(IMoniker
* iface
)
218 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
219 method in the OLE-provided moniker interfaces always return S_FALSE because
220 their internal state never changes. */
222 TRACE(ole
,"(%p)\n",iface
);
227 /******************************************************************************
229 ******************************************************************************/
230 HRESULT WINAPI
ItemMonikerImpl_Load(IMoniker
* iface
,IStream
* pStm
)
233 ICOM_THIS(ItemMonikerImpl
,iface
);
235 DWORD delimiterLength
,nameLength
;
236 CHAR
*itemNameA
,*itemDelimiterA
;
239 /* for more details about data read by this function see coments of ItemMonikerImpl_Save function */
241 /* read item delimiter string length + 1 */
242 res
=IStream_Read(pStm
,&delimiterLength
,sizeof(DWORD
),&bread
);
243 if (bread
!= sizeof(DWORD
))
246 /* read item delimiter string */
247 itemDelimiterA
=HeapAlloc(GetProcessHeap(),0,delimiterLength
);
248 res
=IStream_Read(pStm
,itemDelimiterA
,delimiterLength
,&bread
);
249 if (bread
!= delimiterLength
)
252 This
->itemDelimiter
=HeapReAlloc(GetProcessHeap(),0,This
->itemDelimiter
,delimiterLength
*sizeof(WCHAR
));
253 if (!This
->itemDelimiter
)
254 return E_OUTOFMEMORY
;
256 lstrcpyAtoW(This
->itemDelimiter
,itemDelimiterA
);
258 /* read item name string length + 1*/
259 res
=IStream_Read(pStm
,&nameLength
,sizeof(DWORD
),&bread
);
260 if (bread
!= sizeof(DWORD
))
263 /* read item name string */
264 itemNameA
=HeapAlloc(GetProcessHeap(),0,nameLength
);
265 res
=IStream_Read(pStm
,itemNameA
,nameLength
,&bread
);
266 if (bread
!= nameLength
)
269 This
->itemName
=HeapReAlloc(GetProcessHeap(),0,This
->itemName
,nameLength
*sizeof(WCHAR
));
271 return E_OUTOFMEMORY
;
273 lstrcpyAtoW(This
->itemName
,itemNameA
);
278 /******************************************************************************
280 ******************************************************************************/
281 HRESULT WINAPI
ItemMonikerImpl_Save(IMoniker
* iface
,
282 IStream
* pStm
,/* pointer to the stream where the object is to be saved */
283 BOOL fClearDirty
)/* Specifies whether to clear the dirty flag */
285 ICOM_THIS(ItemMonikerImpl
,iface
);
287 DWORD delimiterLength
=lstrlenW(This
->itemDelimiter
)+1;
288 DWORD nameLength
=lstrlenW(This
->itemName
)+1;
289 CHAR
*itemNameA
,*itemDelimiterA
;
291 /* data writen by this function are : 1) DWORD : size of item delimiter string ('\0' included ) */
292 /* 2) String (type A): item delimiter string ('\0' included) */
293 /* 3) DWORD : size of item name string ('\0' included) */
294 /* 4) String (type A): item name string ('\0' included) */
296 itemNameA
=HeapAlloc(GetProcessHeap(),0,nameLength
);
297 itemDelimiterA
=HeapAlloc(GetProcessHeap(),0,delimiterLength
);
298 lstrcpyWtoA(itemNameA
,This
->itemName
);
299 lstrcpyWtoA(itemDelimiterA
,This
->itemDelimiter
);
301 res
=IStream_Write(pStm
,&delimiterLength
,sizeof(DWORD
),NULL
);
302 res
=IStream_Write(pStm
,itemDelimiterA
,delimiterLength
* sizeof(CHAR
),NULL
);
303 res
=IStream_Write(pStm
,&nameLength
,sizeof(DWORD
),NULL
);
304 res
=IStream_Write(pStm
,itemNameA
,nameLength
* sizeof(CHAR
),NULL
);
309 /******************************************************************************
310 * ItemMoniker_GetSizeMax
311 ******************************************************************************/
312 HRESULT WINAPI
ItemMonikerImpl_GetSizeMax(IMoniker
* iface
,
313 ULARGE_INTEGER
* pcbSize
)/* Pointer to size of stream needed to save object */
315 ICOM_THIS(ItemMonikerImpl
,iface
);
316 DWORD delimiterLength
=lstrlenW(This
->itemDelimiter
)+1;
317 DWORD nameLength
=lstrlenW(This
->itemName
)+1;
319 TRACE(ole
,"(%p,%p)\n",iface
,pcbSize
);
324 /* for more details see ItemMonikerImpl_Save coments */
326 pcbSize
->LowPart
= sizeof(DWORD
) + /* DWORD witch contains delimiter length */
327 delimiterLength
+ /* item delimiter string */
328 sizeof(DWORD
) + /* DWORD witch contains item name length */
329 nameLength
+ /* item name string */
330 34; /* this constant was added ! because when I tested this function it usually */
331 /* returns 34 bytes more than the number of bytes used by IMoniker::Save function */
337 /******************************************************************************
338 * ItemMoniker_Construct (local function)
339 *******************************************************************************/
340 HRESULT WINAPI
ItemMonikerImpl_Construct(ItemMonikerImpl
* This
, LPCOLESTR lpszDelim
,LPCOLESTR lpszItem
)
343 int sizeStr1
=lstrlenW(lpszItem
);
344 int sizeStr2
=lstrlenW(lpszDelim
);
346 TRACE(ole
,"(%p,%p)\n",This
,lpszItem
);
348 /* Initialize the virtual fgunction table. */
349 This
->lpvtbl1
= &VT_ItemMonikerImpl
;
350 This
->lpvtbl2
= &VT_ROTDataImpl
;
353 This
->itemName
=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*(sizeStr1
+1));
354 This
->itemDelimiter
=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*(sizeStr2
+1));
356 if ((This
->itemName
==NULL
)||(This
->itemDelimiter
==NULL
))
357 return E_OUTOFMEMORY
;
359 lstrcpyW(This
->itemName
,lpszItem
);
360 lstrcpyW(This
->itemDelimiter
,lpszDelim
);
365 /******************************************************************************
366 * ItemMoniker_Destroy (local function)
367 *******************************************************************************/
368 HRESULT WINAPI
ItemMonikerImpl_Destroy(ItemMonikerImpl
* This
)
370 TRACE(ole
,"(%p)\n",This
);
373 HeapFree(GetProcessHeap(),0,This
->itemName
);
375 if (This
->itemDelimiter
)
376 HeapFree(GetProcessHeap(),0,This
->itemDelimiter
);
378 HeapFree(GetProcessHeap(),0,This
);
383 /******************************************************************************
384 * ItemMoniker_BindToObject
385 ******************************************************************************/
386 HRESULT WINAPI
ItemMonikerImpl_BindToObject(IMoniker
* iface
,
392 ICOM_THIS(ItemMonikerImpl
,iface
);
395 IID refid
=IID_IOleItemContainer
;
396 IOleItemContainer
*poic
=0;
398 TRACE(ole
,"(%p,%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,riid
,ppvResult
);
408 res
=IMoniker_BindToObject(pmkToLeft
,pbc
,NULL
,&refid
,(void**)&poic
);
412 res
=IOleItemContainer_GetObject(poic
,This
->itemName
,BINDSPEED_MODERATE
,pbc
,riid
,ppvResult
);
414 IOleItemContainer_Release(poic
);
420 /******************************************************************************
421 * ItemMoniker_BindToStorage
422 ******************************************************************************/
423 HRESULT WINAPI
ItemMonikerImpl_BindToStorage(IMoniker
* iface
,
429 ICOM_THIS(ItemMonikerImpl
,iface
);
432 IOleItemContainer
*poic
=0;
434 TRACE(ole
,"(%p,%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,riid
,ppvResult
);
441 res
=IMoniker_BindToObject(pmkToLeft
,pbc
,NULL
,&IID_IOleItemContainer
,(void**)&poic
);
445 res
=IOleItemContainer_GetObjectStorage(poic
,This
->itemName
,pbc
,riid
,ppvResult
);
447 IOleItemContainer_Release(poic
);
453 /******************************************************************************
455 ******************************************************************************/
456 HRESULT WINAPI
ItemMonikerImpl_Reduce(IMoniker
* iface
,
458 DWORD dwReduceHowFar
,
459 IMoniker
** ppmkToLeft
,
460 IMoniker
** ppmkReduced
)
462 TRACE(ole
,"(%p,%p,%ld,%p,%p)\n",iface
,pbc
,dwReduceHowFar
,ppmkToLeft
,ppmkReduced
);
464 if (ppmkReduced
==NULL
)
467 ItemMonikerImpl_AddRef(iface
);
471 return MK_S_REDUCED_TO_SELF
;
473 /******************************************************************************
474 * ItemMoniker_ComposeWith
475 ******************************************************************************/
476 HRESULT WINAPI
ItemMonikerImpl_ComposeWith(IMoniker
* iface
,
478 BOOL fOnlyIfNotGeneric
,
479 IMoniker
** ppmkComposite
)
483 IEnumMoniker
* penumMk
=0;
484 IMoniker
*pmostLeftMk
=0;
485 IMoniker
* tempMkComposite
=0;
487 TRACE(ole
,"(%p,%p,%d,%p)\n",iface
,pmkRight
,fOnlyIfNotGeneric
,ppmkComposite
);
489 if ((ppmkComposite
==NULL
)||(pmkRight
==NULL
))
494 IMoniker_IsSystemMoniker(pmkRight
,&mkSys
);
496 /* If pmkRight is an anti-moniker, the returned moniker is NULL */
497 if(mkSys
==MKSYS_ANTIMONIKER
)
501 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */
502 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
504 if(mkSys
==MKSYS_GENERICCOMPOSITE
){
506 res
=IMoniker_Enum(pmkRight
,TRUE
,&penumMk
);
511 res
=IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
);
513 IMoniker_IsSystemMoniker(pmostLeftMk
,&mkSys2
);
515 if(mkSys2
==MKSYS_ANTIMONIKER
){
517 IMoniker_Release(pmostLeftMk
);
519 tempMkComposite
=iface
;
520 IMoniker_AddRef(iface
);
522 while(IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
)==S_OK
){
524 res
=CreateGenericComposite(tempMkComposite
,pmostLeftMk
,ppmkComposite
);
526 IMoniker_Release(tempMkComposite
);
527 IMoniker_Release(pmostLeftMk
);
529 tempMkComposite
=*ppmkComposite
;
530 IMoniker_AddRef(tempMkComposite
);
535 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
537 /* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic
538 composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns
539 a NULL moniker and a return value of MK_E_NEEDGENERIC */
541 if (!fOnlyIfNotGeneric
)
542 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
545 return MK_E_NEEDGENERIC
;
548 /******************************************************************************
550 ******************************************************************************/
551 HRESULT WINAPI
ItemMonikerImpl_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
553 TRACE(ole
,"(%p,%d,%p)\n",iface
,fForward
,ppenumMoniker
);
555 if (ppenumMoniker
== NULL
)
558 *ppenumMoniker
= NULL
;
563 /******************************************************************************
564 * ItemMoniker_IsEqual
565 ******************************************************************************/
566 HRESULT WINAPI
ItemMonikerImpl_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
)
570 LPOLESTR dispName1
,dispName2
;
574 TRACE(ole
,"(%p,%p)\n",iface
,pmkOtherMoniker
);
576 if (pmkOtherMoniker
==NULL
)
579 /* This method returns S_OK if both monikers are item monikers and their display names are */
580 /* identical (using a case-insensitive comparison); otherwise, the method returns S_FALSE. */
582 IMoniker_GetClassID(pmkOtherMoniker
,&clsid
);
584 if (!IsEqualCLSID(&clsid
,&CLSID_ItemMoniker
))
587 res
=CreateBindCtx(0,&bind
);
591 IMoniker_GetDisplayName(iface
,bind
,NULL
,&dispName1
);
592 IMoniker_GetDisplayName(pmkOtherMoniker
,bind
,NULL
,&dispName2
);
594 if (lstrcmpW(dispName1
,dispName2
)!=0)
600 /******************************************************************************
602 ******************************************************************************/
603 HRESULT WINAPI
ItemMonikerImpl_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
605 ICOM_THIS(ItemMonikerImpl
,iface
);
607 int h
= 0,i
,skip
,len
;
614 val
= This
->itemName
;
618 for (i
= len
; i
> 0; i
--) {
619 h
= (h
* 37) + val
[off
++];
622 /* only sample some characters */
624 for (i
= len
; i
> 0; i
-= skip
, off
+= skip
) {
625 h
= (h
* 39) + val
[off
];
634 /******************************************************************************
635 * ItemMoniker_IsRunning
636 ******************************************************************************/
637 HRESULT WINAPI
ItemMonikerImpl_IsRunning(IMoniker
* iface
,
640 IMoniker
* pmkNewlyRunning
)
642 IRunningObjectTable
* rot
;
644 IOleItemContainer
*poic
=0;
645 ICOM_THIS(ItemMonikerImpl
,iface
);
647 TRACE(ole
,"(%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,pmkNewlyRunning
);
649 /* If pmkToLeft is NULL, this method returns TRUE if pmkNewlyRunning is non-NULL and is equal to this */
650 /* moniker. Otherwise, the method checks the ROT to see whether this moniker is running. */
652 if ((pmkNewlyRunning
!=NULL
)&&(IMoniker_IsEqual(pmkNewlyRunning
,iface
)==S_OK
))
658 res
=IBindCtx_GetRunningObjectTable(pbc
,&rot
);
663 res
= IRunningObjectTable_IsRunning(rot
,iface
);
665 IRunningObjectTable_Release(rot
);
669 /* If pmkToLeft is non-NULL, the method calls IMoniker::BindToObject on the pmkToLeft parameter, */
670 /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/
671 /* passing the string contained within this moniker. */
673 res
=IMoniker_BindToObject(pmkToLeft
,pbc
,NULL
,&IID_IOleItemContainer
,(void**)&poic
);
677 res
=IOleItemContainer_IsRunning(poic
,This
->itemName
);
679 IOleItemContainer_Release(poic
);
686 /******************************************************************************
687 * ItemMoniker_GetTimeOfLastChange
688 ******************************************************************************/
689 HRESULT WINAPI
ItemMonikerImpl_GetTimeOfLastChange(IMoniker
* iface
,
694 IRunningObjectTable
* rot
;
696 IMoniker
*compositeMk
;
698 TRACE(ole
,"(%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,pItemTime
);
703 /* If pmkToLeft is NULL, this method returns MK_E_NOTBINDABLE */
706 return MK_E_NOTBINDABLE
;
709 /* Otherwise, the method creates a composite of pmkToLeft and this moniker and uses the ROT to access */
710 /* the time of last change. If the object is not in the ROT, the method calls */
711 /* IMoniker::GetTimeOfLastChange on the pmkToLeft parameter. */
713 res
=CreateGenericComposite(pmkToLeft
,iface
,&compositeMk
);
715 res
=IBindCtx_GetRunningObjectTable(pbc
,&rot
);
717 if (IRunningObjectTable_GetTimeOfLastChange(rot
,compositeMk
,pItemTime
)!=S_OK
)
719 res
=IMoniker_GetTimeOfLastChange(pmkToLeft
,pbc
,NULL
,pItemTime
);
721 IMoniker_Release(compositeMk
);
727 /******************************************************************************
728 * ItemMoniker_Inverse
729 ******************************************************************************/
730 HRESULT WINAPI
ItemMonikerImpl_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
732 TRACE(ole
,"(%p,%p)\n",iface
,ppmk
);
737 return CreateAntiMoniker(ppmk
);
740 /******************************************************************************
741 * ItemMoniker_CommonPrefixWith
742 ******************************************************************************/
743 HRESULT WINAPI
ItemMonikerImpl_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
746 IMoniker_IsSystemMoniker(pmkOther
,&mkSys
);
747 /* If the other moniker is an item moniker that is equal to this moniker, this method sets *ppmkPrefix */
748 /* to this moniker and returns MK_S_US */
750 if((mkSys
==MKSYS_ITEMMONIKER
) && (IMoniker_IsEqual(iface
,pmkOther
)==S_OK
) ){
754 IMoniker_AddRef(iface
);
759 /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
760 /* the case where the other moniker is a generic composite. */
761 return MonikerCommonPrefixWith(iface
,pmkOther
,ppmkPrefix
);
764 /******************************************************************************
765 * ItemMoniker_RelativePathTo
766 ******************************************************************************/
767 HRESULT WINAPI
ItemMonikerImpl_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
769 TRACE(ole
,"(%p,%p,%p)\n",iface
,pmOther
,ppmkRelPath
);
771 if (ppmkRelPath
==NULL
)
776 return MK_E_NOTBINDABLE
;
779 /******************************************************************************
780 * ItemMoniker_GetDisplayName
781 ******************************************************************************/
782 HRESULT WINAPI
ItemMonikerImpl_GetDisplayName(IMoniker
* iface
,
785 LPOLESTR
*ppszDisplayName
)
787 ICOM_THIS(ItemMonikerImpl
,iface
);
789 TRACE(ole
,"(%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,ppszDisplayName
);
791 if (ppszDisplayName
==NULL
)
794 if (pmkToLeft
!=NULL
){
798 *ppszDisplayName
=CoTaskMemAlloc(sizeof(WCHAR
)*(lstrlenW(This
->itemDelimiter
)+lstrlenW(This
->itemName
)+1));
800 if (*ppszDisplayName
==NULL
)
801 return E_OUTOFMEMORY
;
803 lstrcpyW(*ppszDisplayName
,This
->itemDelimiter
);
804 lstrcatW(*ppszDisplayName
,This
->itemName
);
809 /******************************************************************************
810 * ItemMoniker_ParseDisplayName
811 ******************************************************************************/
812 HRESULT WINAPI
ItemMonikerImpl_ParseDisplayName(IMoniker
* iface
,
815 LPOLESTR pszDisplayName
,
819 IOleItemContainer
* poic
=0;
820 IParseDisplayName
* ppdn
=0;
821 LPOLESTR displayName
;
823 ICOM_THIS(ItemMonikerImpl
,iface
);
825 /* If pmkToLeft is NULL, this method returns MK_E_SYNTAX */
831 /* Otherwise, the method calls IMoniker::BindToObject on the pmkToLeft parameter, requesting an */
832 /* IParseDisplayName interface pointer to the object identified by the moniker, and passes the display */ /* name to IParseDisplayName::ParseDisplayName */
833 res
=IMoniker_BindToObject(pmkToLeft
,pbc
,NULL
,&IID_IOleItemContainer
,(void**)&poic
);
837 res
=IOleItemContainer_GetObject(poic
,This
->itemName
,BINDSPEED_MODERATE
,pbc
,&IID_IParseDisplayName
,(void**)&ppdn
);
839 res
=IMoniker_GetDisplayName(iface
,pbc
,NULL
,&displayName
);
841 res
=IParseDisplayName_ParseDisplayName(ppdn
,pbc
,displayName
,pchEaten
,ppmkOut
);
843 IOleItemContainer_Release(poic
);
844 IParseDisplayName_Release(ppdn
);
850 /******************************************************************************
851 * ItemMoniker_IsSystemMonker
852 ******************************************************************************/
853 HRESULT WINAPI
ItemMonikerImpl_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
855 TRACE(ole
,"(%p,%p)\n",iface
,pwdMksys
);
860 (*pwdMksys
)=MKSYS_ITEMMONIKER
;
865 /*******************************************************************************
866 * ItemMonikerIROTData_QueryInterface
867 *******************************************************************************/
868 HRESULT WINAPI
ItemMonikerROTDataImpl_QueryInterface(IROTData
*iface
,REFIID riid
,VOID
** ppvObject
)
871 ICOM_THIS_From_IROTData(IMoniker
, iface
);
873 TRACE(ole
,"(%p,%p,%p)\n",iface
,riid
,ppvObject
);
875 return ItemMonikerImpl_QueryInterface(This
, riid
, ppvObject
);
878 /***********************************************************************
879 * ItemMonikerIROTData_AddRef
881 ULONG WINAPI
ItemMonikerROTDataImpl_AddRef(IROTData
*iface
)
883 ICOM_THIS_From_IROTData(IMoniker
, iface
);
885 TRACE(ole
,"(%p)\n",iface
);
887 return ItemMonikerImpl_AddRef(This
);
890 /***********************************************************************
891 * ItemMonikerIROTData_Release
893 ULONG WINAPI
ItemMonikerROTDataImpl_Release(IROTData
* iface
)
895 ICOM_THIS_From_IROTData(IMoniker
, iface
);
897 TRACE(ole
,"(%p)\n",iface
);
899 return ItemMonikerImpl_Release(This
);
902 /******************************************************************************
903 * ItemMonikerIROTData_GetComparaisonData
904 ******************************************************************************/
905 HRESULT WINAPI
ItemMonikerROTDataImpl_GetComparaisonData(IROTData
* iface
,
910 FIXME(ole
,"(),stub!\n");
914 /******************************************************************************
915 * CreateItemMoniker16 [OLE2.28]
916 ******************************************************************************/
917 HRESULT WINAPI
CreateItemMoniker16(LPCOLESTR16 lpszDelim
,LPCOLESTR lpszItem
,LPMONIKER
* ppmk
)
920 FIXME(ole
,"(%s,%p),stub!\n",lpszDelim
,ppmk
);
925 /******************************************************************************
926 * CreateItemMoniker [OLE.55]
927 ******************************************************************************/
928 HRESULT WINAPI
CreateItemMoniker(LPCOLESTR lpszDelim
,LPCOLESTR lpszItem
, LPMONIKER
* ppmk
)
930 ItemMonikerImpl
* newItemMoniker
= 0;
932 IID riid
=IID_IMoniker
;
934 TRACE(ole
,"(%p,%p,%p)\n",lpszDelim
,lpszItem
,ppmk
);
936 newItemMoniker
= HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl
));
938 if (newItemMoniker
== 0)
939 return STG_E_INSUFFICIENTMEMORY
;
941 hr
= ItemMonikerImpl_Construct(newItemMoniker
,lpszDelim
,lpszItem
);
945 HeapFree(GetProcessHeap(),0,newItemMoniker
);
949 return ItemMonikerImpl_QueryInterface((IMoniker
*)newItemMoniker
,&riid
,(void**)ppmk
);