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, (%d,%d))\n", iface
, dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1064 return OLE_E_NOTRUNNING
;
1067 /************************************************************************
1068 * DefaultHandler_GetExtent (IOleObject)
1070 * The default handler's implementation of this method returns uses
1071 * the cache to locate the aspect and extract the extent from it.
1073 * See Windows documentation for more details on IOleObject methods.
1075 static HRESULT WINAPI
DefaultHandler_GetExtent(
1080 DVTARGETDEVICE
* targetDevice
;
1081 IViewObject2
* cacheView
= NULL
;
1084 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1086 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1088 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1091 return E_UNEXPECTED
;
1094 * Prepare the call to the cache's GetExtent method.
1096 * Here we would build a valid DVTARGETDEVICE structure
1097 * but, since we are calling into the data cache, we
1098 * know it's implementation and we'll skip this
1099 * extra work until later.
1101 targetDevice
= NULL
;
1103 hres
= IViewObject2_GetExtent(cacheView
,
1112 IViewObject2_Release(cacheView
);
1117 /************************************************************************
1118 * DefaultHandler_Advise (IOleObject)
1120 * The default handler's implementation of this method simply
1121 * delegates to the OleAdviseHolder.
1123 * See Windows documentation for more details on IOleObject methods.
1125 static HRESULT WINAPI
DefaultHandler_Advise(
1127 IAdviseSink
* pAdvSink
,
1128 DWORD
* pdwConnection
)
1130 HRESULT hres
= S_OK
;
1131 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1133 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1136 * Make sure we have an advise holder before we start.
1138 if (this->oleAdviseHolder
==NULL
)
1140 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1143 if (SUCCEEDED(hres
))
1145 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1153 /************************************************************************
1154 * DefaultHandler_Unadvise (IOleObject)
1156 * The default handler's implementation of this method simply
1157 * delegates to the OleAdviseHolder.
1159 * See Windows documentation for more details on IOleObject methods.
1161 static HRESULT WINAPI
DefaultHandler_Unadvise(
1165 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1167 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1170 * If we don't have an advise holder yet, it means we don't have
1173 if (this->oleAdviseHolder
==NULL
)
1174 return OLE_E_NOCONNECTION
;
1176 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1180 /************************************************************************
1181 * DefaultHandler_EnumAdvise (IOleObject)
1183 * The default handler's implementation of this method simply
1184 * delegates to the OleAdviseHolder.
1186 * See Windows documentation for more details on IOleObject methods.
1188 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1190 IEnumSTATDATA
** ppenumAdvise
)
1192 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1194 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1199 if (ppenumAdvise
==NULL
)
1203 * Initialize the out parameter.
1205 *ppenumAdvise
= NULL
;
1207 if (this->oleAdviseHolder
==NULL
)
1208 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1214 /************************************************************************
1215 * DefaultHandler_GetMiscStatus (IOleObject)
1217 * The default handler's implementation of this method simply delegates
1218 * to OleRegGetMiscStatus.
1220 * See Windows documentation for more details on IOleObject methods.
1222 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1228 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1230 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1232 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1240 /************************************************************************
1241 * DefaultHandler_SetExtent (IOleObject)
1243 * This method is meaningless if the server is not running
1245 * See Windows documentation for more details on IOleObject methods.
1247 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1249 struct tagLOGPALETTE
* pLogpal
)
1251 TRACE("(%p, %p))\n", iface
, pLogpal
);
1252 return OLE_E_NOTRUNNING
;
1255 /*********************************************************
1256 * Methods implementation for the IDataObject part of
1257 * the DefaultHandler class.
1260 /************************************************************************
1261 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1263 * See Windows documentation for more details on IUnknown methods.
1265 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1270 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1272 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1275 /************************************************************************
1276 * DefaultHandler_IDataObject_AddRef (IUnknown)
1278 * See Windows documentation for more details on IUnknown methods.
1280 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1283 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1285 return IUnknown_AddRef(this->outerUnknown
);
1288 /************************************************************************
1289 * DefaultHandler_IDataObject_Release (IUnknown)
1291 * See Windows documentation for more details on IUnknown methods.
1293 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1296 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1298 return IUnknown_Release(this->outerUnknown
);
1301 /************************************************************************
1302 * DefaultHandler_GetData
1304 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1305 * See Windows documentation for more details on GetData.
1306 * Default handler's implementation of this method delegates to the cache.
1308 static HRESULT WINAPI
DefaultHandler_GetData(
1310 LPFORMATETC pformatetcIn
,
1313 IDataObject
* cacheDataObject
= NULL
;
1316 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1318 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1320 hres
= IUnknown_QueryInterface(this->dataCache
,
1322 (void**)&cacheDataObject
);
1325 return E_UNEXPECTED
;
1327 hres
= IDataObject_GetData(cacheDataObject
,
1331 IDataObject_Release(cacheDataObject
);
1336 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1338 LPFORMATETC pformatetc
,
1345 /************************************************************************
1346 * DefaultHandler_QueryGetData (IDataObject)
1348 * The default handler's implementation of this method delegates to
1351 * See Windows documentation for more details on IDataObject methods.
1353 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1355 LPFORMATETC pformatetc
)
1357 IDataObject
* cacheDataObject
= NULL
;
1360 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1362 TRACE("(%p, %p)\n", iface
, pformatetc
);
1364 hres
= IUnknown_QueryInterface(this->dataCache
,
1366 (void**)&cacheDataObject
);
1369 return E_UNEXPECTED
;
1371 hres
= IDataObject_QueryGetData(cacheDataObject
,
1374 IDataObject_Release(cacheDataObject
);
1379 /************************************************************************
1380 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1382 * This method is meaningless if the server is not running
1384 * See Windows documentation for more details on IDataObject methods.
1386 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1388 LPFORMATETC pformatectIn
,
1389 LPFORMATETC pformatetcOut
)
1391 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1393 return OLE_E_NOTRUNNING
;
1396 /************************************************************************
1397 * DefaultHandler_SetData (IDataObject)
1399 * The default handler's implementation of this method delegates to
1402 * See Windows documentation for more details on IDataObject methods.
1404 static HRESULT WINAPI
DefaultHandler_SetData(
1406 LPFORMATETC pformatetc
,
1410 IDataObject
* cacheDataObject
= NULL
;
1413 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1415 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1417 hres
= IUnknown_QueryInterface(this->dataCache
,
1419 (void**)&cacheDataObject
);
1422 return E_UNEXPECTED
;
1424 hres
= IDataObject_SetData(cacheDataObject
,
1429 IDataObject_Release(cacheDataObject
);
1434 /************************************************************************
1435 * DefaultHandler_EnumFormatEtc (IDataObject)
1437 * The default handler's implementation of this method simply delegates
1438 * to OleRegEnumFormatEtc.
1440 * See Windows documentation for more details on IDataObject methods.
1442 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1445 IEnumFORMATETC
** ppenumFormatEtc
)
1448 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1450 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1452 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1457 /************************************************************************
1458 * DefaultHandler_DAdvise (IDataObject)
1460 * The default handler's implementation of this method simply
1461 * delegates to the DataAdviseHolder.
1463 * See Windows documentation for more details on IDataObject methods.
1465 static HRESULT WINAPI
DefaultHandler_DAdvise(
1467 FORMATETC
* pformatetc
,
1469 IAdviseSink
* pAdvSink
,
1470 DWORD
* pdwConnection
)
1472 HRESULT hres
= S_OK
;
1473 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1475 TRACE("(%p, %p, %ld, %p, %p)\n",
1476 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1479 * Make sure we have a data advise holder before we start.
1481 if (this->dataAdviseHolder
==NULL
)
1483 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1486 if (SUCCEEDED(hres
))
1488 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1499 /************************************************************************
1500 * DefaultHandler_DUnadvise (IDataObject)
1502 * The default handler's implementation of this method simply
1503 * delegates to the DataAdviseHolder.
1505 * See Windows documentation for more details on IDataObject methods.
1507 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1511 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1513 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1516 * If we don't have a data advise holder yet, it means that
1517 * we don't have any connections..
1519 if (this->dataAdviseHolder
==NULL
)
1521 return OLE_E_NOCONNECTION
;
1524 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1528 /************************************************************************
1529 * DefaultHandler_EnumDAdvise (IDataObject)
1531 * The default handler's implementation of this method simply
1532 * delegates to the DataAdviseHolder.
1534 * See Windows documentation for more details on IDataObject methods.
1536 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1538 IEnumSTATDATA
** ppenumAdvise
)
1540 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1542 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1547 if (ppenumAdvise
== NULL
)
1551 * Initialize the out parameter.
1553 *ppenumAdvise
= NULL
;
1556 * If we have a data advise holder object, delegate.
1558 if (this->dataAdviseHolder
!=NULL
)
1560 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1567 /*********************************************************
1568 * Methods implementation for the IRunnableObject part
1569 * of the DefaultHandler class.
1572 /************************************************************************
1573 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1575 * See Windows documentation for more details on IUnknown methods.
1577 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1578 IRunnableObject
* iface
,
1582 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1584 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1587 /************************************************************************
1588 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1590 * See Windows documentation for more details on IUnknown methods.
1592 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1593 IRunnableObject
* iface
)
1595 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1597 return IUnknown_AddRef(this->outerUnknown
);
1600 /************************************************************************
1601 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1603 * See Windows documentation for more details on IUnknown methods.
1605 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1606 IRunnableObject
* iface
)
1608 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1610 return IUnknown_Release(this->outerUnknown
);
1613 /************************************************************************
1614 * DefaultHandler_GetRunningClass (IRunnableObject)
1616 * According to Brockscmidt, Chapter 19, the default handler's
1617 * implementation of IRunnableobject does nothing until the object
1618 * is actually running.
1620 * See Windows documentation for more details on IRunnableObject methods.
1622 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1623 IRunnableObject
* iface
,
1630 static HRESULT WINAPI
DefaultHandler_Run(
1631 IRunnableObject
* iface
,
1638 /************************************************************************
1639 * DefaultHandler_IsRunning (IRunnableObject)
1641 * According to Brockscmidt, Chapter 19, the default handler's
1642 * implementation of IRunnableobject does nothing until the object
1643 * is actually running.
1645 * See Windows documentation for more details on IRunnableObject methods.
1647 static BOOL WINAPI
DefaultHandler_IsRunning(
1648 IRunnableObject
* iface
)
1654 /************************************************************************
1655 * DefaultHandler_LockRunning (IRunnableObject)
1657 * According to Brockscmidt, Chapter 19, the default handler's
1658 * implementation of IRunnableobject does nothing until the object
1659 * is actually running.
1661 * See Windows documentation for more details on IRunnableObject methods.
1663 static HRESULT WINAPI
DefaultHandler_LockRunning(
1664 IRunnableObject
* iface
,
1666 BOOL fLastUnlockCloses
)
1672 /************************************************************************
1673 * DefaultHandler_SetContainedObject (IRunnableObject)
1675 * According to Brockscmidt, Chapter 19, the default handler's
1676 * implementation of IRunnableobject does nothing until the object
1677 * is actually running.
1679 * See Windows documentation for more details on IRunnableObject methods.
1681 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1682 IRunnableObject
* iface
,