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.
38 #include "wine/unicode.h"
40 #include "wine/obj_oleview.h"
41 #include "debugtools.h"
43 DEFAULT_DEBUG_CHANNEL(ole
);
45 /****************************************************************************
52 * List all interface VTables here
54 ICOM_VTABLE(IOleObject
)* lpvtbl1
;
55 ICOM_VTABLE(IUnknown
)* lpvtbl2
;
56 ICOM_VTABLE(IDataObject
)* lpvtbl3
;
57 ICOM_VTABLE(IRunnableObject
)* lpvtbl4
;
60 * Reference count of this object
65 * IUnknown implementation of the outer object.
67 IUnknown
* outerUnknown
;
70 * Class Id that this handler object represents.
75 * IUnknown implementation of the datacache.
80 * Client site for the embedded object.
82 IOleClientSite
* clientSite
;
85 * The IOleAdviseHolder maintains the connections
86 * on behalf of the default handler.
88 IOleAdviseHolder
* oleAdviseHolder
;
91 * The IDataAdviseHolder maintains the data
92 * connections on behalf of the default handler.
94 IDataAdviseHolder
* dataAdviseHolder
;
97 * Name of the container and object contained
104 typedef struct DefaultHandler DefaultHandler
;
107 * Here, I define utility macros to help with the casting of the
109 * There is a version to accomodate all of the VTables implemented
112 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
113 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
114 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
115 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
118 * Prototypes for the methods of the DefaultHandler class.
120 static DefaultHandler
* DefaultHandler_Construct(REFCLSID clsid
,
121 LPUNKNOWN pUnkOuter
);
122 static void DefaultHandler_Destroy(DefaultHandler
* ptrToDestroy
);
125 * Prototypes for the methods of the DefaultHandler class
126 * that implement non delegating IUnknown methods.
128 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
132 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
134 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
138 * Prototypes for the methods of the DefaultHandler class
139 * that implement IOleObject methods.
141 static HRESULT WINAPI
DefaultHandler_QueryInterface(
145 static ULONG WINAPI
DefaultHandler_AddRef(
147 static ULONG WINAPI
DefaultHandler_Release(
149 static HRESULT WINAPI
DefaultHandler_SetClientSite(
151 IOleClientSite
* pClientSite
);
152 static HRESULT WINAPI
DefaultHandler_GetClientSite(
154 IOleClientSite
** ppClientSite
);
155 static HRESULT WINAPI
DefaultHandler_SetHostNames(
157 LPCOLESTR szContainerApp
,
158 LPCOLESTR szContainerObj
);
159 static HRESULT WINAPI
DefaultHandler_Close(
162 static HRESULT WINAPI
DefaultHandler_SetMoniker(
164 DWORD dwWhichMoniker
,
166 static HRESULT WINAPI
DefaultHandler_GetMoniker(
169 DWORD dwWhichMoniker
,
171 static HRESULT WINAPI
DefaultHandler_InitFromData(
173 IDataObject
* pDataObject
,
176 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
179 IDataObject
** ppDataObject
);
180 static HRESULT WINAPI
DefaultHandler_DoVerb(
183 struct tagMSG
* lpmsg
,
184 IOleClientSite
* pActiveSite
,
187 LPCRECT lprcPosRect
);
188 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
190 IEnumOLEVERB
** ppEnumOleVerb
);
191 static HRESULT WINAPI
DefaultHandler_Update(
193 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
195 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
198 static HRESULT WINAPI
DefaultHandler_GetUserType(
201 LPOLESTR
* pszUserType
);
202 static HRESULT WINAPI
DefaultHandler_SetExtent(
206 static HRESULT WINAPI
DefaultHandler_GetExtent(
210 static HRESULT WINAPI
DefaultHandler_Advise(
212 IAdviseSink
* pAdvSink
,
213 DWORD
* pdwConnection
);
214 static HRESULT WINAPI
DefaultHandler_Unadvise(
217 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
219 IEnumSTATDATA
** ppenumAdvise
);
220 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
224 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
226 struct tagLOGPALETTE
* pLogpal
);
229 * Prototypes for the methods of the DefaultHandler class
230 * that implement IDataObject methods.
232 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
236 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
238 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
240 static HRESULT WINAPI
DefaultHandler_GetData(
242 LPFORMATETC pformatetcIn
,
244 static HRESULT WINAPI
DefaultHandler_GetDataHere(
246 LPFORMATETC pformatetc
,
248 static HRESULT WINAPI
DefaultHandler_QueryGetData(
250 LPFORMATETC pformatetc
);
251 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
253 LPFORMATETC pformatectIn
,
254 LPFORMATETC pformatetcOut
);
255 static HRESULT WINAPI
DefaultHandler_SetData(
257 LPFORMATETC pformatetc
,
260 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
263 IEnumFORMATETC
** ppenumFormatEtc
);
264 static HRESULT WINAPI
DefaultHandler_DAdvise(
266 FORMATETC
* pformatetc
,
268 IAdviseSink
* pAdvSink
,
269 DWORD
* pdwConnection
);
270 static HRESULT WINAPI
DefaultHandler_DUnadvise(
273 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
275 IEnumSTATDATA
** ppenumAdvise
);
278 * Prototypes for the methods of the DefaultHandler class
279 * that implement IRunnableObject methods.
281 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
282 IRunnableObject
* iface
,
285 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
286 IRunnableObject
* iface
);
287 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
288 IRunnableObject
* iface
);
289 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
290 IRunnableObject
* iface
,
292 static HRESULT WINAPI
DefaultHandler_Run(
293 IRunnableObject
* iface
,
295 static BOOL WINAPI
DefaultHandler_IsRunning(
296 IRunnableObject
* iface
);
297 static HRESULT WINAPI
DefaultHandler_LockRunning(
298 IRunnableObject
* iface
,
300 BOOL fLastUnlockCloses
);
301 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
302 IRunnableObject
* iface
,
307 * Virtual function tables for the DefaultHandler class.
309 static ICOM_VTABLE(IOleObject
) DefaultHandler_IOleObject_VTable
=
311 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
312 DefaultHandler_QueryInterface
,
313 DefaultHandler_AddRef
,
314 DefaultHandler_Release
,
315 DefaultHandler_SetClientSite
,
316 DefaultHandler_GetClientSite
,
317 DefaultHandler_SetHostNames
,
318 DefaultHandler_Close
,
319 DefaultHandler_SetMoniker
,
320 DefaultHandler_GetMoniker
,
321 DefaultHandler_InitFromData
,
322 DefaultHandler_GetClipboardData
,
323 DefaultHandler_DoVerb
,
324 DefaultHandler_EnumVerbs
,
325 DefaultHandler_Update
,
326 DefaultHandler_IsUpToDate
,
327 DefaultHandler_GetUserClassID
,
328 DefaultHandler_GetUserType
,
329 DefaultHandler_SetExtent
,
330 DefaultHandler_GetExtent
,
331 DefaultHandler_Advise
,
332 DefaultHandler_Unadvise
,
333 DefaultHandler_EnumAdvise
,
334 DefaultHandler_GetMiscStatus
,
335 DefaultHandler_SetColorScheme
338 static ICOM_VTABLE(IUnknown
) DefaultHandler_NDIUnknown_VTable
=
340 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
341 DefaultHandler_NDIUnknown_QueryInterface
,
342 DefaultHandler_NDIUnknown_AddRef
,
343 DefaultHandler_NDIUnknown_Release
,
346 static ICOM_VTABLE(IDataObject
) DefaultHandler_IDataObject_VTable
=
348 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
349 DefaultHandler_IDataObject_QueryInterface
,
350 DefaultHandler_IDataObject_AddRef
,
351 DefaultHandler_IDataObject_Release
,
352 DefaultHandler_GetData
,
353 DefaultHandler_GetDataHere
,
354 DefaultHandler_QueryGetData
,
355 DefaultHandler_GetCanonicalFormatEtc
,
356 DefaultHandler_SetData
,
357 DefaultHandler_EnumFormatEtc
,
358 DefaultHandler_DAdvise
,
359 DefaultHandler_DUnadvise
,
360 DefaultHandler_EnumDAdvise
363 static ICOM_VTABLE(IRunnableObject
) DefaultHandler_IRunnableObject_VTable
=
365 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
366 DefaultHandler_IRunnableObject_QueryInterface
,
367 DefaultHandler_IRunnableObject_AddRef
,
368 DefaultHandler_IRunnableObject_Release
,
369 DefaultHandler_GetRunningClass
,
371 DefaultHandler_IsRunning
,
372 DefaultHandler_LockRunning
,
373 DefaultHandler_SetContainedObject
376 /******************************************************************************
377 * OleCreateDefaultHandler [OLE32.90]
379 HRESULT WINAPI
OleCreateDefaultHandler(
385 DefaultHandler
* newHandler
= NULL
;
388 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid
), pUnkOuter
, debugstr_guid(riid
), ppvObj
);
399 * If this handler is constructed for aggregation, make sure
400 * the caller is requesting the IUnknown interface.
401 * This is necessary because it's the only time the non-delegating
402 * IUnknown pointer can be returned to the outside.
404 if ( (pUnkOuter
!=NULL
) &&
405 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
406 return CLASS_E_NOAGGREGATION
;
409 * Try to construct a new instance of the class.
411 newHandler
= DefaultHandler_Construct(clsid
,
415 return E_OUTOFMEMORY
;
418 * Make sure it supports the interface required by the caller.
420 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
423 * Release the reference obtained in the constructor. If
424 * the QueryInterface was unsuccessful, it will free the class.
426 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
431 /*********************************************************
432 * Methods implementation for the DefaultHandler class.
434 static DefaultHandler
* DefaultHandler_Construct(
438 DefaultHandler
* newObject
= 0;
441 * Allocate space for the object.
443 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
449 * Initialize the virtual function table.
451 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
452 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
453 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
454 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
457 * Start with one reference count. The caller of this function
458 * must release the interface pointer when it is done.
463 * Initialize the outer unknown
464 * We don't keep a reference on the outer unknown since, the way
465 * aggregation works, our lifetime is at least as large as it's
469 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
471 newObject
->outerUnknown
= pUnkOuter
;
474 * Create a datacache object.
475 * We aggregate with the datacache. Make sure we pass our outer
476 * unknown as the datacache's outer unknown.
478 CreateDataCache(newObject
->outerUnknown
,
481 (void**)&newObject
->dataCache
);
484 * Initialize the other data members of the class.
486 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
487 newObject
->clientSite
= NULL
;
488 newObject
->oleAdviseHolder
= NULL
;
489 newObject
->dataAdviseHolder
= NULL
;
490 newObject
->containerApp
= NULL
;
491 newObject
->containerObj
= NULL
;
496 static void DefaultHandler_Destroy(
497 DefaultHandler
* ptrToDestroy
)
500 * Free the strings idenfitying the object
502 if (ptrToDestroy
->containerApp
!=NULL
)
504 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerApp
);
505 ptrToDestroy
->containerApp
= NULL
;
508 if (ptrToDestroy
->containerObj
!=NULL
)
510 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerObj
);
511 ptrToDestroy
->containerObj
= NULL
;
515 * Release our reference to the data cache.
517 if (ptrToDestroy
->dataCache
!=NULL
)
519 IUnknown_Release(ptrToDestroy
->dataCache
);
520 ptrToDestroy
->dataCache
= NULL
;
524 * Same thing for the client site.
526 if (ptrToDestroy
->clientSite
!=NULL
)
528 IOleClientSite_Release(ptrToDestroy
->clientSite
);
529 ptrToDestroy
->clientSite
= NULL
;
533 * And the advise holder.
535 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
537 IOleAdviseHolder_Release(ptrToDestroy
->oleAdviseHolder
);
538 ptrToDestroy
->oleAdviseHolder
= NULL
;
542 * And the data advise holder.
544 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
546 IDataAdviseHolder_Release(ptrToDestroy
->dataAdviseHolder
);
547 ptrToDestroy
->dataAdviseHolder
= NULL
;
552 * Free the actual default handler structure.
554 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
557 /*********************************************************
558 * Method implementation for the non delegating IUnknown
559 * part of the DefaultHandler class.
562 /************************************************************************
563 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
565 * See Windows documentation for more details on IUnknown methods.
567 * This version of QueryInterface will not delegate it's implementation
568 * to the outer unknown.
570 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
575 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
578 * Perform a sanity check on the parameters.
580 if ( (this==0) || (ppvObject
==0) )
584 * Initialize the return parameter.
589 * Compare the riid with the interface IDs implemented by this object.
591 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
595 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
597 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
599 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
601 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
603 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
605 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
610 * Blind aggregate the data cache to "inherit" it's interfaces.
612 if (IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
) == S_OK
)
617 * Check that we obtained an interface.
621 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid
));
622 return E_NOINTERFACE
;
626 * Query Interface always increases the reference count by one when it is
629 IUnknown_AddRef((IUnknown
*)*ppvObject
);
634 /************************************************************************
635 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
637 * See Windows documentation for more details on IUnknown methods.
639 * This version of QueryInterface will not delegate it's implementation
640 * to the outer unknown.
642 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
645 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
652 /************************************************************************
653 * DefaultHandler_NDIUnknown_Release (IUnknown)
655 * See Windows documentation for more details on IUnknown methods.
657 * This version of QueryInterface will not delegate it's implementation
658 * to the outer unknown.
660 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
663 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
666 * Decrease the reference count on this object.
671 * If the reference count goes down to 0, perform suicide.
675 DefaultHandler_Destroy(this);
683 /*********************************************************
684 * Methods implementation for the IOleObject part of
685 * the DefaultHandler class.
688 /************************************************************************
689 * DefaultHandler_QueryInterface (IUnknown)
691 * See Windows documentation for more details on IUnknown methods.
693 static HRESULT WINAPI
DefaultHandler_QueryInterface(
698 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
700 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
703 /************************************************************************
704 * DefaultHandler_AddRef (IUnknown)
706 * See Windows documentation for more details on IUnknown methods.
708 static ULONG WINAPI
DefaultHandler_AddRef(
711 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
713 return IUnknown_AddRef(this->outerUnknown
);
716 /************************************************************************
717 * DefaultHandler_Release (IUnknown)
719 * See Windows documentation for more details on IUnknown methods.
721 static ULONG WINAPI
DefaultHandler_Release(
724 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
726 return IUnknown_Release(this->outerUnknown
);
729 /************************************************************************
730 * DefaultHandler_SetClientSite (IOleObject)
732 * The default handler's implementation of this method only keeps the
733 * client site pointer for future reference.
735 * See Windows documentation for more details on IOleObject methods.
737 static HRESULT WINAPI
DefaultHandler_SetClientSite(
739 IOleClientSite
* pClientSite
)
741 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
743 TRACE("(%p, %p)\n", iface
, pClientSite
);
746 * Make sure we release the previous client site if there
749 if (this->clientSite
!=NULL
)
751 IOleClientSite_Release(this->clientSite
);
754 this->clientSite
= pClientSite
;
756 if (this->clientSite
!=NULL
)
758 IOleClientSite_AddRef(this->clientSite
);
764 /************************************************************************
765 * DefaultHandler_GetClientSite (IOleObject)
767 * The default handler's implementation of this method returns the
768 * last pointer set in IOleObject_SetClientSite.
770 * See Windows documentation for more details on IOleObject methods.
772 static HRESULT WINAPI
DefaultHandler_GetClientSite(
774 IOleClientSite
** ppClientSite
)
776 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
781 if (ppClientSite
== NULL
)
784 *ppClientSite
= this->clientSite
;
786 if (this->clientSite
!= NULL
)
788 IOleClientSite_AddRef(this->clientSite
);
794 /************************************************************************
795 * DefaultHandler_SetHostNames (IOleObject)
797 * The default handler's implementation of this method just stores
798 * the strings and returns S_OK.
800 * See Windows documentation for more details on IOleObject methods.
802 static HRESULT WINAPI
DefaultHandler_SetHostNames(
804 LPCOLESTR szContainerApp
,
805 LPCOLESTR szContainerObj
)
807 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
809 TRACE("(%p, %s, %s)\n",
811 debugstr_w(szContainerApp
),
812 debugstr_w(szContainerObj
));
815 * Be sure to cleanup before re-assinging the strings.
817 if (this->containerApp
!=NULL
)
819 HeapFree( GetProcessHeap(), 0, this->containerApp
);
820 this->containerApp
= NULL
;
823 if (this->containerObj
!=NULL
)
825 HeapFree( GetProcessHeap(), 0, this->containerObj
);
826 this->containerObj
= NULL
;
830 * Copy the string supplied.
832 if (szContainerApp
!= NULL
)
834 if ((this->containerApp
= HeapAlloc( GetProcessHeap(), 0,
835 (lstrlenW(szContainerApp
) + 1) * sizeof(WCHAR
) )))
836 strcpyW( this->containerApp
, szContainerApp
);
839 if (szContainerObj
!= NULL
)
841 if ((this->containerObj
= HeapAlloc( GetProcessHeap(), 0,
842 (lstrlenW(szContainerObj
) + 1) * sizeof(WCHAR
) )))
843 strcpyW( this->containerObj
, szContainerObj
);
848 /************************************************************************
849 * DefaultHandler_Close (IOleObject)
851 * The default handler's implementation of this method is meaningless
852 * without a running server so it does nothing.
854 * See Windows documentation for more details on IOleObject methods.
856 static HRESULT WINAPI
DefaultHandler_Close(
864 /************************************************************************
865 * DefaultHandler_SetMoniker (IOleObject)
867 * The default handler's implementation of this method does nothing.
869 * See Windows documentation for more details on IOleObject methods.
871 static HRESULT WINAPI
DefaultHandler_SetMoniker(
873 DWORD dwWhichMoniker
,
876 TRACE("(%p, %ld, %p)\n",
884 /************************************************************************
885 * DefaultHandler_GetMoniker (IOleObject)
887 * Delegate this request to the client site if we have one.
889 * See Windows documentation for more details on IOleObject methods.
891 static HRESULT WINAPI
DefaultHandler_GetMoniker(
894 DWORD dwWhichMoniker
,
897 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
899 TRACE("(%p, %ld, %ld, %p)\n",
900 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
902 if (this->clientSite
)
904 return IOleClientSite_GetMoniker(this->clientSite
,
914 /************************************************************************
915 * DefaultHandler_InitFromData (IOleObject)
917 * This method is meaningless if the server is not running
919 * See Windows documentation for more details on IOleObject methods.
921 static HRESULT WINAPI
DefaultHandler_InitFromData(
923 IDataObject
* pDataObject
,
927 TRACE("(%p, %p, %d, %ld)\n",
928 iface
, pDataObject
, fCreation
, dwReserved
);
930 return OLE_E_NOTRUNNING
;
933 /************************************************************************
934 * DefaultHandler_GetClipboardData (IOleObject)
936 * This method is meaningless if the server is not running
938 * See Windows documentation for more details on IOleObject methods.
940 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
943 IDataObject
** ppDataObject
)
945 TRACE("(%p, %ld, %p)\n",
946 iface
, dwReserved
, ppDataObject
);
948 return OLE_E_NOTRUNNING
;
951 static HRESULT WINAPI
DefaultHandler_DoVerb(
954 struct tagMSG
* lpmsg
,
955 IOleClientSite
* pActiveSite
,
964 /************************************************************************
965 * DefaultHandler_EnumVerbs (IOleObject)
967 * The default handler implementation of this method simply delegates
970 * See Windows documentation for more details on IOleObject methods.
972 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
974 IEnumOLEVERB
** ppEnumOleVerb
)
976 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
978 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
980 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
983 static HRESULT WINAPI
DefaultHandler_Update(
990 /************************************************************************
991 * DefaultHandler_IsUpToDate (IOleObject)
993 * This method is meaningless if the server is not running
995 * See Windows documentation for more details on IOleObject methods.
997 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
1000 TRACE("(%p)\n", iface
);
1002 return OLE_E_NOTRUNNING
;
1005 /************************************************************************
1006 * DefaultHandler_GetUserClassID (IOleObject)
1008 * TODO: Map to a new class ID if emulation is active.
1010 * See Windows documentation for more details on IOleObject methods.
1012 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1016 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1018 TRACE("(%p, %p)\n", iface
, pClsid
);
1026 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1031 /************************************************************************
1032 * DefaultHandler_GetUserType (IOleObject)
1034 * The default handler implementation of this method simply delegates
1035 * to OleRegGetUserType
1037 * See Windows documentation for more details on IOleObject methods.
1039 static HRESULT WINAPI
DefaultHandler_GetUserType(
1042 LPOLESTR
* pszUserType
)
1044 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1046 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1048 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1051 /************************************************************************
1052 * DefaultHandler_SetExtent (IOleObject)
1054 * This method is meaningless if the server is not running
1056 * See Windows documentation for more details on IOleObject methods.
1058 static HRESULT WINAPI
DefaultHandler_SetExtent(
1063 TRACE("(%p, %lx, (%ld x %ld))\n", iface
,
1064 dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1065 return OLE_E_NOTRUNNING
;
1068 /************************************************************************
1069 * DefaultHandler_GetExtent (IOleObject)
1071 * The default handler's implementation of this method returns uses
1072 * the cache to locate the aspect and extract the extent from it.
1074 * See Windows documentation for more details on IOleObject methods.
1076 static HRESULT WINAPI
DefaultHandler_GetExtent(
1081 DVTARGETDEVICE
* targetDevice
;
1082 IViewObject2
* cacheView
= NULL
;
1085 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1087 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1089 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1092 return E_UNEXPECTED
;
1095 * Prepare the call to the cache's GetExtent method.
1097 * Here we would build a valid DVTARGETDEVICE structure
1098 * but, since we are calling into the data cache, we
1099 * know it's implementation and we'll skip this
1100 * extra work until later.
1102 targetDevice
= NULL
;
1104 hres
= IViewObject2_GetExtent(cacheView
,
1113 IViewObject2_Release(cacheView
);
1118 /************************************************************************
1119 * DefaultHandler_Advise (IOleObject)
1121 * The default handler's implementation of this method simply
1122 * delegates to the OleAdviseHolder.
1124 * See Windows documentation for more details on IOleObject methods.
1126 static HRESULT WINAPI
DefaultHandler_Advise(
1128 IAdviseSink
* pAdvSink
,
1129 DWORD
* pdwConnection
)
1131 HRESULT hres
= S_OK
;
1132 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1134 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1137 * Make sure we have an advise holder before we start.
1139 if (this->oleAdviseHolder
==NULL
)
1141 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1144 if (SUCCEEDED(hres
))
1146 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1154 /************************************************************************
1155 * DefaultHandler_Unadvise (IOleObject)
1157 * The default handler's implementation of this method simply
1158 * delegates to the OleAdviseHolder.
1160 * See Windows documentation for more details on IOleObject methods.
1162 static HRESULT WINAPI
DefaultHandler_Unadvise(
1166 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1168 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1171 * If we don't have an advise holder yet, it means we don't have
1174 if (this->oleAdviseHolder
==NULL
)
1175 return OLE_E_NOCONNECTION
;
1177 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1181 /************************************************************************
1182 * DefaultHandler_EnumAdvise (IOleObject)
1184 * The default handler's implementation of this method simply
1185 * delegates to the OleAdviseHolder.
1187 * See Windows documentation for more details on IOleObject methods.
1189 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1191 IEnumSTATDATA
** ppenumAdvise
)
1193 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1195 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1200 if (ppenumAdvise
==NULL
)
1204 * Initialize the out parameter.
1206 *ppenumAdvise
= NULL
;
1208 if (this->oleAdviseHolder
==NULL
)
1209 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1215 /************************************************************************
1216 * DefaultHandler_GetMiscStatus (IOleObject)
1218 * The default handler's implementation of this method simply delegates
1219 * to OleRegGetMiscStatus.
1221 * See Windows documentation for more details on IOleObject methods.
1223 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1229 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1231 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1233 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1241 /************************************************************************
1242 * DefaultHandler_SetExtent (IOleObject)
1244 * This method is meaningless if the server is not running
1246 * See Windows documentation for more details on IOleObject methods.
1248 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1250 struct tagLOGPALETTE
* pLogpal
)
1252 TRACE("(%p, %p))\n", iface
, pLogpal
);
1253 return OLE_E_NOTRUNNING
;
1256 /*********************************************************
1257 * Methods implementation for the IDataObject part of
1258 * the DefaultHandler class.
1261 /************************************************************************
1262 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1264 * See Windows documentation for more details on IUnknown methods.
1266 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1271 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1273 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1276 /************************************************************************
1277 * DefaultHandler_IDataObject_AddRef (IUnknown)
1279 * See Windows documentation for more details on IUnknown methods.
1281 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1284 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1286 return IUnknown_AddRef(this->outerUnknown
);
1289 /************************************************************************
1290 * DefaultHandler_IDataObject_Release (IUnknown)
1292 * See Windows documentation for more details on IUnknown methods.
1294 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1297 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1299 return IUnknown_Release(this->outerUnknown
);
1302 /************************************************************************
1303 * DefaultHandler_GetData
1305 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1306 * See Windows documentation for more details on GetData.
1307 * Default handler's implementation of this method delegates to the cache.
1309 static HRESULT WINAPI
DefaultHandler_GetData(
1311 LPFORMATETC pformatetcIn
,
1314 IDataObject
* cacheDataObject
= NULL
;
1317 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1319 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1321 hres
= IUnknown_QueryInterface(this->dataCache
,
1323 (void**)&cacheDataObject
);
1326 return E_UNEXPECTED
;
1328 hres
= IDataObject_GetData(cacheDataObject
,
1332 IDataObject_Release(cacheDataObject
);
1337 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1339 LPFORMATETC pformatetc
,
1346 /************************************************************************
1347 * DefaultHandler_QueryGetData (IDataObject)
1349 * The default handler's implementation of this method delegates to
1352 * See Windows documentation for more details on IDataObject methods.
1354 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1356 LPFORMATETC pformatetc
)
1358 IDataObject
* cacheDataObject
= NULL
;
1361 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1363 TRACE("(%p, %p)\n", iface
, pformatetc
);
1365 hres
= IUnknown_QueryInterface(this->dataCache
,
1367 (void**)&cacheDataObject
);
1370 return E_UNEXPECTED
;
1372 hres
= IDataObject_QueryGetData(cacheDataObject
,
1375 IDataObject_Release(cacheDataObject
);
1380 /************************************************************************
1381 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1383 * This method is meaningless if the server is not running
1385 * See Windows documentation for more details on IDataObject methods.
1387 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1389 LPFORMATETC pformatectIn
,
1390 LPFORMATETC pformatetcOut
)
1392 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1394 return OLE_E_NOTRUNNING
;
1397 /************************************************************************
1398 * DefaultHandler_SetData (IDataObject)
1400 * The default handler's implementation of this method delegates to
1403 * See Windows documentation for more details on IDataObject methods.
1405 static HRESULT WINAPI
DefaultHandler_SetData(
1407 LPFORMATETC pformatetc
,
1411 IDataObject
* cacheDataObject
= NULL
;
1414 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1416 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1418 hres
= IUnknown_QueryInterface(this->dataCache
,
1420 (void**)&cacheDataObject
);
1423 return E_UNEXPECTED
;
1425 hres
= IDataObject_SetData(cacheDataObject
,
1430 IDataObject_Release(cacheDataObject
);
1435 /************************************************************************
1436 * DefaultHandler_EnumFormatEtc (IDataObject)
1438 * The default handler's implementation of this method simply delegates
1439 * to OleRegEnumFormatEtc.
1441 * See Windows documentation for more details on IDataObject methods.
1443 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1446 IEnumFORMATETC
** ppenumFormatEtc
)
1449 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1451 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1453 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1458 /************************************************************************
1459 * DefaultHandler_DAdvise (IDataObject)
1461 * The default handler's implementation of this method simply
1462 * delegates to the DataAdviseHolder.
1464 * See Windows documentation for more details on IDataObject methods.
1466 static HRESULT WINAPI
DefaultHandler_DAdvise(
1468 FORMATETC
* pformatetc
,
1470 IAdviseSink
* pAdvSink
,
1471 DWORD
* pdwConnection
)
1473 HRESULT hres
= S_OK
;
1474 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1476 TRACE("(%p, %p, %ld, %p, %p)\n",
1477 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1480 * Make sure we have a data advise holder before we start.
1482 if (this->dataAdviseHolder
==NULL
)
1484 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1487 if (SUCCEEDED(hres
))
1489 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1500 /************************************************************************
1501 * DefaultHandler_DUnadvise (IDataObject)
1503 * The default handler's implementation of this method simply
1504 * delegates to the DataAdviseHolder.
1506 * See Windows documentation for more details on IDataObject methods.
1508 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1512 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1514 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1517 * If we don't have a data advise holder yet, it means that
1518 * we don't have any connections..
1520 if (this->dataAdviseHolder
==NULL
)
1522 return OLE_E_NOCONNECTION
;
1525 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1529 /************************************************************************
1530 * DefaultHandler_EnumDAdvise (IDataObject)
1532 * The default handler's implementation of this method simply
1533 * delegates to the DataAdviseHolder.
1535 * See Windows documentation for more details on IDataObject methods.
1537 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1539 IEnumSTATDATA
** ppenumAdvise
)
1541 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1543 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1548 if (ppenumAdvise
== NULL
)
1552 * Initialize the out parameter.
1554 *ppenumAdvise
= NULL
;
1557 * If we have a data advise holder object, delegate.
1559 if (this->dataAdviseHolder
!=NULL
)
1561 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1568 /*********************************************************
1569 * Methods implementation for the IRunnableObject part
1570 * of the DefaultHandler class.
1573 /************************************************************************
1574 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1576 * See Windows documentation for more details on IUnknown methods.
1578 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1579 IRunnableObject
* iface
,
1583 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1585 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1588 /************************************************************************
1589 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1591 * See Windows documentation for more details on IUnknown methods.
1593 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1594 IRunnableObject
* iface
)
1596 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1598 return IUnknown_AddRef(this->outerUnknown
);
1601 /************************************************************************
1602 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1604 * See Windows documentation for more details on IUnknown methods.
1606 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1607 IRunnableObject
* iface
)
1609 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1611 return IUnknown_Release(this->outerUnknown
);
1614 /************************************************************************
1615 * DefaultHandler_GetRunningClass (IRunnableObject)
1617 * According to Brockscmidt, Chapter 19, the default handler's
1618 * implementation of IRunnableobject does nothing until the object
1619 * is actually running.
1621 * See Windows documentation for more details on IRunnableObject methods.
1623 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1624 IRunnableObject
* iface
,
1631 static HRESULT WINAPI
DefaultHandler_Run(
1632 IRunnableObject
* iface
,
1639 /************************************************************************
1640 * DefaultHandler_IsRunning (IRunnableObject)
1642 * According to Brockscmidt, Chapter 19, the default handler's
1643 * implementation of IRunnableobject does nothing until the object
1644 * is actually running.
1646 * See Windows documentation for more details on IRunnableObject methods.
1648 static BOOL WINAPI
DefaultHandler_IsRunning(
1649 IRunnableObject
* iface
)
1655 /************************************************************************
1656 * DefaultHandler_LockRunning (IRunnableObject)
1658 * According to Brockscmidt, Chapter 19, the default handler's
1659 * implementation of IRunnableobject does nothing until the object
1660 * is actually running.
1662 * See Windows documentation for more details on IRunnableObject methods.
1664 static HRESULT WINAPI
DefaultHandler_LockRunning(
1665 IRunnableObject
* iface
,
1667 BOOL fLastUnlockCloses
)
1673 /************************************************************************
1674 * DefaultHandler_SetContainedObject (IRunnableObject)
1676 * According to Brockscmidt, Chapter 19, the default handler's
1677 * implementation of IRunnableobject does nothing until the object
1678 * is actually running.
1680 * See Windows documentation for more details on IRunnableObject methods.
1682 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1683 IRunnableObject
* iface
,