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/unicode.h"
41 #include "wine/obj_oleview.h"
42 #include "debugtools.h"
44 DEFAULT_DEBUG_CHANNEL(ole
);
46 /****************************************************************************
53 * List all interface VTables here
55 ICOM_VTABLE(IOleObject
)* lpvtbl1
;
56 ICOM_VTABLE(IUnknown
)* lpvtbl2
;
57 ICOM_VTABLE(IDataObject
)* lpvtbl3
;
58 ICOM_VTABLE(IRunnableObject
)* lpvtbl4
;
61 * Reference count of this object
66 * IUnknown implementation of the outer object.
68 IUnknown
* outerUnknown
;
71 * Class Id that this handler object represents.
76 * IUnknown implementation of the datacache.
81 * Client site for the embedded object.
83 IOleClientSite
* clientSite
;
86 * The IOleAdviseHolder maintains the connections
87 * on behalf of the default handler.
89 IOleAdviseHolder
* oleAdviseHolder
;
92 * The IDataAdviseHolder maintains the data
93 * connections on behalf of the default handler.
95 IDataAdviseHolder
* dataAdviseHolder
;
98 * Name of the container and object contained
105 typedef struct DefaultHandler DefaultHandler
;
108 * Here, I define utility macros to help with the casting of the
110 * There is a version to accomodate all of the VTables implemented
113 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
114 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
115 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
116 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
119 * Prototypes for the methods of the DefaultHandler class.
121 static DefaultHandler
* DefaultHandler_Construct(REFCLSID clsid
,
122 LPUNKNOWN pUnkOuter
);
123 static void DefaultHandler_Destroy(DefaultHandler
* ptrToDestroy
);
126 * Prototypes for the methods of the DefaultHandler class
127 * that implement non delegating IUnknown methods.
129 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
133 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
135 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
139 * Prototypes for the methods of the DefaultHandler class
140 * that implement IOleObject methods.
142 static HRESULT WINAPI
DefaultHandler_QueryInterface(
146 static ULONG WINAPI
DefaultHandler_AddRef(
148 static ULONG WINAPI
DefaultHandler_Release(
150 static HRESULT WINAPI
DefaultHandler_SetClientSite(
152 IOleClientSite
* pClientSite
);
153 static HRESULT WINAPI
DefaultHandler_GetClientSite(
155 IOleClientSite
** ppClientSite
);
156 static HRESULT WINAPI
DefaultHandler_SetHostNames(
158 LPCOLESTR szContainerApp
,
159 LPCOLESTR szContainerObj
);
160 static HRESULT WINAPI
DefaultHandler_Close(
163 static HRESULT WINAPI
DefaultHandler_SetMoniker(
165 DWORD dwWhichMoniker
,
167 static HRESULT WINAPI
DefaultHandler_GetMoniker(
170 DWORD dwWhichMoniker
,
172 static HRESULT WINAPI
DefaultHandler_InitFromData(
174 IDataObject
* pDataObject
,
177 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
180 IDataObject
** ppDataObject
);
181 static HRESULT WINAPI
DefaultHandler_DoVerb(
184 struct tagMSG
* lpmsg
,
185 IOleClientSite
* pActiveSite
,
188 LPCRECT lprcPosRect
);
189 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
191 IEnumOLEVERB
** ppEnumOleVerb
);
192 static HRESULT WINAPI
DefaultHandler_Update(
194 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
196 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
199 static HRESULT WINAPI
DefaultHandler_GetUserType(
202 LPOLESTR
* pszUserType
);
203 static HRESULT WINAPI
DefaultHandler_SetExtent(
207 static HRESULT WINAPI
DefaultHandler_GetExtent(
211 static HRESULT WINAPI
DefaultHandler_Advise(
213 IAdviseSink
* pAdvSink
,
214 DWORD
* pdwConnection
);
215 static HRESULT WINAPI
DefaultHandler_Unadvise(
218 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
220 IEnumSTATDATA
** ppenumAdvise
);
221 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
225 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
227 struct tagLOGPALETTE
* pLogpal
);
230 * Prototypes for the methods of the DefaultHandler class
231 * that implement IDataObject methods.
233 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
237 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
239 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
241 static HRESULT WINAPI
DefaultHandler_GetData(
243 LPFORMATETC pformatetcIn
,
245 static HRESULT WINAPI
DefaultHandler_GetDataHere(
247 LPFORMATETC pformatetc
,
249 static HRESULT WINAPI
DefaultHandler_QueryGetData(
251 LPFORMATETC pformatetc
);
252 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
254 LPFORMATETC pformatectIn
,
255 LPFORMATETC pformatetcOut
);
256 static HRESULT WINAPI
DefaultHandler_SetData(
258 LPFORMATETC pformatetc
,
261 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
264 IEnumFORMATETC
** ppenumFormatEtc
);
265 static HRESULT WINAPI
DefaultHandler_DAdvise(
267 FORMATETC
* pformatetc
,
269 IAdviseSink
* pAdvSink
,
270 DWORD
* pdwConnection
);
271 static HRESULT WINAPI
DefaultHandler_DUnadvise(
274 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
276 IEnumSTATDATA
** ppenumAdvise
);
279 * Prototypes for the methods of the DefaultHandler class
280 * that implement IRunnableObject methods.
282 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
283 IRunnableObject
* iface
,
286 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
287 IRunnableObject
* iface
);
288 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
289 IRunnableObject
* iface
);
290 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
291 IRunnableObject
* iface
,
293 static HRESULT WINAPI
DefaultHandler_Run(
294 IRunnableObject
* iface
,
296 static BOOL WINAPI
DefaultHandler_IsRunning(
297 IRunnableObject
* iface
);
298 static HRESULT WINAPI
DefaultHandler_LockRunning(
299 IRunnableObject
* iface
,
301 BOOL fLastUnlockCloses
);
302 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
303 IRunnableObject
* iface
,
308 * Virtual function tables for the DefaultHandler class.
310 static ICOM_VTABLE(IOleObject
) DefaultHandler_IOleObject_VTable
=
312 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
313 DefaultHandler_QueryInterface
,
314 DefaultHandler_AddRef
,
315 DefaultHandler_Release
,
316 DefaultHandler_SetClientSite
,
317 DefaultHandler_GetClientSite
,
318 DefaultHandler_SetHostNames
,
319 DefaultHandler_Close
,
320 DefaultHandler_SetMoniker
,
321 DefaultHandler_GetMoniker
,
322 DefaultHandler_InitFromData
,
323 DefaultHandler_GetClipboardData
,
324 DefaultHandler_DoVerb
,
325 DefaultHandler_EnumVerbs
,
326 DefaultHandler_Update
,
327 DefaultHandler_IsUpToDate
,
328 DefaultHandler_GetUserClassID
,
329 DefaultHandler_GetUserType
,
330 DefaultHandler_SetExtent
,
331 DefaultHandler_GetExtent
,
332 DefaultHandler_Advise
,
333 DefaultHandler_Unadvise
,
334 DefaultHandler_EnumAdvise
,
335 DefaultHandler_GetMiscStatus
,
336 DefaultHandler_SetColorScheme
339 static ICOM_VTABLE(IUnknown
) DefaultHandler_NDIUnknown_VTable
=
341 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
342 DefaultHandler_NDIUnknown_QueryInterface
,
343 DefaultHandler_NDIUnknown_AddRef
,
344 DefaultHandler_NDIUnknown_Release
,
347 static ICOM_VTABLE(IDataObject
) DefaultHandler_IDataObject_VTable
=
349 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
350 DefaultHandler_IDataObject_QueryInterface
,
351 DefaultHandler_IDataObject_AddRef
,
352 DefaultHandler_IDataObject_Release
,
353 DefaultHandler_GetData
,
354 DefaultHandler_GetDataHere
,
355 DefaultHandler_QueryGetData
,
356 DefaultHandler_GetCanonicalFormatEtc
,
357 DefaultHandler_SetData
,
358 DefaultHandler_EnumFormatEtc
,
359 DefaultHandler_DAdvise
,
360 DefaultHandler_DUnadvise
,
361 DefaultHandler_EnumDAdvise
364 static ICOM_VTABLE(IRunnableObject
) DefaultHandler_IRunnableObject_VTable
=
366 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
367 DefaultHandler_IRunnableObject_QueryInterface
,
368 DefaultHandler_IRunnableObject_AddRef
,
369 DefaultHandler_IRunnableObject_Release
,
370 DefaultHandler_GetRunningClass
,
372 DefaultHandler_IsRunning
,
373 DefaultHandler_LockRunning
,
374 DefaultHandler_SetContainedObject
377 /******************************************************************************
378 * OleCreateDefaultHandler [OLE32.90]
380 HRESULT WINAPI
OleCreateDefaultHandler(
386 DefaultHandler
* newHandler
= NULL
;
389 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid
), pUnkOuter
, debugstr_guid(riid
), ppvObj
);
400 * If this handler is constructed for aggregation, make sure
401 * the caller is requesting the IUnknown interface.
402 * This is necessary because it's the only time the non-delegating
403 * IUnknown pointer can be returned to the outside.
405 if ( (pUnkOuter
!=NULL
) &&
406 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
407 return CLASS_E_NOAGGREGATION
;
410 * Try to construct a new instance of the class.
412 newHandler
= DefaultHandler_Construct(clsid
,
416 return E_OUTOFMEMORY
;
419 * Make sure it supports the interface required by the caller.
421 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
424 * Release the reference obtained in the constructor. If
425 * the QueryInterface was unsuccessful, it will free the class.
427 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
432 /*********************************************************
433 * Methods implementation for the DefaultHandler class.
435 static DefaultHandler
* DefaultHandler_Construct(
439 DefaultHandler
* newObject
= 0;
442 * Allocate space for the object.
444 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
450 * Initialize the virtual function table.
452 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
453 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
454 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
455 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
458 * Start with one reference count. The caller of this function
459 * must release the interface pointer when it is done.
464 * Initialize the outer unknown
465 * We don't keep a reference on the outer unknown since, the way
466 * aggregation works, our lifetime is at least as large as it's
470 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
472 newObject
->outerUnknown
= pUnkOuter
;
475 * Create a datacache object.
476 * We aggregate with the datacache. Make sure we pass our outer
477 * unknown as the datacache's outer unknown.
479 CreateDataCache(newObject
->outerUnknown
,
482 (void**)&newObject
->dataCache
);
485 * Initialize the other data members of the class.
487 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
488 newObject
->clientSite
= NULL
;
489 newObject
->oleAdviseHolder
= NULL
;
490 newObject
->dataAdviseHolder
= NULL
;
491 newObject
->containerApp
= NULL
;
492 newObject
->containerObj
= NULL
;
497 static void DefaultHandler_Destroy(
498 DefaultHandler
* ptrToDestroy
)
501 * Free the strings idenfitying the object
503 if (ptrToDestroy
->containerApp
!=NULL
)
505 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerApp
);
506 ptrToDestroy
->containerApp
= NULL
;
509 if (ptrToDestroy
->containerObj
!=NULL
)
511 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerObj
);
512 ptrToDestroy
->containerObj
= NULL
;
516 * Release our reference to the data cache.
518 if (ptrToDestroy
->dataCache
!=NULL
)
520 IUnknown_Release(ptrToDestroy
->dataCache
);
521 ptrToDestroy
->dataCache
= NULL
;
525 * Same thing for the client site.
527 if (ptrToDestroy
->clientSite
!=NULL
)
529 IOleClientSite_Release(ptrToDestroy
->clientSite
);
530 ptrToDestroy
->clientSite
= NULL
;
534 * And the advise holder.
536 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
538 IOleAdviseHolder_Release(ptrToDestroy
->oleAdviseHolder
);
539 ptrToDestroy
->oleAdviseHolder
= NULL
;
543 * And the data advise holder.
545 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
547 IDataAdviseHolder_Release(ptrToDestroy
->dataAdviseHolder
);
548 ptrToDestroy
->dataAdviseHolder
= NULL
;
553 * Free the actual default handler structure.
555 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
558 /*********************************************************
559 * Method implementation for the non delegating IUnknown
560 * part of the DefaultHandler class.
563 /************************************************************************
564 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
566 * See Windows documentation for more details on IUnknown methods.
568 * This version of QueryInterface will not delegate it's implementation
569 * to the outer unknown.
571 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
576 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
579 * Perform a sanity check on the parameters.
581 if ( (this==0) || (ppvObject
==0) )
585 * Initialize the return parameter.
590 * Compare the riid with the interface IDs implemented by this object.
592 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
596 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
598 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
600 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
602 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
604 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
606 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
611 * Blind aggregate the data cache to "inherit" it's interfaces.
613 if (IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
) == S_OK
)
618 * Check that we obtained an interface.
622 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid
));
623 return E_NOINTERFACE
;
627 * Query Interface always increases the reference count by one when it is
630 IUnknown_AddRef((IUnknown
*)*ppvObject
);
635 /************************************************************************
636 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
638 * See Windows documentation for more details on IUnknown methods.
640 * This version of QueryInterface will not delegate it's implementation
641 * to the outer unknown.
643 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
646 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
653 /************************************************************************
654 * DefaultHandler_NDIUnknown_Release (IUnknown)
656 * See Windows documentation for more details on IUnknown methods.
658 * This version of QueryInterface will not delegate it's implementation
659 * to the outer unknown.
661 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
664 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
667 * Decrease the reference count on this object.
672 * If the reference count goes down to 0, perform suicide.
676 DefaultHandler_Destroy(this);
684 /*********************************************************
685 * Methods implementation for the IOleObject part of
686 * the DefaultHandler class.
689 /************************************************************************
690 * DefaultHandler_QueryInterface (IUnknown)
692 * See Windows documentation for more details on IUnknown methods.
694 static HRESULT WINAPI
DefaultHandler_QueryInterface(
699 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
701 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
704 /************************************************************************
705 * DefaultHandler_AddRef (IUnknown)
707 * See Windows documentation for more details on IUnknown methods.
709 static ULONG WINAPI
DefaultHandler_AddRef(
712 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
714 return IUnknown_AddRef(this->outerUnknown
);
717 /************************************************************************
718 * DefaultHandler_Release (IUnknown)
720 * See Windows documentation for more details on IUnknown methods.
722 static ULONG WINAPI
DefaultHandler_Release(
725 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
727 return IUnknown_Release(this->outerUnknown
);
730 /************************************************************************
731 * DefaultHandler_SetClientSite (IOleObject)
733 * The default handler's implementation of this method only keeps the
734 * client site pointer for future reference.
736 * See Windows documentation for more details on IOleObject methods.
738 static HRESULT WINAPI
DefaultHandler_SetClientSite(
740 IOleClientSite
* pClientSite
)
742 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
744 TRACE("(%p, %p)\n", iface
, pClientSite
);
747 * Make sure we release the previous client site if there
750 if (this->clientSite
!=NULL
)
752 IOleClientSite_Release(this->clientSite
);
755 this->clientSite
= pClientSite
;
757 if (this->clientSite
!=NULL
)
759 IOleClientSite_AddRef(this->clientSite
);
765 /************************************************************************
766 * DefaultHandler_GetClientSite (IOleObject)
768 * The default handler's implementation of this method returns the
769 * last pointer set in IOleObject_SetClientSite.
771 * See Windows documentation for more details on IOleObject methods.
773 static HRESULT WINAPI
DefaultHandler_GetClientSite(
775 IOleClientSite
** ppClientSite
)
777 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
782 if (ppClientSite
== NULL
)
785 *ppClientSite
= this->clientSite
;
787 if (this->clientSite
!= NULL
)
789 IOleClientSite_AddRef(this->clientSite
);
795 /************************************************************************
796 * DefaultHandler_SetHostNames (IOleObject)
798 * The default handler's implementation of this method just stores
799 * the strings and returns S_OK.
801 * See Windows documentation for more details on IOleObject methods.
803 static HRESULT WINAPI
DefaultHandler_SetHostNames(
805 LPCOLESTR szContainerApp
,
806 LPCOLESTR szContainerObj
)
808 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
810 TRACE("(%p, %s, %s)\n",
812 debugstr_w(szContainerApp
),
813 debugstr_w(szContainerObj
));
816 * Be sure to cleanup before re-assinging the strings.
818 if (this->containerApp
!=NULL
)
820 HeapFree( GetProcessHeap(), 0, this->containerApp
);
821 this->containerApp
= NULL
;
824 if (this->containerObj
!=NULL
)
826 HeapFree( GetProcessHeap(), 0, this->containerObj
);
827 this->containerObj
= NULL
;
831 * Copy the string supplied.
833 if (szContainerApp
!= NULL
)
835 if ((this->containerApp
= HeapAlloc( GetProcessHeap(), 0,
836 (lstrlenW(szContainerApp
) + 1) * sizeof(WCHAR
) )))
837 strcpyW( this->containerApp
, szContainerApp
);
840 if (szContainerObj
!= NULL
)
842 if ((this->containerObj
= HeapAlloc( GetProcessHeap(), 0,
843 (lstrlenW(szContainerObj
) + 1) * sizeof(WCHAR
) )))
844 strcpyW( this->containerObj
, szContainerObj
);
849 /************************************************************************
850 * DefaultHandler_Close (IOleObject)
852 * The default handler's implementation of this method is meaningless
853 * without a running server so it does nothing.
855 * See Windows documentation for more details on IOleObject methods.
857 static HRESULT WINAPI
DefaultHandler_Close(
865 /************************************************************************
866 * DefaultHandler_SetMoniker (IOleObject)
868 * The default handler's implementation of this method does nothing.
870 * See Windows documentation for more details on IOleObject methods.
872 static HRESULT WINAPI
DefaultHandler_SetMoniker(
874 DWORD dwWhichMoniker
,
877 TRACE("(%p, %ld, %p)\n",
885 /************************************************************************
886 * DefaultHandler_GetMoniker (IOleObject)
888 * Delegate this request to the client site if we have one.
890 * See Windows documentation for more details on IOleObject methods.
892 static HRESULT WINAPI
DefaultHandler_GetMoniker(
895 DWORD dwWhichMoniker
,
898 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
900 TRACE("(%p, %ld, %ld, %p)\n",
901 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
903 if (this->clientSite
)
905 return IOleClientSite_GetMoniker(this->clientSite
,
915 /************************************************************************
916 * DefaultHandler_InitFromData (IOleObject)
918 * This method is meaningless if the server is not running
920 * See Windows documentation for more details on IOleObject methods.
922 static HRESULT WINAPI
DefaultHandler_InitFromData(
924 IDataObject
* pDataObject
,
928 TRACE("(%p, %p, %d, %ld)\n",
929 iface
, pDataObject
, fCreation
, dwReserved
);
931 return OLE_E_NOTRUNNING
;
934 /************************************************************************
935 * DefaultHandler_GetClipboardData (IOleObject)
937 * This method is meaningless if the server is not running
939 * See Windows documentation for more details on IOleObject methods.
941 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
944 IDataObject
** ppDataObject
)
946 TRACE("(%p, %ld, %p)\n",
947 iface
, dwReserved
, ppDataObject
);
949 return OLE_E_NOTRUNNING
;
952 static HRESULT WINAPI
DefaultHandler_DoVerb(
955 struct tagMSG
* lpmsg
,
956 IOleClientSite
* pActiveSite
,
965 /************************************************************************
966 * DefaultHandler_EnumVerbs (IOleObject)
968 * The default handler implementation of this method simply delegates
971 * See Windows documentation for more details on IOleObject methods.
973 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
975 IEnumOLEVERB
** ppEnumOleVerb
)
977 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
979 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
981 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
984 static HRESULT WINAPI
DefaultHandler_Update(
991 /************************************************************************
992 * DefaultHandler_IsUpToDate (IOleObject)
994 * This method is meaningless if the server is not running
996 * See Windows documentation for more details on IOleObject methods.
998 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
1001 TRACE("(%p)\n", iface
);
1003 return OLE_E_NOTRUNNING
;
1006 /************************************************************************
1007 * DefaultHandler_GetUserClassID (IOleObject)
1009 * TODO: Map to a new class ID if emulation is active.
1011 * See Windows documentation for more details on IOleObject methods.
1013 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1017 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1019 TRACE("(%p, %p)\n", iface
, pClsid
);
1027 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1032 /************************************************************************
1033 * DefaultHandler_GetUserType (IOleObject)
1035 * The default handler implementation of this method simply delegates
1036 * to OleRegGetUserType
1038 * See Windows documentation for more details on IOleObject methods.
1040 static HRESULT WINAPI
DefaultHandler_GetUserType(
1043 LPOLESTR
* pszUserType
)
1045 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1047 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1049 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1052 /************************************************************************
1053 * DefaultHandler_SetExtent (IOleObject)
1055 * This method is meaningless if the server is not running
1057 * See Windows documentation for more details on IOleObject methods.
1059 static HRESULT WINAPI
DefaultHandler_SetExtent(
1064 TRACE("(%p, %lx, (%ld x %ld))\n", iface
,
1065 dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1066 return OLE_E_NOTRUNNING
;
1069 /************************************************************************
1070 * DefaultHandler_GetExtent (IOleObject)
1072 * The default handler's implementation of this method returns uses
1073 * the cache to locate the aspect and extract the extent from it.
1075 * See Windows documentation for more details on IOleObject methods.
1077 static HRESULT WINAPI
DefaultHandler_GetExtent(
1082 DVTARGETDEVICE
* targetDevice
;
1083 IViewObject2
* cacheView
= NULL
;
1086 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1088 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1090 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1093 return E_UNEXPECTED
;
1096 * Prepare the call to the cache's GetExtent method.
1098 * Here we would build a valid DVTARGETDEVICE structure
1099 * but, since we are calling into the data cache, we
1100 * know it's implementation and we'll skip this
1101 * extra work until later.
1103 targetDevice
= NULL
;
1105 hres
= IViewObject2_GetExtent(cacheView
,
1114 IViewObject2_Release(cacheView
);
1119 /************************************************************************
1120 * DefaultHandler_Advise (IOleObject)
1122 * The default handler's implementation of this method simply
1123 * delegates to the OleAdviseHolder.
1125 * See Windows documentation for more details on IOleObject methods.
1127 static HRESULT WINAPI
DefaultHandler_Advise(
1129 IAdviseSink
* pAdvSink
,
1130 DWORD
* pdwConnection
)
1132 HRESULT hres
= S_OK
;
1133 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1135 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1138 * Make sure we have an advise holder before we start.
1140 if (this->oleAdviseHolder
==NULL
)
1142 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1145 if (SUCCEEDED(hres
))
1147 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1155 /************************************************************************
1156 * DefaultHandler_Unadvise (IOleObject)
1158 * The default handler's implementation of this method simply
1159 * delegates to the OleAdviseHolder.
1161 * See Windows documentation for more details on IOleObject methods.
1163 static HRESULT WINAPI
DefaultHandler_Unadvise(
1167 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1169 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1172 * If we don't have an advise holder yet, it means we don't have
1175 if (this->oleAdviseHolder
==NULL
)
1176 return OLE_E_NOCONNECTION
;
1178 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1182 /************************************************************************
1183 * DefaultHandler_EnumAdvise (IOleObject)
1185 * The default handler's implementation of this method simply
1186 * delegates to the OleAdviseHolder.
1188 * See Windows documentation for more details on IOleObject methods.
1190 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1192 IEnumSTATDATA
** ppenumAdvise
)
1194 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1196 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1201 if (ppenumAdvise
==NULL
)
1205 * Initialize the out parameter.
1207 *ppenumAdvise
= NULL
;
1209 if (this->oleAdviseHolder
==NULL
)
1210 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1216 /************************************************************************
1217 * DefaultHandler_GetMiscStatus (IOleObject)
1219 * The default handler's implementation of this method simply delegates
1220 * to OleRegGetMiscStatus.
1222 * See Windows documentation for more details on IOleObject methods.
1224 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1230 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1232 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1234 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1242 /************************************************************************
1243 * DefaultHandler_SetExtent (IOleObject)
1245 * This method is meaningless if the server is not running
1247 * See Windows documentation for more details on IOleObject methods.
1249 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1251 struct tagLOGPALETTE
* pLogpal
)
1253 TRACE("(%p, %p))\n", iface
, pLogpal
);
1254 return OLE_E_NOTRUNNING
;
1257 /*********************************************************
1258 * Methods implementation for the IDataObject part of
1259 * the DefaultHandler class.
1262 /************************************************************************
1263 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1265 * See Windows documentation for more details on IUnknown methods.
1267 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1272 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1274 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1277 /************************************************************************
1278 * DefaultHandler_IDataObject_AddRef (IUnknown)
1280 * See Windows documentation for more details on IUnknown methods.
1282 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1285 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1287 return IUnknown_AddRef(this->outerUnknown
);
1290 /************************************************************************
1291 * DefaultHandler_IDataObject_Release (IUnknown)
1293 * See Windows documentation for more details on IUnknown methods.
1295 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1298 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1300 return IUnknown_Release(this->outerUnknown
);
1303 /************************************************************************
1304 * DefaultHandler_GetData
1306 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1307 * See Windows documentation for more details on GetData.
1308 * Default handler's implementation of this method delegates to the cache.
1310 static HRESULT WINAPI
DefaultHandler_GetData(
1312 LPFORMATETC pformatetcIn
,
1315 IDataObject
* cacheDataObject
= NULL
;
1318 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1320 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1322 hres
= IUnknown_QueryInterface(this->dataCache
,
1324 (void**)&cacheDataObject
);
1327 return E_UNEXPECTED
;
1329 hres
= IDataObject_GetData(cacheDataObject
,
1333 IDataObject_Release(cacheDataObject
);
1338 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1340 LPFORMATETC pformatetc
,
1347 /************************************************************************
1348 * DefaultHandler_QueryGetData (IDataObject)
1350 * The default handler's implementation of this method delegates to
1353 * See Windows documentation for more details on IDataObject methods.
1355 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1357 LPFORMATETC pformatetc
)
1359 IDataObject
* cacheDataObject
= NULL
;
1362 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1364 TRACE("(%p, %p)\n", iface
, pformatetc
);
1366 hres
= IUnknown_QueryInterface(this->dataCache
,
1368 (void**)&cacheDataObject
);
1371 return E_UNEXPECTED
;
1373 hres
= IDataObject_QueryGetData(cacheDataObject
,
1376 IDataObject_Release(cacheDataObject
);
1381 /************************************************************************
1382 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1384 * This method is meaningless if the server is not running
1386 * See Windows documentation for more details on IDataObject methods.
1388 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1390 LPFORMATETC pformatectIn
,
1391 LPFORMATETC pformatetcOut
)
1393 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1395 return OLE_E_NOTRUNNING
;
1398 /************************************************************************
1399 * DefaultHandler_SetData (IDataObject)
1401 * The default handler's implementation of this method delegates to
1404 * See Windows documentation for more details on IDataObject methods.
1406 static HRESULT WINAPI
DefaultHandler_SetData(
1408 LPFORMATETC pformatetc
,
1412 IDataObject
* cacheDataObject
= NULL
;
1415 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1417 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1419 hres
= IUnknown_QueryInterface(this->dataCache
,
1421 (void**)&cacheDataObject
);
1424 return E_UNEXPECTED
;
1426 hres
= IDataObject_SetData(cacheDataObject
,
1431 IDataObject_Release(cacheDataObject
);
1436 /************************************************************************
1437 * DefaultHandler_EnumFormatEtc (IDataObject)
1439 * The default handler's implementation of this method simply delegates
1440 * to OleRegEnumFormatEtc.
1442 * See Windows documentation for more details on IDataObject methods.
1444 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1447 IEnumFORMATETC
** ppenumFormatEtc
)
1450 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1452 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1454 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1459 /************************************************************************
1460 * DefaultHandler_DAdvise (IDataObject)
1462 * The default handler's implementation of this method simply
1463 * delegates to the DataAdviseHolder.
1465 * See Windows documentation for more details on IDataObject methods.
1467 static HRESULT WINAPI
DefaultHandler_DAdvise(
1469 FORMATETC
* pformatetc
,
1471 IAdviseSink
* pAdvSink
,
1472 DWORD
* pdwConnection
)
1474 HRESULT hres
= S_OK
;
1475 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1477 TRACE("(%p, %p, %ld, %p, %p)\n",
1478 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1481 * Make sure we have a data advise holder before we start.
1483 if (this->dataAdviseHolder
==NULL
)
1485 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1488 if (SUCCEEDED(hres
))
1490 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1501 /************************************************************************
1502 * DefaultHandler_DUnadvise (IDataObject)
1504 * The default handler's implementation of this method simply
1505 * delegates to the DataAdviseHolder.
1507 * See Windows documentation for more details on IDataObject methods.
1509 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1513 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1515 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1518 * If we don't have a data advise holder yet, it means that
1519 * we don't have any connections..
1521 if (this->dataAdviseHolder
==NULL
)
1523 return OLE_E_NOCONNECTION
;
1526 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1530 /************************************************************************
1531 * DefaultHandler_EnumDAdvise (IDataObject)
1533 * The default handler's implementation of this method simply
1534 * delegates to the DataAdviseHolder.
1536 * See Windows documentation for more details on IDataObject methods.
1538 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1540 IEnumSTATDATA
** ppenumAdvise
)
1542 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1544 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1549 if (ppenumAdvise
== NULL
)
1553 * Initialize the out parameter.
1555 *ppenumAdvise
= NULL
;
1558 * If we have a data advise holder object, delegate.
1560 if (this->dataAdviseHolder
!=NULL
)
1562 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1569 /*********************************************************
1570 * Methods implementation for the IRunnableObject part
1571 * of the DefaultHandler class.
1574 /************************************************************************
1575 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1577 * See Windows documentation for more details on IUnknown methods.
1579 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1580 IRunnableObject
* iface
,
1584 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1586 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1589 /************************************************************************
1590 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1592 * See Windows documentation for more details on IUnknown methods.
1594 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1595 IRunnableObject
* iface
)
1597 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1599 return IUnknown_AddRef(this->outerUnknown
);
1602 /************************************************************************
1603 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1605 * See Windows documentation for more details on IUnknown methods.
1607 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1608 IRunnableObject
* iface
)
1610 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1612 return IUnknown_Release(this->outerUnknown
);
1615 /************************************************************************
1616 * DefaultHandler_GetRunningClass (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 HRESULT WINAPI
DefaultHandler_GetRunningClass(
1625 IRunnableObject
* iface
,
1632 static HRESULT WINAPI
DefaultHandler_Run(
1633 IRunnableObject
* iface
,
1640 /************************************************************************
1641 * DefaultHandler_IsRunning (IRunnableObject)
1643 * According to Brockscmidt, Chapter 19, the default handler's
1644 * implementation of IRunnableobject does nothing until the object
1645 * is actually running.
1647 * See Windows documentation for more details on IRunnableObject methods.
1649 static BOOL WINAPI
DefaultHandler_IsRunning(
1650 IRunnableObject
* iface
)
1656 /************************************************************************
1657 * DefaultHandler_LockRunning (IRunnableObject)
1659 * According to Brockscmidt, Chapter 19, the default handler's
1660 * implementation of IRunnableobject does nothing until the object
1661 * is actually running.
1663 * See Windows documentation for more details on IRunnableObject methods.
1665 static HRESULT WINAPI
DefaultHandler_LockRunning(
1666 IRunnableObject
* iface
,
1668 BOOL fLastUnlockCloses
)
1674 /************************************************************************
1675 * DefaultHandler_SetContainedObject (IRunnableObject)
1677 * According to Brockscmidt, Chapter 19, the default handler's
1678 * implementation of IRunnableobject does nothing until the object
1679 * is actually running.
1681 * See Windows documentation for more details on IRunnableObject methods.
1683 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1684 IRunnableObject
* iface
,