2 * OLE 2 default object handler
4 * Copyright 1999 Francis Beaudet
5 * Copyright 2000 Abey George
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * The OLE2 default object handler supports a whole whack of
23 * interfaces including:
24 * IOleObject, IDataObject, IPersistStorage, IViewObject2,
25 * IRunnableObject, IOleCache2, IOleCacheControl and much more.
27 * All the implementation details are taken from: Inside OLE
28 * second edition by Kraig Brockschmidt,
31 * - This implementation of the default handler does not launch the
32 * server in the DoVerb, Update, GetData, GetDataHere and Run
33 * methods. When it is fixed to do so, all the methods will have
34 * to be revisited to allow delegating to the running object
36 * - All methods in the class that use the class ID should be
37 * aware that it is possible for a class to be treated as
38 * another one and go into emulation mode. Nothing has been
41 * - Some functions still return E_NOTIMPL they have to be
42 * implemented. Most of those are related to the running of the
45 * - All the methods related to notification and advise sinks are
46 * in place but no notifications are sent to the sinks yet.
55 #include "wine/unicode.h"
57 #include "wine/debug.h"
59 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
61 /****************************************************************************
68 * List all interface VTables here
70 ICOM_VTABLE(IOleObject
)* lpvtbl1
;
71 ICOM_VTABLE(IUnknown
)* lpvtbl2
;
72 ICOM_VTABLE(IDataObject
)* lpvtbl3
;
73 ICOM_VTABLE(IRunnableObject
)* lpvtbl4
;
76 * Reference count of this object
81 * IUnknown implementation of the outer object.
83 IUnknown
* outerUnknown
;
86 * Class Id that this handler object represents.
91 * IUnknown implementation of the datacache.
96 * Client site for the embedded object.
98 IOleClientSite
* clientSite
;
101 * The IOleAdviseHolder maintains the connections
102 * on behalf of the default handler.
104 IOleAdviseHolder
* oleAdviseHolder
;
107 * The IDataAdviseHolder maintains the data
108 * connections on behalf of the default handler.
110 IDataAdviseHolder
* dataAdviseHolder
;
113 * Name of the container and object contained
120 typedef struct DefaultHandler DefaultHandler
;
123 * Here, I define utility macros to help with the casting of the
125 * There is a version to accomodate all of the VTables implemented
128 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
129 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
130 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
131 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
134 * Prototypes for the methods of the DefaultHandler class.
136 static DefaultHandler
* DefaultHandler_Construct(REFCLSID clsid
,
137 LPUNKNOWN pUnkOuter
);
138 static void DefaultHandler_Destroy(DefaultHandler
* ptrToDestroy
);
141 * Prototypes for the methods of the DefaultHandler class
142 * that implement non delegating IUnknown methods.
144 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
148 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
150 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
154 * Prototypes for the methods of the DefaultHandler class
155 * that implement IOleObject methods.
157 static HRESULT WINAPI
DefaultHandler_QueryInterface(
161 static ULONG WINAPI
DefaultHandler_AddRef(
163 static ULONG WINAPI
DefaultHandler_Release(
165 static HRESULT WINAPI
DefaultHandler_SetClientSite(
167 IOleClientSite
* pClientSite
);
168 static HRESULT WINAPI
DefaultHandler_GetClientSite(
170 IOleClientSite
** ppClientSite
);
171 static HRESULT WINAPI
DefaultHandler_SetHostNames(
173 LPCOLESTR szContainerApp
,
174 LPCOLESTR szContainerObj
);
175 static HRESULT WINAPI
DefaultHandler_Close(
178 static HRESULT WINAPI
DefaultHandler_SetMoniker(
180 DWORD dwWhichMoniker
,
182 static HRESULT WINAPI
DefaultHandler_GetMoniker(
185 DWORD dwWhichMoniker
,
187 static HRESULT WINAPI
DefaultHandler_InitFromData(
189 IDataObject
* pDataObject
,
192 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
195 IDataObject
** ppDataObject
);
196 static HRESULT WINAPI
DefaultHandler_DoVerb(
199 struct tagMSG
* lpmsg
,
200 IOleClientSite
* pActiveSite
,
203 LPCRECT lprcPosRect
);
204 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
206 IEnumOLEVERB
** ppEnumOleVerb
);
207 static HRESULT WINAPI
DefaultHandler_Update(
209 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
211 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
214 static HRESULT WINAPI
DefaultHandler_GetUserType(
217 LPOLESTR
* pszUserType
);
218 static HRESULT WINAPI
DefaultHandler_SetExtent(
222 static HRESULT WINAPI
DefaultHandler_GetExtent(
226 static HRESULT WINAPI
DefaultHandler_Advise(
228 IAdviseSink
* pAdvSink
,
229 DWORD
* pdwConnection
);
230 static HRESULT WINAPI
DefaultHandler_Unadvise(
233 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
235 IEnumSTATDATA
** ppenumAdvise
);
236 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
240 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
242 struct tagLOGPALETTE
* pLogpal
);
245 * Prototypes for the methods of the DefaultHandler class
246 * that implement IDataObject methods.
248 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
252 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
254 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
256 static HRESULT WINAPI
DefaultHandler_GetData(
258 LPFORMATETC pformatetcIn
,
260 static HRESULT WINAPI
DefaultHandler_GetDataHere(
262 LPFORMATETC pformatetc
,
264 static HRESULT WINAPI
DefaultHandler_QueryGetData(
266 LPFORMATETC pformatetc
);
267 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
269 LPFORMATETC pformatectIn
,
270 LPFORMATETC pformatetcOut
);
271 static HRESULT WINAPI
DefaultHandler_SetData(
273 LPFORMATETC pformatetc
,
276 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
279 IEnumFORMATETC
** ppenumFormatEtc
);
280 static HRESULT WINAPI
DefaultHandler_DAdvise(
282 FORMATETC
* pformatetc
,
284 IAdviseSink
* pAdvSink
,
285 DWORD
* pdwConnection
);
286 static HRESULT WINAPI
DefaultHandler_DUnadvise(
289 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
291 IEnumSTATDATA
** ppenumAdvise
);
294 * Prototypes for the methods of the DefaultHandler class
295 * that implement IRunnableObject methods.
297 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
298 IRunnableObject
* iface
,
301 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
302 IRunnableObject
* iface
);
303 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
304 IRunnableObject
* iface
);
305 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
306 IRunnableObject
* iface
,
308 static HRESULT WINAPI
DefaultHandler_Run(
309 IRunnableObject
* iface
,
311 static BOOL WINAPI
DefaultHandler_IsRunning(
312 IRunnableObject
* iface
);
313 static HRESULT WINAPI
DefaultHandler_LockRunning(
314 IRunnableObject
* iface
,
316 BOOL fLastUnlockCloses
);
317 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
318 IRunnableObject
* iface
,
323 * Virtual function tables for the DefaultHandler class.
325 static ICOM_VTABLE(IOleObject
) DefaultHandler_IOleObject_VTable
=
327 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
328 DefaultHandler_QueryInterface
,
329 DefaultHandler_AddRef
,
330 DefaultHandler_Release
,
331 DefaultHandler_SetClientSite
,
332 DefaultHandler_GetClientSite
,
333 DefaultHandler_SetHostNames
,
334 DefaultHandler_Close
,
335 DefaultHandler_SetMoniker
,
336 DefaultHandler_GetMoniker
,
337 DefaultHandler_InitFromData
,
338 DefaultHandler_GetClipboardData
,
339 DefaultHandler_DoVerb
,
340 DefaultHandler_EnumVerbs
,
341 DefaultHandler_Update
,
342 DefaultHandler_IsUpToDate
,
343 DefaultHandler_GetUserClassID
,
344 DefaultHandler_GetUserType
,
345 DefaultHandler_SetExtent
,
346 DefaultHandler_GetExtent
,
347 DefaultHandler_Advise
,
348 DefaultHandler_Unadvise
,
349 DefaultHandler_EnumAdvise
,
350 DefaultHandler_GetMiscStatus
,
351 DefaultHandler_SetColorScheme
354 static ICOM_VTABLE(IUnknown
) DefaultHandler_NDIUnknown_VTable
=
356 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
357 DefaultHandler_NDIUnknown_QueryInterface
,
358 DefaultHandler_NDIUnknown_AddRef
,
359 DefaultHandler_NDIUnknown_Release
,
362 static ICOM_VTABLE(IDataObject
) DefaultHandler_IDataObject_VTable
=
364 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
365 DefaultHandler_IDataObject_QueryInterface
,
366 DefaultHandler_IDataObject_AddRef
,
367 DefaultHandler_IDataObject_Release
,
368 DefaultHandler_GetData
,
369 DefaultHandler_GetDataHere
,
370 DefaultHandler_QueryGetData
,
371 DefaultHandler_GetCanonicalFormatEtc
,
372 DefaultHandler_SetData
,
373 DefaultHandler_EnumFormatEtc
,
374 DefaultHandler_DAdvise
,
375 DefaultHandler_DUnadvise
,
376 DefaultHandler_EnumDAdvise
379 static ICOM_VTABLE(IRunnableObject
) DefaultHandler_IRunnableObject_VTable
=
381 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
382 DefaultHandler_IRunnableObject_QueryInterface
,
383 DefaultHandler_IRunnableObject_AddRef
,
384 DefaultHandler_IRunnableObject_Release
,
385 DefaultHandler_GetRunningClass
,
387 DefaultHandler_IsRunning
,
388 DefaultHandler_LockRunning
,
389 DefaultHandler_SetContainedObject
392 /******************************************************************************
393 * OleCreateDefaultHandler [OLE32.90]
395 HRESULT WINAPI
OleCreateDefaultHandler(
401 DefaultHandler
* newHandler
= NULL
;
404 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid
), pUnkOuter
, debugstr_guid(riid
), ppvObj
);
415 * If this handler is constructed for aggregation, make sure
416 * the caller is requesting the IUnknown interface.
417 * This is necessary because it's the only time the non-delegating
418 * IUnknown pointer can be returned to the outside.
420 if ( (pUnkOuter
!=NULL
) &&
421 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
422 return CLASS_E_NOAGGREGATION
;
425 * Try to construct a new instance of the class.
427 newHandler
= DefaultHandler_Construct(clsid
,
431 return E_OUTOFMEMORY
;
434 * Make sure it supports the interface required by the caller.
436 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
439 * Release the reference obtained in the constructor. If
440 * the QueryInterface was unsuccessful, it will free the class.
442 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
447 /*********************************************************
448 * Methods implementation for the DefaultHandler class.
450 static DefaultHandler
* DefaultHandler_Construct(
454 DefaultHandler
* newObject
= 0;
457 * Allocate space for the object.
459 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
465 * Initialize the virtual function table.
467 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
468 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
469 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
470 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
473 * Start with one reference count. The caller of this function
474 * must release the interface pointer when it is done.
479 * Initialize the outer unknown
480 * We don't keep a reference on the outer unknown since, the way
481 * aggregation works, our lifetime is at least as large as it's
485 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
487 newObject
->outerUnknown
= pUnkOuter
;
490 * Create a datacache object.
491 * We aggregate with the datacache. Make sure we pass our outer
492 * unknown as the datacache's outer unknown.
494 CreateDataCache(newObject
->outerUnknown
,
497 (void**)&newObject
->dataCache
);
500 * Initialize the other data members of the class.
502 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
503 newObject
->clientSite
= NULL
;
504 newObject
->oleAdviseHolder
= NULL
;
505 newObject
->dataAdviseHolder
= NULL
;
506 newObject
->containerApp
= NULL
;
507 newObject
->containerObj
= NULL
;
512 static void DefaultHandler_Destroy(
513 DefaultHandler
* ptrToDestroy
)
516 * Free the strings idenfitying the object
518 if (ptrToDestroy
->containerApp
!=NULL
)
520 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerApp
);
521 ptrToDestroy
->containerApp
= NULL
;
524 if (ptrToDestroy
->containerObj
!=NULL
)
526 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerObj
);
527 ptrToDestroy
->containerObj
= NULL
;
531 * Release our reference to the data cache.
533 if (ptrToDestroy
->dataCache
!=NULL
)
535 IUnknown_Release(ptrToDestroy
->dataCache
);
536 ptrToDestroy
->dataCache
= NULL
;
540 * Same thing for the client site.
542 if (ptrToDestroy
->clientSite
!=NULL
)
544 IOleClientSite_Release(ptrToDestroy
->clientSite
);
545 ptrToDestroy
->clientSite
= NULL
;
549 * And the advise holder.
551 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
553 IOleAdviseHolder_Release(ptrToDestroy
->oleAdviseHolder
);
554 ptrToDestroy
->oleAdviseHolder
= NULL
;
558 * And the data advise holder.
560 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
562 IDataAdviseHolder_Release(ptrToDestroy
->dataAdviseHolder
);
563 ptrToDestroy
->dataAdviseHolder
= NULL
;
568 * Free the actual default handler structure.
570 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
573 /*********************************************************
574 * Method implementation for the non delegating IUnknown
575 * part of the DefaultHandler class.
578 /************************************************************************
579 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
581 * See Windows documentation for more details on IUnknown methods.
583 * This version of QueryInterface will not delegate it's implementation
584 * to the outer unknown.
586 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
591 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
594 * Perform a sanity check on the parameters.
596 if ( (this==0) || (ppvObject
==0) )
600 * Initialize the return parameter.
605 * Compare the riid with the interface IDs implemented by this object.
607 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
611 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
613 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
615 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
617 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
619 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
621 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
626 * Blind aggregate the data cache to "inherit" it's interfaces.
628 if (IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
) == S_OK
)
633 * Check that we obtained an interface.
637 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid
));
638 return E_NOINTERFACE
;
642 * Query Interface always increases the reference count by one when it is
645 IUnknown_AddRef((IUnknown
*)*ppvObject
);
650 /************************************************************************
651 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
653 * See Windows documentation for more details on IUnknown methods.
655 * This version of QueryInterface will not delegate it's implementation
656 * to the outer unknown.
658 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
661 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
668 /************************************************************************
669 * DefaultHandler_NDIUnknown_Release (IUnknown)
671 * See Windows documentation for more details on IUnknown methods.
673 * This version of QueryInterface will not delegate it's implementation
674 * to the outer unknown.
676 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
679 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
682 * Decrease the reference count on this object.
687 * If the reference count goes down to 0, perform suicide.
691 DefaultHandler_Destroy(this);
699 /*********************************************************
700 * Methods implementation for the IOleObject part of
701 * the DefaultHandler class.
704 /************************************************************************
705 * DefaultHandler_QueryInterface (IUnknown)
707 * See Windows documentation for more details on IUnknown methods.
709 static HRESULT WINAPI
DefaultHandler_QueryInterface(
714 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
716 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
719 /************************************************************************
720 * DefaultHandler_AddRef (IUnknown)
722 * See Windows documentation for more details on IUnknown methods.
724 static ULONG WINAPI
DefaultHandler_AddRef(
727 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
729 return IUnknown_AddRef(this->outerUnknown
);
732 /************************************************************************
733 * DefaultHandler_Release (IUnknown)
735 * See Windows documentation for more details on IUnknown methods.
737 static ULONG WINAPI
DefaultHandler_Release(
740 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
742 return IUnknown_Release(this->outerUnknown
);
745 /************************************************************************
746 * DefaultHandler_SetClientSite (IOleObject)
748 * The default handler's implementation of this method only keeps the
749 * client site pointer for future reference.
751 * See Windows documentation for more details on IOleObject methods.
753 static HRESULT WINAPI
DefaultHandler_SetClientSite(
755 IOleClientSite
* pClientSite
)
757 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
759 TRACE("(%p, %p)\n", iface
, pClientSite
);
762 * Make sure we release the previous client site if there
765 if (this->clientSite
!=NULL
)
767 IOleClientSite_Release(this->clientSite
);
770 this->clientSite
= pClientSite
;
772 if (this->clientSite
!=NULL
)
774 IOleClientSite_AddRef(this->clientSite
);
780 /************************************************************************
781 * DefaultHandler_GetClientSite (IOleObject)
783 * The default handler's implementation of this method returns the
784 * last pointer set in IOleObject_SetClientSite.
786 * See Windows documentation for more details on IOleObject methods.
788 static HRESULT WINAPI
DefaultHandler_GetClientSite(
790 IOleClientSite
** ppClientSite
)
792 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
797 if (ppClientSite
== NULL
)
800 *ppClientSite
= this->clientSite
;
802 if (this->clientSite
!= NULL
)
804 IOleClientSite_AddRef(this->clientSite
);
810 /************************************************************************
811 * DefaultHandler_SetHostNames (IOleObject)
813 * The default handler's implementation of this method just stores
814 * the strings and returns S_OK.
816 * See Windows documentation for more details on IOleObject methods.
818 static HRESULT WINAPI
DefaultHandler_SetHostNames(
820 LPCOLESTR szContainerApp
,
821 LPCOLESTR szContainerObj
)
823 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
825 TRACE("(%p, %s, %s)\n",
827 debugstr_w(szContainerApp
),
828 debugstr_w(szContainerObj
));
831 * Be sure to cleanup before re-assinging the strings.
833 if (this->containerApp
!=NULL
)
835 HeapFree( GetProcessHeap(), 0, this->containerApp
);
836 this->containerApp
= NULL
;
839 if (this->containerObj
!=NULL
)
841 HeapFree( GetProcessHeap(), 0, this->containerObj
);
842 this->containerObj
= NULL
;
846 * Copy the string supplied.
848 if (szContainerApp
!= NULL
)
850 if ((this->containerApp
= HeapAlloc( GetProcessHeap(), 0,
851 (lstrlenW(szContainerApp
) + 1) * sizeof(WCHAR
) )))
852 strcpyW( this->containerApp
, szContainerApp
);
855 if (szContainerObj
!= NULL
)
857 if ((this->containerObj
= HeapAlloc( GetProcessHeap(), 0,
858 (lstrlenW(szContainerObj
) + 1) * sizeof(WCHAR
) )))
859 strcpyW( this->containerObj
, szContainerObj
);
864 /************************************************************************
865 * DefaultHandler_Close (IOleObject)
867 * The default handler's implementation of this method is meaningless
868 * without a running server so it does nothing.
870 * See Windows documentation for more details on IOleObject methods.
872 static HRESULT WINAPI
DefaultHandler_Close(
880 /************************************************************************
881 * DefaultHandler_SetMoniker (IOleObject)
883 * The default handler's implementation of this method does nothing.
885 * See Windows documentation for more details on IOleObject methods.
887 static HRESULT WINAPI
DefaultHandler_SetMoniker(
889 DWORD dwWhichMoniker
,
892 TRACE("(%p, %ld, %p)\n",
900 /************************************************************************
901 * DefaultHandler_GetMoniker (IOleObject)
903 * Delegate this request to the client site if we have one.
905 * See Windows documentation for more details on IOleObject methods.
907 static HRESULT WINAPI
DefaultHandler_GetMoniker(
910 DWORD dwWhichMoniker
,
913 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
915 TRACE("(%p, %ld, %ld, %p)\n",
916 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
918 if (this->clientSite
)
920 return IOleClientSite_GetMoniker(this->clientSite
,
930 /************************************************************************
931 * DefaultHandler_InitFromData (IOleObject)
933 * This method is meaningless if the server is not running
935 * See Windows documentation for more details on IOleObject methods.
937 static HRESULT WINAPI
DefaultHandler_InitFromData(
939 IDataObject
* pDataObject
,
943 TRACE("(%p, %p, %d, %ld)\n",
944 iface
, pDataObject
, fCreation
, dwReserved
);
946 return OLE_E_NOTRUNNING
;
949 /************************************************************************
950 * DefaultHandler_GetClipboardData (IOleObject)
952 * This method is meaningless if the server is not running
954 * See Windows documentation for more details on IOleObject methods.
956 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
959 IDataObject
** ppDataObject
)
961 TRACE("(%p, %ld, %p)\n",
962 iface
, dwReserved
, ppDataObject
);
964 return OLE_E_NOTRUNNING
;
967 static HRESULT WINAPI
DefaultHandler_DoVerb(
970 struct tagMSG
* lpmsg
,
971 IOleClientSite
* pActiveSite
,
980 /************************************************************************
981 * DefaultHandler_EnumVerbs (IOleObject)
983 * The default handler implementation of this method simply delegates
986 * See Windows documentation for more details on IOleObject methods.
988 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
990 IEnumOLEVERB
** ppEnumOleVerb
)
992 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
994 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
996 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
999 static HRESULT WINAPI
DefaultHandler_Update(
1006 /************************************************************************
1007 * DefaultHandler_IsUpToDate (IOleObject)
1009 * This method is meaningless if the server is not running
1011 * See Windows documentation for more details on IOleObject methods.
1013 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
1016 TRACE("(%p)\n", iface
);
1018 return OLE_E_NOTRUNNING
;
1021 /************************************************************************
1022 * DefaultHandler_GetUserClassID (IOleObject)
1024 * TODO: Map to a new class ID if emulation is active.
1026 * See Windows documentation for more details on IOleObject methods.
1028 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1032 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1034 TRACE("(%p, %p)\n", iface
, pClsid
);
1042 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1047 /************************************************************************
1048 * DefaultHandler_GetUserType (IOleObject)
1050 * The default handler implementation of this method simply delegates
1051 * to OleRegGetUserType
1053 * See Windows documentation for more details on IOleObject methods.
1055 static HRESULT WINAPI
DefaultHandler_GetUserType(
1058 LPOLESTR
* pszUserType
)
1060 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1062 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1064 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1067 /************************************************************************
1068 * DefaultHandler_SetExtent (IOleObject)
1070 * This method is meaningless if the server is not running
1072 * See Windows documentation for more details on IOleObject methods.
1074 static HRESULT WINAPI
DefaultHandler_SetExtent(
1079 TRACE("(%p, %lx, (%ld x %ld))\n", iface
,
1080 dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1081 return OLE_E_NOTRUNNING
;
1084 /************************************************************************
1085 * DefaultHandler_GetExtent (IOleObject)
1087 * The default handler's implementation of this method returns uses
1088 * the cache to locate the aspect and extract the extent from it.
1090 * See Windows documentation for more details on IOleObject methods.
1092 static HRESULT WINAPI
DefaultHandler_GetExtent(
1097 DVTARGETDEVICE
* targetDevice
;
1098 IViewObject2
* cacheView
= NULL
;
1101 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1103 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1105 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1108 return E_UNEXPECTED
;
1111 * Prepare the call to the cache's GetExtent method.
1113 * Here we would build a valid DVTARGETDEVICE structure
1114 * but, since we are calling into the data cache, we
1115 * know it's implementation and we'll skip this
1116 * extra work until later.
1118 targetDevice
= NULL
;
1120 hres
= IViewObject2_GetExtent(cacheView
,
1129 IViewObject2_Release(cacheView
);
1134 /************************************************************************
1135 * DefaultHandler_Advise (IOleObject)
1137 * The default handler's implementation of this method simply
1138 * delegates to the OleAdviseHolder.
1140 * See Windows documentation for more details on IOleObject methods.
1142 static HRESULT WINAPI
DefaultHandler_Advise(
1144 IAdviseSink
* pAdvSink
,
1145 DWORD
* pdwConnection
)
1147 HRESULT hres
= S_OK
;
1148 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1150 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1153 * Make sure we have an advise holder before we start.
1155 if (this->oleAdviseHolder
==NULL
)
1157 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1160 if (SUCCEEDED(hres
))
1162 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1170 /************************************************************************
1171 * DefaultHandler_Unadvise (IOleObject)
1173 * The default handler's implementation of this method simply
1174 * delegates to the OleAdviseHolder.
1176 * See Windows documentation for more details on IOleObject methods.
1178 static HRESULT WINAPI
DefaultHandler_Unadvise(
1182 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1184 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1187 * If we don't have an advise holder yet, it means we don't have
1190 if (this->oleAdviseHolder
==NULL
)
1191 return OLE_E_NOCONNECTION
;
1193 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1197 /************************************************************************
1198 * DefaultHandler_EnumAdvise (IOleObject)
1200 * The default handler's implementation of this method simply
1201 * delegates to the OleAdviseHolder.
1203 * See Windows documentation for more details on IOleObject methods.
1205 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1207 IEnumSTATDATA
** ppenumAdvise
)
1209 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1211 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1216 if (ppenumAdvise
==NULL
)
1220 * Initialize the out parameter.
1222 *ppenumAdvise
= NULL
;
1224 if (this->oleAdviseHolder
==NULL
)
1225 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1231 /************************************************************************
1232 * DefaultHandler_GetMiscStatus (IOleObject)
1234 * The default handler's implementation of this method simply delegates
1235 * to OleRegGetMiscStatus.
1237 * See Windows documentation for more details on IOleObject methods.
1239 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1245 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1247 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1249 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1257 /************************************************************************
1258 * DefaultHandler_SetExtent (IOleObject)
1260 * This method is meaningless if the server is not running
1262 * See Windows documentation for more details on IOleObject methods.
1264 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1266 struct tagLOGPALETTE
* pLogpal
)
1268 TRACE("(%p, %p))\n", iface
, pLogpal
);
1269 return OLE_E_NOTRUNNING
;
1272 /*********************************************************
1273 * Methods implementation for the IDataObject part of
1274 * the DefaultHandler class.
1277 /************************************************************************
1278 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1280 * See Windows documentation for more details on IUnknown methods.
1282 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1287 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1289 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1292 /************************************************************************
1293 * DefaultHandler_IDataObject_AddRef (IUnknown)
1295 * See Windows documentation for more details on IUnknown methods.
1297 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1300 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1302 return IUnknown_AddRef(this->outerUnknown
);
1305 /************************************************************************
1306 * DefaultHandler_IDataObject_Release (IUnknown)
1308 * See Windows documentation for more details on IUnknown methods.
1310 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1313 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1315 return IUnknown_Release(this->outerUnknown
);
1318 /************************************************************************
1319 * DefaultHandler_GetData
1321 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1322 * See Windows documentation for more details on GetData.
1323 * Default handler's implementation of this method delegates to the cache.
1325 static HRESULT WINAPI
DefaultHandler_GetData(
1327 LPFORMATETC pformatetcIn
,
1330 IDataObject
* cacheDataObject
= NULL
;
1333 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1335 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1337 hres
= IUnknown_QueryInterface(this->dataCache
,
1339 (void**)&cacheDataObject
);
1342 return E_UNEXPECTED
;
1344 hres
= IDataObject_GetData(cacheDataObject
,
1348 IDataObject_Release(cacheDataObject
);
1353 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1355 LPFORMATETC pformatetc
,
1362 /************************************************************************
1363 * DefaultHandler_QueryGetData (IDataObject)
1365 * The default handler's implementation of this method delegates to
1368 * See Windows documentation for more details on IDataObject methods.
1370 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1372 LPFORMATETC pformatetc
)
1374 IDataObject
* cacheDataObject
= NULL
;
1377 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1379 TRACE("(%p, %p)\n", iface
, pformatetc
);
1381 hres
= IUnknown_QueryInterface(this->dataCache
,
1383 (void**)&cacheDataObject
);
1386 return E_UNEXPECTED
;
1388 hres
= IDataObject_QueryGetData(cacheDataObject
,
1391 IDataObject_Release(cacheDataObject
);
1396 /************************************************************************
1397 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1399 * This method is meaningless if the server is not running
1401 * See Windows documentation for more details on IDataObject methods.
1403 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1405 LPFORMATETC pformatectIn
,
1406 LPFORMATETC pformatetcOut
)
1408 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1410 return OLE_E_NOTRUNNING
;
1413 /************************************************************************
1414 * DefaultHandler_SetData (IDataObject)
1416 * The default handler's implementation of this method delegates to
1419 * See Windows documentation for more details on IDataObject methods.
1421 static HRESULT WINAPI
DefaultHandler_SetData(
1423 LPFORMATETC pformatetc
,
1427 IDataObject
* cacheDataObject
= NULL
;
1430 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1432 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1434 hres
= IUnknown_QueryInterface(this->dataCache
,
1436 (void**)&cacheDataObject
);
1439 return E_UNEXPECTED
;
1441 hres
= IDataObject_SetData(cacheDataObject
,
1446 IDataObject_Release(cacheDataObject
);
1451 /************************************************************************
1452 * DefaultHandler_EnumFormatEtc (IDataObject)
1454 * The default handler's implementation of this method simply delegates
1455 * to OleRegEnumFormatEtc.
1457 * See Windows documentation for more details on IDataObject methods.
1459 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1462 IEnumFORMATETC
** ppenumFormatEtc
)
1465 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1467 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1469 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1474 /************************************************************************
1475 * DefaultHandler_DAdvise (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_DAdvise(
1484 FORMATETC
* pformatetc
,
1486 IAdviseSink
* pAdvSink
,
1487 DWORD
* pdwConnection
)
1489 HRESULT hres
= S_OK
;
1490 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1492 TRACE("(%p, %p, %ld, %p, %p)\n",
1493 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1496 * Make sure we have a data advise holder before we start.
1498 if (this->dataAdviseHolder
==NULL
)
1500 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1503 if (SUCCEEDED(hres
))
1505 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1516 /************************************************************************
1517 * DefaultHandler_DUnadvise (IDataObject)
1519 * The default handler's implementation of this method simply
1520 * delegates to the DataAdviseHolder.
1522 * See Windows documentation for more details on IDataObject methods.
1524 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1528 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1530 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1533 * If we don't have a data advise holder yet, it means that
1534 * we don't have any connections..
1536 if (this->dataAdviseHolder
==NULL
)
1538 return OLE_E_NOCONNECTION
;
1541 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1545 /************************************************************************
1546 * DefaultHandler_EnumDAdvise (IDataObject)
1548 * The default handler's implementation of this method simply
1549 * delegates to the DataAdviseHolder.
1551 * See Windows documentation for more details on IDataObject methods.
1553 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1555 IEnumSTATDATA
** ppenumAdvise
)
1557 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1559 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1564 if (ppenumAdvise
== NULL
)
1568 * Initialize the out parameter.
1570 *ppenumAdvise
= NULL
;
1573 * If we have a data advise holder object, delegate.
1575 if (this->dataAdviseHolder
!=NULL
)
1577 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1584 /*********************************************************
1585 * Methods implementation for the IRunnableObject part
1586 * of the DefaultHandler class.
1589 /************************************************************************
1590 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1592 * See Windows documentation for more details on IUnknown methods.
1594 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1595 IRunnableObject
* iface
,
1599 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1601 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1604 /************************************************************************
1605 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1607 * See Windows documentation for more details on IUnknown methods.
1609 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1610 IRunnableObject
* iface
)
1612 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1614 return IUnknown_AddRef(this->outerUnknown
);
1617 /************************************************************************
1618 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1620 * See Windows documentation for more details on IUnknown methods.
1622 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1623 IRunnableObject
* iface
)
1625 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1627 return IUnknown_Release(this->outerUnknown
);
1630 /************************************************************************
1631 * DefaultHandler_GetRunningClass (IRunnableObject)
1633 * According to Brockscmidt, Chapter 19, the default handler's
1634 * implementation of IRunnableobject does nothing until the object
1635 * is actually running.
1637 * See Windows documentation for more details on IRunnableObject methods.
1639 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1640 IRunnableObject
* iface
,
1647 static HRESULT WINAPI
DefaultHandler_Run(
1648 IRunnableObject
* iface
,
1655 /************************************************************************
1656 * DefaultHandler_IsRunning (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 BOOL WINAPI
DefaultHandler_IsRunning(
1665 IRunnableObject
* iface
)
1671 /************************************************************************
1672 * DefaultHandler_LockRunning (IRunnableObject)
1674 * According to Brockscmidt, Chapter 19, the default handler's
1675 * implementation of IRunnableobject does nothing until the object
1676 * is actually running.
1678 * See Windows documentation for more details on IRunnableObject methods.
1680 static HRESULT WINAPI
DefaultHandler_LockRunning(
1681 IRunnableObject
* iface
,
1683 BOOL fLastUnlockCloses
)
1689 /************************************************************************
1690 * DefaultHandler_SetContainedObject (IRunnableObject)
1692 * According to Brockscmidt, Chapter 19, the default handler's
1693 * implementation of IRunnableobject does nothing until the object
1694 * is actually running.
1696 * See Windows documentation for more details on IRunnableObject methods.
1698 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1699 IRunnableObject
* iface
,