2 * OLE 2 default object handler
4 * Copyright 1999 Francis Beaudet
7 * The OLE2 default object handler supports a whole whack of
8 * interfaces including:
9 * IOleObject, IDataObject, IPersistStorage, IViewObject2,
10 * IRunnableObject, IOleCache2, IOleCacheControl and much more.
12 * All the implementation details are taken from: Inside OLE
13 * second edition by Kraig Brockschmidt,
16 * - This implementation of the default handler does not launch the
17 * server in the DoVerb, Update, GetData, GetDataHere and Run
18 * methods. When it is fixed to do so, all the methods will have
19 * to be revisited to allow delegating to the running object
21 * - All methods in the class that use the class ID should be
22 * aware that it is possible for a class to be treated as
23 * another one and go into emulation mode. Nothing has been
26 * - Some functions still return E_NOTIMPL they have to be
27 * implemented. Most of those are related to the running of the
30 * - All the methods related to notification and advise sinks are
31 * in place but no notifications are sent to the sinks yet.
40 DEFAULT_DEBUG_CHANNEL(ole
)
42 /****************************************************************************
49 * List all interface VTables here
51 ICOM_VTABLE(IOleObject
)* lpvtbl1
;
52 ICOM_VTABLE(IUnknown
)* lpvtbl2
;
53 ICOM_VTABLE(IDataObject
)* lpvtbl3
;
54 ICOM_VTABLE(IRunnableObject
)* lpvtbl4
;
57 * Reference count of this object
62 * IUnknown implementation of the outer object.
64 IUnknown
* outerUnknown
;
67 * Class Id that this handler object represents.
72 * IUnknown implementation of the datacache.
77 * Client site for the embedded object.
79 IOleClientSite
* clientSite
;
82 * The IOleAdviseHolder maintains the connections
83 * on behalf of the default handler.
85 IOleAdviseHolder
* oleAdviseHolder
;
88 * The IDataAdviseHolder maintains the data
89 * connections on behalf of the default handler.
91 IDataAdviseHolder
* dataAdviseHolder
;
94 * Name of the container and object contained
101 typedef struct DefaultHandler DefaultHandler
;
104 * Here, I define utility macros to help with the casting of the
106 * There is a version to accomodate all of the VTables implemented
109 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
110 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
111 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
112 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
115 * Prototypes for the methods of the DefaultHandler class.
117 static DefaultHandler
* DefaultHandler_Construct(REFCLSID clsid
,
118 LPUNKNOWN pUnkOuter
);
119 static void DefaultHandler_Destroy(DefaultHandler
* ptrToDestroy
);
122 * Prototypes for the methods of the DefaultHandler class
123 * that implement non delegating IUnknown methods.
125 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
129 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
131 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
135 * Prototypes for the methods of the DefaultHandler class
136 * that implement IOleObject methods.
138 static HRESULT WINAPI
DefaultHandler_QueryInterface(
142 static ULONG WINAPI
DefaultHandler_AddRef(
144 static ULONG WINAPI
DefaultHandler_Release(
146 static HRESULT WINAPI
DefaultHandler_SetClientSite(
148 IOleClientSite
* pClientSite
);
149 static HRESULT WINAPI
DefaultHandler_GetClientSite(
151 IOleClientSite
** ppClientSite
);
152 static HRESULT WINAPI
DefaultHandler_SetHostNames(
154 LPCOLESTR szContainerApp
,
155 LPCOLESTR szContainerObj
);
156 static HRESULT WINAPI
DefaultHandler_Close(
159 static HRESULT WINAPI
DefaultHandler_SetMoniker(
161 DWORD dwWhichMoniker
,
163 static HRESULT WINAPI
DefaultHandler_GetMoniker(
166 DWORD dwWhichMoniker
,
168 static HRESULT WINAPI
DefaultHandler_InitFromData(
170 IDataObject
* pDataObject
,
173 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
176 IDataObject
** ppDataObject
);
177 static HRESULT WINAPI
DefaultHandler_DoVerb(
181 IOleClientSite
* pActiveSite
,
184 LPCRECT lprcPosRect
);
185 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
187 IEnumOLEVERB
** ppEnumOleVerb
);
188 static HRESULT WINAPI
DefaultHandler_Update(
190 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
192 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
195 static HRESULT WINAPI
DefaultHandler_GetUserType(
198 LPOLESTR
* pszUserType
);
199 static HRESULT WINAPI
DefaultHandler_SetExtent(
203 static HRESULT WINAPI
DefaultHandler_GetExtent(
207 static HRESULT WINAPI
DefaultHandler_Advise(
209 IAdviseSink
* pAdvSink
,
210 DWORD
* pdwConnection
);
211 static HRESULT WINAPI
DefaultHandler_Unadvise(
214 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
216 IEnumSTATDATA
** ppenumAdvise
);
217 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
221 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
223 LOGPALETTE
* pLogpal
);
226 * Prototypes for the methods of the DefaultHandler class
227 * that implement IDataObject methods.
229 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
233 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
235 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
237 static HRESULT WINAPI
DefaultHandler_GetData(
239 LPFORMATETC pformatetcIn
,
241 static HRESULT WINAPI
DefaultHandler_GetDataHere(
243 LPFORMATETC pformatetc
,
245 static HRESULT WINAPI
DefaultHandler_QueryGetData(
247 LPFORMATETC pformatetc
);
248 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
250 LPFORMATETC pformatectIn
,
251 LPFORMATETC pformatetcOut
);
252 static HRESULT WINAPI
DefaultHandler_SetData(
254 LPFORMATETC pformatetc
,
257 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
260 IEnumFORMATETC
** ppenumFormatEtc
);
261 static HRESULT WINAPI
DefaultHandler_DAdvise(
263 FORMATETC
* pformatetc
,
265 IAdviseSink
* pAdvSink
,
266 DWORD
* pdwConnection
);
267 static HRESULT WINAPI
DefaultHandler_DUnadvise(
270 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
272 IEnumSTATDATA
** ppenumAdvise
);
275 * Prototypes for the methods of the DefaultHandler class
276 * that implement IRunnableObject methods.
278 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
279 IRunnableObject
* iface
,
282 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
283 IRunnableObject
* iface
);
284 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
285 IRunnableObject
* iface
);
286 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
287 IRunnableObject
* iface
,
289 static HRESULT WINAPI
DefaultHandler_Run(
290 IRunnableObject
* iface
,
292 static BOOL WINAPI
DefaultHandler_IsRunning(
293 IRunnableObject
* iface
);
294 static HRESULT WINAPI
DefaultHandler_LockRunning(
295 IRunnableObject
* iface
,
297 BOOL fLastUnlockCloses
);
298 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
299 IRunnableObject
* iface
,
304 * Virtual function tables for the DefaultHandler class.
306 static ICOM_VTABLE(IOleObject
) DefaultHandler_IOleObject_VTable
=
308 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
309 DefaultHandler_QueryInterface
,
310 DefaultHandler_AddRef
,
311 DefaultHandler_Release
,
312 DefaultHandler_SetClientSite
,
313 DefaultHandler_GetClientSite
,
314 DefaultHandler_SetHostNames
,
315 DefaultHandler_Close
,
316 DefaultHandler_SetMoniker
,
317 DefaultHandler_GetMoniker
,
318 DefaultHandler_InitFromData
,
319 DefaultHandler_GetClipboardData
,
320 DefaultHandler_DoVerb
,
321 DefaultHandler_EnumVerbs
,
322 DefaultHandler_Update
,
323 DefaultHandler_IsUpToDate
,
324 DefaultHandler_GetUserClassID
,
325 DefaultHandler_GetUserType
,
326 DefaultHandler_SetExtent
,
327 DefaultHandler_GetExtent
,
328 DefaultHandler_Advise
,
329 DefaultHandler_Unadvise
,
330 DefaultHandler_EnumAdvise
,
331 DefaultHandler_GetMiscStatus
,
332 DefaultHandler_SetColorScheme
335 static ICOM_VTABLE(IUnknown
) DefaultHandler_NDIUnknown_VTable
=
337 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
338 DefaultHandler_NDIUnknown_QueryInterface
,
339 DefaultHandler_NDIUnknown_AddRef
,
340 DefaultHandler_NDIUnknown_Release
,
343 static ICOM_VTABLE(IDataObject
) DefaultHandler_IDataObject_VTable
=
345 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
346 DefaultHandler_IDataObject_QueryInterface
,
347 DefaultHandler_IDataObject_AddRef
,
348 DefaultHandler_IDataObject_Release
,
349 DefaultHandler_GetData
,
350 DefaultHandler_GetDataHere
,
351 DefaultHandler_QueryGetData
,
352 DefaultHandler_GetCanonicalFormatEtc
,
353 DefaultHandler_SetData
,
354 DefaultHandler_EnumFormatEtc
,
355 DefaultHandler_DAdvise
,
356 DefaultHandler_DUnadvise
,
357 DefaultHandler_EnumDAdvise
360 static ICOM_VTABLE(IRunnableObject
) DefaultHandler_IRunnableObject_VTable
=
362 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
363 DefaultHandler_IRunnableObject_QueryInterface
,
364 DefaultHandler_IRunnableObject_AddRef
,
365 DefaultHandler_IRunnableObject_Release
,
366 DefaultHandler_GetRunningClass
,
368 DefaultHandler_IsRunning
,
369 DefaultHandler_LockRunning
,
370 DefaultHandler_SetContainedObject
373 /******************************************************************************
374 * OleCreateDefaultHandler [OLE32.90]
376 HRESULT WINAPI
OleCreateDefaultHandler(
382 DefaultHandler
* newHandler
= NULL
;
387 WINE_StringFromCLSID((LPCLSID
)clsid
,xclsid
);
388 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
390 TRACE(ole
, "(%s, %p, %s, %p)\n", xclsid
, pUnkOuter
, xriid
, ppvObj
);
401 * If this handler is constructed for aggregation, make sure
402 * the caller is requesting the IUnknown interface.
403 * This is necessary because it's the only time the non-delegating
404 * IUnknown pointer can be returned to the outside.
406 if ( (pUnkOuter
!=NULL
) &&
407 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
408 return CLASS_E_NOAGGREGATION
;
411 * Try to construct a new instance of the class.
413 newHandler
= DefaultHandler_Construct(clsid
,
417 return E_OUTOFMEMORY
;
420 * Make sure it supports the interface required by the caller.
422 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
425 * Release the reference obtained in the constructor. If
426 * the QueryInterface was unsuccessful, it will free the class.
428 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
433 /*********************************************************
434 * Methods implementation for the DefaultHandler class.
436 static DefaultHandler
* DefaultHandler_Construct(
440 DefaultHandler
* newObject
= 0;
443 * Allocate space for the object.
445 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
451 * Initialize the virtual function table.
453 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
454 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
455 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
456 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
459 * Start with one reference count. The caller of this function
460 * must release the interface pointer when it is done.
465 * Initialize the outer unknown
466 * We don't keep a reference on the outer unknown since, the way
467 * aggregation works, our lifetime is at least as large as it's
471 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
473 newObject
->outerUnknown
= pUnkOuter
;
476 * Create a datacache object.
477 * We aggregate with the datacache. Make sure we pass our outer
478 * unknown as the datacache's outer unknown.
480 CreateDataCache(newObject
->outerUnknown
,
483 (void**)&newObject
->dataCache
);
486 * Initialize the other data members of the class.
488 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
489 newObject
->clientSite
= NULL
;
490 newObject
->oleAdviseHolder
= NULL
;
491 newObject
->dataAdviseHolder
= NULL
;
492 newObject
->containerApp
= NULL
;
493 newObject
->containerObj
= NULL
;
498 static void DefaultHandler_Destroy(
499 DefaultHandler
* ptrToDestroy
)
502 * Free the strings idenfitying the object
504 if (ptrToDestroy
->containerApp
!=NULL
)
506 SysFreeString(ptrToDestroy
->containerApp
);
507 ptrToDestroy
->containerApp
= NULL
;
510 if (ptrToDestroy
->containerObj
!=NULL
)
512 SysFreeString(ptrToDestroy
->containerObj
);
513 ptrToDestroy
->containerObj
= NULL
;
517 * Release our reference to the data cache.
519 if (ptrToDestroy
->dataCache
!=NULL
)
521 IUnknown_Release(ptrToDestroy
->dataCache
);
522 ptrToDestroy
->dataCache
= NULL
;
526 * Same thing for the client site.
528 if (ptrToDestroy
->clientSite
!=NULL
)
530 IOleClientSite_Release(ptrToDestroy
->clientSite
);
531 ptrToDestroy
->clientSite
= NULL
;
535 * And the advise holder.
537 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
539 IOleClientSite_Release(ptrToDestroy
->oleAdviseHolder
);
540 ptrToDestroy
->oleAdviseHolder
= NULL
;
544 * And the data advise holder.
546 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
548 IOleClientSite_Release(ptrToDestroy
->dataAdviseHolder
);
549 ptrToDestroy
->dataAdviseHolder
= NULL
;
554 * Free the actual default handler structure.
556 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
559 /*********************************************************
560 * Method implementation for the non delegating IUnknown
561 * part of the DefaultHandler class.
564 /************************************************************************
565 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
567 * See Windows documentation for more details on IUnknown methods.
569 * This version of QueryInterface will not delegate it's implementation
570 * to the outer unknown.
572 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
577 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
580 * Perform a sanity check on the parameters.
582 if ( (this==0) || (ppvObject
==0) )
586 * Initialize the return parameter.
591 * Compare the riid with the interface IDs implemented by this object.
593 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
597 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
599 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
601 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
603 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
605 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
607 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
612 * Blind aggregate the data cache to "inherit" it's interfaces.
614 IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
);
618 * Check that we obtained an interface.
624 WINE_StringFromCLSID((LPCLSID
)riid
,clsid
);
627 "() : asking for un supported interface %s\n",
630 return E_NOINTERFACE
;
634 * Query Interface always increases the reference count by one when it is
637 IUnknown_AddRef((IUnknown
*)*ppvObject
);
642 /************************************************************************
643 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
645 * See Windows documentation for more details on IUnknown methods.
647 * This version of QueryInterface will not delegate it's implementation
648 * to the outer unknown.
650 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
653 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
660 /************************************************************************
661 * DefaultHandler_NDIUnknown_Release (IUnknown)
663 * See Windows documentation for more details on IUnknown methods.
665 * This version of QueryInterface will not delegate it's implementation
666 * to the outer unknown.
668 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
671 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
674 * Decrease the reference count on this object.
679 * If the reference count goes down to 0, perform suicide.
683 DefaultHandler_Destroy(this);
691 /*********************************************************
692 * Methods implementation for the IOleObject part of
693 * the DefaultHandler class.
696 /************************************************************************
697 * DefaultHandler_QueryInterface (IUnknown)
699 * See Windows documentation for more details on IUnknown methods.
701 static HRESULT WINAPI
DefaultHandler_QueryInterface(
706 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
708 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
711 /************************************************************************
712 * DefaultHandler_AddRef (IUnknown)
714 * See Windows documentation for more details on IUnknown methods.
716 static ULONG WINAPI
DefaultHandler_AddRef(
719 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
721 return IUnknown_AddRef(this->outerUnknown
);
724 /************************************************************************
725 * DefaultHandler_Release (IUnknown)
727 * See Windows documentation for more details on IUnknown methods.
729 static ULONG WINAPI
DefaultHandler_Release(
732 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
734 return IUnknown_Release(this->outerUnknown
);
737 /************************************************************************
738 * DefaultHandler_SetClientSite (IOleObject)
740 * The default handler's implementation of this method only keeps the
741 * client site pointer for future reference.
743 * See Windows documentation for more details on IOleObject methods.
745 static HRESULT WINAPI
DefaultHandler_SetClientSite(
747 IOleClientSite
* pClientSite
)
749 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
751 TRACE(ole
, "(%p, %p)\n", iface
, pClientSite
);
754 * Make sure we release the previous client site if there
757 if (this->clientSite
!=NULL
)
759 IOleClientSite_Release(this->clientSite
);
762 this->clientSite
= pClientSite
;
764 if (this->clientSite
!=NULL
)
766 IOleClientSite_AddRef(this->clientSite
);
772 /************************************************************************
773 * DefaultHandler_GetClientSite (IOleObject)
775 * The default handler's implementation of this method returns the
776 * last pointer set in IOleObject_SetClientSite.
778 * See Windows documentation for more details on IOleObject methods.
780 static HRESULT WINAPI
DefaultHandler_GetClientSite(
782 IOleClientSite
** ppClientSite
)
784 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
789 if (ppClientSite
== NULL
)
792 *ppClientSite
= this->clientSite
;
794 if (*ppClientSite
!=NULL
)
796 IOleClientSite_Release(*ppClientSite
);
802 /************************************************************************
803 * DefaultHandler_SetHostNames (IOleObject)
805 * The default handler's implementation of this method just stores
806 * the strings and returns S_OK.
808 * See Windows documentation for more details on IOleObject methods.
810 static HRESULT WINAPI
DefaultHandler_SetHostNames(
812 LPCOLESTR szContainerApp
,
813 LPCOLESTR szContainerObj
)
815 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
817 TRACE(ole
, "(%p, %s, %s)\n",
819 debugstr_w(szContainerApp
),
820 debugstr_w(szContainerObj
));
823 * Be sure to cleanup before re-assinging the strings.
825 if (this->containerApp
!=NULL
)
827 SysFreeString(this->containerApp
);
828 this->containerApp
= NULL
;
831 if (this->containerObj
!=NULL
)
833 SysFreeString(this->containerObj
);
834 this->containerObj
= NULL
;
838 * Copy the string supplied.
840 if (szContainerApp
!= NULL
)
841 this->containerApp
= SysAllocString(szContainerApp
);
843 if (szContainerObj
!= NULL
)
844 this->containerObj
= SysAllocString(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(ole
, "(%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(ole
, "(%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(ole
, "(%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(ole
, "(%p, %ld, %p)\n",
947 iface
, dwReserved
, ppDataObject
);
949 return OLE_E_NOTRUNNING
;
952 static HRESULT WINAPI
DefaultHandler_DoVerb(
956 IOleClientSite
* pActiveSite
,
961 FIXME(ole
, ": Stub\n");
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(ole
, "(%p, %p)\n", iface
, ppEnumOleVerb
);
981 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
984 static HRESULT WINAPI
DefaultHandler_Update(
987 FIXME(ole
, ": Stub\n");
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(ole
, "(%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(ole
, "(%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(ole
, "(%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(ole
, "(%p, %lx, (%d,%d))\n", iface
, 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(ole
, "(%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(ole
, "(%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(ole
, "(%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(ole
, "(%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(ole
, "(%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 LOGPALETTE
* pLogpal
)
1252 TRACE(ole
, "(%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 static HRESULT WINAPI
DefaultHandler_GetData(
1304 LPFORMATETC pformatetcIn
,
1307 FIXME(ole
, ": Stub\n");
1311 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1313 LPFORMATETC pformatetc
,
1316 FIXME(ole
, ": Stub\n");
1320 /************************************************************************
1321 * DefaultHandler_QueryGetData (IDataObject)
1323 * The default handler's implementation of this method delegates to
1326 * See Windows documentation for more details on IDataObject methods.
1328 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1330 LPFORMATETC pformatetc
)
1332 IDataObject
* cacheDataObject
= NULL
;
1335 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1337 TRACE(ole
, "(%p, %p)\n", iface
, pformatetc
);
1339 hres
= IUnknown_QueryInterface(this->dataCache
,
1341 (void**)&cacheDataObject
);
1344 return E_UNEXPECTED
;
1346 hres
= IDataObject_QueryGetData(cacheDataObject
,
1349 IDataObject_Release(cacheDataObject
);
1354 /************************************************************************
1355 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1357 * This method is meaningless if the server is not running
1359 * See Windows documentation for more details on IDataObject methods.
1361 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1363 LPFORMATETC pformatectIn
,
1364 LPFORMATETC pformatetcOut
)
1366 FIXME(ole
, "(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1368 return OLE_E_NOTRUNNING
;
1371 /************************************************************************
1372 * DefaultHandler_SetData (IDataObject)
1374 * The default handler's implementation of this method delegates to
1377 * See Windows documentation for more details on IDataObject methods.
1379 static HRESULT WINAPI
DefaultHandler_SetData(
1381 LPFORMATETC pformatetc
,
1385 IDataObject
* cacheDataObject
= NULL
;
1388 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1390 TRACE(ole
, "(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1392 hres
= IUnknown_QueryInterface(this->dataCache
,
1394 (void**)&cacheDataObject
);
1397 return E_UNEXPECTED
;
1399 hres
= IDataObject_SetData(cacheDataObject
,
1404 IDataObject_Release(cacheDataObject
);
1409 /************************************************************************
1410 * DefaultHandler_EnumFormatEtc (IDataObject)
1412 * The default handler's implementation of this method simply delegates
1413 * to OleRegEnumFormatEtc.
1415 * See Windows documentation for more details on IDataObject methods.
1417 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1420 IEnumFORMATETC
** ppenumFormatEtc
)
1423 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1425 TRACE(ole
, "(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1427 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1432 /************************************************************************
1433 * DefaultHandler_DAdvise (IDataObject)
1435 * The default handler's implementation of this method simply
1436 * delegates to the DataAdviseHolder.
1438 * See Windows documentation for more details on IDataObject methods.
1440 static HRESULT WINAPI
DefaultHandler_DAdvise(
1442 FORMATETC
* pformatetc
,
1444 IAdviseSink
* pAdvSink
,
1445 DWORD
* pdwConnection
)
1447 HRESULT hres
= S_OK
;
1448 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1450 TRACE(ole
, "(%p, %p, %ld, %p, %p)\n",
1451 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1454 * Make sure we have a data advise holder before we start.
1456 if (this->dataAdviseHolder
==NULL
)
1458 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1461 if (SUCCEEDED(hres
))
1463 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1474 /************************************************************************
1475 * DefaultHandler_DUnadvise (IDataObject)
1477 * The default handler's implementation of this method simply
1478 * delegates to the DataAdviseHolder.
1480 * See Windows documentation for more details on IDataObject methods.
1482 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1486 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1488 TRACE(ole
, "(%p, %ld)\n", iface
, dwConnection
);
1491 * If we don't have a data advise holder yet, it means that
1492 * we don't have any connections..
1494 if (this->dataAdviseHolder
==NULL
)
1496 return OLE_E_NOCONNECTION
;
1499 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1503 /************************************************************************
1504 * DefaultHandler_EnumDAdvise (IDataObject)
1506 * The default handler's implementation of this method simply
1507 * delegates to the DataAdviseHolder.
1509 * See Windows documentation for more details on IDataObject methods.
1511 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1513 IEnumSTATDATA
** ppenumAdvise
)
1515 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1517 TRACE(ole
, "(%p, %p)\n", iface
, ppenumAdvise
);
1522 if (ppenumAdvise
== NULL
)
1526 * Initialize the out parameter.
1528 *ppenumAdvise
= NULL
;
1531 * If we have a data advise holder object, delegate.
1533 if (this->dataAdviseHolder
!=NULL
)
1535 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1542 /*********************************************************
1543 * Methods implementation for the IRunnableObject part
1544 * of the DefaultHandler class.
1547 /************************************************************************
1548 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1550 * See Windows documentation for more details on IUnknown methods.
1552 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1553 IRunnableObject
* iface
,
1557 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1559 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1562 /************************************************************************
1563 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1565 * See Windows documentation for more details on IUnknown methods.
1567 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1568 IRunnableObject
* iface
)
1570 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1572 return IUnknown_AddRef(this->outerUnknown
);
1575 /************************************************************************
1576 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1578 * See Windows documentation for more details on IUnknown methods.
1580 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1581 IRunnableObject
* iface
)
1583 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1585 return IUnknown_Release(this->outerUnknown
);
1588 /************************************************************************
1589 * DefaultHandler_GetRunningClass (IRunnableObject)
1591 * According to Brockscmidt, Chapter 19, the default handler's
1592 * implementation of IRunnableobject does nothing until the object
1593 * is actually running.
1595 * See Windows documentation for more details on IRunnableObject methods.
1597 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1598 IRunnableObject
* iface
,
1605 static HRESULT WINAPI
DefaultHandler_Run(
1606 IRunnableObject
* iface
,
1609 FIXME(ole
, ": Stub\n");
1613 /************************************************************************
1614 * DefaultHandler_IsRunning (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 BOOL WINAPI
DefaultHandler_IsRunning(
1623 IRunnableObject
* iface
)
1629 /************************************************************************
1630 * DefaultHandler_LockRunning (IRunnableObject)
1632 * According to Brockscmidt, Chapter 19, the default handler's
1633 * implementation of IRunnableobject does nothing until the object
1634 * is actually running.
1636 * See Windows documentation for more details on IRunnableObject methods.
1638 static HRESULT WINAPI
DefaultHandler_LockRunning(
1639 IRunnableObject
* iface
,
1641 BOOL fLastUnlockCloses
)
1647 /************************************************************************
1648 * DefaultHandler_SetContainedObject (IRunnableObject)
1650 * According to Brockscmidt, Chapter 19, the default handler's
1651 * implementation of IRunnableobject does nothing until the object
1652 * is actually running.
1654 * See Windows documentation for more details on IRunnableObject methods.
1656 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1657 IRunnableObject
* iface
,