2 * OLE 2 default object handler
4 * Copyright 1999 Francis Beaudet
5 * Copyright 2000 Abey George
8 * The OLE2 default object handler supports a whole whack of
9 * interfaces including:
10 * IOleObject, IDataObject, IPersistStorage, IViewObject2,
11 * IRunnableObject, IOleCache2, IOleCacheControl and much more.
13 * All the implementation details are taken from: Inside OLE
14 * second edition by Kraig Brockschmidt,
17 * - This implementation of the default handler does not launch the
18 * server in the DoVerb, Update, GetData, GetDataHere and Run
19 * methods. When it is fixed to do so, all the methods will have
20 * to be revisited to allow delegating to the running object
22 * - All methods in the class that use the class ID should be
23 * aware that it is possible for a class to be treated as
24 * another one and go into emulation mode. Nothing has been
27 * - Some functions still return E_NOTIMPL they have to be
28 * implemented. Most of those are related to the running of the
31 * - All the methods related to notification and advise sinks are
32 * in place but no notifications are sent to the sinks yet.
39 #include "wine/obj_oleview.h"
40 #include "debugtools.h"
42 DEFAULT_DEBUG_CHANNEL(ole
)
44 /****************************************************************************
51 * List all interface VTables here
53 ICOM_VTABLE(IOleObject
)* lpvtbl1
;
54 ICOM_VTABLE(IUnknown
)* lpvtbl2
;
55 ICOM_VTABLE(IDataObject
)* lpvtbl3
;
56 ICOM_VTABLE(IRunnableObject
)* lpvtbl4
;
59 * Reference count of this object
64 * IUnknown implementation of the outer object.
66 IUnknown
* outerUnknown
;
69 * Class Id that this handler object represents.
74 * IUnknown implementation of the datacache.
79 * Client site for the embedded object.
81 IOleClientSite
* clientSite
;
84 * The IOleAdviseHolder maintains the connections
85 * on behalf of the default handler.
87 IOleAdviseHolder
* oleAdviseHolder
;
90 * The IDataAdviseHolder maintains the data
91 * connections on behalf of the default handler.
93 IDataAdviseHolder
* dataAdviseHolder
;
96 * Name of the container and object contained
103 typedef struct DefaultHandler DefaultHandler
;
106 * Here, I define utility macros to help with the casting of the
108 * There is a version to accomodate all of the VTables implemented
111 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
112 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
113 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
114 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
117 * Prototypes for the methods of the DefaultHandler class.
119 static DefaultHandler
* DefaultHandler_Construct(REFCLSID clsid
,
120 LPUNKNOWN pUnkOuter
);
121 static void DefaultHandler_Destroy(DefaultHandler
* ptrToDestroy
);
124 * Prototypes for the methods of the DefaultHandler class
125 * that implement non delegating IUnknown methods.
127 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
131 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
133 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
137 * Prototypes for the methods of the DefaultHandler class
138 * that implement IOleObject methods.
140 static HRESULT WINAPI
DefaultHandler_QueryInterface(
144 static ULONG WINAPI
DefaultHandler_AddRef(
146 static ULONG WINAPI
DefaultHandler_Release(
148 static HRESULT WINAPI
DefaultHandler_SetClientSite(
150 IOleClientSite
* pClientSite
);
151 static HRESULT WINAPI
DefaultHandler_GetClientSite(
153 IOleClientSite
** ppClientSite
);
154 static HRESULT WINAPI
DefaultHandler_SetHostNames(
156 LPCOLESTR szContainerApp
,
157 LPCOLESTR szContainerObj
);
158 static HRESULT WINAPI
DefaultHandler_Close(
161 static HRESULT WINAPI
DefaultHandler_SetMoniker(
163 DWORD dwWhichMoniker
,
165 static HRESULT WINAPI
DefaultHandler_GetMoniker(
168 DWORD dwWhichMoniker
,
170 static HRESULT WINAPI
DefaultHandler_InitFromData(
172 IDataObject
* pDataObject
,
175 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
178 IDataObject
** ppDataObject
);
179 static HRESULT WINAPI
DefaultHandler_DoVerb(
182 struct tagMSG
* lpmsg
,
183 IOleClientSite
* pActiveSite
,
186 LPCRECT lprcPosRect
);
187 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
189 IEnumOLEVERB
** ppEnumOleVerb
);
190 static HRESULT WINAPI
DefaultHandler_Update(
192 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
194 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
197 static HRESULT WINAPI
DefaultHandler_GetUserType(
200 LPOLESTR
* pszUserType
);
201 static HRESULT WINAPI
DefaultHandler_SetExtent(
205 static HRESULT WINAPI
DefaultHandler_GetExtent(
209 static HRESULT WINAPI
DefaultHandler_Advise(
211 IAdviseSink
* pAdvSink
,
212 DWORD
* pdwConnection
);
213 static HRESULT WINAPI
DefaultHandler_Unadvise(
216 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
218 IEnumSTATDATA
** ppenumAdvise
);
219 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
223 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
225 struct tagLOGPALETTE
* pLogpal
);
228 * Prototypes for the methods of the DefaultHandler class
229 * that implement IDataObject methods.
231 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
235 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
237 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
239 static HRESULT WINAPI
DefaultHandler_GetData(
241 LPFORMATETC pformatetcIn
,
243 static HRESULT WINAPI
DefaultHandler_GetDataHere(
245 LPFORMATETC pformatetc
,
247 static HRESULT WINAPI
DefaultHandler_QueryGetData(
249 LPFORMATETC pformatetc
);
250 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
252 LPFORMATETC pformatectIn
,
253 LPFORMATETC pformatetcOut
);
254 static HRESULT WINAPI
DefaultHandler_SetData(
256 LPFORMATETC pformatetc
,
259 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
262 IEnumFORMATETC
** ppenumFormatEtc
);
263 static HRESULT WINAPI
DefaultHandler_DAdvise(
265 FORMATETC
* pformatetc
,
267 IAdviseSink
* pAdvSink
,
268 DWORD
* pdwConnection
);
269 static HRESULT WINAPI
DefaultHandler_DUnadvise(
272 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
274 IEnumSTATDATA
** ppenumAdvise
);
277 * Prototypes for the methods of the DefaultHandler class
278 * that implement IRunnableObject methods.
280 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
281 IRunnableObject
* iface
,
284 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
285 IRunnableObject
* iface
);
286 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
287 IRunnableObject
* iface
);
288 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
289 IRunnableObject
* iface
,
291 static HRESULT WINAPI
DefaultHandler_Run(
292 IRunnableObject
* iface
,
294 static BOOL WINAPI
DefaultHandler_IsRunning(
295 IRunnableObject
* iface
);
296 static HRESULT WINAPI
DefaultHandler_LockRunning(
297 IRunnableObject
* iface
,
299 BOOL fLastUnlockCloses
);
300 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
301 IRunnableObject
* iface
,
306 * Virtual function tables for the DefaultHandler class.
308 static ICOM_VTABLE(IOleObject
) DefaultHandler_IOleObject_VTable
=
310 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
311 DefaultHandler_QueryInterface
,
312 DefaultHandler_AddRef
,
313 DefaultHandler_Release
,
314 DefaultHandler_SetClientSite
,
315 DefaultHandler_GetClientSite
,
316 DefaultHandler_SetHostNames
,
317 DefaultHandler_Close
,
318 DefaultHandler_SetMoniker
,
319 DefaultHandler_GetMoniker
,
320 DefaultHandler_InitFromData
,
321 DefaultHandler_GetClipboardData
,
322 DefaultHandler_DoVerb
,
323 DefaultHandler_EnumVerbs
,
324 DefaultHandler_Update
,
325 DefaultHandler_IsUpToDate
,
326 DefaultHandler_GetUserClassID
,
327 DefaultHandler_GetUserType
,
328 DefaultHandler_SetExtent
,
329 DefaultHandler_GetExtent
,
330 DefaultHandler_Advise
,
331 DefaultHandler_Unadvise
,
332 DefaultHandler_EnumAdvise
,
333 DefaultHandler_GetMiscStatus
,
334 DefaultHandler_SetColorScheme
337 static ICOM_VTABLE(IUnknown
) DefaultHandler_NDIUnknown_VTable
=
339 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
340 DefaultHandler_NDIUnknown_QueryInterface
,
341 DefaultHandler_NDIUnknown_AddRef
,
342 DefaultHandler_NDIUnknown_Release
,
345 static ICOM_VTABLE(IDataObject
) DefaultHandler_IDataObject_VTable
=
347 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
348 DefaultHandler_IDataObject_QueryInterface
,
349 DefaultHandler_IDataObject_AddRef
,
350 DefaultHandler_IDataObject_Release
,
351 DefaultHandler_GetData
,
352 DefaultHandler_GetDataHere
,
353 DefaultHandler_QueryGetData
,
354 DefaultHandler_GetCanonicalFormatEtc
,
355 DefaultHandler_SetData
,
356 DefaultHandler_EnumFormatEtc
,
357 DefaultHandler_DAdvise
,
358 DefaultHandler_DUnadvise
,
359 DefaultHandler_EnumDAdvise
362 static ICOM_VTABLE(IRunnableObject
) DefaultHandler_IRunnableObject_VTable
=
364 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
365 DefaultHandler_IRunnableObject_QueryInterface
,
366 DefaultHandler_IRunnableObject_AddRef
,
367 DefaultHandler_IRunnableObject_Release
,
368 DefaultHandler_GetRunningClass
,
370 DefaultHandler_IsRunning
,
371 DefaultHandler_LockRunning
,
372 DefaultHandler_SetContainedObject
375 /******************************************************************************
376 * OleCreateDefaultHandler [OLE32.90]
378 HRESULT WINAPI
OleCreateDefaultHandler(
384 DefaultHandler
* newHandler
= NULL
;
387 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid
), pUnkOuter
, debugstr_guid(riid
), ppvObj
);
398 * If this handler is constructed for aggregation, make sure
399 * the caller is requesting the IUnknown interface.
400 * This is necessary because it's the only time the non-delegating
401 * IUnknown pointer can be returned to the outside.
403 if ( (pUnkOuter
!=NULL
) &&
404 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
405 return CLASS_E_NOAGGREGATION
;
408 * Try to construct a new instance of the class.
410 newHandler
= DefaultHandler_Construct(clsid
,
414 return E_OUTOFMEMORY
;
417 * Make sure it supports the interface required by the caller.
419 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
422 * Release the reference obtained in the constructor. If
423 * the QueryInterface was unsuccessful, it will free the class.
425 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
430 /*********************************************************
431 * Methods implementation for the DefaultHandler class.
433 static DefaultHandler
* DefaultHandler_Construct(
437 DefaultHandler
* newObject
= 0;
440 * Allocate space for the object.
442 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
448 * Initialize the virtual function table.
450 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
451 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
452 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
453 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
456 * Start with one reference count. The caller of this function
457 * must release the interface pointer when it is done.
462 * Initialize the outer unknown
463 * We don't keep a reference on the outer unknown since, the way
464 * aggregation works, our lifetime is at least as large as it's
468 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
470 newObject
->outerUnknown
= pUnkOuter
;
473 * Create a datacache object.
474 * We aggregate with the datacache. Make sure we pass our outer
475 * unknown as the datacache's outer unknown.
477 CreateDataCache(newObject
->outerUnknown
,
480 (void**)&newObject
->dataCache
);
483 * Initialize the other data members of the class.
485 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
486 newObject
->clientSite
= NULL
;
487 newObject
->oleAdviseHolder
= NULL
;
488 newObject
->dataAdviseHolder
= NULL
;
489 newObject
->containerApp
= NULL
;
490 newObject
->containerObj
= NULL
;
495 static void DefaultHandler_Destroy(
496 DefaultHandler
* ptrToDestroy
)
499 * Free the strings idenfitying the object
501 if (ptrToDestroy
->containerApp
!=NULL
)
503 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerApp
);
504 ptrToDestroy
->containerApp
= NULL
;
507 if (ptrToDestroy
->containerObj
!=NULL
)
509 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerObj
);
510 ptrToDestroy
->containerObj
= NULL
;
514 * Release our reference to the data cache.
516 if (ptrToDestroy
->dataCache
!=NULL
)
518 IUnknown_Release(ptrToDestroy
->dataCache
);
519 ptrToDestroy
->dataCache
= NULL
;
523 * Same thing for the client site.
525 if (ptrToDestroy
->clientSite
!=NULL
)
527 IOleClientSite_Release(ptrToDestroy
->clientSite
);
528 ptrToDestroy
->clientSite
= NULL
;
532 * And the advise holder.
534 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
536 IOleAdviseHolder_Release(ptrToDestroy
->oleAdviseHolder
);
537 ptrToDestroy
->oleAdviseHolder
= NULL
;
541 * And the data advise holder.
543 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
545 IDataAdviseHolder_Release(ptrToDestroy
->dataAdviseHolder
);
546 ptrToDestroy
->dataAdviseHolder
= NULL
;
551 * Free the actual default handler structure.
553 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
556 /*********************************************************
557 * Method implementation for the non delegating IUnknown
558 * part of the DefaultHandler class.
561 /************************************************************************
562 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
564 * See Windows documentation for more details on IUnknown methods.
566 * This version of QueryInterface will not delegate it's implementation
567 * to the outer unknown.
569 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
574 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
577 * Perform a sanity check on the parameters.
579 if ( (this==0) || (ppvObject
==0) )
583 * Initialize the return parameter.
588 * Compare the riid with the interface IDs implemented by this object.
590 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
594 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
596 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
598 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
600 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
602 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
604 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
609 * Blind aggregate the data cache to "inherit" it's interfaces.
611 if (IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
) == S_OK
)
616 * Check that we obtained an interface.
620 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid
));
621 return E_NOINTERFACE
;
625 * Query Interface always increases the reference count by one when it is
628 IUnknown_AddRef((IUnknown
*)*ppvObject
);
633 /************************************************************************
634 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
636 * See Windows documentation for more details on IUnknown methods.
638 * This version of QueryInterface will not delegate it's implementation
639 * to the outer unknown.
641 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
644 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
651 /************************************************************************
652 * DefaultHandler_NDIUnknown_Release (IUnknown)
654 * See Windows documentation for more details on IUnknown methods.
656 * This version of QueryInterface will not delegate it's implementation
657 * to the outer unknown.
659 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
662 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
665 * Decrease the reference count on this object.
670 * If the reference count goes down to 0, perform suicide.
674 DefaultHandler_Destroy(this);
682 /*********************************************************
683 * Methods implementation for the IOleObject part of
684 * the DefaultHandler class.
687 /************************************************************************
688 * DefaultHandler_QueryInterface (IUnknown)
690 * See Windows documentation for more details on IUnknown methods.
692 static HRESULT WINAPI
DefaultHandler_QueryInterface(
697 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
699 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
702 /************************************************************************
703 * DefaultHandler_AddRef (IUnknown)
705 * See Windows documentation for more details on IUnknown methods.
707 static ULONG WINAPI
DefaultHandler_AddRef(
710 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
712 return IUnknown_AddRef(this->outerUnknown
);
715 /************************************************************************
716 * DefaultHandler_Release (IUnknown)
718 * See Windows documentation for more details on IUnknown methods.
720 static ULONG WINAPI
DefaultHandler_Release(
723 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
725 return IUnknown_Release(this->outerUnknown
);
728 /************************************************************************
729 * DefaultHandler_SetClientSite (IOleObject)
731 * The default handler's implementation of this method only keeps the
732 * client site pointer for future reference.
734 * See Windows documentation for more details on IOleObject methods.
736 static HRESULT WINAPI
DefaultHandler_SetClientSite(
738 IOleClientSite
* pClientSite
)
740 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
742 TRACE("(%p, %p)\n", iface
, pClientSite
);
745 * Make sure we release the previous client site if there
748 if (this->clientSite
!=NULL
)
750 IOleClientSite_Release(this->clientSite
);
753 this->clientSite
= pClientSite
;
755 if (this->clientSite
!=NULL
)
757 IOleClientSite_AddRef(this->clientSite
);
763 /************************************************************************
764 * DefaultHandler_GetClientSite (IOleObject)
766 * The default handler's implementation of this method returns the
767 * last pointer set in IOleObject_SetClientSite.
769 * See Windows documentation for more details on IOleObject methods.
771 static HRESULT WINAPI
DefaultHandler_GetClientSite(
773 IOleClientSite
** ppClientSite
)
775 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
780 if (ppClientSite
== NULL
)
783 *ppClientSite
= this->clientSite
;
785 if (this->clientSite
!= NULL
)
787 IOleClientSite_AddRef(this->clientSite
);
793 /************************************************************************
794 * DefaultHandler_SetHostNames (IOleObject)
796 * The default handler's implementation of this method just stores
797 * the strings and returns S_OK.
799 * See Windows documentation for more details on IOleObject methods.
801 static HRESULT WINAPI
DefaultHandler_SetHostNames(
803 LPCOLESTR szContainerApp
,
804 LPCOLESTR szContainerObj
)
806 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
808 TRACE("(%p, %s, %s)\n",
810 debugstr_w(szContainerApp
),
811 debugstr_w(szContainerObj
));
814 * Be sure to cleanup before re-assinging the strings.
816 if (this->containerApp
!=NULL
)
818 HeapFree( GetProcessHeap(), 0, this->containerApp
);
819 this->containerApp
= NULL
;
822 if (this->containerObj
!=NULL
)
824 HeapFree( GetProcessHeap(), 0, this->containerObj
);
825 this->containerObj
= NULL
;
829 * Copy the string supplied.
831 if (szContainerApp
!= NULL
)
833 if ((this->containerApp
= HeapAlloc( GetProcessHeap(), 0,
834 (lstrlenW(szContainerApp
) + 1) * sizeof(WCHAR
) )))
835 lstrcpyW( this->containerApp
, szContainerApp
);
838 if (szContainerObj
!= NULL
)
840 if ((this->containerObj
= HeapAlloc( GetProcessHeap(), 0,
841 (lstrlenW(szContainerObj
) + 1) * sizeof(WCHAR
) )))
842 lstrcpyW( this->containerObj
, szContainerObj
);
847 /************************************************************************
848 * DefaultHandler_Close (IOleObject)
850 * The default handler's implementation of this method is meaningless
851 * without a running server so it does nothing.
853 * See Windows documentation for more details on IOleObject methods.
855 static HRESULT WINAPI
DefaultHandler_Close(
863 /************************************************************************
864 * DefaultHandler_SetMoniker (IOleObject)
866 * The default handler's implementation of this method does nothing.
868 * See Windows documentation for more details on IOleObject methods.
870 static HRESULT WINAPI
DefaultHandler_SetMoniker(
872 DWORD dwWhichMoniker
,
875 TRACE("(%p, %ld, %p)\n",
883 /************************************************************************
884 * DefaultHandler_GetMoniker (IOleObject)
886 * Delegate this request to the client site if we have one.
888 * See Windows documentation for more details on IOleObject methods.
890 static HRESULT WINAPI
DefaultHandler_GetMoniker(
893 DWORD dwWhichMoniker
,
896 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
898 TRACE("(%p, %ld, %ld, %p)\n",
899 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
901 if (this->clientSite
)
903 return IOleClientSite_GetMoniker(this->clientSite
,
913 /************************************************************************
914 * DefaultHandler_InitFromData (IOleObject)
916 * This method is meaningless if the server is not running
918 * See Windows documentation for more details on IOleObject methods.
920 static HRESULT WINAPI
DefaultHandler_InitFromData(
922 IDataObject
* pDataObject
,
926 TRACE("(%p, %p, %d, %ld)\n",
927 iface
, pDataObject
, fCreation
, dwReserved
);
929 return OLE_E_NOTRUNNING
;
932 /************************************************************************
933 * DefaultHandler_GetClipboardData (IOleObject)
935 * This method is meaningless if the server is not running
937 * See Windows documentation for more details on IOleObject methods.
939 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
942 IDataObject
** ppDataObject
)
944 TRACE("(%p, %ld, %p)\n",
945 iface
, dwReserved
, ppDataObject
);
947 return OLE_E_NOTRUNNING
;
950 static HRESULT WINAPI
DefaultHandler_DoVerb(
953 struct tagMSG
* lpmsg
,
954 IOleClientSite
* pActiveSite
,
963 /************************************************************************
964 * DefaultHandler_EnumVerbs (IOleObject)
966 * The default handler implementation of this method simply delegates
969 * See Windows documentation for more details on IOleObject methods.
971 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
973 IEnumOLEVERB
** ppEnumOleVerb
)
975 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
977 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
979 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
982 static HRESULT WINAPI
DefaultHandler_Update(
989 /************************************************************************
990 * DefaultHandler_IsUpToDate (IOleObject)
992 * This method is meaningless if the server is not running
994 * See Windows documentation for more details on IOleObject methods.
996 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
999 TRACE("(%p)\n", iface
);
1001 return OLE_E_NOTRUNNING
;
1004 /************************************************************************
1005 * DefaultHandler_GetUserClassID (IOleObject)
1007 * TODO: Map to a new class ID if emulation is active.
1009 * See Windows documentation for more details on IOleObject methods.
1011 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1015 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1017 TRACE("(%p, %p)\n", iface
, pClsid
);
1025 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1030 /************************************************************************
1031 * DefaultHandler_GetUserType (IOleObject)
1033 * The default handler implementation of this method simply delegates
1034 * to OleRegGetUserType
1036 * See Windows documentation for more details on IOleObject methods.
1038 static HRESULT WINAPI
DefaultHandler_GetUserType(
1041 LPOLESTR
* pszUserType
)
1043 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1045 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1047 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1050 /************************************************************************
1051 * DefaultHandler_SetExtent (IOleObject)
1053 * This method is meaningless if the server is not running
1055 * See Windows documentation for more details on IOleObject methods.
1057 static HRESULT WINAPI
DefaultHandler_SetExtent(
1062 TRACE("(%p, %lx, (%d,%d))\n", iface
, dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1063 return OLE_E_NOTRUNNING
;
1066 /************************************************************************
1067 * DefaultHandler_GetExtent (IOleObject)
1069 * The default handler's implementation of this method returns uses
1070 * the cache to locate the aspect and extract the extent from it.
1072 * See Windows documentation for more details on IOleObject methods.
1074 static HRESULT WINAPI
DefaultHandler_GetExtent(
1079 DVTARGETDEVICE
* targetDevice
;
1080 IViewObject2
* cacheView
= NULL
;
1083 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1085 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1087 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1090 return E_UNEXPECTED
;
1093 * Prepare the call to the cache's GetExtent method.
1095 * Here we would build a valid DVTARGETDEVICE structure
1096 * but, since we are calling into the data cache, we
1097 * know it's implementation and we'll skip this
1098 * extra work until later.
1100 targetDevice
= NULL
;
1102 hres
= IViewObject2_GetExtent(cacheView
,
1111 IViewObject2_Release(cacheView
);
1116 /************************************************************************
1117 * DefaultHandler_Advise (IOleObject)
1119 * The default handler's implementation of this method simply
1120 * delegates to the OleAdviseHolder.
1122 * See Windows documentation for more details on IOleObject methods.
1124 static HRESULT WINAPI
DefaultHandler_Advise(
1126 IAdviseSink
* pAdvSink
,
1127 DWORD
* pdwConnection
)
1129 HRESULT hres
= S_OK
;
1130 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1132 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1135 * Make sure we have an advise holder before we start.
1137 if (this->oleAdviseHolder
==NULL
)
1139 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1142 if (SUCCEEDED(hres
))
1144 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1152 /************************************************************************
1153 * DefaultHandler_Unadvise (IOleObject)
1155 * The default handler's implementation of this method simply
1156 * delegates to the OleAdviseHolder.
1158 * See Windows documentation for more details on IOleObject methods.
1160 static HRESULT WINAPI
DefaultHandler_Unadvise(
1164 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1166 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1169 * If we don't have an advise holder yet, it means we don't have
1172 if (this->oleAdviseHolder
==NULL
)
1173 return OLE_E_NOCONNECTION
;
1175 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1179 /************************************************************************
1180 * DefaultHandler_EnumAdvise (IOleObject)
1182 * The default handler's implementation of this method simply
1183 * delegates to the OleAdviseHolder.
1185 * See Windows documentation for more details on IOleObject methods.
1187 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1189 IEnumSTATDATA
** ppenumAdvise
)
1191 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1193 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1198 if (ppenumAdvise
==NULL
)
1202 * Initialize the out parameter.
1204 *ppenumAdvise
= NULL
;
1206 if (this->oleAdviseHolder
==NULL
)
1207 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1213 /************************************************************************
1214 * DefaultHandler_GetMiscStatus (IOleObject)
1216 * The default handler's implementation of this method simply delegates
1217 * to OleRegGetMiscStatus.
1219 * See Windows documentation for more details on IOleObject methods.
1221 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1227 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1229 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1231 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1239 /************************************************************************
1240 * DefaultHandler_SetExtent (IOleObject)
1242 * This method is meaningless if the server is not running
1244 * See Windows documentation for more details on IOleObject methods.
1246 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1248 struct tagLOGPALETTE
* pLogpal
)
1250 TRACE("(%p, %p))\n", iface
, pLogpal
);
1251 return OLE_E_NOTRUNNING
;
1254 /*********************************************************
1255 * Methods implementation for the IDataObject part of
1256 * the DefaultHandler class.
1259 /************************************************************************
1260 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1262 * See Windows documentation for more details on IUnknown methods.
1264 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1269 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1271 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1274 /************************************************************************
1275 * DefaultHandler_IDataObject_AddRef (IUnknown)
1277 * See Windows documentation for more details on IUnknown methods.
1279 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1282 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1284 return IUnknown_AddRef(this->outerUnknown
);
1287 /************************************************************************
1288 * DefaultHandler_IDataObject_Release (IUnknown)
1290 * See Windows documentation for more details on IUnknown methods.
1292 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1295 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1297 return IUnknown_Release(this->outerUnknown
);
1300 /************************************************************************
1301 * DefaultHandler_GetData
1303 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1304 * See Windows documentation for more details on GetData.
1305 * Default handler's implementation of this method delegates to the cache.
1307 static HRESULT WINAPI
DefaultHandler_GetData(
1309 LPFORMATETC pformatetcIn
,
1312 IDataObject
* cacheDataObject
= NULL
;
1315 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1317 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1319 hres
= IUnknown_QueryInterface(this->dataCache
,
1321 (void**)&cacheDataObject
);
1324 return E_UNEXPECTED
;
1326 hres
= IDataObject_GetData(cacheDataObject
,
1330 IDataObject_Release(cacheDataObject
);
1335 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1337 LPFORMATETC pformatetc
,
1344 /************************************************************************
1345 * DefaultHandler_QueryGetData (IDataObject)
1347 * The default handler's implementation of this method delegates to
1350 * See Windows documentation for more details on IDataObject methods.
1352 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1354 LPFORMATETC pformatetc
)
1356 IDataObject
* cacheDataObject
= NULL
;
1359 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1361 TRACE("(%p, %p)\n", iface
, pformatetc
);
1363 hres
= IUnknown_QueryInterface(this->dataCache
,
1365 (void**)&cacheDataObject
);
1368 return E_UNEXPECTED
;
1370 hres
= IDataObject_QueryGetData(cacheDataObject
,
1373 IDataObject_Release(cacheDataObject
);
1378 /************************************************************************
1379 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1381 * This method is meaningless if the server is not running
1383 * See Windows documentation for more details on IDataObject methods.
1385 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1387 LPFORMATETC pformatectIn
,
1388 LPFORMATETC pformatetcOut
)
1390 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1392 return OLE_E_NOTRUNNING
;
1395 /************************************************************************
1396 * DefaultHandler_SetData (IDataObject)
1398 * The default handler's implementation of this method delegates to
1401 * See Windows documentation for more details on IDataObject methods.
1403 static HRESULT WINAPI
DefaultHandler_SetData(
1405 LPFORMATETC pformatetc
,
1409 IDataObject
* cacheDataObject
= NULL
;
1412 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1414 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1416 hres
= IUnknown_QueryInterface(this->dataCache
,
1418 (void**)&cacheDataObject
);
1421 return E_UNEXPECTED
;
1423 hres
= IDataObject_SetData(cacheDataObject
,
1428 IDataObject_Release(cacheDataObject
);
1433 /************************************************************************
1434 * DefaultHandler_EnumFormatEtc (IDataObject)
1436 * The default handler's implementation of this method simply delegates
1437 * to OleRegEnumFormatEtc.
1439 * See Windows documentation for more details on IDataObject methods.
1441 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1444 IEnumFORMATETC
** ppenumFormatEtc
)
1447 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1449 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1451 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1456 /************************************************************************
1457 * DefaultHandler_DAdvise (IDataObject)
1459 * The default handler's implementation of this method simply
1460 * delegates to the DataAdviseHolder.
1462 * See Windows documentation for more details on IDataObject methods.
1464 static HRESULT WINAPI
DefaultHandler_DAdvise(
1466 FORMATETC
* pformatetc
,
1468 IAdviseSink
* pAdvSink
,
1469 DWORD
* pdwConnection
)
1471 HRESULT hres
= S_OK
;
1472 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1474 TRACE("(%p, %p, %ld, %p, %p)\n",
1475 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1478 * Make sure we have a data advise holder before we start.
1480 if (this->dataAdviseHolder
==NULL
)
1482 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1485 if (SUCCEEDED(hres
))
1487 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1498 /************************************************************************
1499 * DefaultHandler_DUnadvise (IDataObject)
1501 * The default handler's implementation of this method simply
1502 * delegates to the DataAdviseHolder.
1504 * See Windows documentation for more details on IDataObject methods.
1506 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1510 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1512 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1515 * If we don't have a data advise holder yet, it means that
1516 * we don't have any connections..
1518 if (this->dataAdviseHolder
==NULL
)
1520 return OLE_E_NOCONNECTION
;
1523 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1527 /************************************************************************
1528 * DefaultHandler_EnumDAdvise (IDataObject)
1530 * The default handler's implementation of this method simply
1531 * delegates to the DataAdviseHolder.
1533 * See Windows documentation for more details on IDataObject methods.
1535 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1537 IEnumSTATDATA
** ppenumAdvise
)
1539 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1541 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1546 if (ppenumAdvise
== NULL
)
1550 * Initialize the out parameter.
1552 *ppenumAdvise
= NULL
;
1555 * If we have a data advise holder object, delegate.
1557 if (this->dataAdviseHolder
!=NULL
)
1559 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1566 /*********************************************************
1567 * Methods implementation for the IRunnableObject part
1568 * of the DefaultHandler class.
1571 /************************************************************************
1572 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1574 * See Windows documentation for more details on IUnknown methods.
1576 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1577 IRunnableObject
* iface
,
1581 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1583 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1586 /************************************************************************
1587 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1589 * See Windows documentation for more details on IUnknown methods.
1591 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1592 IRunnableObject
* iface
)
1594 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1596 return IUnknown_AddRef(this->outerUnknown
);
1599 /************************************************************************
1600 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1602 * See Windows documentation for more details on IUnknown methods.
1604 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1605 IRunnableObject
* iface
)
1607 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1609 return IUnknown_Release(this->outerUnknown
);
1612 /************************************************************************
1613 * DefaultHandler_GetRunningClass (IRunnableObject)
1615 * According to Brockscmidt, Chapter 19, the default handler's
1616 * implementation of IRunnableobject does nothing until the object
1617 * is actually running.
1619 * See Windows documentation for more details on IRunnableObject methods.
1621 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1622 IRunnableObject
* iface
,
1629 static HRESULT WINAPI
DefaultHandler_Run(
1630 IRunnableObject
* iface
,
1637 /************************************************************************
1638 * DefaultHandler_IsRunning (IRunnableObject)
1640 * According to Brockscmidt, Chapter 19, the default handler's
1641 * implementation of IRunnableobject does nothing until the object
1642 * is actually running.
1644 * See Windows documentation for more details on IRunnableObject methods.
1646 static BOOL WINAPI
DefaultHandler_IsRunning(
1647 IRunnableObject
* iface
)
1653 /************************************************************************
1654 * DefaultHandler_LockRunning (IRunnableObject)
1656 * According to Brockscmidt, Chapter 19, the default handler's
1657 * implementation of IRunnableobject does nothing until the object
1658 * is actually running.
1660 * See Windows documentation for more details on IRunnableObject methods.
1662 static HRESULT WINAPI
DefaultHandler_LockRunning(
1663 IRunnableObject
* iface
,
1665 BOOL fLastUnlockCloses
)
1671 /************************************************************************
1672 * DefaultHandler_SetContainedObject (IRunnableObject)
1674 * According to Brockscmidt, Chapter 19, the default handler's
1675 * implementation of IRunnableobject does nothing until the object
1676 * is actually running.
1678 * See Windows documentation for more details on IRunnableObject methods.
1680 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1681 IRunnableObject
* iface
,