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.
38 #include "wine/obj_oleview.h"
39 #include "debugtools.h"
41 DEFAULT_DEBUG_CHANNEL(ole)
43 /****************************************************************************
50 * List all interface VTables here
52 ICOM_VTABLE(IOleObject)* lpvtbl1;
53 ICOM_VTABLE(IUnknown)* lpvtbl2;
54 ICOM_VTABLE(IDataObject)* lpvtbl3;
55 ICOM_VTABLE(IRunnableObject)* lpvtbl4;
58 * Reference count of this object
63 * IUnknown implementation of the outer object.
65 IUnknown* outerUnknown;
68 * Class Id that this handler object represents.
73 * IUnknown implementation of the datacache.
78 * Client site for the embedded object.
80 IOleClientSite* clientSite;
83 * The IOleAdviseHolder maintains the connections
84 * on behalf of the default handler.
86 IOleAdviseHolder* oleAdviseHolder;
89 * The IDataAdviseHolder maintains the data
90 * connections on behalf of the default handler.
92 IDataAdviseHolder* dataAdviseHolder;
95 * Name of the container and object contained
102 typedef struct DefaultHandler DefaultHandler;
105 * Here, I define utility macros to help with the casting of the
107 * There is a version to accomodate all of the VTables implemented
110 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
111 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
112 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
113 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
116 * Prototypes for the methods of the DefaultHandler class.
118 static DefaultHandler* DefaultHandler_Construct(REFCLSID clsid,
119 LPUNKNOWN pUnkOuter);
120 static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
123 * Prototypes for the methods of the DefaultHandler class
124 * that implement non delegating IUnknown methods.
126 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
130 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
132 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
136 * Prototypes for the methods of the DefaultHandler class
137 * that implement IOleObject methods.
139 static HRESULT WINAPI DefaultHandler_QueryInterface(
143 static ULONG WINAPI DefaultHandler_AddRef(
145 static ULONG WINAPI DefaultHandler_Release(
147 static HRESULT WINAPI DefaultHandler_SetClientSite(
149 IOleClientSite* pClientSite);
150 static HRESULT WINAPI DefaultHandler_GetClientSite(
152 IOleClientSite** ppClientSite);
153 static HRESULT WINAPI DefaultHandler_SetHostNames(
155 LPCOLESTR szContainerApp,
156 LPCOLESTR szContainerObj);
157 static HRESULT WINAPI DefaultHandler_Close(
160 static HRESULT WINAPI DefaultHandler_SetMoniker(
162 DWORD dwWhichMoniker,
164 static HRESULT WINAPI DefaultHandler_GetMoniker(
167 DWORD dwWhichMoniker,
169 static HRESULT WINAPI DefaultHandler_InitFromData(
171 IDataObject* pDataObject,
174 static HRESULT WINAPI DefaultHandler_GetClipboardData(
177 IDataObject** ppDataObject);
178 static HRESULT WINAPI DefaultHandler_DoVerb(
181 struct tagMSG* lpmsg,
182 IOleClientSite* pActiveSite,
185 LPCRECT lprcPosRect);
186 static HRESULT WINAPI DefaultHandler_EnumVerbs(
188 IEnumOLEVERB** ppEnumOleVerb);
189 static HRESULT WINAPI DefaultHandler_Update(
191 static HRESULT WINAPI DefaultHandler_IsUpToDate(
193 static HRESULT WINAPI DefaultHandler_GetUserClassID(
196 static HRESULT WINAPI DefaultHandler_GetUserType(
199 LPOLESTR* pszUserType);
200 static HRESULT WINAPI DefaultHandler_SetExtent(
204 static HRESULT WINAPI DefaultHandler_GetExtent(
208 static HRESULT WINAPI DefaultHandler_Advise(
210 IAdviseSink* pAdvSink,
211 DWORD* pdwConnection);
212 static HRESULT WINAPI DefaultHandler_Unadvise(
215 static HRESULT WINAPI DefaultHandler_EnumAdvise(
217 IEnumSTATDATA** ppenumAdvise);
218 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
222 static HRESULT WINAPI DefaultHandler_SetColorScheme(
224 struct tagLOGPALETTE* pLogpal);
227 * Prototypes for the methods of the DefaultHandler class
228 * that implement IDataObject methods.
230 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
234 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
236 static ULONG WINAPI DefaultHandler_IDataObject_Release(
238 static HRESULT WINAPI DefaultHandler_GetData(
240 LPFORMATETC pformatetcIn,
242 static HRESULT WINAPI DefaultHandler_GetDataHere(
244 LPFORMATETC pformatetc,
246 static HRESULT WINAPI DefaultHandler_QueryGetData(
248 LPFORMATETC pformatetc);
249 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
251 LPFORMATETC pformatectIn,
252 LPFORMATETC pformatetcOut);
253 static HRESULT WINAPI DefaultHandler_SetData(
255 LPFORMATETC pformatetc,
258 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
261 IEnumFORMATETC** ppenumFormatEtc);
262 static HRESULT WINAPI DefaultHandler_DAdvise(
264 FORMATETC* pformatetc,
266 IAdviseSink* pAdvSink,
267 DWORD* pdwConnection);
268 static HRESULT WINAPI DefaultHandler_DUnadvise(
271 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
273 IEnumSTATDATA** ppenumAdvise);
276 * Prototypes for the methods of the DefaultHandler class
277 * that implement IRunnableObject methods.
279 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
280 IRunnableObject* iface,
283 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
284 IRunnableObject* iface);
285 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
286 IRunnableObject* iface);
287 static HRESULT WINAPI DefaultHandler_GetRunningClass(
288 IRunnableObject* iface,
290 static HRESULT WINAPI DefaultHandler_Run(
291 IRunnableObject* iface,
293 static BOOL WINAPI DefaultHandler_IsRunning(
294 IRunnableObject* iface);
295 static HRESULT WINAPI DefaultHandler_LockRunning(
296 IRunnableObject* iface,
298 BOOL fLastUnlockCloses);
299 static HRESULT WINAPI DefaultHandler_SetContainedObject(
300 IRunnableObject* iface,
305 * Virtual function tables for the DefaultHandler class.
307 static ICOM_VTABLE(IOleObject) DefaultHandler_IOleObject_VTable =
309 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
310 DefaultHandler_QueryInterface,
311 DefaultHandler_AddRef,
312 DefaultHandler_Release,
313 DefaultHandler_SetClientSite,
314 DefaultHandler_GetClientSite,
315 DefaultHandler_SetHostNames,
316 DefaultHandler_Close,
317 DefaultHandler_SetMoniker,
318 DefaultHandler_GetMoniker,
319 DefaultHandler_InitFromData,
320 DefaultHandler_GetClipboardData,
321 DefaultHandler_DoVerb,
322 DefaultHandler_EnumVerbs,
323 DefaultHandler_Update,
324 DefaultHandler_IsUpToDate,
325 DefaultHandler_GetUserClassID,
326 DefaultHandler_GetUserType,
327 DefaultHandler_SetExtent,
328 DefaultHandler_GetExtent,
329 DefaultHandler_Advise,
330 DefaultHandler_Unadvise,
331 DefaultHandler_EnumAdvise,
332 DefaultHandler_GetMiscStatus,
333 DefaultHandler_SetColorScheme
336 static ICOM_VTABLE(IUnknown) DefaultHandler_NDIUnknown_VTable =
338 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
339 DefaultHandler_NDIUnknown_QueryInterface,
340 DefaultHandler_NDIUnknown_AddRef,
341 DefaultHandler_NDIUnknown_Release,
344 static ICOM_VTABLE(IDataObject) DefaultHandler_IDataObject_VTable =
346 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
347 DefaultHandler_IDataObject_QueryInterface,
348 DefaultHandler_IDataObject_AddRef,
349 DefaultHandler_IDataObject_Release,
350 DefaultHandler_GetData,
351 DefaultHandler_GetDataHere,
352 DefaultHandler_QueryGetData,
353 DefaultHandler_GetCanonicalFormatEtc,
354 DefaultHandler_SetData,
355 DefaultHandler_EnumFormatEtc,
356 DefaultHandler_DAdvise,
357 DefaultHandler_DUnadvise,
358 DefaultHandler_EnumDAdvise
361 static ICOM_VTABLE(IRunnableObject) DefaultHandler_IRunnableObject_VTable =
363 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
364 DefaultHandler_IRunnableObject_QueryInterface,
365 DefaultHandler_IRunnableObject_AddRef,
366 DefaultHandler_IRunnableObject_Release,
367 DefaultHandler_GetRunningClass,
369 DefaultHandler_IsRunning,
370 DefaultHandler_LockRunning,
371 DefaultHandler_SetContainedObject
374 /******************************************************************************
375 * OleCreateDefaultHandler [OLE32.90]
377 HRESULT WINAPI OleCreateDefaultHandler(
383 DefaultHandler* newHandler = NULL;
386 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter, debugstr_guid(riid), ppvObj);
397 * If this handler is constructed for aggregation, make sure
398 * the caller is requesting the IUnknown interface.
399 * This is necessary because it's the only time the non-delegating
400 * IUnknown pointer can be returned to the outside.
402 if ( (pUnkOuter!=NULL) &&
403 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
404 return CLASS_E_NOAGGREGATION;
407 * Try to construct a new instance of the class.
409 newHandler = DefaultHandler_Construct(clsid,
413 return E_OUTOFMEMORY;
416 * Make sure it supports the interface required by the caller.
418 hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtbl2), riid, ppvObj);
421 * Release the reference obtained in the constructor. If
422 * the QueryInterface was unsuccessful, it will free the class.
424 IUnknown_Release((IUnknown*)&(newHandler->lpvtbl2));
429 /*********************************************************
430 * Methods implementation for the DefaultHandler class.
432 static DefaultHandler* DefaultHandler_Construct(
436 DefaultHandler* newObject = 0;
439 * Allocate space for the object.
441 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
447 * Initialize the virtual function table.
449 newObject->lpvtbl1 = &DefaultHandler_IOleObject_VTable;
450 newObject->lpvtbl2 = &DefaultHandler_NDIUnknown_VTable;
451 newObject->lpvtbl3 = &DefaultHandler_IDataObject_VTable;
452 newObject->lpvtbl4 = &DefaultHandler_IRunnableObject_VTable;
455 * Start with one reference count. The caller of this function
456 * must release the interface pointer when it is done.
461 * Initialize the outer unknown
462 * We don't keep a reference on the outer unknown since, the way
463 * aggregation works, our lifetime is at least as large as it's
467 pUnkOuter = (IUnknown*)&(newObject->lpvtbl2);
469 newObject->outerUnknown = pUnkOuter;
472 * Create a datacache object.
473 * We aggregate with the datacache. Make sure we pass our outer
474 * unknown as the datacache's outer unknown.
476 CreateDataCache(newObject->outerUnknown,
479 (void**)&newObject->dataCache);
482 * Initialize the other data members of the class.
484 memcpy(&(newObject->clsid), clsid, sizeof(CLSID));
485 newObject->clientSite = NULL;
486 newObject->oleAdviseHolder = NULL;
487 newObject->dataAdviseHolder = NULL;
488 newObject->containerApp = NULL;
489 newObject->containerObj = NULL;
494 static void DefaultHandler_Destroy(
495 DefaultHandler* ptrToDestroy)
498 * Free the strings idenfitying the object
500 if (ptrToDestroy->containerApp!=NULL)
502 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerApp );
503 ptrToDestroy->containerApp = NULL;
506 if (ptrToDestroy->containerObj!=NULL)
508 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerObj );
509 ptrToDestroy->containerObj = NULL;
513 * Release our reference to the data cache.
515 if (ptrToDestroy->dataCache!=NULL)
517 IUnknown_Release(ptrToDestroy->dataCache);
518 ptrToDestroy->dataCache = NULL;
522 * Same thing for the client site.
524 if (ptrToDestroy->clientSite!=NULL)
526 IOleClientSite_Release(ptrToDestroy->clientSite);
527 ptrToDestroy->clientSite = NULL;
531 * And the advise holder.
533 if (ptrToDestroy->oleAdviseHolder!=NULL)
535 IOleAdviseHolder_Release(ptrToDestroy->oleAdviseHolder);
536 ptrToDestroy->oleAdviseHolder = NULL;
540 * And the data advise holder.
542 if (ptrToDestroy->dataAdviseHolder!=NULL)
544 IDataAdviseHolder_Release(ptrToDestroy->dataAdviseHolder);
545 ptrToDestroy->dataAdviseHolder = NULL;
550 * Free the actual default handler structure.
552 HeapFree(GetProcessHeap(), 0, ptrToDestroy);
555 /*********************************************************
556 * Method implementation for the non delegating IUnknown
557 * part of the DefaultHandler class.
560 /************************************************************************
561 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
563 * See Windows documentation for more details on IUnknown methods.
565 * This version of QueryInterface will not delegate it's implementation
566 * to the outer unknown.
568 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
573 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
576 * Perform a sanity check on the parameters.
578 if ( (this==0) || (ppvObject==0) )
582 * Initialize the return parameter.
587 * Compare the riid with the interface IDs implemented by this object.
589 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
593 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
595 *ppvObject = (IOleObject*)&(this->lpvtbl1);
597 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
599 *ppvObject = (IDataObject*)&(this->lpvtbl3);
601 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
603 *ppvObject = (IRunnableObject*)&(this->lpvtbl4);
608 * Blind aggregate the data cache to "inherit" it's interfaces.
610 if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK)
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 (this->clientSite != NULL)
786 IOleClientSite_AddRef(this->clientSite);
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 HeapFree( GetProcessHeap(), 0, this->containerApp );
818 this->containerApp = NULL;
821 if (this->containerObj!=NULL)
823 HeapFree( GetProcessHeap(), 0, this->containerObj );
824 this->containerObj = NULL;
828 * Copy the string supplied.
830 if (szContainerApp != NULL)
832 if ((this->containerApp = HeapAlloc( GetProcessHeap(), 0,
833 (lstrlenW(szContainerApp) + 1) * sizeof(WCHAR) )))
834 lstrcpyW( this->containerApp, szContainerApp );
837 if (szContainerObj != NULL)
839 if ((this->containerObj = HeapAlloc( GetProcessHeap(), 0,
840 (lstrlenW(szContainerObj) + 1) * sizeof(WCHAR) )))
841 lstrcpyW( this->containerObj, szContainerObj );
846 /************************************************************************
847 * DefaultHandler_Close (IOleObject)
849 * The default handler's implementation of this method is meaningless
850 * without a running server so it does nothing.
852 * See Windows documentation for more details on IOleObject methods.
854 static HRESULT WINAPI DefaultHandler_Close(
862 /************************************************************************
863 * DefaultHandler_SetMoniker (IOleObject)
865 * The default handler's implementation of this method does nothing.
867 * See Windows documentation for more details on IOleObject methods.
869 static HRESULT WINAPI DefaultHandler_SetMoniker(
871 DWORD dwWhichMoniker,
874 TRACE("(%p, %ld, %p)\n",
882 /************************************************************************
883 * DefaultHandler_GetMoniker (IOleObject)
885 * Delegate this request to the client site if we have one.
887 * See Windows documentation for more details on IOleObject methods.
889 static HRESULT WINAPI DefaultHandler_GetMoniker(
892 DWORD dwWhichMoniker,
895 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
897 TRACE("(%p, %ld, %ld, %p)\n",
898 iface, dwAssign, dwWhichMoniker, ppmk);
900 if (this->clientSite)
902 return IOleClientSite_GetMoniker(this->clientSite,
912 /************************************************************************
913 * DefaultHandler_InitFromData (IOleObject)
915 * This method is meaningless if the server is not running
917 * See Windows documentation for more details on IOleObject methods.
919 static HRESULT WINAPI DefaultHandler_InitFromData(
921 IDataObject* pDataObject,
925 TRACE("(%p, %p, %d, %ld)\n",
926 iface, pDataObject, fCreation, dwReserved);
928 return OLE_E_NOTRUNNING;
931 /************************************************************************
932 * DefaultHandler_GetClipboardData (IOleObject)
934 * This method is meaningless if the server is not running
936 * See Windows documentation for more details on IOleObject methods.
938 static HRESULT WINAPI DefaultHandler_GetClipboardData(
941 IDataObject** ppDataObject)
943 TRACE("(%p, %ld, %p)\n",
944 iface, dwReserved, ppDataObject);
946 return OLE_E_NOTRUNNING;
949 static HRESULT WINAPI DefaultHandler_DoVerb(
952 struct tagMSG* lpmsg,
953 IOleClientSite* pActiveSite,
962 /************************************************************************
963 * DefaultHandler_EnumVerbs (IOleObject)
965 * The default handler implementation of this method simply delegates
968 * See Windows documentation for more details on IOleObject methods.
970 static HRESULT WINAPI DefaultHandler_EnumVerbs(
972 IEnumOLEVERB** ppEnumOleVerb)
974 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
976 TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
978 return OleRegEnumVerbs(&this->clsid, ppEnumOleVerb);
981 static HRESULT WINAPI DefaultHandler_Update(
988 /************************************************************************
989 * DefaultHandler_IsUpToDate (IOleObject)
991 * This method is meaningless if the server is not running
993 * See Windows documentation for more details on IOleObject methods.
995 static HRESULT WINAPI DefaultHandler_IsUpToDate(
998 TRACE("(%p)\n", iface);
1000 return OLE_E_NOTRUNNING;
1003 /************************************************************************
1004 * DefaultHandler_GetUserClassID (IOleObject)
1006 * TODO: Map to a new class ID if emulation is active.
1008 * See Windows documentation for more details on IOleObject methods.
1010 static HRESULT WINAPI DefaultHandler_GetUserClassID(
1014 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1016 TRACE("(%p, %p)\n", iface, pClsid);
1024 memcpy(pClsid, &this->clsid, sizeof(CLSID));
1029 /************************************************************************
1030 * DefaultHandler_GetUserType (IOleObject)
1032 * The default handler implementation of this method simply delegates
1033 * to OleRegGetUserType
1035 * See Windows documentation for more details on IOleObject methods.
1037 static HRESULT WINAPI DefaultHandler_GetUserType(
1040 LPOLESTR* pszUserType)
1042 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1044 TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
1046 return OleRegGetUserType(&this->clsid, dwFormOfType, pszUserType);
1049 /************************************************************************
1050 * DefaultHandler_SetExtent (IOleObject)
1052 * This method is meaningless if the server is not running
1054 * See Windows documentation for more details on IOleObject methods.
1056 static HRESULT WINAPI DefaultHandler_SetExtent(
1061 TRACE("(%p, %lx, (%d,%d))\n", iface, dwDrawAspect, psizel->cx, psizel->cy);
1062 return OLE_E_NOTRUNNING;
1065 /************************************************************************
1066 * DefaultHandler_GetExtent (IOleObject)
1068 * The default handler's implementation of this method returns uses
1069 * the cache to locate the aspect and extract the extent from it.
1071 * See Windows documentation for more details on IOleObject methods.
1073 static HRESULT WINAPI DefaultHandler_GetExtent(
1078 DVTARGETDEVICE* targetDevice;
1079 IViewObject2* cacheView = NULL;
1082 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1084 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
1086 hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
1089 return E_UNEXPECTED;
1092 * Prepare the call to the cache's GetExtent method.
1094 * Here we would build a valid DVTARGETDEVICE structure
1095 * but, since we are calling into the data cache, we
1096 * know it's implementation and we'll skip this
1097 * extra work until later.
1099 targetDevice = NULL;
1101 hres = IViewObject2_GetExtent(cacheView,
1110 IViewObject2_Release(cacheView);
1115 /************************************************************************
1116 * DefaultHandler_Advise (IOleObject)
1118 * The default handler's implementation of this method simply
1119 * delegates to the OleAdviseHolder.
1121 * See Windows documentation for more details on IOleObject methods.
1123 static HRESULT WINAPI DefaultHandler_Advise(
1125 IAdviseSink* pAdvSink,
1126 DWORD* pdwConnection)
1128 HRESULT hres = S_OK;
1129 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1131 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
1134 * Make sure we have an advise holder before we start.
1136 if (this->oleAdviseHolder==NULL)
1138 hres = CreateOleAdviseHolder(&this->oleAdviseHolder);
1141 if (SUCCEEDED(hres))
1143 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
1151 /************************************************************************
1152 * DefaultHandler_Unadvise (IOleObject)
1154 * The default handler's implementation of this method simply
1155 * delegates to the OleAdviseHolder.
1157 * See Windows documentation for more details on IOleObject methods.
1159 static HRESULT WINAPI DefaultHandler_Unadvise(
1163 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1165 TRACE("(%p, %ld)\n", iface, dwConnection);
1168 * If we don't have an advise holder yet, it means we don't have
1171 if (this->oleAdviseHolder==NULL)
1172 return OLE_E_NOCONNECTION;
1174 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
1178 /************************************************************************
1179 * DefaultHandler_EnumAdvise (IOleObject)
1181 * The default handler's implementation of this method simply
1182 * delegates to the OleAdviseHolder.
1184 * See Windows documentation for more details on IOleObject methods.
1186 static HRESULT WINAPI DefaultHandler_EnumAdvise(
1188 IEnumSTATDATA** ppenumAdvise)
1190 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1192 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1197 if (ppenumAdvise==NULL)
1201 * Initialize the out parameter.
1203 *ppenumAdvise = NULL;
1205 if (this->oleAdviseHolder==NULL)
1206 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
1212 /************************************************************************
1213 * DefaultHandler_GetMiscStatus (IOleObject)
1215 * The default handler's implementation of this method simply delegates
1216 * to OleRegGetMiscStatus.
1218 * See Windows documentation for more details on IOleObject methods.
1220 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
1226 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1228 TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
1230 hres = OleRegGetMiscStatus(&(this->clsid), dwAspect, pdwStatus);
1238 /************************************************************************
1239 * DefaultHandler_SetExtent (IOleObject)
1241 * This method is meaningless if the server is not running
1243 * See Windows documentation for more details on IOleObject methods.
1245 static HRESULT WINAPI DefaultHandler_SetColorScheme(
1247 struct tagLOGPALETTE* pLogpal)
1249 TRACE("(%p, %p))\n", iface, pLogpal);
1250 return OLE_E_NOTRUNNING;
1253 /*********************************************************
1254 * Methods implementation for the IDataObject part of
1255 * the DefaultHandler class.
1258 /************************************************************************
1259 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1261 * See Windows documentation for more details on IUnknown methods.
1263 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
1268 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1270 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1273 /************************************************************************
1274 * DefaultHandler_IDataObject_AddRef (IUnknown)
1276 * See Windows documentation for more details on IUnknown methods.
1278 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
1281 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1283 return IUnknown_AddRef(this->outerUnknown);
1286 /************************************************************************
1287 * DefaultHandler_IDataObject_Release (IUnknown)
1289 * See Windows documentation for more details on IUnknown methods.
1291 static ULONG WINAPI DefaultHandler_IDataObject_Release(
1294 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1296 return IUnknown_Release(this->outerUnknown);
1299 static HRESULT WINAPI DefaultHandler_GetData(
1301 LPFORMATETC pformatetcIn,
1308 static HRESULT WINAPI DefaultHandler_GetDataHere(
1310 LPFORMATETC pformatetc,
1317 /************************************************************************
1318 * DefaultHandler_QueryGetData (IDataObject)
1320 * The default handler's implementation of this method delegates to
1323 * See Windows documentation for more details on IDataObject methods.
1325 static HRESULT WINAPI DefaultHandler_QueryGetData(
1327 LPFORMATETC pformatetc)
1329 IDataObject* cacheDataObject = NULL;
1332 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1334 TRACE("(%p, %p)\n", iface, pformatetc);
1336 hres = IUnknown_QueryInterface(this->dataCache,
1338 (void**)&cacheDataObject);
1341 return E_UNEXPECTED;
1343 hres = IDataObject_QueryGetData(cacheDataObject,
1346 IDataObject_Release(cacheDataObject);
1351 /************************************************************************
1352 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1354 * This method is meaningless if the server is not running
1356 * See Windows documentation for more details on IDataObject methods.
1358 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
1360 LPFORMATETC pformatectIn,
1361 LPFORMATETC pformatetcOut)
1363 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
1365 return OLE_E_NOTRUNNING;
1368 /************************************************************************
1369 * DefaultHandler_SetData (IDataObject)
1371 * The default handler's implementation of this method delegates to
1374 * See Windows documentation for more details on IDataObject methods.
1376 static HRESULT WINAPI DefaultHandler_SetData(
1378 LPFORMATETC pformatetc,
1382 IDataObject* cacheDataObject = NULL;
1385 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1387 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1389 hres = IUnknown_QueryInterface(this->dataCache,
1391 (void**)&cacheDataObject);
1394 return E_UNEXPECTED;
1396 hres = IDataObject_SetData(cacheDataObject,
1401 IDataObject_Release(cacheDataObject);
1406 /************************************************************************
1407 * DefaultHandler_EnumFormatEtc (IDataObject)
1409 * The default handler's implementation of this method simply delegates
1410 * to OleRegEnumFormatEtc.
1412 * See Windows documentation for more details on IDataObject methods.
1414 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
1417 IEnumFORMATETC** ppenumFormatEtc)
1420 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1422 TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
1424 hres = OleRegEnumFormatEtc(&(this->clsid), dwDirection, ppenumFormatEtc);
1429 /************************************************************************
1430 * DefaultHandler_DAdvise (IDataObject)
1432 * The default handler's implementation of this method simply
1433 * delegates to the DataAdviseHolder.
1435 * See Windows documentation for more details on IDataObject methods.
1437 static HRESULT WINAPI DefaultHandler_DAdvise(
1439 FORMATETC* pformatetc,
1441 IAdviseSink* pAdvSink,
1442 DWORD* pdwConnection)
1444 HRESULT hres = S_OK;
1445 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1447 TRACE("(%p, %p, %ld, %p, %p)\n",
1448 iface, pformatetc, advf, pAdvSink, pdwConnection);
1451 * Make sure we have a data advise holder before we start.
1453 if (this->dataAdviseHolder==NULL)
1455 hres = CreateDataAdviseHolder(&this->dataAdviseHolder);
1458 if (SUCCEEDED(hres))
1460 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
1471 /************************************************************************
1472 * DefaultHandler_DUnadvise (IDataObject)
1474 * The default handler's implementation of this method simply
1475 * delegates to the DataAdviseHolder.
1477 * See Windows documentation for more details on IDataObject methods.
1479 static HRESULT WINAPI DefaultHandler_DUnadvise(
1483 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1485 TRACE("(%p, %ld)\n", iface, dwConnection);
1488 * If we don't have a data advise holder yet, it means that
1489 * we don't have any connections..
1491 if (this->dataAdviseHolder==NULL)
1493 return OLE_E_NOCONNECTION;
1496 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
1500 /************************************************************************
1501 * DefaultHandler_EnumDAdvise (IDataObject)
1503 * The default handler's implementation of this method simply
1504 * delegates to the DataAdviseHolder.
1506 * See Windows documentation for more details on IDataObject methods.
1508 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
1510 IEnumSTATDATA** ppenumAdvise)
1512 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1514 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1519 if (ppenumAdvise == NULL)
1523 * Initialize the out parameter.
1525 *ppenumAdvise = NULL;
1528 * If we have a data advise holder object, delegate.
1530 if (this->dataAdviseHolder!=NULL)
1532 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
1539 /*********************************************************
1540 * Methods implementation for the IRunnableObject part
1541 * of the DefaultHandler class.
1544 /************************************************************************
1545 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1547 * See Windows documentation for more details on IUnknown methods.
1549 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
1550 IRunnableObject* iface,
1554 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1556 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1559 /************************************************************************
1560 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1562 * See Windows documentation for more details on IUnknown methods.
1564 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
1565 IRunnableObject* iface)
1567 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1569 return IUnknown_AddRef(this->outerUnknown);
1572 /************************************************************************
1573 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1575 * See Windows documentation for more details on IUnknown methods.
1577 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
1578 IRunnableObject* iface)
1580 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1582 return IUnknown_Release(this->outerUnknown);
1585 /************************************************************************
1586 * DefaultHandler_GetRunningClass (IRunnableObject)
1588 * According to Brockscmidt, Chapter 19, the default handler's
1589 * implementation of IRunnableobject does nothing until the object
1590 * is actually running.
1592 * See Windows documentation for more details on IRunnableObject methods.
1594 static HRESULT WINAPI DefaultHandler_GetRunningClass(
1595 IRunnableObject* iface,
1602 static HRESULT WINAPI DefaultHandler_Run(
1603 IRunnableObject* iface,
1610 /************************************************************************
1611 * DefaultHandler_IsRunning (IRunnableObject)
1613 * According to Brockscmidt, Chapter 19, the default handler's
1614 * implementation of IRunnableobject does nothing until the object
1615 * is actually running.
1617 * See Windows documentation for more details on IRunnableObject methods.
1619 static BOOL WINAPI DefaultHandler_IsRunning(
1620 IRunnableObject* iface)
1626 /************************************************************************
1627 * DefaultHandler_LockRunning (IRunnableObject)
1629 * According to Brockscmidt, Chapter 19, the default handler's
1630 * implementation of IRunnableobject does nothing until the object
1631 * is actually running.
1633 * See Windows documentation for more details on IRunnableObject methods.
1635 static HRESULT WINAPI DefaultHandler_LockRunning(
1636 IRunnableObject* iface,
1638 BOOL fLastUnlockCloses)
1644 /************************************************************************
1645 * DefaultHandler_SetContainedObject (IRunnableObject)
1647 * According to Brockscmidt, Chapter 19, the default handler's
1648 * implementation of IRunnableobject does nothing until the object
1649 * is actually running.
1651 * See Windows documentation for more details on IRunnableObject methods.
1653 static HRESULT WINAPI DefaultHandler_SetContainedObject(
1654 IRunnableObject* iface,