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
;
389 WINE_StringFromCLSID((LPCLSID
)clsid
,xclsid
);
390 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
392 TRACE("(%s, %p, %s, %p)\n", xclsid
, pUnkOuter
, xriid
, ppvObj
);
403 * If this handler is constructed for aggregation, make sure
404 * the caller is requesting the IUnknown interface.
405 * This is necessary because it's the only time the non-delegating
406 * IUnknown pointer can be returned to the outside.
408 if ( (pUnkOuter
!=NULL
) &&
409 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
410 return CLASS_E_NOAGGREGATION
;
413 * Try to construct a new instance of the class.
415 newHandler
= DefaultHandler_Construct(clsid
,
419 return E_OUTOFMEMORY
;
422 * Make sure it supports the interface required by the caller.
424 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
427 * Release the reference obtained in the constructor. If
428 * the QueryInterface was unsuccessful, it will free the class.
430 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
435 /*********************************************************
436 * Methods implementation for the DefaultHandler class.
438 static DefaultHandler
* DefaultHandler_Construct(
442 DefaultHandler
* newObject
= 0;
445 * Allocate space for the object.
447 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
453 * Initialize the virtual function table.
455 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
456 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
457 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
458 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
461 * Start with one reference count. The caller of this function
462 * must release the interface pointer when it is done.
467 * Initialize the outer unknown
468 * We don't keep a reference on the outer unknown since, the way
469 * aggregation works, our lifetime is at least as large as it's
473 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
475 newObject
->outerUnknown
= pUnkOuter
;
478 * Create a datacache object.
479 * We aggregate with the datacache. Make sure we pass our outer
480 * unknown as the datacache's outer unknown.
482 CreateDataCache(newObject
->outerUnknown
,
485 (void**)&newObject
->dataCache
);
488 * Initialize the other data members of the class.
490 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
491 newObject
->clientSite
= NULL
;
492 newObject
->oleAdviseHolder
= NULL
;
493 newObject
->dataAdviseHolder
= NULL
;
494 newObject
->containerApp
= NULL
;
495 newObject
->containerObj
= NULL
;
500 static void DefaultHandler_Destroy(
501 DefaultHandler
* ptrToDestroy
)
504 * Free the strings idenfitying the object
506 if (ptrToDestroy
->containerApp
!=NULL
)
508 SysFreeString(ptrToDestroy
->containerApp
);
509 ptrToDestroy
->containerApp
= NULL
;
512 if (ptrToDestroy
->containerObj
!=NULL
)
514 SysFreeString(ptrToDestroy
->containerObj
);
515 ptrToDestroy
->containerObj
= NULL
;
519 * Release our reference to the data cache.
521 if (ptrToDestroy
->dataCache
!=NULL
)
523 IUnknown_Release(ptrToDestroy
->dataCache
);
524 ptrToDestroy
->dataCache
= NULL
;
528 * Same thing for the client site.
530 if (ptrToDestroy
->clientSite
!=NULL
)
532 IOleClientSite_Release(ptrToDestroy
->clientSite
);
533 ptrToDestroy
->clientSite
= NULL
;
537 * And the advise holder.
539 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
541 IOleClientSite_Release(ptrToDestroy
->oleAdviseHolder
);
542 ptrToDestroy
->oleAdviseHolder
= NULL
;
546 * And the data advise holder.
548 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
550 IOleClientSite_Release(ptrToDestroy
->dataAdviseHolder
);
551 ptrToDestroy
->dataAdviseHolder
= NULL
;
556 * Free the actual default handler structure.
558 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
561 /*********************************************************
562 * Method implementation for the non delegating IUnknown
563 * part of the DefaultHandler class.
566 /************************************************************************
567 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
569 * See Windows documentation for more details on IUnknown methods.
571 * This version of QueryInterface will not delegate it's implementation
572 * to the outer unknown.
574 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
579 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
582 * Perform a sanity check on the parameters.
584 if ( (this==0) || (ppvObject
==0) )
588 * Initialize the return parameter.
593 * Compare the riid with the interface IDs implemented by this object.
595 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
599 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
601 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
603 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
605 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
607 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
609 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
614 * Blind aggregate the data cache to "inherit" it's interfaces.
616 IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
);
620 * Check that we obtained an interface.
626 WINE_StringFromCLSID((LPCLSID
)riid
,clsid
);
629 "() : asking for un supported interface %s\n",
632 return E_NOINTERFACE
;
636 * Query Interface always increases the reference count by one when it is
639 IUnknown_AddRef((IUnknown
*)*ppvObject
);
644 /************************************************************************
645 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
647 * See Windows documentation for more details on IUnknown methods.
649 * This version of QueryInterface will not delegate it's implementation
650 * to the outer unknown.
652 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
655 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
662 /************************************************************************
663 * DefaultHandler_NDIUnknown_Release (IUnknown)
665 * See Windows documentation for more details on IUnknown methods.
667 * This version of QueryInterface will not delegate it's implementation
668 * to the outer unknown.
670 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
673 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
676 * Decrease the reference count on this object.
681 * If the reference count goes down to 0, perform suicide.
685 DefaultHandler_Destroy(this);
693 /*********************************************************
694 * Methods implementation for the IOleObject part of
695 * the DefaultHandler class.
698 /************************************************************************
699 * DefaultHandler_QueryInterface (IUnknown)
701 * See Windows documentation for more details on IUnknown methods.
703 static HRESULT WINAPI
DefaultHandler_QueryInterface(
708 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
710 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
713 /************************************************************************
714 * DefaultHandler_AddRef (IUnknown)
716 * See Windows documentation for more details on IUnknown methods.
718 static ULONG WINAPI
DefaultHandler_AddRef(
721 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
723 return IUnknown_AddRef(this->outerUnknown
);
726 /************************************************************************
727 * DefaultHandler_Release (IUnknown)
729 * See Windows documentation for more details on IUnknown methods.
731 static ULONG WINAPI
DefaultHandler_Release(
734 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
736 return IUnknown_Release(this->outerUnknown
);
739 /************************************************************************
740 * DefaultHandler_SetClientSite (IOleObject)
742 * The default handler's implementation of this method only keeps the
743 * client site pointer for future reference.
745 * See Windows documentation for more details on IOleObject methods.
747 static HRESULT WINAPI
DefaultHandler_SetClientSite(
749 IOleClientSite
* pClientSite
)
751 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
753 TRACE("(%p, %p)\n", iface
, pClientSite
);
756 * Make sure we release the previous client site if there
759 if (this->clientSite
!=NULL
)
761 IOleClientSite_Release(this->clientSite
);
764 this->clientSite
= pClientSite
;
766 if (this->clientSite
!=NULL
)
768 IOleClientSite_AddRef(this->clientSite
);
774 /************************************************************************
775 * DefaultHandler_GetClientSite (IOleObject)
777 * The default handler's implementation of this method returns the
778 * last pointer set in IOleObject_SetClientSite.
780 * See Windows documentation for more details on IOleObject methods.
782 static HRESULT WINAPI
DefaultHandler_GetClientSite(
784 IOleClientSite
** ppClientSite
)
786 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
791 if (ppClientSite
== NULL
)
794 *ppClientSite
= this->clientSite
;
796 if (*ppClientSite
!=NULL
)
798 IOleClientSite_Release(*ppClientSite
);
804 /************************************************************************
805 * DefaultHandler_SetHostNames (IOleObject)
807 * The default handler's implementation of this method just stores
808 * the strings and returns S_OK.
810 * See Windows documentation for more details on IOleObject methods.
812 static HRESULT WINAPI
DefaultHandler_SetHostNames(
814 LPCOLESTR szContainerApp
,
815 LPCOLESTR szContainerObj
)
817 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
819 TRACE("(%p, %s, %s)\n",
821 debugstr_w(szContainerApp
),
822 debugstr_w(szContainerObj
));
825 * Be sure to cleanup before re-assinging the strings.
827 if (this->containerApp
!=NULL
)
829 SysFreeString(this->containerApp
);
830 this->containerApp
= NULL
;
833 if (this->containerObj
!=NULL
)
835 SysFreeString(this->containerObj
);
836 this->containerObj
= NULL
;
840 * Copy the string supplied.
842 if (szContainerApp
!= NULL
)
843 this->containerApp
= SysAllocString(szContainerApp
);
845 if (szContainerObj
!= NULL
)
846 this->containerObj
= SysAllocString(szContainerObj
);
851 /************************************************************************
852 * DefaultHandler_Close (IOleObject)
854 * The default handler's implementation of this method is meaningless
855 * without a running server so it does nothing.
857 * See Windows documentation for more details on IOleObject methods.
859 static HRESULT WINAPI
DefaultHandler_Close(
867 /************************************************************************
868 * DefaultHandler_SetMoniker (IOleObject)
870 * The default handler's implementation of this method does nothing.
872 * See Windows documentation for more details on IOleObject methods.
874 static HRESULT WINAPI
DefaultHandler_SetMoniker(
876 DWORD dwWhichMoniker
,
879 TRACE("(%p, %ld, %p)\n",
887 /************************************************************************
888 * DefaultHandler_GetMoniker (IOleObject)
890 * Delegate this request to the client site if we have one.
892 * See Windows documentation for more details on IOleObject methods.
894 static HRESULT WINAPI
DefaultHandler_GetMoniker(
897 DWORD dwWhichMoniker
,
900 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
902 TRACE("(%p, %ld, %ld, %p)\n",
903 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
905 if (this->clientSite
)
907 return IOleClientSite_GetMoniker(this->clientSite
,
917 /************************************************************************
918 * DefaultHandler_InitFromData (IOleObject)
920 * This method is meaningless if the server is not running
922 * See Windows documentation for more details on IOleObject methods.
924 static HRESULT WINAPI
DefaultHandler_InitFromData(
926 IDataObject
* pDataObject
,
930 TRACE("(%p, %p, %d, %ld)\n",
931 iface
, pDataObject
, fCreation
, dwReserved
);
933 return OLE_E_NOTRUNNING
;
936 /************************************************************************
937 * DefaultHandler_GetClipboardData (IOleObject)
939 * This method is meaningless if the server is not running
941 * See Windows documentation for more details on IOleObject methods.
943 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
946 IDataObject
** ppDataObject
)
948 TRACE("(%p, %ld, %p)\n",
949 iface
, dwReserved
, ppDataObject
);
951 return OLE_E_NOTRUNNING
;
954 static HRESULT WINAPI
DefaultHandler_DoVerb(
957 struct tagMSG
* lpmsg
,
958 IOleClientSite
* pActiveSite
,
967 /************************************************************************
968 * DefaultHandler_EnumVerbs (IOleObject)
970 * The default handler implementation of this method simply delegates
973 * See Windows documentation for more details on IOleObject methods.
975 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
977 IEnumOLEVERB
** ppEnumOleVerb
)
979 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
981 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
983 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
986 static HRESULT WINAPI
DefaultHandler_Update(
993 /************************************************************************
994 * DefaultHandler_IsUpToDate (IOleObject)
996 * This method is meaningless if the server is not running
998 * See Windows documentation for more details on IOleObject methods.
1000 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
1003 TRACE("(%p)\n", iface
);
1005 return OLE_E_NOTRUNNING
;
1008 /************************************************************************
1009 * DefaultHandler_GetUserClassID (IOleObject)
1011 * TODO: Map to a new class ID if emulation is active.
1013 * See Windows documentation for more details on IOleObject methods.
1015 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1019 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1021 TRACE("(%p, %p)\n", iface
, pClsid
);
1029 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1034 /************************************************************************
1035 * DefaultHandler_GetUserType (IOleObject)
1037 * The default handler implementation of this method simply delegates
1038 * to OleRegGetUserType
1040 * See Windows documentation for more details on IOleObject methods.
1042 static HRESULT WINAPI
DefaultHandler_GetUserType(
1045 LPOLESTR
* pszUserType
)
1047 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1049 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1051 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1054 /************************************************************************
1055 * DefaultHandler_SetExtent (IOleObject)
1057 * This method is meaningless if the server is not running
1059 * See Windows documentation for more details on IOleObject methods.
1061 static HRESULT WINAPI
DefaultHandler_SetExtent(
1066 TRACE("(%p, %lx, (%d,%d))\n", iface
, dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1067 return OLE_E_NOTRUNNING
;
1070 /************************************************************************
1071 * DefaultHandler_GetExtent (IOleObject)
1073 * The default handler's implementation of this method returns uses
1074 * the cache to locate the aspect and extract the extent from it.
1076 * See Windows documentation for more details on IOleObject methods.
1078 static HRESULT WINAPI
DefaultHandler_GetExtent(
1083 DVTARGETDEVICE
* targetDevice
;
1084 IViewObject2
* cacheView
= NULL
;
1087 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1089 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1091 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1094 return E_UNEXPECTED
;
1097 * Prepare the call to the cache's GetExtent method.
1099 * Here we would build a valid DVTARGETDEVICE structure
1100 * but, since we are calling into the data cache, we
1101 * know it's implementation and we'll skip this
1102 * extra work until later.
1104 targetDevice
= NULL
;
1106 hres
= IViewObject2_GetExtent(cacheView
,
1115 IViewObject2_Release(cacheView
);
1120 /************************************************************************
1121 * DefaultHandler_Advise (IOleObject)
1123 * The default handler's implementation of this method simply
1124 * delegates to the OleAdviseHolder.
1126 * See Windows documentation for more details on IOleObject methods.
1128 static HRESULT WINAPI
DefaultHandler_Advise(
1130 IAdviseSink
* pAdvSink
,
1131 DWORD
* pdwConnection
)
1133 HRESULT hres
= S_OK
;
1134 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1136 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1139 * Make sure we have an advise holder before we start.
1141 if (this->oleAdviseHolder
==NULL
)
1143 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1146 if (SUCCEEDED(hres
))
1148 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1156 /************************************************************************
1157 * DefaultHandler_Unadvise (IOleObject)
1159 * The default handler's implementation of this method simply
1160 * delegates to the OleAdviseHolder.
1162 * See Windows documentation for more details on IOleObject methods.
1164 static HRESULT WINAPI
DefaultHandler_Unadvise(
1168 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1170 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1173 * If we don't have an advise holder yet, it means we don't have
1176 if (this->oleAdviseHolder
==NULL
)
1177 return OLE_E_NOCONNECTION
;
1179 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1183 /************************************************************************
1184 * DefaultHandler_EnumAdvise (IOleObject)
1186 * The default handler's implementation of this method simply
1187 * delegates to the OleAdviseHolder.
1189 * See Windows documentation for more details on IOleObject methods.
1191 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1193 IEnumSTATDATA
** ppenumAdvise
)
1195 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1197 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1202 if (ppenumAdvise
==NULL
)
1206 * Initialize the out parameter.
1208 *ppenumAdvise
= NULL
;
1210 if (this->oleAdviseHolder
==NULL
)
1211 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1217 /************************************************************************
1218 * DefaultHandler_GetMiscStatus (IOleObject)
1220 * The default handler's implementation of this method simply delegates
1221 * to OleRegGetMiscStatus.
1223 * See Windows documentation for more details on IOleObject methods.
1225 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1231 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1233 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1235 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1243 /************************************************************************
1244 * DefaultHandler_SetExtent (IOleObject)
1246 * This method is meaningless if the server is not running
1248 * See Windows documentation for more details on IOleObject methods.
1250 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1252 struct tagLOGPALETTE
* pLogpal
)
1254 TRACE("(%p, %p))\n", iface
, pLogpal
);
1255 return OLE_E_NOTRUNNING
;
1258 /*********************************************************
1259 * Methods implementation for the IDataObject part of
1260 * the DefaultHandler class.
1263 /************************************************************************
1264 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1266 * See Windows documentation for more details on IUnknown methods.
1268 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1273 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1275 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1278 /************************************************************************
1279 * DefaultHandler_IDataObject_AddRef (IUnknown)
1281 * See Windows documentation for more details on IUnknown methods.
1283 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1286 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1288 return IUnknown_AddRef(this->outerUnknown
);
1291 /************************************************************************
1292 * DefaultHandler_IDataObject_Release (IUnknown)
1294 * See Windows documentation for more details on IUnknown methods.
1296 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1299 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1301 return IUnknown_Release(this->outerUnknown
);
1304 static HRESULT WINAPI
DefaultHandler_GetData(
1306 LPFORMATETC pformatetcIn
,
1313 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1315 LPFORMATETC pformatetc
,
1322 /************************************************************************
1323 * DefaultHandler_QueryGetData (IDataObject)
1325 * The default handler's implementation of this method delegates to
1328 * See Windows documentation for more details on IDataObject methods.
1330 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1332 LPFORMATETC pformatetc
)
1334 IDataObject
* cacheDataObject
= NULL
;
1337 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1339 TRACE("(%p, %p)\n", iface
, pformatetc
);
1341 hres
= IUnknown_QueryInterface(this->dataCache
,
1343 (void**)&cacheDataObject
);
1346 return E_UNEXPECTED
;
1348 hres
= IDataObject_QueryGetData(cacheDataObject
,
1351 IDataObject_Release(cacheDataObject
);
1356 /************************************************************************
1357 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1359 * This method is meaningless if the server is not running
1361 * See Windows documentation for more details on IDataObject methods.
1363 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1365 LPFORMATETC pformatectIn
,
1366 LPFORMATETC pformatetcOut
)
1368 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1370 return OLE_E_NOTRUNNING
;
1373 /************************************************************************
1374 * DefaultHandler_SetData (IDataObject)
1376 * The default handler's implementation of this method delegates to
1379 * See Windows documentation for more details on IDataObject methods.
1381 static HRESULT WINAPI
DefaultHandler_SetData(
1383 LPFORMATETC pformatetc
,
1387 IDataObject
* cacheDataObject
= NULL
;
1390 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1392 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1394 hres
= IUnknown_QueryInterface(this->dataCache
,
1396 (void**)&cacheDataObject
);
1399 return E_UNEXPECTED
;
1401 hres
= IDataObject_SetData(cacheDataObject
,
1406 IDataObject_Release(cacheDataObject
);
1411 /************************************************************************
1412 * DefaultHandler_EnumFormatEtc (IDataObject)
1414 * The default handler's implementation of this method simply delegates
1415 * to OleRegEnumFormatEtc.
1417 * See Windows documentation for more details on IDataObject methods.
1419 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1422 IEnumFORMATETC
** ppenumFormatEtc
)
1425 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1427 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1429 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1434 /************************************************************************
1435 * DefaultHandler_DAdvise (IDataObject)
1437 * The default handler's implementation of this method simply
1438 * delegates to the DataAdviseHolder.
1440 * See Windows documentation for more details on IDataObject methods.
1442 static HRESULT WINAPI
DefaultHandler_DAdvise(
1444 FORMATETC
* pformatetc
,
1446 IAdviseSink
* pAdvSink
,
1447 DWORD
* pdwConnection
)
1449 HRESULT hres
= S_OK
;
1450 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1452 TRACE("(%p, %p, %ld, %p, %p)\n",
1453 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1456 * Make sure we have a data advise holder before we start.
1458 if (this->dataAdviseHolder
==NULL
)
1460 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1463 if (SUCCEEDED(hres
))
1465 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1476 /************************************************************************
1477 * DefaultHandler_DUnadvise (IDataObject)
1479 * The default handler's implementation of this method simply
1480 * delegates to the DataAdviseHolder.
1482 * See Windows documentation for more details on IDataObject methods.
1484 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1488 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1490 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1493 * If we don't have a data advise holder yet, it means that
1494 * we don't have any connections..
1496 if (this->dataAdviseHolder
==NULL
)
1498 return OLE_E_NOCONNECTION
;
1501 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1505 /************************************************************************
1506 * DefaultHandler_EnumDAdvise (IDataObject)
1508 * The default handler's implementation of this method simply
1509 * delegates to the DataAdviseHolder.
1511 * See Windows documentation for more details on IDataObject methods.
1513 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1515 IEnumSTATDATA
** ppenumAdvise
)
1517 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1519 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1524 if (ppenumAdvise
== NULL
)
1528 * Initialize the out parameter.
1530 *ppenumAdvise
= NULL
;
1533 * If we have a data advise holder object, delegate.
1535 if (this->dataAdviseHolder
!=NULL
)
1537 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1544 /*********************************************************
1545 * Methods implementation for the IRunnableObject part
1546 * of the DefaultHandler class.
1549 /************************************************************************
1550 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1552 * See Windows documentation for more details on IUnknown methods.
1554 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1555 IRunnableObject
* iface
,
1559 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1561 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1564 /************************************************************************
1565 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1567 * See Windows documentation for more details on IUnknown methods.
1569 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1570 IRunnableObject
* iface
)
1572 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1574 return IUnknown_AddRef(this->outerUnknown
);
1577 /************************************************************************
1578 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1580 * See Windows documentation for more details on IUnknown methods.
1582 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1583 IRunnableObject
* iface
)
1585 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1587 return IUnknown_Release(this->outerUnknown
);
1590 /************************************************************************
1591 * DefaultHandler_GetRunningClass (IRunnableObject)
1593 * According to Brockscmidt, Chapter 19, the default handler's
1594 * implementation of IRunnableobject does nothing until the object
1595 * is actually running.
1597 * See Windows documentation for more details on IRunnableObject methods.
1599 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1600 IRunnableObject
* iface
,
1607 static HRESULT WINAPI
DefaultHandler_Run(
1608 IRunnableObject
* iface
,
1615 /************************************************************************
1616 * DefaultHandler_IsRunning (IRunnableObject)
1618 * According to Brockscmidt, Chapter 19, the default handler's
1619 * implementation of IRunnableobject does nothing until the object
1620 * is actually running.
1622 * See Windows documentation for more details on IRunnableObject methods.
1624 static BOOL WINAPI
DefaultHandler_IsRunning(
1625 IRunnableObject
* iface
)
1631 /************************************************************************
1632 * DefaultHandler_LockRunning (IRunnableObject)
1634 * According to Brockscmidt, Chapter 19, the default handler's
1635 * implementation of IRunnableobject does nothing until the object
1636 * is actually running.
1638 * See Windows documentation for more details on IRunnableObject methods.
1640 static HRESULT WINAPI
DefaultHandler_LockRunning(
1641 IRunnableObject
* iface
,
1643 BOOL fLastUnlockCloses
)
1649 /************************************************************************
1650 * DefaultHandler_SetContainedObject (IRunnableObject)
1652 * According to Brockscmidt, Chapter 19, the default handler's
1653 * implementation of IRunnableobject does nothing until the object
1654 * is actually running.
1656 * See Windows documentation for more details on IRunnableObject methods.
1658 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1659 IRunnableObject
* iface
,