2 * OLE 2 default object handler
4 * Copyright 1999 Francis Beaudet
7 * The OLE2 default object handler supports a whole whack of
8 * interfaces including:
9 * IOleObject, IDataObject, IPersistStorage, IViewObject2,
10 * IRunnableObject, IOleCache2, IOleCacheControl and much more.
12 * All the implementation details are taken from: Inside OLE
13 * second edition by Kraig Brockschmidt,
16 * - This implementation of the default handler does not launch the
17 * server in the DoVerb, Update, GetData, GetDataHere and Run
18 * methods. When it is fixed to do so, all the methods will have
19 * to be revisited to allow delegating to the running object
21 * - All methods in the class that use the class ID should be
22 * aware that it is possible for a class to be treated as
23 * another one and go into emulation mode. Nothing has been
26 * - Some functions still return E_NOTIMPL they have to be
27 * implemented. Most of those are related to the running of the
30 * - All the methods related to notification and advise sinks are
31 * in place but no notifications are sent to the sinks yet.
36 #include "oleauto.h" /* for SysFreeString(BSTR) */
39 #include "wine/obj_oleview.h"
40 #include "debugtools.h"
42 DEFAULT_DEBUG_CHANNEL(ole)
44 /****************************************************************************
51 * List all interface VTables here
53 ICOM_VTABLE(IOleObject)* lpvtbl1;
54 ICOM_VTABLE(IUnknown)* lpvtbl2;
55 ICOM_VTABLE(IDataObject)* lpvtbl3;
56 ICOM_VTABLE(IRunnableObject)* lpvtbl4;
59 * Reference count of this object
64 * IUnknown implementation of the outer object.
66 IUnknown* outerUnknown;
69 * Class Id that this handler object represents.
74 * IUnknown implementation of the datacache.
79 * Client site for the embedded object.
81 IOleClientSite* clientSite;
84 * The IOleAdviseHolder maintains the connections
85 * on behalf of the default handler.
87 IOleAdviseHolder* oleAdviseHolder;
90 * The IDataAdviseHolder maintains the data
91 * connections on behalf of the default handler.
93 IDataAdviseHolder* dataAdviseHolder;
96 * Name of the container and object contained
103 typedef struct DefaultHandler DefaultHandler;
106 * Here, I define utility macros to help with the casting of the
108 * There is a version to accomodate all of the VTables implemented
111 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
112 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
113 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
114 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
117 * Prototypes for the methods of the DefaultHandler class.
119 static DefaultHandler* DefaultHandler_Construct(REFCLSID clsid,
120 LPUNKNOWN pUnkOuter);
121 static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
124 * Prototypes for the methods of the DefaultHandler class
125 * that implement non delegating IUnknown methods.
127 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
131 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
133 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
137 * Prototypes for the methods of the DefaultHandler class
138 * that implement IOleObject methods.
140 static HRESULT WINAPI DefaultHandler_QueryInterface(
144 static ULONG WINAPI DefaultHandler_AddRef(
146 static ULONG WINAPI DefaultHandler_Release(
148 static HRESULT WINAPI DefaultHandler_SetClientSite(
150 IOleClientSite* pClientSite);
151 static HRESULT WINAPI DefaultHandler_GetClientSite(
153 IOleClientSite** ppClientSite);
154 static HRESULT WINAPI DefaultHandler_SetHostNames(
156 LPCOLESTR szContainerApp,
157 LPCOLESTR szContainerObj);
158 static HRESULT WINAPI DefaultHandler_Close(
161 static HRESULT WINAPI DefaultHandler_SetMoniker(
163 DWORD dwWhichMoniker,
165 static HRESULT WINAPI DefaultHandler_GetMoniker(
168 DWORD dwWhichMoniker,
170 static HRESULT WINAPI DefaultHandler_InitFromData(
172 IDataObject* pDataObject,
175 static HRESULT WINAPI DefaultHandler_GetClipboardData(
178 IDataObject** ppDataObject);
179 static HRESULT WINAPI DefaultHandler_DoVerb(
182 struct tagMSG* lpmsg,
183 IOleClientSite* pActiveSite,
186 LPCRECT lprcPosRect);
187 static HRESULT WINAPI DefaultHandler_EnumVerbs(
189 IEnumOLEVERB** ppEnumOleVerb);
190 static HRESULT WINAPI DefaultHandler_Update(
192 static HRESULT WINAPI DefaultHandler_IsUpToDate(
194 static HRESULT WINAPI DefaultHandler_GetUserClassID(
197 static HRESULT WINAPI DefaultHandler_GetUserType(
200 LPOLESTR* pszUserType);
201 static HRESULT WINAPI DefaultHandler_SetExtent(
205 static HRESULT WINAPI DefaultHandler_GetExtent(
209 static HRESULT WINAPI DefaultHandler_Advise(
211 IAdviseSink* pAdvSink,
212 DWORD* pdwConnection);
213 static HRESULT WINAPI DefaultHandler_Unadvise(
216 static HRESULT WINAPI DefaultHandler_EnumAdvise(
218 IEnumSTATDATA** ppenumAdvise);
219 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
223 static HRESULT WINAPI DefaultHandler_SetColorScheme(
225 struct tagLOGPALETTE* pLogpal);
228 * Prototypes for the methods of the DefaultHandler class
229 * that implement IDataObject methods.
231 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
235 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
237 static ULONG WINAPI DefaultHandler_IDataObject_Release(
239 static HRESULT WINAPI DefaultHandler_GetData(
241 LPFORMATETC pformatetcIn,
243 static HRESULT WINAPI DefaultHandler_GetDataHere(
245 LPFORMATETC pformatetc,
247 static HRESULT WINAPI DefaultHandler_QueryGetData(
249 LPFORMATETC pformatetc);
250 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
252 LPFORMATETC pformatectIn,
253 LPFORMATETC pformatetcOut);
254 static HRESULT WINAPI DefaultHandler_SetData(
256 LPFORMATETC pformatetc,
259 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
262 IEnumFORMATETC** ppenumFormatEtc);
263 static HRESULT WINAPI DefaultHandler_DAdvise(
265 FORMATETC* pformatetc,
267 IAdviseSink* pAdvSink,
268 DWORD* pdwConnection);
269 static HRESULT WINAPI DefaultHandler_DUnadvise(
272 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
274 IEnumSTATDATA** ppenumAdvise);
277 * Prototypes for the methods of the DefaultHandler class
278 * that implement IRunnableObject methods.
280 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
281 IRunnableObject* iface,
284 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
285 IRunnableObject* iface);
286 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
287 IRunnableObject* iface);
288 static HRESULT WINAPI DefaultHandler_GetRunningClass(
289 IRunnableObject* iface,
291 static HRESULT WINAPI DefaultHandler_Run(
292 IRunnableObject* iface,
294 static BOOL WINAPI DefaultHandler_IsRunning(
295 IRunnableObject* iface);
296 static HRESULT WINAPI DefaultHandler_LockRunning(
297 IRunnableObject* iface,
299 BOOL fLastUnlockCloses);
300 static HRESULT WINAPI DefaultHandler_SetContainedObject(
301 IRunnableObject* iface,
306 * Virtual function tables for the DefaultHandler class.
308 static ICOM_VTABLE(IOleObject) DefaultHandler_IOleObject_VTable =
310 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
311 DefaultHandler_QueryInterface,
312 DefaultHandler_AddRef,
313 DefaultHandler_Release,
314 DefaultHandler_SetClientSite,
315 DefaultHandler_GetClientSite,
316 DefaultHandler_SetHostNames,
317 DefaultHandler_Close,
318 DefaultHandler_SetMoniker,
319 DefaultHandler_GetMoniker,
320 DefaultHandler_InitFromData,
321 DefaultHandler_GetClipboardData,
322 DefaultHandler_DoVerb,
323 DefaultHandler_EnumVerbs,
324 DefaultHandler_Update,
325 DefaultHandler_IsUpToDate,
326 DefaultHandler_GetUserClassID,
327 DefaultHandler_GetUserType,
328 DefaultHandler_SetExtent,
329 DefaultHandler_GetExtent,
330 DefaultHandler_Advise,
331 DefaultHandler_Unadvise,
332 DefaultHandler_EnumAdvise,
333 DefaultHandler_GetMiscStatus,
334 DefaultHandler_SetColorScheme
337 static ICOM_VTABLE(IUnknown) DefaultHandler_NDIUnknown_VTable =
339 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
340 DefaultHandler_NDIUnknown_QueryInterface,
341 DefaultHandler_NDIUnknown_AddRef,
342 DefaultHandler_NDIUnknown_Release,
345 static ICOM_VTABLE(IDataObject) DefaultHandler_IDataObject_VTable =
347 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
348 DefaultHandler_IDataObject_QueryInterface,
349 DefaultHandler_IDataObject_AddRef,
350 DefaultHandler_IDataObject_Release,
351 DefaultHandler_GetData,
352 DefaultHandler_GetDataHere,
353 DefaultHandler_QueryGetData,
354 DefaultHandler_GetCanonicalFormatEtc,
355 DefaultHandler_SetData,
356 DefaultHandler_EnumFormatEtc,
357 DefaultHandler_DAdvise,
358 DefaultHandler_DUnadvise,
359 DefaultHandler_EnumDAdvise
362 static ICOM_VTABLE(IRunnableObject) DefaultHandler_IRunnableObject_VTable =
364 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
365 DefaultHandler_IRunnableObject_QueryInterface,
366 DefaultHandler_IRunnableObject_AddRef,
367 DefaultHandler_IRunnableObject_Release,
368 DefaultHandler_GetRunningClass,
370 DefaultHandler_IsRunning,
371 DefaultHandler_LockRunning,
372 DefaultHandler_SetContainedObject
375 /******************************************************************************
376 * OleCreateDefaultHandler [OLE32.90]
378 HRESULT WINAPI OleCreateDefaultHandler(
384 DefaultHandler* newHandler = NULL;
387 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter, debugstr_guid(riid), ppvObj);
398 * If this handler is constructed for aggregation, make sure
399 * the caller is requesting the IUnknown interface.
400 * This is necessary because it's the only time the non-delegating
401 * IUnknown pointer can be returned to the outside.
403 if ( (pUnkOuter!=NULL) &&
404 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
405 return CLASS_E_NOAGGREGATION;
408 * Try to construct a new instance of the class.
410 newHandler = DefaultHandler_Construct(clsid,
414 return E_OUTOFMEMORY;
417 * Make sure it supports the interface required by the caller.
419 hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtbl2), riid, ppvObj);
422 * Release the reference obtained in the constructor. If
423 * the QueryInterface was unsuccessful, it will free the class.
425 IUnknown_Release((IUnknown*)&(newHandler->lpvtbl2));
430 /*********************************************************
431 * Methods implementation for the DefaultHandler class.
433 static DefaultHandler* DefaultHandler_Construct(
437 DefaultHandler* newObject = 0;
440 * Allocate space for the object.
442 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
448 * Initialize the virtual function table.
450 newObject->lpvtbl1 = &DefaultHandler_IOleObject_VTable;
451 newObject->lpvtbl2 = &DefaultHandler_NDIUnknown_VTable;
452 newObject->lpvtbl3 = &DefaultHandler_IDataObject_VTable;
453 newObject->lpvtbl4 = &DefaultHandler_IRunnableObject_VTable;
456 * Start with one reference count. The caller of this function
457 * must release the interface pointer when it is done.
462 * Initialize the outer unknown
463 * We don't keep a reference on the outer unknown since, the way
464 * aggregation works, our lifetime is at least as large as it's
468 pUnkOuter = (IUnknown*)&(newObject->lpvtbl2);
470 newObject->outerUnknown = pUnkOuter;
473 * Create a datacache object.
474 * We aggregate with the datacache. Make sure we pass our outer
475 * unknown as the datacache's outer unknown.
477 CreateDataCache(newObject->outerUnknown,
480 (void**)&newObject->dataCache);
483 * Initialize the other data members of the class.
485 memcpy(&(newObject->clsid), clsid, sizeof(CLSID));
486 newObject->clientSite = NULL;
487 newObject->oleAdviseHolder = NULL;
488 newObject->dataAdviseHolder = NULL;
489 newObject->containerApp = NULL;
490 newObject->containerObj = NULL;
495 static void DefaultHandler_Destroy(
496 DefaultHandler* ptrToDestroy)
499 * Free the strings idenfitying the object
501 if (ptrToDestroy->containerApp!=NULL)
503 SysFreeString(ptrToDestroy->containerApp);
504 ptrToDestroy->containerApp = NULL;
507 if (ptrToDestroy->containerObj!=NULL)
509 SysFreeString(ptrToDestroy->containerObj);
510 ptrToDestroy->containerObj = NULL;
514 * Release our reference to the data cache.
516 if (ptrToDestroy->dataCache!=NULL)
518 IUnknown_Release(ptrToDestroy->dataCache);
519 ptrToDestroy->dataCache = NULL;
523 * Same thing for the client site.
525 if (ptrToDestroy->clientSite!=NULL)
527 IOleClientSite_Release(ptrToDestroy->clientSite);
528 ptrToDestroy->clientSite = NULL;
532 * And the advise holder.
534 if (ptrToDestroy->oleAdviseHolder!=NULL)
536 IOleClientSite_Release(ptrToDestroy->oleAdviseHolder);
537 ptrToDestroy->oleAdviseHolder = NULL;
541 * And the data advise holder.
543 if (ptrToDestroy->dataAdviseHolder!=NULL)
545 IOleClientSite_Release(ptrToDestroy->dataAdviseHolder);
546 ptrToDestroy->dataAdviseHolder = NULL;
551 * Free the actual default handler structure.
553 HeapFree(GetProcessHeap(), 0, ptrToDestroy);
556 /*********************************************************
557 * Method implementation for the non delegating IUnknown
558 * part of the DefaultHandler class.
561 /************************************************************************
562 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
564 * See Windows documentation for more details on IUnknown methods.
566 * This version of QueryInterface will not delegate it's implementation
567 * to the outer unknown.
569 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
574 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
577 * Perform a sanity check on the parameters.
579 if ( (this==0) || (ppvObject==0) )
583 * Initialize the return parameter.
588 * Compare the riid with the interface IDs implemented by this object.
590 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
594 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
596 *ppvObject = (IOleObject*)&(this->lpvtbl1);
598 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
600 *ppvObject = (IDataObject*)&(this->lpvtbl3);
602 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
604 *ppvObject = (IRunnableObject*)&(this->lpvtbl4);
609 * Blind aggregate the data cache to "inherit" it's interfaces.
611 IUnknown_QueryInterface(this->dataCache, riid, ppvObject);
615 * Check that we obtained an interface.
619 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid));
620 return E_NOINTERFACE;
624 * Query Interface always increases the reference count by one when it is
627 IUnknown_AddRef((IUnknown*)*ppvObject);
632 /************************************************************************
633 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
635 * See Windows documentation for more details on IUnknown methods.
637 * This version of QueryInterface will not delegate it's implementation
638 * to the outer unknown.
640 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
643 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
650 /************************************************************************
651 * DefaultHandler_NDIUnknown_Release (IUnknown)
653 * See Windows documentation for more details on IUnknown methods.
655 * This version of QueryInterface will not delegate it's implementation
656 * to the outer unknown.
658 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
661 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
664 * Decrease the reference count on this object.
669 * If the reference count goes down to 0, perform suicide.
673 DefaultHandler_Destroy(this);
681 /*********************************************************
682 * Methods implementation for the IOleObject part of
683 * the DefaultHandler class.
686 /************************************************************************
687 * DefaultHandler_QueryInterface (IUnknown)
689 * See Windows documentation for more details on IUnknown methods.
691 static HRESULT WINAPI DefaultHandler_QueryInterface(
696 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
698 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
701 /************************************************************************
702 * DefaultHandler_AddRef (IUnknown)
704 * See Windows documentation for more details on IUnknown methods.
706 static ULONG WINAPI DefaultHandler_AddRef(
709 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
711 return IUnknown_AddRef(this->outerUnknown);
714 /************************************************************************
715 * DefaultHandler_Release (IUnknown)
717 * See Windows documentation for more details on IUnknown methods.
719 static ULONG WINAPI DefaultHandler_Release(
722 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
724 return IUnknown_Release(this->outerUnknown);
727 /************************************************************************
728 * DefaultHandler_SetClientSite (IOleObject)
730 * The default handler's implementation of this method only keeps the
731 * client site pointer for future reference.
733 * See Windows documentation for more details on IOleObject methods.
735 static HRESULT WINAPI DefaultHandler_SetClientSite(
737 IOleClientSite* pClientSite)
739 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
741 TRACE("(%p, %p)\n", iface, pClientSite);
744 * Make sure we release the previous client site if there
747 if (this->clientSite!=NULL)
749 IOleClientSite_Release(this->clientSite);
752 this->clientSite = pClientSite;
754 if (this->clientSite!=NULL)
756 IOleClientSite_AddRef(this->clientSite);
762 /************************************************************************
763 * DefaultHandler_GetClientSite (IOleObject)
765 * The default handler's implementation of this method returns the
766 * last pointer set in IOleObject_SetClientSite.
768 * See Windows documentation for more details on IOleObject methods.
770 static HRESULT WINAPI DefaultHandler_GetClientSite(
772 IOleClientSite** ppClientSite)
774 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
779 if (ppClientSite == NULL)
782 *ppClientSite = this->clientSite;
784 if (*ppClientSite!=NULL)
786 IOleClientSite_Release(*ppClientSite);
792 /************************************************************************
793 * DefaultHandler_SetHostNames (IOleObject)
795 * The default handler's implementation of this method just stores
796 * the strings and returns S_OK.
798 * See Windows documentation for more details on IOleObject methods.
800 static HRESULT WINAPI DefaultHandler_SetHostNames(
802 LPCOLESTR szContainerApp,
803 LPCOLESTR szContainerObj)
805 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
807 TRACE("(%p, %s, %s)\n",
809 debugstr_w(szContainerApp),
810 debugstr_w(szContainerObj));
813 * Be sure to cleanup before re-assinging the strings.
815 if (this->containerApp!=NULL)
817 SysFreeString(this->containerApp);
818 this->containerApp = NULL;
821 if (this->containerObj!=NULL)
823 SysFreeString(this->containerObj);
824 this->containerObj = NULL;
828 * Copy the string supplied.
830 if (szContainerApp != NULL)
831 this->containerApp = SysAllocString(szContainerApp);
833 if (szContainerObj != NULL)
834 this->containerObj = SysAllocString(szContainerObj);
839 /************************************************************************
840 * DefaultHandler_Close (IOleObject)
842 * The default handler's implementation of this method is meaningless
843 * without a running server so it does nothing.
845 * See Windows documentation for more details on IOleObject methods.
847 static HRESULT WINAPI DefaultHandler_Close(
855 /************************************************************************
856 * DefaultHandler_SetMoniker (IOleObject)
858 * The default handler's implementation of this method does nothing.
860 * See Windows documentation for more details on IOleObject methods.
862 static HRESULT WINAPI DefaultHandler_SetMoniker(
864 DWORD dwWhichMoniker,
867 TRACE("(%p, %ld, %p)\n",
875 /************************************************************************
876 * DefaultHandler_GetMoniker (IOleObject)
878 * Delegate this request to the client site if we have one.
880 * See Windows documentation for more details on IOleObject methods.
882 static HRESULT WINAPI DefaultHandler_GetMoniker(
885 DWORD dwWhichMoniker,
888 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
890 TRACE("(%p, %ld, %ld, %p)\n",
891 iface, dwAssign, dwWhichMoniker, ppmk);
893 if (this->clientSite)
895 return IOleClientSite_GetMoniker(this->clientSite,
905 /************************************************************************
906 * DefaultHandler_InitFromData (IOleObject)
908 * This method is meaningless if the server is not running
910 * See Windows documentation for more details on IOleObject methods.
912 static HRESULT WINAPI DefaultHandler_InitFromData(
914 IDataObject* pDataObject,
918 TRACE("(%p, %p, %d, %ld)\n",
919 iface, pDataObject, fCreation, dwReserved);
921 return OLE_E_NOTRUNNING;
924 /************************************************************************
925 * DefaultHandler_GetClipboardData (IOleObject)
927 * This method is meaningless if the server is not running
929 * See Windows documentation for more details on IOleObject methods.
931 static HRESULT WINAPI DefaultHandler_GetClipboardData(
934 IDataObject** ppDataObject)
936 TRACE("(%p, %ld, %p)\n",
937 iface, dwReserved, ppDataObject);
939 return OLE_E_NOTRUNNING;
942 static HRESULT WINAPI DefaultHandler_DoVerb(
945 struct tagMSG* lpmsg,
946 IOleClientSite* pActiveSite,
955 /************************************************************************
956 * DefaultHandler_EnumVerbs (IOleObject)
958 * The default handler implementation of this method simply delegates
961 * See Windows documentation for more details on IOleObject methods.
963 static HRESULT WINAPI DefaultHandler_EnumVerbs(
965 IEnumOLEVERB** ppEnumOleVerb)
967 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
969 TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
971 return OleRegEnumVerbs(&this->clsid, ppEnumOleVerb);
974 static HRESULT WINAPI DefaultHandler_Update(
981 /************************************************************************
982 * DefaultHandler_IsUpToDate (IOleObject)
984 * This method is meaningless if the server is not running
986 * See Windows documentation for more details on IOleObject methods.
988 static HRESULT WINAPI DefaultHandler_IsUpToDate(
991 TRACE("(%p)\n", iface);
993 return OLE_E_NOTRUNNING;
996 /************************************************************************
997 * DefaultHandler_GetUserClassID (IOleObject)
999 * TODO: Map to a new class ID if emulation is active.
1001 * See Windows documentation for more details on IOleObject methods.
1003 static HRESULT WINAPI DefaultHandler_GetUserClassID(
1007 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1009 TRACE("(%p, %p)\n", iface, pClsid);
1017 memcpy(pClsid, &this->clsid, sizeof(CLSID));
1022 /************************************************************************
1023 * DefaultHandler_GetUserType (IOleObject)
1025 * The default handler implementation of this method simply delegates
1026 * to OleRegGetUserType
1028 * See Windows documentation for more details on IOleObject methods.
1030 static HRESULT WINAPI DefaultHandler_GetUserType(
1033 LPOLESTR* pszUserType)
1035 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1037 TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
1039 return OleRegGetUserType(&this->clsid, dwFormOfType, pszUserType);
1042 /************************************************************************
1043 * DefaultHandler_SetExtent (IOleObject)
1045 * This method is meaningless if the server is not running
1047 * See Windows documentation for more details on IOleObject methods.
1049 static HRESULT WINAPI DefaultHandler_SetExtent(
1054 TRACE("(%p, %lx, (%d,%d))\n", iface, dwDrawAspect, psizel->cx, psizel->cy);
1055 return OLE_E_NOTRUNNING;
1058 /************************************************************************
1059 * DefaultHandler_GetExtent (IOleObject)
1061 * The default handler's implementation of this method returns uses
1062 * the cache to locate the aspect and extract the extent from it.
1064 * See Windows documentation for more details on IOleObject methods.
1066 static HRESULT WINAPI DefaultHandler_GetExtent(
1071 DVTARGETDEVICE* targetDevice;
1072 IViewObject2* cacheView = NULL;
1075 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1077 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
1079 hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
1082 return E_UNEXPECTED;
1085 * Prepare the call to the cache's GetExtent method.
1087 * Here we would build a valid DVTARGETDEVICE structure
1088 * but, since we are calling into the data cache, we
1089 * know it's implementation and we'll skip this
1090 * extra work until later.
1092 targetDevice = NULL;
1094 hres = IViewObject2_GetExtent(cacheView,
1103 IViewObject2_Release(cacheView);
1108 /************************************************************************
1109 * DefaultHandler_Advise (IOleObject)
1111 * The default handler's implementation of this method simply
1112 * delegates to the OleAdviseHolder.
1114 * See Windows documentation for more details on IOleObject methods.
1116 static HRESULT WINAPI DefaultHandler_Advise(
1118 IAdviseSink* pAdvSink,
1119 DWORD* pdwConnection)
1121 HRESULT hres = S_OK;
1122 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1124 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
1127 * Make sure we have an advise holder before we start.
1129 if (this->oleAdviseHolder==NULL)
1131 hres = CreateOleAdviseHolder(&this->oleAdviseHolder);
1134 if (SUCCEEDED(hres))
1136 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
1144 /************************************************************************
1145 * DefaultHandler_Unadvise (IOleObject)
1147 * The default handler's implementation of this method simply
1148 * delegates to the OleAdviseHolder.
1150 * See Windows documentation for more details on IOleObject methods.
1152 static HRESULT WINAPI DefaultHandler_Unadvise(
1156 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1158 TRACE("(%p, %ld)\n", iface, dwConnection);
1161 * If we don't have an advise holder yet, it means we don't have
1164 if (this->oleAdviseHolder==NULL)
1165 return OLE_E_NOCONNECTION;
1167 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
1171 /************************************************************************
1172 * DefaultHandler_EnumAdvise (IOleObject)
1174 * The default handler's implementation of this method simply
1175 * delegates to the OleAdviseHolder.
1177 * See Windows documentation for more details on IOleObject methods.
1179 static HRESULT WINAPI DefaultHandler_EnumAdvise(
1181 IEnumSTATDATA** ppenumAdvise)
1183 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1185 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1190 if (ppenumAdvise==NULL)
1194 * Initialize the out parameter.
1196 *ppenumAdvise = NULL;
1198 if (this->oleAdviseHolder==NULL)
1199 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
1205 /************************************************************************
1206 * DefaultHandler_GetMiscStatus (IOleObject)
1208 * The default handler's implementation of this method simply delegates
1209 * to OleRegGetMiscStatus.
1211 * See Windows documentation for more details on IOleObject methods.
1213 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
1219 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1221 TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
1223 hres = OleRegGetMiscStatus(&(this->clsid), dwAspect, pdwStatus);
1231 /************************************************************************
1232 * DefaultHandler_SetExtent (IOleObject)
1234 * This method is meaningless if the server is not running
1236 * See Windows documentation for more details on IOleObject methods.
1238 static HRESULT WINAPI DefaultHandler_SetColorScheme(
1240 struct tagLOGPALETTE* pLogpal)
1242 TRACE("(%p, %p))\n", iface, pLogpal);
1243 return OLE_E_NOTRUNNING;
1246 /*********************************************************
1247 * Methods implementation for the IDataObject part of
1248 * the DefaultHandler class.
1251 /************************************************************************
1252 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1254 * See Windows documentation for more details on IUnknown methods.
1256 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
1261 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1263 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1266 /************************************************************************
1267 * DefaultHandler_IDataObject_AddRef (IUnknown)
1269 * See Windows documentation for more details on IUnknown methods.
1271 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
1274 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1276 return IUnknown_AddRef(this->outerUnknown);
1279 /************************************************************************
1280 * DefaultHandler_IDataObject_Release (IUnknown)
1282 * See Windows documentation for more details on IUnknown methods.
1284 static ULONG WINAPI DefaultHandler_IDataObject_Release(
1287 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1289 return IUnknown_Release(this->outerUnknown);
1292 static HRESULT WINAPI DefaultHandler_GetData(
1294 LPFORMATETC pformatetcIn,
1301 static HRESULT WINAPI DefaultHandler_GetDataHere(
1303 LPFORMATETC pformatetc,
1310 /************************************************************************
1311 * DefaultHandler_QueryGetData (IDataObject)
1313 * The default handler's implementation of this method delegates to
1316 * See Windows documentation for more details on IDataObject methods.
1318 static HRESULT WINAPI DefaultHandler_QueryGetData(
1320 LPFORMATETC pformatetc)
1322 IDataObject* cacheDataObject = NULL;
1325 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1327 TRACE("(%p, %p)\n", iface, pformatetc);
1329 hres = IUnknown_QueryInterface(this->dataCache,
1331 (void**)&cacheDataObject);
1334 return E_UNEXPECTED;
1336 hres = IDataObject_QueryGetData(cacheDataObject,
1339 IDataObject_Release(cacheDataObject);
1344 /************************************************************************
1345 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1347 * This method is meaningless if the server is not running
1349 * See Windows documentation for more details on IDataObject methods.
1351 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
1353 LPFORMATETC pformatectIn,
1354 LPFORMATETC pformatetcOut)
1356 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
1358 return OLE_E_NOTRUNNING;
1361 /************************************************************************
1362 * DefaultHandler_SetData (IDataObject)
1364 * The default handler's implementation of this method delegates to
1367 * See Windows documentation for more details on IDataObject methods.
1369 static HRESULT WINAPI DefaultHandler_SetData(
1371 LPFORMATETC pformatetc,
1375 IDataObject* cacheDataObject = NULL;
1378 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1380 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1382 hres = IUnknown_QueryInterface(this->dataCache,
1384 (void**)&cacheDataObject);
1387 return E_UNEXPECTED;
1389 hres = IDataObject_SetData(cacheDataObject,
1394 IDataObject_Release(cacheDataObject);
1399 /************************************************************************
1400 * DefaultHandler_EnumFormatEtc (IDataObject)
1402 * The default handler's implementation of this method simply delegates
1403 * to OleRegEnumFormatEtc.
1405 * See Windows documentation for more details on IDataObject methods.
1407 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
1410 IEnumFORMATETC** ppenumFormatEtc)
1413 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1415 TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
1417 hres = OleRegEnumFormatEtc(&(this->clsid), dwDirection, ppenumFormatEtc);
1422 /************************************************************************
1423 * DefaultHandler_DAdvise (IDataObject)
1425 * The default handler's implementation of this method simply
1426 * delegates to the DataAdviseHolder.
1428 * See Windows documentation for more details on IDataObject methods.
1430 static HRESULT WINAPI DefaultHandler_DAdvise(
1432 FORMATETC* pformatetc,
1434 IAdviseSink* pAdvSink,
1435 DWORD* pdwConnection)
1437 HRESULT hres = S_OK;
1438 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1440 TRACE("(%p, %p, %ld, %p, %p)\n",
1441 iface, pformatetc, advf, pAdvSink, pdwConnection);
1444 * Make sure we have a data advise holder before we start.
1446 if (this->dataAdviseHolder==NULL)
1448 hres = CreateDataAdviseHolder(&this->dataAdviseHolder);
1451 if (SUCCEEDED(hres))
1453 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
1464 /************************************************************************
1465 * DefaultHandler_DUnadvise (IDataObject)
1467 * The default handler's implementation of this method simply
1468 * delegates to the DataAdviseHolder.
1470 * See Windows documentation for more details on IDataObject methods.
1472 static HRESULT WINAPI DefaultHandler_DUnadvise(
1476 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1478 TRACE("(%p, %ld)\n", iface, dwConnection);
1481 * If we don't have a data advise holder yet, it means that
1482 * we don't have any connections..
1484 if (this->dataAdviseHolder==NULL)
1486 return OLE_E_NOCONNECTION;
1489 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
1493 /************************************************************************
1494 * DefaultHandler_EnumDAdvise (IDataObject)
1496 * The default handler's implementation of this method simply
1497 * delegates to the DataAdviseHolder.
1499 * See Windows documentation for more details on IDataObject methods.
1501 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
1503 IEnumSTATDATA** ppenumAdvise)
1505 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1507 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1512 if (ppenumAdvise == NULL)
1516 * Initialize the out parameter.
1518 *ppenumAdvise = NULL;
1521 * If we have a data advise holder object, delegate.
1523 if (this->dataAdviseHolder!=NULL)
1525 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
1532 /*********************************************************
1533 * Methods implementation for the IRunnableObject part
1534 * of the DefaultHandler class.
1537 /************************************************************************
1538 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1540 * See Windows documentation for more details on IUnknown methods.
1542 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
1543 IRunnableObject* iface,
1547 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1549 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1552 /************************************************************************
1553 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1555 * See Windows documentation for more details on IUnknown methods.
1557 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
1558 IRunnableObject* iface)
1560 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1562 return IUnknown_AddRef(this->outerUnknown);
1565 /************************************************************************
1566 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1568 * See Windows documentation for more details on IUnknown methods.
1570 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
1571 IRunnableObject* iface)
1573 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1575 return IUnknown_Release(this->outerUnknown);
1578 /************************************************************************
1579 * DefaultHandler_GetRunningClass (IRunnableObject)
1581 * According to Brockscmidt, Chapter 19, the default handler's
1582 * implementation of IRunnableobject does nothing until the object
1583 * is actually running.
1585 * See Windows documentation for more details on IRunnableObject methods.
1587 static HRESULT WINAPI DefaultHandler_GetRunningClass(
1588 IRunnableObject* iface,
1595 static HRESULT WINAPI DefaultHandler_Run(
1596 IRunnableObject* iface,
1603 /************************************************************************
1604 * DefaultHandler_IsRunning (IRunnableObject)
1606 * According to Brockscmidt, Chapter 19, the default handler's
1607 * implementation of IRunnableobject does nothing until the object
1608 * is actually running.
1610 * See Windows documentation for more details on IRunnableObject methods.
1612 static BOOL WINAPI DefaultHandler_IsRunning(
1613 IRunnableObject* iface)
1619 /************************************************************************
1620 * DefaultHandler_LockRunning (IRunnableObject)
1622 * According to Brockscmidt, Chapter 19, the default handler's
1623 * implementation of IRunnableobject does nothing until the object
1624 * is actually running.
1626 * See Windows documentation for more details on IRunnableObject methods.
1628 static HRESULT WINAPI DefaultHandler_LockRunning(
1629 IRunnableObject* iface,
1631 BOOL fLastUnlockCloses)
1637 /************************************************************************
1638 * DefaultHandler_SetContainedObject (IRunnableObject)
1640 * According to Brockscmidt, Chapter 19, the default handler's
1641 * implementation of IRunnableobject does nothing until the object
1642 * is actually running.
1644 * See Windows documentation for more details on IRunnableObject methods.
1646 static HRESULT WINAPI DefaultHandler_SetContainedObject(
1647 IRunnableObject* iface,