| 1 | /*************************************************************************************** | 
|---|
| 2 | *                            ItemMonikers implementation | 
|---|
| 3 | * | 
|---|
| 4 | *           Copyright 1999  Noomen Hamza | 
|---|
| 5 | * | 
|---|
| 6 | * This library is free software; you can redistribute it and/or | 
|---|
| 7 | * modify it under the terms of the GNU Lesser General Public | 
|---|
| 8 | * License as published by the Free Software Foundation; either | 
|---|
| 9 | * version 2.1 of the License, or (at your option) any later version. | 
|---|
| 10 | * | 
|---|
| 11 | * This library is distributed in the hope that it will be useful, | 
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 14 | * Lesser General Public License for more details. | 
|---|
| 15 | * | 
|---|
| 16 | * You should have received a copy of the GNU Lesser General Public | 
|---|
| 17 | * License along with this library; if not, write to the Free Software | 
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|---|
| 19 | ***************************************************************************************/ | 
|---|
| 20 |  | 
|---|
| 21 | #include <assert.h> | 
|---|
| 22 | #include <string.h> | 
|---|
| 23 | #include "winerror.h" | 
|---|
| 24 | #include "winbase.h" | 
|---|
| 25 | #include "winnls.h" | 
|---|
| 26 | #include "wine/debug.h" | 
|---|
| 27 | #include "wine/obj_base.h" | 
|---|
| 28 | #include "wine/obj_misc.h" | 
|---|
| 29 | #include "wine/obj_storage.h" | 
|---|
| 30 | #include "wine/obj_moniker.h" | 
|---|
| 31 | #include "wine/obj_inplace.h" | 
|---|
| 32 | #include "wine/unicode.h" | 
|---|
| 33 |  | 
|---|
| 34 | WINE_DEFAULT_DEBUG_CHANNEL(ole); | 
|---|
| 35 |  | 
|---|
| 36 | /* ItemMoniker data structure */ | 
|---|
| 37 | typedef struct ItemMonikerImpl{ | 
|---|
| 38 |  | 
|---|
| 39 | ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/ | 
|---|
| 40 |  | 
|---|
| 41 | /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether | 
|---|
| 42 | * two monikers are equal. That's whay IROTData interface is implemented by monikers. | 
|---|
| 43 | */ | 
|---|
| 44 | ICOM_VTABLE(IROTData)*  lpvtbl2;  /* VTable relative to the IROTData interface.*/ | 
|---|
| 45 |  | 
|---|
| 46 | ULONG ref; /* reference counter for this object */ | 
|---|
| 47 |  | 
|---|
| 48 | LPOLESTR itemName; /* item name identified by this ItemMoniker */ | 
|---|
| 49 |  | 
|---|
| 50 | LPOLESTR itemDelimiter; /* Delimiter string */ | 
|---|
| 51 |  | 
|---|
| 52 | } ItemMonikerImpl; | 
|---|
| 53 |  | 
|---|
| 54 | /********************************************************************************/ | 
|---|
| 55 | /* ItemMoniker prototype functions :                                            */ | 
|---|
| 56 |  | 
|---|
| 57 | /* IUnknown prototype functions */ | 
|---|
| 58 | static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject); | 
|---|
| 59 | static ULONG   WINAPI ItemMonikerImpl_AddRef(IMoniker* iface); | 
|---|
| 60 | static ULONG   WINAPI ItemMonikerImpl_Release(IMoniker* iface); | 
|---|
| 61 |  | 
|---|
| 62 | /* IPersist prototype functions */ | 
|---|
| 63 | static HRESULT WINAPI ItemMonikerImpl_GetClassID(IMoniker* iface, CLSID *pClassID); | 
|---|
| 64 |  | 
|---|
| 65 | /* IPersistStream prototype functions */ | 
|---|
| 66 | static HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface); | 
|---|
| 67 | static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface, IStream* pStm); | 
|---|
| 68 | static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty); | 
|---|
| 69 | static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize); | 
|---|
| 70 |  | 
|---|
| 71 | /* IMoniker prototype functions */ | 
|---|
| 72 | static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult); | 
|---|
| 73 | static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult); | 
|---|
| 74 | static HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced); | 
|---|
| 75 | static HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite); | 
|---|
| 76 | static HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker); | 
|---|
| 77 | static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker); | 
|---|
| 78 | static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash); | 
|---|
| 79 | static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning); | 
|---|
| 80 | static HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pItemTime); | 
|---|
| 81 | static HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk); | 
|---|
| 82 | static HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix); | 
|---|
| 83 | static HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath); | 
|---|
| 84 | static HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName); | 
|---|
| 85 | static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut); | 
|---|
| 86 | static HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys); | 
|---|
| 87 |  | 
|---|
| 88 | /* Local function used by ItemMoniker implementation */ | 
|---|
| 89 | HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* iface, LPCOLESTR lpszDelim,LPCOLESTR lpszPathName); | 
|---|
| 90 | HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* iface); | 
|---|
| 91 |  | 
|---|
| 92 | /********************************************************************************/ | 
|---|
| 93 | /* IROTData prototype functions                                                 */ | 
|---|
| 94 |  | 
|---|
| 95 | /* IUnknown prototype functions */ | 
|---|
| 96 | static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData* iface,REFIID riid,VOID** ppvObject); | 
|---|
| 97 | static ULONG   WINAPI ItemMonikerROTDataImpl_AddRef(IROTData* iface); | 
|---|
| 98 | static ULONG   WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface); | 
|---|
| 99 |  | 
|---|
| 100 | /* IROTData prototype function */ | 
|---|
| 101 | static HRESULT WINAPI ItemMonikerROTDataImpl_GetComparaisonData(IROTData* iface,BYTE* pbData,ULONG cbMax,ULONG* pcbData); | 
|---|
| 102 |  | 
|---|
| 103 | /********************************************************************************/ | 
|---|
| 104 | /* Virtual function table for the ItemMonikerImpl class which  include IPersist,*/ | 
|---|
| 105 | /* IPersistStream and IMoniker functions.                                       */ | 
|---|
| 106 | static ICOM_VTABLE(IMoniker) VT_ItemMonikerImpl = | 
|---|
| 107 | { | 
|---|
| 108 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 109 | ItemMonikerImpl_QueryInterface, | 
|---|
| 110 | ItemMonikerImpl_AddRef, | 
|---|
| 111 | ItemMonikerImpl_Release, | 
|---|
| 112 | ItemMonikerImpl_GetClassID, | 
|---|
| 113 | ItemMonikerImpl_IsDirty, | 
|---|
| 114 | ItemMonikerImpl_Load, | 
|---|
| 115 | ItemMonikerImpl_Save, | 
|---|
| 116 | ItemMonikerImpl_GetSizeMax, | 
|---|
| 117 | ItemMonikerImpl_BindToObject, | 
|---|
| 118 | ItemMonikerImpl_BindToStorage, | 
|---|
| 119 | ItemMonikerImpl_Reduce, | 
|---|
| 120 | ItemMonikerImpl_ComposeWith, | 
|---|
| 121 | ItemMonikerImpl_Enum, | 
|---|
| 122 | ItemMonikerImpl_IsEqual, | 
|---|
| 123 | ItemMonikerImpl_Hash, | 
|---|
| 124 | ItemMonikerImpl_IsRunning, | 
|---|
| 125 | ItemMonikerImpl_GetTimeOfLastChange, | 
|---|
| 126 | ItemMonikerImpl_Inverse, | 
|---|
| 127 | ItemMonikerImpl_CommonPrefixWith, | 
|---|
| 128 | ItemMonikerImpl_RelativePathTo, | 
|---|
| 129 | ItemMonikerImpl_GetDisplayName, | 
|---|
| 130 | ItemMonikerImpl_ParseDisplayName, | 
|---|
| 131 | ItemMonikerImpl_IsSystemMoniker | 
|---|
| 132 | }; | 
|---|
| 133 |  | 
|---|
| 134 | /********************************************************************************/ | 
|---|
| 135 | /* Virtual function table for the IROTData class.                               */ | 
|---|
| 136 | static ICOM_VTABLE(IROTData) VT_ROTDataImpl = | 
|---|
| 137 | { | 
|---|
| 138 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 139 | ItemMonikerROTDataImpl_QueryInterface, | 
|---|
| 140 | ItemMonikerROTDataImpl_AddRef, | 
|---|
| 141 | ItemMonikerROTDataImpl_Release, | 
|---|
| 142 | ItemMonikerROTDataImpl_GetComparaisonData | 
|---|
| 143 | }; | 
|---|
| 144 |  | 
|---|
| 145 | /******************************************************************************* | 
|---|
| 146 | *        ItemMoniker_QueryInterface | 
|---|
| 147 | *******************************************************************************/ | 
|---|
| 148 | HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject) | 
|---|
| 149 | { | 
|---|
| 150 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 151 |  | 
|---|
| 152 | TRACE("(%p,%p,%p)\n",This,riid,ppvObject); | 
|---|
| 153 |  | 
|---|
| 154 | /* Perform a sanity check on the parameters.*/ | 
|---|
| 155 | if ( (This==0) || (ppvObject==0) ) | 
|---|
| 156 | return E_INVALIDARG; | 
|---|
| 157 |  | 
|---|
| 158 | /* Initialize the return parameter */ | 
|---|
| 159 | *ppvObject = 0; | 
|---|
| 160 |  | 
|---|
| 161 | /* Compare the riid with the interface IDs implemented by this object.*/ | 
|---|
| 162 | if (IsEqualIID(&IID_IUnknown, riid) || | 
|---|
| 163 | IsEqualIID(&IID_IPersist, riid) || | 
|---|
| 164 | IsEqualIID(&IID_IPersistStream, riid) || | 
|---|
| 165 | IsEqualIID(&IID_IMoniker, riid) | 
|---|
| 166 | ) | 
|---|
| 167 | *ppvObject = iface; | 
|---|
| 168 |  | 
|---|
| 169 | else if (IsEqualIID(&IID_IROTData, riid)) | 
|---|
| 170 | *ppvObject = (IROTData*)&(This->lpvtbl2); | 
|---|
| 171 |  | 
|---|
| 172 | /* Check that we obtained an interface.*/ | 
|---|
| 173 | if ((*ppvObject)==0) | 
|---|
| 174 | return E_NOINTERFACE; | 
|---|
| 175 |  | 
|---|
| 176 | /* Query Interface always increases the reference count by one when it is successful */ | 
|---|
| 177 | ItemMonikerImpl_AddRef(iface); | 
|---|
| 178 |  | 
|---|
| 179 | return S_OK; | 
|---|
| 180 | } | 
|---|
| 181 |  | 
|---|
| 182 | /****************************************************************************** | 
|---|
| 183 | *        ItemMoniker_AddRef | 
|---|
| 184 | ******************************************************************************/ | 
|---|
| 185 | ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface) | 
|---|
| 186 | { | 
|---|
| 187 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 188 |  | 
|---|
| 189 | TRACE("(%p)\n",This); | 
|---|
| 190 |  | 
|---|
| 191 | return ++(This->ref); | 
|---|
| 192 | } | 
|---|
| 193 |  | 
|---|
| 194 | /****************************************************************************** | 
|---|
| 195 | *        ItemMoniker_Release | 
|---|
| 196 | ******************************************************************************/ | 
|---|
| 197 | ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface) | 
|---|
| 198 | { | 
|---|
| 199 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 200 |  | 
|---|
| 201 | TRACE("(%p)\n",This); | 
|---|
| 202 |  | 
|---|
| 203 | This->ref--; | 
|---|
| 204 |  | 
|---|
| 205 | /* destroy the object if there's no more reference on it */ | 
|---|
| 206 | if (This->ref==0){ | 
|---|
| 207 |  | 
|---|
| 208 | ItemMonikerImpl_Destroy(This); | 
|---|
| 209 |  | 
|---|
| 210 | return 0; | 
|---|
| 211 | } | 
|---|
| 212 | return This->ref; | 
|---|
| 213 | } | 
|---|
| 214 |  | 
|---|
| 215 | /****************************************************************************** | 
|---|
| 216 | *        ItemMoniker_GetClassID | 
|---|
| 217 | ******************************************************************************/ | 
|---|
| 218 | HRESULT WINAPI ItemMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID) | 
|---|
| 219 | { | 
|---|
| 220 | TRACE("(%p,%p),stub!\n",iface,pClassID); | 
|---|
| 221 |  | 
|---|
| 222 | if (pClassID==NULL) | 
|---|
| 223 | return E_POINTER; | 
|---|
| 224 |  | 
|---|
| 225 | *pClassID = CLSID_ItemMoniker; | 
|---|
| 226 |  | 
|---|
| 227 | return S_OK; | 
|---|
| 228 | } | 
|---|
| 229 |  | 
|---|
| 230 | /****************************************************************************** | 
|---|
| 231 | *        ItemMoniker_IsDirty | 
|---|
| 232 | ******************************************************************************/ | 
|---|
| 233 | HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface) | 
|---|
| 234 | { | 
|---|
| 235 | /* Note that the OLE-provided implementations of the IPersistStream::IsDirty | 
|---|
| 236 | method in the OLE-provided moniker interfaces always return S_FALSE because | 
|---|
| 237 | their internal state never changes. */ | 
|---|
| 238 |  | 
|---|
| 239 | TRACE("(%p)\n",iface); | 
|---|
| 240 |  | 
|---|
| 241 | return S_FALSE; | 
|---|
| 242 | } | 
|---|
| 243 |  | 
|---|
| 244 | /****************************************************************************** | 
|---|
| 245 | *        ItemMoniker_Load | 
|---|
| 246 | ******************************************************************************/ | 
|---|
| 247 | HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm) | 
|---|
| 248 | { | 
|---|
| 249 |  | 
|---|
| 250 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 251 | HRESULT res; | 
|---|
| 252 | DWORD delimiterLength,nameLength,lenW; | 
|---|
| 253 | CHAR *itemNameA,*itemDelimiterA; | 
|---|
| 254 | ULONG bread; | 
|---|
| 255 |  | 
|---|
| 256 | /* for more details about data read by this function see coments of ItemMonikerImpl_Save function */ | 
|---|
| 257 |  | 
|---|
| 258 | /* read item delimiter string length + 1 */ | 
|---|
| 259 | res=IStream_Read(pStm,&delimiterLength,sizeof(DWORD),&bread); | 
|---|
| 260 | if (bread != sizeof(DWORD)) | 
|---|
| 261 | return E_FAIL; | 
|---|
| 262 |  | 
|---|
| 263 | /* read item delimiter string */ | 
|---|
| 264 | if (!(itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength))) | 
|---|
| 265 | return E_OUTOFMEMORY; | 
|---|
| 266 | res=IStream_Read(pStm,itemDelimiterA,delimiterLength,&bread); | 
|---|
| 267 | if (bread != delimiterLength) | 
|---|
| 268 | { | 
|---|
| 269 | HeapFree( GetProcessHeap(), 0, itemDelimiterA ); | 
|---|
| 270 | return E_FAIL; | 
|---|
| 271 | } | 
|---|
| 272 |  | 
|---|
| 273 | lenW = MultiByteToWideChar( CP_ACP, 0, itemDelimiterA, -1, NULL, 0 ); | 
|---|
| 274 | This->itemDelimiter=HeapReAlloc(GetProcessHeap(),0,This->itemDelimiter,lenW*sizeof(WCHAR)); | 
|---|
| 275 | if (!This->itemDelimiter) | 
|---|
| 276 | { | 
|---|
| 277 | HeapFree( GetProcessHeap(), 0, itemDelimiterA ); | 
|---|
| 278 | return E_OUTOFMEMORY; | 
|---|
| 279 | } | 
|---|
| 280 | MultiByteToWideChar( CP_ACP, 0, itemDelimiterA, -1, This->itemDelimiter, lenW ); | 
|---|
| 281 | HeapFree( GetProcessHeap(), 0, itemDelimiterA ); | 
|---|
| 282 |  | 
|---|
| 283 | /* read item name string length + 1*/ | 
|---|
| 284 | res=IStream_Read(pStm,&nameLength,sizeof(DWORD),&bread); | 
|---|
| 285 | if (bread != sizeof(DWORD)) | 
|---|
| 286 | return E_FAIL; | 
|---|
| 287 |  | 
|---|
| 288 | /* read item name string */ | 
|---|
| 289 | if (!(itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength))) | 
|---|
| 290 | return E_OUTOFMEMORY; | 
|---|
| 291 | res=IStream_Read(pStm,itemNameA,nameLength,&bread); | 
|---|
| 292 | if (bread != nameLength) | 
|---|
| 293 | { | 
|---|
| 294 | HeapFree( GetProcessHeap(), 0, itemNameA ); | 
|---|
| 295 | return E_FAIL; | 
|---|
| 296 | } | 
|---|
| 297 |  | 
|---|
| 298 | lenW = MultiByteToWideChar( CP_ACP, 0, itemNameA, -1, NULL, 0 ); | 
|---|
| 299 | This->itemName=HeapReAlloc(GetProcessHeap(),0,This->itemName,lenW*sizeof(WCHAR)); | 
|---|
| 300 | if (!This->itemName) | 
|---|
| 301 | { | 
|---|
| 302 | HeapFree( GetProcessHeap(), 0, itemNameA ); | 
|---|
| 303 | return E_OUTOFMEMORY; | 
|---|
| 304 | } | 
|---|
| 305 | MultiByteToWideChar( CP_ACP, 0, itemNameA, -1, This->itemName, lenW ); | 
|---|
| 306 | HeapFree( GetProcessHeap(), 0, itemNameA ); | 
|---|
| 307 |  | 
|---|
| 308 | return res; | 
|---|
| 309 | } | 
|---|
| 310 |  | 
|---|
| 311 | /****************************************************************************** | 
|---|
| 312 | *        ItemMoniker_Save | 
|---|
| 313 | ******************************************************************************/ | 
|---|
| 314 | HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, | 
|---|
| 315 | IStream* pStm,/* pointer to the stream where the object is to be saved */ | 
|---|
| 316 | BOOL fClearDirty)/* Specifies whether to clear the dirty flag */ | 
|---|
| 317 | { | 
|---|
| 318 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 319 | HRESULT res; | 
|---|
| 320 | CHAR *itemNameA,*itemDelimiterA; | 
|---|
| 321 |  | 
|---|
| 322 | /* data writen by this function are : 1) DWORD : size of item delimiter string ('\0' included ) */ | 
|---|
| 323 | /*                                    2) String (type A): item delimiter string ('\0' included)          */ | 
|---|
| 324 | /*                                    3) DWORD : size of item name string ('\0' included)       */ | 
|---|
| 325 | /*                                    4) String (type A): item name string ('\0' included)               */ | 
|---|
| 326 |  | 
|---|
| 327 | DWORD nameLength = WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, NULL, 0, NULL, NULL); | 
|---|
| 328 | DWORD delimiterLength = WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, NULL, 0, NULL, NULL); | 
|---|
| 329 | itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength); | 
|---|
| 330 | itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength); | 
|---|
| 331 | WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, itemNameA, nameLength, NULL, NULL); | 
|---|
| 332 | WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, itemDelimiterA, delimiterLength, NULL, NULL); | 
|---|
| 333 |  | 
|---|
| 334 | res=IStream_Write(pStm,&delimiterLength,sizeof(DWORD),NULL); | 
|---|
| 335 | res=IStream_Write(pStm,itemDelimiterA,delimiterLength * sizeof(CHAR),NULL); | 
|---|
| 336 | res=IStream_Write(pStm,&nameLength,sizeof(DWORD),NULL); | 
|---|
| 337 | res=IStream_Write(pStm,itemNameA,nameLength * sizeof(CHAR),NULL); | 
|---|
| 338 |  | 
|---|
| 339 | return res; | 
|---|
| 340 | } | 
|---|
| 341 |  | 
|---|
| 342 | /****************************************************************************** | 
|---|
| 343 | *        ItemMoniker_GetSizeMax | 
|---|
| 344 | ******************************************************************************/ | 
|---|
| 345 | HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, | 
|---|
| 346 | ULARGE_INTEGER* pcbSize)/* Pointer to size of stream needed to save object */ | 
|---|
| 347 | { | 
|---|
| 348 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 349 | DWORD delimiterLength=lstrlenW(This->itemDelimiter)+1; | 
|---|
| 350 | DWORD nameLength=lstrlenW(This->itemName)+1; | 
|---|
| 351 |  | 
|---|
| 352 | TRACE("(%p,%p)\n",iface,pcbSize); | 
|---|
| 353 |  | 
|---|
| 354 | if (pcbSize!=NULL) | 
|---|
| 355 | return E_POINTER; | 
|---|
| 356 |  | 
|---|
| 357 | /* for more details see ItemMonikerImpl_Save coments */ | 
|---|
| 358 |  | 
|---|
| 359 | pcbSize->s.LowPart =  sizeof(DWORD) + /* DWORD which contains delimiter length */ | 
|---|
| 360 | delimiterLength + /* item delimiter string */ | 
|---|
| 361 | sizeof(DWORD) + /* DWORD which contains item name length */ | 
|---|
| 362 | nameLength + /* item name string */ | 
|---|
| 363 | 34; /* this constant was added ! because when I tested this function it usually */ | 
|---|
| 364 | /*  returns 34 bytes more than the number of bytes used by IMoniker::Save function */ | 
|---|
| 365 | pcbSize->s.HighPart=0; | 
|---|
| 366 |  | 
|---|
| 367 | return S_OK; | 
|---|
| 368 | } | 
|---|
| 369 |  | 
|---|
| 370 | /****************************************************************************** | 
|---|
| 371 | *         ItemMoniker_Construct (local function) | 
|---|
| 372 | *******************************************************************************/ | 
|---|
| 373 | HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem) | 
|---|
| 374 | { | 
|---|
| 375 |  | 
|---|
| 376 | int sizeStr1=lstrlenW(lpszItem), sizeStr2; | 
|---|
| 377 | static const OLECHAR emptystr[1]; | 
|---|
| 378 | LPCOLESTR   delim; | 
|---|
| 379 |  | 
|---|
| 380 | TRACE("(%p,%p)\n",This,lpszItem); | 
|---|
| 381 |  | 
|---|
| 382 | /* Initialize the virtual fgunction table. */ | 
|---|
| 383 | This->lpvtbl1      = &VT_ItemMonikerImpl; | 
|---|
| 384 | This->lpvtbl2      = &VT_ROTDataImpl; | 
|---|
| 385 | This->ref          = 0; | 
|---|
| 386 |  | 
|---|
| 387 | This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1)); | 
|---|
| 388 | if (!This->itemName) | 
|---|
| 389 | return E_OUTOFMEMORY; | 
|---|
| 390 | lstrcpyW(This->itemName,lpszItem); | 
|---|
| 391 |  | 
|---|
| 392 | if (!lpszDelim) | 
|---|
| 393 | FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n"); | 
|---|
| 394 |  | 
|---|
| 395 | delim = lpszDelim ? lpszDelim : emptystr; | 
|---|
| 396 |  | 
|---|
| 397 | sizeStr2=lstrlenW(delim); | 
|---|
| 398 | This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1)); | 
|---|
| 399 | if (!This->itemDelimiter) { | 
|---|
| 400 | HeapFree(GetProcessHeap(),0,This->itemName); | 
|---|
| 401 | return E_OUTOFMEMORY; | 
|---|
| 402 | } | 
|---|
| 403 | lstrcpyW(This->itemDelimiter,delim); | 
|---|
| 404 | return S_OK; | 
|---|
| 405 | } | 
|---|
| 406 |  | 
|---|
| 407 | /****************************************************************************** | 
|---|
| 408 | *        ItemMoniker_Destroy (local function) | 
|---|
| 409 | *******************************************************************************/ | 
|---|
| 410 | HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* This) | 
|---|
| 411 | { | 
|---|
| 412 | TRACE("(%p)\n",This); | 
|---|
| 413 |  | 
|---|
| 414 | if (This->itemName) | 
|---|
| 415 | HeapFree(GetProcessHeap(),0,This->itemName); | 
|---|
| 416 |  | 
|---|
| 417 | if (This->itemDelimiter) | 
|---|
| 418 | HeapFree(GetProcessHeap(),0,This->itemDelimiter); | 
|---|
| 419 |  | 
|---|
| 420 | HeapFree(GetProcessHeap(),0,This); | 
|---|
| 421 |  | 
|---|
| 422 | return S_OK; | 
|---|
| 423 | } | 
|---|
| 424 |  | 
|---|
| 425 | /****************************************************************************** | 
|---|
| 426 | *                  ItemMoniker_BindToObject | 
|---|
| 427 | ******************************************************************************/ | 
|---|
| 428 | HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface, | 
|---|
| 429 | IBindCtx* pbc, | 
|---|
| 430 | IMoniker* pmkToLeft, | 
|---|
| 431 | REFIID riid, | 
|---|
| 432 | VOID** ppvResult) | 
|---|
| 433 | { | 
|---|
| 434 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 435 |  | 
|---|
| 436 | HRESULT   res; | 
|---|
| 437 | IID    refid=IID_IOleItemContainer; | 
|---|
| 438 | IOleItemContainer *poic=0; | 
|---|
| 439 |  | 
|---|
| 440 | TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); | 
|---|
| 441 |  | 
|---|
| 442 | if(ppvResult ==NULL) | 
|---|
| 443 | return E_POINTER; | 
|---|
| 444 |  | 
|---|
| 445 | if(pmkToLeft==NULL) | 
|---|
| 446 | return E_INVALIDARG; | 
|---|
| 447 |  | 
|---|
| 448 | *ppvResult=0; | 
|---|
| 449 |  | 
|---|
| 450 | res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&refid,(void**)&poic); | 
|---|
| 451 |  | 
|---|
| 452 | if (SUCCEEDED(res)){ | 
|---|
| 453 |  | 
|---|
| 454 | res=IOleItemContainer_GetObject(poic,This->itemName,BINDSPEED_MODERATE,pbc,riid,ppvResult); | 
|---|
| 455 |  | 
|---|
| 456 | IOleItemContainer_Release(poic); | 
|---|
| 457 | } | 
|---|
| 458 |  | 
|---|
| 459 | return res; | 
|---|
| 460 | } | 
|---|
| 461 |  | 
|---|
| 462 | /****************************************************************************** | 
|---|
| 463 | *        ItemMoniker_BindToStorage | 
|---|
| 464 | ******************************************************************************/ | 
|---|
| 465 | HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface, | 
|---|
| 466 | IBindCtx* pbc, | 
|---|
| 467 | IMoniker* pmkToLeft, | 
|---|
| 468 | REFIID riid, | 
|---|
| 469 | VOID** ppvResult) | 
|---|
| 470 | { | 
|---|
| 471 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 472 |  | 
|---|
| 473 | HRESULT   res; | 
|---|
| 474 | IOleItemContainer *poic=0; | 
|---|
| 475 |  | 
|---|
| 476 | TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); | 
|---|
| 477 |  | 
|---|
| 478 | *ppvResult=0; | 
|---|
| 479 |  | 
|---|
| 480 | if(pmkToLeft==NULL) | 
|---|
| 481 | return E_INVALIDARG; | 
|---|
| 482 |  | 
|---|
| 483 | res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); | 
|---|
| 484 |  | 
|---|
| 485 | if (SUCCEEDED(res)){ | 
|---|
| 486 |  | 
|---|
| 487 | res=IOleItemContainer_GetObjectStorage(poic,This->itemName,pbc,riid,ppvResult); | 
|---|
| 488 |  | 
|---|
| 489 | IOleItemContainer_Release(poic); | 
|---|
| 490 | } | 
|---|
| 491 |  | 
|---|
| 492 | return res; | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 | /****************************************************************************** | 
|---|
| 496 | *        ItemMoniker_Reduce | 
|---|
| 497 | ******************************************************************************/ | 
|---|
| 498 | HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface, | 
|---|
| 499 | IBindCtx* pbc, | 
|---|
| 500 | DWORD dwReduceHowFar, | 
|---|
| 501 | IMoniker** ppmkToLeft, | 
|---|
| 502 | IMoniker** ppmkReduced) | 
|---|
| 503 | { | 
|---|
| 504 | TRACE("(%p,%p,%ld,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced); | 
|---|
| 505 |  | 
|---|
| 506 | if (ppmkReduced==NULL) | 
|---|
| 507 | return E_POINTER; | 
|---|
| 508 |  | 
|---|
| 509 | ItemMonikerImpl_AddRef(iface); | 
|---|
| 510 |  | 
|---|
| 511 | *ppmkReduced=iface; | 
|---|
| 512 |  | 
|---|
| 513 | return MK_S_REDUCED_TO_SELF; | 
|---|
| 514 | } | 
|---|
| 515 | /****************************************************************************** | 
|---|
| 516 | *        ItemMoniker_ComposeWith | 
|---|
| 517 | ******************************************************************************/ | 
|---|
| 518 | HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface, | 
|---|
| 519 | IMoniker* pmkRight, | 
|---|
| 520 | BOOL fOnlyIfNotGeneric, | 
|---|
| 521 | IMoniker** ppmkComposite) | 
|---|
| 522 | { | 
|---|
| 523 | HRESULT res=S_OK; | 
|---|
| 524 | DWORD mkSys,mkSys2; | 
|---|
| 525 | IEnumMoniker* penumMk=0; | 
|---|
| 526 | IMoniker *pmostLeftMk=0; | 
|---|
| 527 | IMoniker* tempMkComposite=0; | 
|---|
| 528 |  | 
|---|
| 529 | TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite); | 
|---|
| 530 |  | 
|---|
| 531 | if ((ppmkComposite==NULL)||(pmkRight==NULL)) | 
|---|
| 532 | return E_POINTER; | 
|---|
| 533 |  | 
|---|
| 534 | *ppmkComposite=0; | 
|---|
| 535 |  | 
|---|
| 536 | IMoniker_IsSystemMoniker(pmkRight,&mkSys); | 
|---|
| 537 |  | 
|---|
| 538 | /* If pmkRight is an anti-moniker, the returned moniker is NULL */ | 
|---|
| 539 | if(mkSys==MKSYS_ANTIMONIKER) | 
|---|
| 540 | return res; | 
|---|
| 541 |  | 
|---|
| 542 | else | 
|---|
| 543 | /* if pmkRight is a composite whose leftmost component is an anti-moniker,           */ | 
|---|
| 544 | /* the returned moniker is the composite after the leftmost anti-moniker is removed. */ | 
|---|
| 545 |  | 
|---|
| 546 | if(mkSys==MKSYS_GENERICCOMPOSITE){ | 
|---|
| 547 |  | 
|---|
| 548 | res=IMoniker_Enum(pmkRight,TRUE,&penumMk); | 
|---|
| 549 |  | 
|---|
| 550 | if (FAILED(res)) | 
|---|
| 551 | return res; | 
|---|
| 552 |  | 
|---|
| 553 | res=IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL); | 
|---|
| 554 |  | 
|---|
| 555 | IMoniker_IsSystemMoniker(pmostLeftMk,&mkSys2); | 
|---|
| 556 |  | 
|---|
| 557 | if(mkSys2==MKSYS_ANTIMONIKER){ | 
|---|
| 558 |  | 
|---|
| 559 | IMoniker_Release(pmostLeftMk); | 
|---|
| 560 |  | 
|---|
| 561 | tempMkComposite=iface; | 
|---|
| 562 | IMoniker_AddRef(iface); | 
|---|
| 563 |  | 
|---|
| 564 | while(IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL)==S_OK){ | 
|---|
| 565 |  | 
|---|
| 566 | res=CreateGenericComposite(tempMkComposite,pmostLeftMk,ppmkComposite); | 
|---|
| 567 |  | 
|---|
| 568 | IMoniker_Release(tempMkComposite); | 
|---|
| 569 | IMoniker_Release(pmostLeftMk); | 
|---|
| 570 |  | 
|---|
| 571 | tempMkComposite=*ppmkComposite; | 
|---|
| 572 | IMoniker_AddRef(tempMkComposite); | 
|---|
| 573 | } | 
|---|
| 574 | return res; | 
|---|
| 575 | } | 
|---|
| 576 | else | 
|---|
| 577 | return CreateGenericComposite(iface,pmkRight,ppmkComposite); | 
|---|
| 578 | } | 
|---|
| 579 | /* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic | 
|---|
| 580 | composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns | 
|---|
| 581 | a NULL moniker and a return value of MK_E_NEEDGENERIC */ | 
|---|
| 582 | else | 
|---|
| 583 | if (!fOnlyIfNotGeneric) | 
|---|
| 584 | return CreateGenericComposite(iface,pmkRight,ppmkComposite); | 
|---|
| 585 |  | 
|---|
| 586 | else | 
|---|
| 587 | return MK_E_NEEDGENERIC; | 
|---|
| 588 | } | 
|---|
| 589 |  | 
|---|
| 590 | /****************************************************************************** | 
|---|
| 591 | *        ItemMoniker_Enum | 
|---|
| 592 | ******************************************************************************/ | 
|---|
| 593 | HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker) | 
|---|
| 594 | { | 
|---|
| 595 | TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker); | 
|---|
| 596 |  | 
|---|
| 597 | if (ppenumMoniker == NULL) | 
|---|
| 598 | return E_POINTER; | 
|---|
| 599 |  | 
|---|
| 600 | *ppenumMoniker = NULL; | 
|---|
| 601 |  | 
|---|
| 602 | return S_OK; | 
|---|
| 603 | } | 
|---|
| 604 |  | 
|---|
| 605 | /****************************************************************************** | 
|---|
| 606 | *        ItemMoniker_IsEqual | 
|---|
| 607 | ******************************************************************************/ | 
|---|
| 608 | HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker) | 
|---|
| 609 | { | 
|---|
| 610 |  | 
|---|
| 611 | CLSID clsid; | 
|---|
| 612 | LPOLESTR dispName1,dispName2; | 
|---|
| 613 | IBindCtx* bind; | 
|---|
| 614 | HRESULT res = S_FALSE; | 
|---|
| 615 |  | 
|---|
| 616 | TRACE("(%p,%p)\n",iface,pmkOtherMoniker); | 
|---|
| 617 |  | 
|---|
| 618 | if (!pmkOtherMoniker) return S_FALSE; | 
|---|
| 619 |  | 
|---|
| 620 |  | 
|---|
| 621 | /* check if both are ItemMoniker */ | 
|---|
| 622 | if(FAILED (IMoniker_GetClassID(pmkOtherMoniker,&clsid))) return S_FALSE; | 
|---|
| 623 | if(!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) return S_FALSE; | 
|---|
| 624 |  | 
|---|
| 625 | /* check if both displaynames are the same */ | 
|---|
| 626 | if(SUCCEEDED ((res = CreateBindCtx(0,&bind)))) { | 
|---|
| 627 | if(SUCCEEDED (IMoniker_GetDisplayName(iface,bind,NULL,&dispName1))) { | 
|---|
| 628 | if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2))) { | 
|---|
| 629 | if(lstrcmpW(dispName1,dispName2)==0) res = S_OK; | 
|---|
| 630 | CoTaskMemFree(dispName2); | 
|---|
| 631 | } | 
|---|
| 632 | CoTaskMemFree(dispName1); | 
|---|
| 633 | } | 
|---|
| 634 | } | 
|---|
| 635 | return res; | 
|---|
| 636 | } | 
|---|
| 637 |  | 
|---|
| 638 | /****************************************************************************** | 
|---|
| 639 | *        ItemMoniker_Hash | 
|---|
| 640 | ******************************************************************************/ | 
|---|
| 641 | HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash) | 
|---|
| 642 | { | 
|---|
| 643 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 644 |  | 
|---|
| 645 | int  h = 0,i,skip,len; | 
|---|
| 646 | int  off = 0; | 
|---|
| 647 | LPOLESTR val; | 
|---|
| 648 |  | 
|---|
| 649 | if (pdwHash==NULL) | 
|---|
| 650 | return E_POINTER; | 
|---|
| 651 |  | 
|---|
| 652 | val =  This->itemName; | 
|---|
| 653 | len = lstrlenW(val); | 
|---|
| 654 |  | 
|---|
| 655 | if (len < 16) { | 
|---|
| 656 | for (i = len ; i > 0; i--) { | 
|---|
| 657 | h = (h * 37) + val[off++]; | 
|---|
| 658 | } | 
|---|
| 659 | } else { | 
|---|
| 660 | /* only sample some characters */ | 
|---|
| 661 | skip = len / 8; | 
|---|
| 662 | for (i = len ; i > 0; i -= skip, off += skip) { | 
|---|
| 663 | h = (h * 39) + val[off]; | 
|---|
| 664 | } | 
|---|
| 665 | } | 
|---|
| 666 |  | 
|---|
| 667 | *pdwHash=h; | 
|---|
| 668 |  | 
|---|
| 669 | return S_OK; | 
|---|
| 670 | } | 
|---|
| 671 |  | 
|---|
| 672 | /****************************************************************************** | 
|---|
| 673 | *        ItemMoniker_IsRunning | 
|---|
| 674 | ******************************************************************************/ | 
|---|
| 675 | HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface, | 
|---|
| 676 | IBindCtx* pbc, | 
|---|
| 677 | IMoniker* pmkToLeft, | 
|---|
| 678 | IMoniker* pmkNewlyRunning) | 
|---|
| 679 | { | 
|---|
| 680 | IRunningObjectTable* rot; | 
|---|
| 681 | HRESULT res; | 
|---|
| 682 | IOleItemContainer *poic=0; | 
|---|
| 683 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 684 |  | 
|---|
| 685 | TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning); | 
|---|
| 686 |  | 
|---|
| 687 | /* If pmkToLeft is NULL, this method returns TRUE if pmkNewlyRunning is non-NULL and is equal to this */ | 
|---|
| 688 | /* moniker. Otherwise, the method checks the ROT to see whether this moniker is running.              */ | 
|---|
| 689 | if (pmkToLeft==NULL) | 
|---|
| 690 | if ((pmkNewlyRunning!=NULL)&&(IMoniker_IsEqual(pmkNewlyRunning,iface)==S_OK)) | 
|---|
| 691 | return S_OK; | 
|---|
| 692 | else { | 
|---|
| 693 | if (pbc==NULL) | 
|---|
| 694 | return E_POINTER; | 
|---|
| 695 |  | 
|---|
| 696 | res=IBindCtx_GetRunningObjectTable(pbc,&rot); | 
|---|
| 697 |  | 
|---|
| 698 | if (FAILED(res)) | 
|---|
| 699 | return res; | 
|---|
| 700 |  | 
|---|
| 701 | res = IRunningObjectTable_IsRunning(rot,iface); | 
|---|
| 702 |  | 
|---|
| 703 | IRunningObjectTable_Release(rot); | 
|---|
| 704 | } | 
|---|
| 705 | else{ | 
|---|
| 706 |  | 
|---|
| 707 | /* If pmkToLeft is non-NULL, the method calls IMoniker::BindToObject on the pmkToLeft parameter,         */ | 
|---|
| 708 | /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/ | 
|---|
| 709 | /* passing the string contained within this moniker. */ | 
|---|
| 710 |  | 
|---|
| 711 | res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); | 
|---|
| 712 |  | 
|---|
| 713 | if (SUCCEEDED(res)){ | 
|---|
| 714 |  | 
|---|
| 715 | res=IOleItemContainer_IsRunning(poic,This->itemName); | 
|---|
| 716 |  | 
|---|
| 717 | IOleItemContainer_Release(poic); | 
|---|
| 718 | } | 
|---|
| 719 | } | 
|---|
| 720 |  | 
|---|
| 721 | return res; | 
|---|
| 722 | } | 
|---|
| 723 |  | 
|---|
| 724 | /****************************************************************************** | 
|---|
| 725 | *        ItemMoniker_GetTimeOfLastChange | 
|---|
| 726 | ******************************************************************************/ | 
|---|
| 727 | HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface, | 
|---|
| 728 | IBindCtx* pbc, | 
|---|
| 729 | IMoniker* pmkToLeft, | 
|---|
| 730 | FILETIME* pItemTime) | 
|---|
| 731 | { | 
|---|
| 732 | IRunningObjectTable* rot; | 
|---|
| 733 | HRESULT res; | 
|---|
| 734 | IMoniker *compositeMk; | 
|---|
| 735 |  | 
|---|
| 736 | TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pItemTime); | 
|---|
| 737 |  | 
|---|
| 738 | if (pItemTime==NULL) | 
|---|
| 739 | return E_INVALIDARG; | 
|---|
| 740 |  | 
|---|
| 741 | /* If pmkToLeft is NULL, this method returns MK_E_NOTBINDABLE */ | 
|---|
| 742 | if (pmkToLeft==NULL) | 
|---|
| 743 |  | 
|---|
| 744 | return MK_E_NOTBINDABLE; | 
|---|
| 745 | else { | 
|---|
| 746 |  | 
|---|
| 747 | /* Otherwise, the method creates a composite of pmkToLeft and this moniker and uses the ROT to access  */ | 
|---|
| 748 | /* the time of last change. If the object is not in the ROT, the method calls                          */ | 
|---|
| 749 | /* IMoniker::GetTimeOfLastChange on the pmkToLeft parameter.                                            */ | 
|---|
| 750 |  | 
|---|
| 751 | res=CreateGenericComposite(pmkToLeft,iface,&compositeMk); | 
|---|
| 752 |  | 
|---|
| 753 | res=IBindCtx_GetRunningObjectTable(pbc,&rot); | 
|---|
| 754 |  | 
|---|
| 755 | if (IRunningObjectTable_GetTimeOfLastChange(rot,compositeMk,pItemTime)!=S_OK) | 
|---|
| 756 |  | 
|---|
| 757 | res=IMoniker_GetTimeOfLastChange(pmkToLeft,pbc,NULL,pItemTime); | 
|---|
| 758 |  | 
|---|
| 759 | IMoniker_Release(compositeMk); | 
|---|
| 760 | } | 
|---|
| 761 |  | 
|---|
| 762 | return res; | 
|---|
| 763 | } | 
|---|
| 764 |  | 
|---|
| 765 | /****************************************************************************** | 
|---|
| 766 | *        ItemMoniker_Inverse | 
|---|
| 767 | ******************************************************************************/ | 
|---|
| 768 | HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk) | 
|---|
| 769 | { | 
|---|
| 770 | TRACE("(%p,%p)\n",iface,ppmk); | 
|---|
| 771 |  | 
|---|
| 772 | if (ppmk==NULL) | 
|---|
| 773 | return E_POINTER; | 
|---|
| 774 |  | 
|---|
| 775 | return CreateAntiMoniker(ppmk); | 
|---|
| 776 | } | 
|---|
| 777 |  | 
|---|
| 778 | /****************************************************************************** | 
|---|
| 779 | *        ItemMoniker_CommonPrefixWith | 
|---|
| 780 | ******************************************************************************/ | 
|---|
| 781 | HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix) | 
|---|
| 782 | { | 
|---|
| 783 | DWORD mkSys; | 
|---|
| 784 | IMoniker_IsSystemMoniker(pmkOther,&mkSys); | 
|---|
| 785 | /* If the other moniker is an item moniker that is equal to this moniker, this method sets *ppmkPrefix */ | 
|---|
| 786 | /* to this moniker and returns MK_S_US */ | 
|---|
| 787 |  | 
|---|
| 788 | if((mkSys==MKSYS_ITEMMONIKER) && (IMoniker_IsEqual(iface,pmkOther)==S_OK) ){ | 
|---|
| 789 |  | 
|---|
| 790 | *ppmkPrefix=iface; | 
|---|
| 791 |  | 
|---|
| 792 | IMoniker_AddRef(iface); | 
|---|
| 793 |  | 
|---|
| 794 | return MK_S_US; | 
|---|
| 795 | } | 
|---|
| 796 | else | 
|---|
| 797 | /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */ | 
|---|
| 798 | /* the case where the other moniker is a generic composite. */ | 
|---|
| 799 | return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix); | 
|---|
| 800 | } | 
|---|
| 801 |  | 
|---|
| 802 | /****************************************************************************** | 
|---|
| 803 | *        ItemMoniker_RelativePathTo | 
|---|
| 804 | ******************************************************************************/ | 
|---|
| 805 | HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath) | 
|---|
| 806 | { | 
|---|
| 807 | TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath); | 
|---|
| 808 |  | 
|---|
| 809 | if (ppmkRelPath==NULL) | 
|---|
| 810 | return E_POINTER; | 
|---|
| 811 |  | 
|---|
| 812 | *ppmkRelPath=0; | 
|---|
| 813 |  | 
|---|
| 814 | return MK_E_NOTBINDABLE; | 
|---|
| 815 | } | 
|---|
| 816 |  | 
|---|
| 817 | /****************************************************************************** | 
|---|
| 818 | *        ItemMoniker_GetDisplayName | 
|---|
| 819 | ******************************************************************************/ | 
|---|
| 820 | HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface, | 
|---|
| 821 | IBindCtx* pbc, | 
|---|
| 822 | IMoniker* pmkToLeft, | 
|---|
| 823 | LPOLESTR *ppszDisplayName) | 
|---|
| 824 | { | 
|---|
| 825 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 826 |  | 
|---|
| 827 | TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName); | 
|---|
| 828 |  | 
|---|
| 829 | if (ppszDisplayName==NULL) | 
|---|
| 830 | return E_POINTER; | 
|---|
| 831 |  | 
|---|
| 832 | if (pmkToLeft!=NULL){ | 
|---|
| 833 | return E_INVALIDARG; | 
|---|
| 834 | } | 
|---|
| 835 |  | 
|---|
| 836 | *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)*(lstrlenW(This->itemDelimiter)+lstrlenW(This->itemName)+1)); | 
|---|
| 837 |  | 
|---|
| 838 | if (*ppszDisplayName==NULL) | 
|---|
| 839 | return E_OUTOFMEMORY; | 
|---|
| 840 |  | 
|---|
| 841 | lstrcpyW(*ppszDisplayName,This->itemDelimiter); | 
|---|
| 842 | lstrcatW(*ppszDisplayName,This->itemName); | 
|---|
| 843 |  | 
|---|
| 844 | return S_OK; | 
|---|
| 845 | } | 
|---|
| 846 |  | 
|---|
| 847 | /****************************************************************************** | 
|---|
| 848 | *        ItemMoniker_ParseDisplayName | 
|---|
| 849 | ******************************************************************************/ | 
|---|
| 850 | HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface, | 
|---|
| 851 | IBindCtx* pbc, | 
|---|
| 852 | IMoniker* pmkToLeft, | 
|---|
| 853 | LPOLESTR pszDisplayName, | 
|---|
| 854 | ULONG* pchEaten, | 
|---|
| 855 | IMoniker** ppmkOut) | 
|---|
| 856 | { | 
|---|
| 857 | IOleItemContainer* poic=0; | 
|---|
| 858 | IParseDisplayName* ppdn=0; | 
|---|
| 859 | LPOLESTR displayName; | 
|---|
| 860 | HRESULT res; | 
|---|
| 861 | ICOM_THIS(ItemMonikerImpl,iface); | 
|---|
| 862 |  | 
|---|
| 863 | /* If pmkToLeft is NULL, this method returns MK_E_SYNTAX */ | 
|---|
| 864 | if (pmkToLeft==NULL) | 
|---|
| 865 |  | 
|---|
| 866 | return MK_E_SYNTAX; | 
|---|
| 867 |  | 
|---|
| 868 | else{ | 
|---|
| 869 | /* Otherwise, the method calls IMoniker::BindToObject on the pmkToLeft parameter, requesting an */ | 
|---|
| 870 | /* IParseDisplayName interface pointer to the object identified by the moniker, and passes the display */ | 
|---|
| 871 | /* name to IParseDisplayName::ParseDisplayName */ | 
|---|
| 872 | res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); | 
|---|
| 873 |  | 
|---|
| 874 | if (SUCCEEDED(res)){ | 
|---|
| 875 |  | 
|---|
| 876 | res=IOleItemContainer_GetObject(poic,This->itemName,BINDSPEED_MODERATE,pbc,&IID_IParseDisplayName,(void**)&ppdn); | 
|---|
| 877 |  | 
|---|
| 878 | res=IMoniker_GetDisplayName(iface,pbc,NULL,&displayName); | 
|---|
| 879 |  | 
|---|
| 880 | res=IParseDisplayName_ParseDisplayName(ppdn,pbc,displayName,pchEaten,ppmkOut); | 
|---|
| 881 |  | 
|---|
| 882 | IOleItemContainer_Release(poic); | 
|---|
| 883 | IParseDisplayName_Release(ppdn); | 
|---|
| 884 | } | 
|---|
| 885 | } | 
|---|
| 886 | return res; | 
|---|
| 887 | } | 
|---|
| 888 |  | 
|---|
| 889 | /****************************************************************************** | 
|---|
| 890 | *        ItemMoniker_IsSystemMoniker | 
|---|
| 891 | ******************************************************************************/ | 
|---|
| 892 | HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys) | 
|---|
| 893 | { | 
|---|
| 894 | TRACE("(%p,%p)\n",iface,pwdMksys); | 
|---|
| 895 |  | 
|---|
| 896 | if (!pwdMksys) | 
|---|
| 897 | return E_POINTER; | 
|---|
| 898 |  | 
|---|
| 899 | (*pwdMksys)=MKSYS_ITEMMONIKER; | 
|---|
| 900 |  | 
|---|
| 901 | return S_OK; | 
|---|
| 902 | } | 
|---|
| 903 |  | 
|---|
| 904 | /******************************************************************************* | 
|---|
| 905 | *        ItemMonikerIROTData_QueryInterface | 
|---|
| 906 | *******************************************************************************/ | 
|---|
| 907 | HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject) | 
|---|
| 908 | { | 
|---|
| 909 |  | 
|---|
| 910 | ICOM_THIS_From_IROTData(IMoniker, iface); | 
|---|
| 911 |  | 
|---|
| 912 | TRACE("(%p,%p,%p)\n",iface,riid,ppvObject); | 
|---|
| 913 |  | 
|---|
| 914 | return ItemMonikerImpl_QueryInterface(This, riid, ppvObject); | 
|---|
| 915 | } | 
|---|
| 916 |  | 
|---|
| 917 | /*********************************************************************** | 
|---|
| 918 | *        ItemMonikerIROTData_AddRef | 
|---|
| 919 | */ | 
|---|
| 920 | ULONG   WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface) | 
|---|
| 921 | { | 
|---|
| 922 | ICOM_THIS_From_IROTData(IMoniker, iface); | 
|---|
| 923 |  | 
|---|
| 924 | TRACE("(%p)\n",iface); | 
|---|
| 925 |  | 
|---|
| 926 | return ItemMonikerImpl_AddRef(This); | 
|---|
| 927 | } | 
|---|
| 928 |  | 
|---|
| 929 | /*********************************************************************** | 
|---|
| 930 | *        ItemMonikerIROTData_Release | 
|---|
| 931 | */ | 
|---|
| 932 | ULONG   WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface) | 
|---|
| 933 | { | 
|---|
| 934 | ICOM_THIS_From_IROTData(IMoniker, iface); | 
|---|
| 935 |  | 
|---|
| 936 | TRACE("(%p)\n",iface); | 
|---|
| 937 |  | 
|---|
| 938 | return ItemMonikerImpl_Release(This); | 
|---|
| 939 | } | 
|---|
| 940 |  | 
|---|
| 941 | /****************************************************************************** | 
|---|
| 942 | *        ItemMonikerIROTData_GetComparaisonData | 
|---|
| 943 | ******************************************************************************/ | 
|---|
| 944 | HRESULT WINAPI ItemMonikerROTDataImpl_GetComparaisonData(IROTData* iface, | 
|---|
| 945 | BYTE* pbData, | 
|---|
| 946 | ULONG cbMax, | 
|---|
| 947 | ULONG* pcbData) | 
|---|
| 948 | { | 
|---|
| 949 | FIXME("(),stub!\n"); | 
|---|
| 950 | return E_NOTIMPL; | 
|---|
| 951 | } | 
|---|
| 952 |  | 
|---|
| 953 | /****************************************************************************** | 
|---|
| 954 | *        CreateItemMoniker16   [OLE2.28] | 
|---|
| 955 | ******************************************************************************/ | 
|---|
| 956 | HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR  lpszItem,LPMONIKER* ppmk) | 
|---|
| 957 | { | 
|---|
| 958 |  | 
|---|
| 959 | FIXME("(%s,%p),stub!\n",lpszDelim,ppmk); | 
|---|
| 960 | *ppmk = NULL; | 
|---|
| 961 | return E_NOTIMPL; | 
|---|
| 962 | } | 
|---|
| 963 |  | 
|---|
| 964 | /****************************************************************************** | 
|---|
| 965 | *        CreateItemMoniker     [OLE32.58] | 
|---|
| 966 | ******************************************************************************/ | 
|---|
| 967 | HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR  lpszItem, LPMONIKER * ppmk) | 
|---|
| 968 | { | 
|---|
| 969 | ItemMonikerImpl* newItemMoniker = 0; | 
|---|
| 970 | HRESULT        hr = S_OK; | 
|---|
| 971 | IID riid=IID_IMoniker; | 
|---|
| 972 |  | 
|---|
| 973 | TRACE("(%p,%p,%p)\n",lpszDelim,lpszItem,ppmk); | 
|---|
| 974 |  | 
|---|
| 975 | newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl)); | 
|---|
| 976 |  | 
|---|
| 977 | if (newItemMoniker == 0) | 
|---|
| 978 | return STG_E_INSUFFICIENTMEMORY; | 
|---|
| 979 |  | 
|---|
| 980 | hr = ItemMonikerImpl_Construct(newItemMoniker,lpszDelim,lpszItem); | 
|---|
| 981 |  | 
|---|
| 982 | if (FAILED(hr)){ | 
|---|
| 983 |  | 
|---|
| 984 | HeapFree(GetProcessHeap(),0,newItemMoniker); | 
|---|
| 985 | return hr; | 
|---|
| 986 | } | 
|---|
| 987 |  | 
|---|
| 988 | return ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker,&riid,(void**)ppmk); | 
|---|
| 989 | } | 
|---|