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 IOleClientSite_Release(ptrToDestroy->oleAdviseHolder);
536 ptrToDestroy->oleAdviseHolder = NULL;
540 * And the data advise holder.
542 if (ptrToDestroy->dataAdviseHolder!=NULL)
544 IOleClientSite_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 IUnknown_QueryInterface(this->dataCache, riid, ppvObject);
614 * Check that we obtained an interface.
618 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid));
619 return E_NOINTERFACE;
623 * Query Interface always increases the reference count by one when it is
626 IUnknown_AddRef((IUnknown*)*ppvObject);
631 /************************************************************************
632 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
634 * See Windows documentation for more details on IUnknown methods.
636 * This version of QueryInterface will not delegate it's implementation
637 * to the outer unknown.
639 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
642 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
649 /************************************************************************
650 * DefaultHandler_NDIUnknown_Release (IUnknown)
652 * See Windows documentation for more details on IUnknown methods.
654 * This version of QueryInterface will not delegate it's implementation
655 * to the outer unknown.
657 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
660 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
663 * Decrease the reference count on this object.
668 * If the reference count goes down to 0, perform suicide.
672 DefaultHandler_Destroy(this);
680 /*********************************************************
681 * Methods implementation for the IOleObject part of
682 * the DefaultHandler class.
685 /************************************************************************
686 * DefaultHandler_QueryInterface (IUnknown)
688 * See Windows documentation for more details on IUnknown methods.
690 static HRESULT WINAPI DefaultHandler_QueryInterface(
695 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
697 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
700 /************************************************************************
701 * DefaultHandler_AddRef (IUnknown)
703 * See Windows documentation for more details on IUnknown methods.
705 static ULONG WINAPI DefaultHandler_AddRef(
708 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
710 return IUnknown_AddRef(this->outerUnknown);
713 /************************************************************************
714 * DefaultHandler_Release (IUnknown)
716 * See Windows documentation for more details on IUnknown methods.
718 static ULONG WINAPI DefaultHandler_Release(
721 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
723 return IUnknown_Release(this->outerUnknown);
726 /************************************************************************
727 * DefaultHandler_SetClientSite (IOleObject)
729 * The default handler's implementation of this method only keeps the
730 * client site pointer for future reference.
732 * See Windows documentation for more details on IOleObject methods.
734 static HRESULT WINAPI DefaultHandler_SetClientSite(
736 IOleClientSite* pClientSite)
738 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
740 TRACE("(%p, %p)\n", iface, pClientSite);
743 * Make sure we release the previous client site if there
746 if (this->clientSite!=NULL)
748 IOleClientSite_Release(this->clientSite);
751 this->clientSite = pClientSite;
753 if (this->clientSite!=NULL)
755 IOleClientSite_AddRef(this->clientSite);
761 /************************************************************************
762 * DefaultHandler_GetClientSite (IOleObject)
764 * The default handler's implementation of this method returns the
765 * last pointer set in IOleObject_SetClientSite.
767 * See Windows documentation for more details on IOleObject methods.
769 static HRESULT WINAPI DefaultHandler_GetClientSite(
771 IOleClientSite** ppClientSite)
773 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
778 if (ppClientSite == NULL)
781 *ppClientSite = this->clientSite;
783 if (*ppClientSite!=NULL)
785 IOleClientSite_Release(*ppClientSite);
791 /************************************************************************
792 * DefaultHandler_SetHostNames (IOleObject)
794 * The default handler's implementation of this method just stores
795 * the strings and returns S_OK.
797 * See Windows documentation for more details on IOleObject methods.
799 static HRESULT WINAPI DefaultHandler_SetHostNames(
801 LPCOLESTR szContainerApp,
802 LPCOLESTR szContainerObj)
804 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
806 TRACE("(%p, %s, %s)\n",
808 debugstr_w(szContainerApp),
809 debugstr_w(szContainerObj));
812 * Be sure to cleanup before re-assinging the strings.
814 if (this->containerApp!=NULL)
816 HeapFree( GetProcessHeap(), 0, this->containerApp );
817 this->containerApp = NULL;
820 if (this->containerObj!=NULL)
822 HeapFree( GetProcessHeap(), 0, this->containerObj );
823 this->containerObj = NULL;
827 * Copy the string supplied.
829 if (szContainerApp != NULL)
831 if ((this->containerApp = HeapAlloc( GetProcessHeap(), 0,
832 (lstrlenW(szContainerApp) + 1) * sizeof(WCHAR) )))
833 lstrcpyW( this->containerApp, szContainerApp );
836 if (szContainerObj != NULL)
838 if ((this->containerObj = HeapAlloc( GetProcessHeap(), 0,
839 (lstrlenW(szContainerObj) + 1) * sizeof(WCHAR) )))
840 lstrcpyW( this->containerObj, szContainerObj );
845 /************************************************************************
846 * DefaultHandler_Close (IOleObject)
848 * The default handler's implementation of this method is meaningless
849 * without a running server so it does nothing.
851 * See Windows documentation for more details on IOleObject methods.
853 static HRESULT WINAPI DefaultHandler_Close(
861 /************************************************************************
862 * DefaultHandler_SetMoniker (IOleObject)
864 * The default handler's implementation of this method does nothing.
866 * See Windows documentation for more details on IOleObject methods.
868 static HRESULT WINAPI DefaultHandler_SetMoniker(
870 DWORD dwWhichMoniker,
873 TRACE("(%p, %ld, %p)\n",
881 /************************************************************************
882 * DefaultHandler_GetMoniker (IOleObject)
884 * Delegate this request to the client site if we have one.
886 * See Windows documentation for more details on IOleObject methods.
888 static HRESULT WINAPI DefaultHandler_GetMoniker(
891 DWORD dwWhichMoniker,
894 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
896 TRACE("(%p, %ld, %ld, %p)\n",
897 iface, dwAssign, dwWhichMoniker, ppmk);
899 if (this->clientSite)
901 return IOleClientSite_GetMoniker(this->clientSite,
911 /************************************************************************
912 * DefaultHandler_InitFromData (IOleObject)
914 * This method is meaningless if the server is not running
916 * See Windows documentation for more details on IOleObject methods.
918 static HRESULT WINAPI DefaultHandler_InitFromData(
920 IDataObject* pDataObject,
924 TRACE("(%p, %p, %d, %ld)\n",
925 iface, pDataObject, fCreation, dwReserved);
927 return OLE_E_NOTRUNNING;
930 /************************************************************************
931 * DefaultHandler_GetClipboardData (IOleObject)
933 * This method is meaningless if the server is not running
935 * See Windows documentation for more details on IOleObject methods.
937 static HRESULT WINAPI DefaultHandler_GetClipboardData(
940 IDataObject** ppDataObject)
942 TRACE("(%p, %ld, %p)\n",
943 iface, dwReserved, ppDataObject);
945 return OLE_E_NOTRUNNING;
948 static HRESULT WINAPI DefaultHandler_DoVerb(
951 struct tagMSG* lpmsg,
952 IOleClientSite* pActiveSite,
961 /************************************************************************
962 * DefaultHandler_EnumVerbs (IOleObject)
964 * The default handler implementation of this method simply delegates
967 * See Windows documentation for more details on IOleObject methods.
969 static HRESULT WINAPI DefaultHandler_EnumVerbs(
971 IEnumOLEVERB** ppEnumOleVerb)
973 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
975 TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
977 return OleRegEnumVerbs(&this->clsid, ppEnumOleVerb);
980 static HRESULT WINAPI DefaultHandler_Update(
987 /************************************************************************
988 * DefaultHandler_IsUpToDate (IOleObject)
990 * This method is meaningless if the server is not running
992 * See Windows documentation for more details on IOleObject methods.
994 static HRESULT WINAPI DefaultHandler_IsUpToDate(
997 TRACE("(%p)\n", iface);
999 return OLE_E_NOTRUNNING;
1002 /************************************************************************
1003 * DefaultHandler_GetUserClassID (IOleObject)
1005 * TODO: Map to a new class ID if emulation is active.
1007 * See Windows documentation for more details on IOleObject methods.
1009 static HRESULT WINAPI DefaultHandler_GetUserClassID(
1013 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1015 TRACE("(%p, %p)\n", iface, pClsid);
1023 memcpy(pClsid, &this->clsid, sizeof(CLSID));
1028 /************************************************************************
1029 * DefaultHandler_GetUserType (IOleObject)
1031 * The default handler implementation of this method simply delegates
1032 * to OleRegGetUserType
1034 * See Windows documentation for more details on IOleObject methods.
1036 static HRESULT WINAPI DefaultHandler_GetUserType(
1039 LPOLESTR* pszUserType)
1041 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1043 TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
1045 return OleRegGetUserType(&this->clsid, dwFormOfType, pszUserType);
1048 /************************************************************************
1049 * DefaultHandler_SetExtent (IOleObject)
1051 * This method is meaningless if the server is not running
1053 * See Windows documentation for more details on IOleObject methods.
1055 static HRESULT WINAPI DefaultHandler_SetExtent(
1060 TRACE("(%p, %lx, (%d,%d))\n", iface, dwDrawAspect, psizel->cx, psizel->cy);
1061 return OLE_E_NOTRUNNING;
1064 /************************************************************************
1065 * DefaultHandler_GetExtent (IOleObject)
1067 * The default handler's implementation of this method returns uses
1068 * the cache to locate the aspect and extract the extent from it.
1070 * See Windows documentation for more details on IOleObject methods.
1072 static HRESULT WINAPI DefaultHandler_GetExtent(
1077 DVTARGETDEVICE* targetDevice;
1078 IViewObject2* cacheView = NULL;
1081 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1083 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
1085 hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
1088 return E_UNEXPECTED;
1091 * Prepare the call to the cache's GetExtent method.
1093 * Here we would build a valid DVTARGETDEVICE structure
1094 * but, since we are calling into the data cache, we
1095 * know it's implementation and we'll skip this
1096 * extra work until later.
1098 targetDevice = NULL;
1100 hres = IViewObject2_GetExtent(cacheView,
1109 IViewObject2_Release(cacheView);
1114 /************************************************************************
1115 * DefaultHandler_Advise (IOleObject)
1117 * The default handler's implementation of this method simply
1118 * delegates to the OleAdviseHolder.
1120 * See Windows documentation for more details on IOleObject methods.
1122 static HRESULT WINAPI DefaultHandler_Advise(
1124 IAdviseSink* pAdvSink,
1125 DWORD* pdwConnection)
1127 HRESULT hres = S_OK;
1128 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1130 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
1133 * Make sure we have an advise holder before we start.
1135 if (this->oleAdviseHolder==NULL)
1137 hres = CreateOleAdviseHolder(&this->oleAdviseHolder);
1140 if (SUCCEEDED(hres))
1142 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
1150 /************************************************************************
1151 * DefaultHandler_Unadvise (IOleObject)
1153 * The default handler's implementation of this method simply
1154 * delegates to the OleAdviseHolder.
1156 * See Windows documentation for more details on IOleObject methods.
1158 static HRESULT WINAPI DefaultHandler_Unadvise(
1162 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1164 TRACE("(%p, %ld)\n", iface, dwConnection);
1167 * If we don't have an advise holder yet, it means we don't have
1170 if (this->oleAdviseHolder==NULL)
1171 return OLE_E_NOCONNECTION;
1173 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
1177 /************************************************************************
1178 * DefaultHandler_EnumAdvise (IOleObject)
1180 * The default handler's implementation of this method simply
1181 * delegates to the OleAdviseHolder.
1183 * See Windows documentation for more details on IOleObject methods.
1185 static HRESULT WINAPI DefaultHandler_EnumAdvise(
1187 IEnumSTATDATA** ppenumAdvise)
1189 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1191 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1196 if (ppenumAdvise==NULL)
1200 * Initialize the out parameter.
1202 *ppenumAdvise = NULL;
1204 if (this->oleAdviseHolder==NULL)
1205 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
1211 /************************************************************************
1212 * DefaultHandler_GetMiscStatus (IOleObject)
1214 * The default handler's implementation of this method simply delegates
1215 * to OleRegGetMiscStatus.
1217 * See Windows documentation for more details on IOleObject methods.
1219 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
1225 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1227 TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
1229 hres = OleRegGetMiscStatus(&(this->clsid), dwAspect, pdwStatus);
1237 /************************************************************************
1238 * DefaultHandler_SetExtent (IOleObject)
1240 * This method is meaningless if the server is not running
1242 * See Windows documentation for more details on IOleObject methods.
1244 static HRESULT WINAPI DefaultHandler_SetColorScheme(
1246 struct tagLOGPALETTE* pLogpal)
1248 TRACE("(%p, %p))\n", iface, pLogpal);
1249 return OLE_E_NOTRUNNING;
1252 /*********************************************************
1253 * Methods implementation for the IDataObject part of
1254 * the DefaultHandler class.
1257 /************************************************************************
1258 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1260 * See Windows documentation for more details on IUnknown methods.
1262 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
1267 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1269 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1272 /************************************************************************
1273 * DefaultHandler_IDataObject_AddRef (IUnknown)
1275 * See Windows documentation for more details on IUnknown methods.
1277 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
1280 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1282 return IUnknown_AddRef(this->outerUnknown);
1285 /************************************************************************
1286 * DefaultHandler_IDataObject_Release (IUnknown)
1288 * See Windows documentation for more details on IUnknown methods.
1290 static ULONG WINAPI DefaultHandler_IDataObject_Release(
1293 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1295 return IUnknown_Release(this->outerUnknown);
1298 static HRESULT WINAPI DefaultHandler_GetData(
1300 LPFORMATETC pformatetcIn,
1307 static HRESULT WINAPI DefaultHandler_GetDataHere(
1309 LPFORMATETC pformatetc,
1316 /************************************************************************
1317 * DefaultHandler_QueryGetData (IDataObject)
1319 * The default handler's implementation of this method delegates to
1322 * See Windows documentation for more details on IDataObject methods.
1324 static HRESULT WINAPI DefaultHandler_QueryGetData(
1326 LPFORMATETC pformatetc)
1328 IDataObject* cacheDataObject = NULL;
1331 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1333 TRACE("(%p, %p)\n", iface, pformatetc);
1335 hres = IUnknown_QueryInterface(this->dataCache,
1337 (void**)&cacheDataObject);
1340 return E_UNEXPECTED;
1342 hres = IDataObject_QueryGetData(cacheDataObject,
1345 IDataObject_Release(cacheDataObject);
1350 /************************************************************************
1351 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1353 * This method is meaningless if the server is not running
1355 * See Windows documentation for more details on IDataObject methods.
1357 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
1359 LPFORMATETC pformatectIn,
1360 LPFORMATETC pformatetcOut)
1362 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
1364 return OLE_E_NOTRUNNING;
1367 /************************************************************************
1368 * DefaultHandler_SetData (IDataObject)
1370 * The default handler's implementation of this method delegates to
1373 * See Windows documentation for more details on IDataObject methods.
1375 static HRESULT WINAPI DefaultHandler_SetData(
1377 LPFORMATETC pformatetc,
1381 IDataObject* cacheDataObject = NULL;
1384 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1386 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1388 hres = IUnknown_QueryInterface(this->dataCache,
1390 (void**)&cacheDataObject);
1393 return E_UNEXPECTED;
1395 hres = IDataObject_SetData(cacheDataObject,
1400 IDataObject_Release(cacheDataObject);
1405 /************************************************************************
1406 * DefaultHandler_EnumFormatEtc (IDataObject)
1408 * The default handler's implementation of this method simply delegates
1409 * to OleRegEnumFormatEtc.
1411 * See Windows documentation for more details on IDataObject methods.
1413 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
1416 IEnumFORMATETC** ppenumFormatEtc)
1419 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1421 TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
1423 hres = OleRegEnumFormatEtc(&(this->clsid), dwDirection, ppenumFormatEtc);
1428 /************************************************************************
1429 * DefaultHandler_DAdvise (IDataObject)
1431 * The default handler's implementation of this method simply
1432 * delegates to the DataAdviseHolder.
1434 * See Windows documentation for more details on IDataObject methods.
1436 static HRESULT WINAPI DefaultHandler_DAdvise(
1438 FORMATETC* pformatetc,
1440 IAdviseSink* pAdvSink,
1441 DWORD* pdwConnection)
1443 HRESULT hres = S_OK;
1444 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1446 TRACE("(%p, %p, %ld, %p, %p)\n",
1447 iface, pformatetc, advf, pAdvSink, pdwConnection);
1450 * Make sure we have a data advise holder before we start.
1452 if (this->dataAdviseHolder==NULL)
1454 hres = CreateDataAdviseHolder(&this->dataAdviseHolder);
1457 if (SUCCEEDED(hres))
1459 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
1470 /************************************************************************
1471 * DefaultHandler_DUnadvise (IDataObject)
1473 * The default handler's implementation of this method simply
1474 * delegates to the DataAdviseHolder.
1476 * See Windows documentation for more details on IDataObject methods.
1478 static HRESULT WINAPI DefaultHandler_DUnadvise(
1482 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1484 TRACE("(%p, %ld)\n", iface, dwConnection);
1487 * If we don't have a data advise holder yet, it means that
1488 * we don't have any connections..
1490 if (this->dataAdviseHolder==NULL)
1492 return OLE_E_NOCONNECTION;
1495 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
1499 /************************************************************************
1500 * DefaultHandler_EnumDAdvise (IDataObject)
1502 * The default handler's implementation of this method simply
1503 * delegates to the DataAdviseHolder.
1505 * See Windows documentation for more details on IDataObject methods.
1507 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
1509 IEnumSTATDATA** ppenumAdvise)
1511 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1513 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1518 if (ppenumAdvise == NULL)
1522 * Initialize the out parameter.
1524 *ppenumAdvise = NULL;
1527 * If we have a data advise holder object, delegate.
1529 if (this->dataAdviseHolder!=NULL)
1531 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
1538 /*********************************************************
1539 * Methods implementation for the IRunnableObject part
1540 * of the DefaultHandler class.
1543 /************************************************************************
1544 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1546 * See Windows documentation for more details on IUnknown methods.
1548 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
1549 IRunnableObject* iface,
1553 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1555 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1558 /************************************************************************
1559 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1561 * See Windows documentation for more details on IUnknown methods.
1563 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
1564 IRunnableObject* iface)
1566 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1568 return IUnknown_AddRef(this->outerUnknown);
1571 /************************************************************************
1572 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1574 * See Windows documentation for more details on IUnknown methods.
1576 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
1577 IRunnableObject* iface)
1579 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1581 return IUnknown_Release(this->outerUnknown);
1584 /************************************************************************
1585 * DefaultHandler_GetRunningClass (IRunnableObject)
1587 * According to Brockscmidt, Chapter 19, the default handler's
1588 * implementation of IRunnableobject does nothing until the object
1589 * is actually running.
1591 * See Windows documentation for more details on IRunnableObject methods.
1593 static HRESULT WINAPI DefaultHandler_GetRunningClass(
1594 IRunnableObject* iface,
1601 static HRESULT WINAPI DefaultHandler_Run(
1602 IRunnableObject* iface,
1609 /************************************************************************
1610 * DefaultHandler_IsRunning (IRunnableObject)
1612 * According to Brockscmidt, Chapter 19, the default handler's
1613 * implementation of IRunnableobject does nothing until the object
1614 * is actually running.
1616 * See Windows documentation for more details on IRunnableObject methods.
1618 static BOOL WINAPI DefaultHandler_IsRunning(
1619 IRunnableObject* iface)
1625 /************************************************************************
1626 * DefaultHandler_LockRunning (IRunnableObject)
1628 * According to Brockscmidt, Chapter 19, the default handler's
1629 * implementation of IRunnableobject does nothing until the object
1630 * is actually running.
1632 * See Windows documentation for more details on IRunnableObject methods.
1634 static HRESULT WINAPI DefaultHandler_LockRunning(
1635 IRunnableObject* iface,
1637 BOOL fLastUnlockCloses)
1643 /************************************************************************
1644 * DefaultHandler_SetContainedObject (IRunnableObject)
1646 * According to Brockscmidt, Chapter 19, the default handler's
1647 * implementation of IRunnableobject does nothing until the object
1648 * is actually running.
1650 * See Windows documentation for more details on IRunnableObject methods.
1652 static HRESULT WINAPI DefaultHandler_SetContainedObject(
1653 IRunnableObject* iface,