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.
56 #include "wine/unicode.h"
58 #include "wine/debug.h"
60 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
62 /****************************************************************************
69 * List all interface VTables here
71 IOleObjectVtbl
* lpvtbl1
;
72 IUnknownVtbl
* lpvtbl2
;
73 IDataObjectVtbl
* lpvtbl3
;
74 IRunnableObjectVtbl
* lpvtbl4
;
77 * Reference count of this object
82 * IUnknown implementation of the outer object.
84 IUnknown
* outerUnknown
;
87 * Class Id that this handler object represents.
92 * IUnknown implementation of the datacache.
97 * Client site for the embedded object.
99 IOleClientSite
* clientSite
;
102 * The IOleAdviseHolder maintains the connections
103 * on behalf of the default handler.
105 IOleAdviseHolder
* oleAdviseHolder
;
108 * The IDataAdviseHolder maintains the data
109 * connections on behalf of the default handler.
111 IDataAdviseHolder
* dataAdviseHolder
;
114 * Name of the container and object contained
121 typedef struct DefaultHandler DefaultHandler
;
124 * Here, I define utility macros to help with the casting of the
126 * There is a version to accomodate all of the VTables implemented
129 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name
130 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
131 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
132 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
135 * Prototypes for the methods of the DefaultHandler class.
137 static DefaultHandler
* DefaultHandler_Construct(REFCLSID clsid
,
138 LPUNKNOWN pUnkOuter
);
139 static void DefaultHandler_Destroy(DefaultHandler
* ptrToDestroy
);
142 * Prototypes for the methods of the DefaultHandler class
143 * that implement non delegating IUnknown methods.
145 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
149 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
151 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
155 * Prototypes for the methods of the DefaultHandler class
156 * that implement IOleObject methods.
158 static HRESULT WINAPI
DefaultHandler_QueryInterface(
162 static ULONG WINAPI
DefaultHandler_AddRef(
164 static ULONG WINAPI
DefaultHandler_Release(
166 static HRESULT WINAPI
DefaultHandler_SetClientSite(
168 IOleClientSite
* pClientSite
);
169 static HRESULT WINAPI
DefaultHandler_GetClientSite(
171 IOleClientSite
** ppClientSite
);
172 static HRESULT WINAPI
DefaultHandler_SetHostNames(
174 LPCOLESTR szContainerApp
,
175 LPCOLESTR szContainerObj
);
176 static HRESULT WINAPI
DefaultHandler_Close(
179 static HRESULT WINAPI
DefaultHandler_SetMoniker(
181 DWORD dwWhichMoniker
,
183 static HRESULT WINAPI
DefaultHandler_GetMoniker(
186 DWORD dwWhichMoniker
,
188 static HRESULT WINAPI
DefaultHandler_InitFromData(
190 IDataObject
* pDataObject
,
193 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
196 IDataObject
** ppDataObject
);
197 static HRESULT WINAPI
DefaultHandler_DoVerb(
200 struct tagMSG
* lpmsg
,
201 IOleClientSite
* pActiveSite
,
204 LPCRECT lprcPosRect
);
205 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
207 IEnumOLEVERB
** ppEnumOleVerb
);
208 static HRESULT WINAPI
DefaultHandler_Update(
210 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
212 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
215 static HRESULT WINAPI
DefaultHandler_GetUserType(
218 LPOLESTR
* pszUserType
);
219 static HRESULT WINAPI
DefaultHandler_SetExtent(
223 static HRESULT WINAPI
DefaultHandler_GetExtent(
227 static HRESULT WINAPI
DefaultHandler_Advise(
229 IAdviseSink
* pAdvSink
,
230 DWORD
* pdwConnection
);
231 static HRESULT WINAPI
DefaultHandler_Unadvise(
234 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
236 IEnumSTATDATA
** ppenumAdvise
);
237 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
241 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
243 struct tagLOGPALETTE
* pLogpal
);
246 * Prototypes for the methods of the DefaultHandler class
247 * that implement IDataObject methods.
249 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
253 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
255 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
257 static HRESULT WINAPI
DefaultHandler_GetData(
259 LPFORMATETC pformatetcIn
,
261 static HRESULT WINAPI
DefaultHandler_GetDataHere(
263 LPFORMATETC pformatetc
,
265 static HRESULT WINAPI
DefaultHandler_QueryGetData(
267 LPFORMATETC pformatetc
);
268 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
270 LPFORMATETC pformatectIn
,
271 LPFORMATETC pformatetcOut
);
272 static HRESULT WINAPI
DefaultHandler_SetData(
274 LPFORMATETC pformatetc
,
277 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
280 IEnumFORMATETC
** ppenumFormatEtc
);
281 static HRESULT WINAPI
DefaultHandler_DAdvise(
283 FORMATETC
* pformatetc
,
285 IAdviseSink
* pAdvSink
,
286 DWORD
* pdwConnection
);
287 static HRESULT WINAPI
DefaultHandler_DUnadvise(
290 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
292 IEnumSTATDATA
** ppenumAdvise
);
295 * Prototypes for the methods of the DefaultHandler class
296 * that implement IRunnableObject methods.
298 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
299 IRunnableObject
* iface
,
302 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
303 IRunnableObject
* iface
);
304 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
305 IRunnableObject
* iface
);
306 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
307 IRunnableObject
* iface
,
309 static HRESULT WINAPI
DefaultHandler_Run(
310 IRunnableObject
* iface
,
312 static BOOL WINAPI
DefaultHandler_IsRunning(
313 IRunnableObject
* iface
);
314 static HRESULT WINAPI
DefaultHandler_LockRunning(
315 IRunnableObject
* iface
,
317 BOOL fLastUnlockCloses
);
318 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
319 IRunnableObject
* iface
,
324 * Virtual function tables for the DefaultHandler class.
326 static IOleObjectVtbl DefaultHandler_IOleObject_VTable
=
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 IUnknownVtbl DefaultHandler_NDIUnknown_VTable
=
356 DefaultHandler_NDIUnknown_QueryInterface
,
357 DefaultHandler_NDIUnknown_AddRef
,
358 DefaultHandler_NDIUnknown_Release
,
361 static IDataObjectVtbl DefaultHandler_IDataObject_VTable
=
363 DefaultHandler_IDataObject_QueryInterface
,
364 DefaultHandler_IDataObject_AddRef
,
365 DefaultHandler_IDataObject_Release
,
366 DefaultHandler_GetData
,
367 DefaultHandler_GetDataHere
,
368 DefaultHandler_QueryGetData
,
369 DefaultHandler_GetCanonicalFormatEtc
,
370 DefaultHandler_SetData
,
371 DefaultHandler_EnumFormatEtc
,
372 DefaultHandler_DAdvise
,
373 DefaultHandler_DUnadvise
,
374 DefaultHandler_EnumDAdvise
377 static IRunnableObjectVtbl DefaultHandler_IRunnableObject_VTable
=
379 DefaultHandler_IRunnableObject_QueryInterface
,
380 DefaultHandler_IRunnableObject_AddRef
,
381 DefaultHandler_IRunnableObject_Release
,
382 DefaultHandler_GetRunningClass
,
384 DefaultHandler_IsRunning
,
385 DefaultHandler_LockRunning
,
386 DefaultHandler_SetContainedObject
389 /******************************************************************************
390 * OleCreateDefaultHandler [OLE32.@]
392 HRESULT WINAPI
OleCreateDefaultHandler(
398 DefaultHandler
* newHandler
= NULL
;
401 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid
), pUnkOuter
, debugstr_guid(riid
), ppvObj
);
412 * If this handler is constructed for aggregation, make sure
413 * the caller is requesting the IUnknown interface.
414 * This is necessary because it's the only time the non-delegating
415 * IUnknown pointer can be returned to the outside.
417 if ( (pUnkOuter
!=NULL
) &&
418 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
419 return CLASS_E_NOAGGREGATION
;
422 * Try to construct a new instance of the class.
424 newHandler
= DefaultHandler_Construct(clsid
,
428 return E_OUTOFMEMORY
;
431 * Make sure it supports the interface required by the caller.
433 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
436 * Release the reference obtained in the constructor. If
437 * the QueryInterface was unsuccessful, it will free the class.
439 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
444 /*********************************************************
445 * Methods implementation for the DefaultHandler class.
447 static DefaultHandler
* DefaultHandler_Construct(
451 DefaultHandler
* newObject
= 0;
454 * Allocate space for the object.
456 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
462 * Initialize the virtual function table.
464 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
465 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
466 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
467 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
470 * Start with one reference count. The caller of this function
471 * must release the interface pointer when it is done.
476 * Initialize the outer unknown
477 * We don't keep a reference on the outer unknown since, the way
478 * aggregation works, our lifetime is at least as large as it's
482 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
484 newObject
->outerUnknown
= pUnkOuter
;
487 * Create a datacache object.
488 * We aggregate with the datacache. Make sure we pass our outer
489 * unknown as the datacache's outer unknown.
491 CreateDataCache(newObject
->outerUnknown
,
494 (void**)&newObject
->dataCache
);
497 * Initialize the other data members of the class.
499 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
500 newObject
->clientSite
= NULL
;
501 newObject
->oleAdviseHolder
= NULL
;
502 newObject
->dataAdviseHolder
= NULL
;
503 newObject
->containerApp
= NULL
;
504 newObject
->containerObj
= NULL
;
509 static void DefaultHandler_Destroy(
510 DefaultHandler
* ptrToDestroy
)
513 * Free the strings idenfitying the object
515 if (ptrToDestroy
->containerApp
!=NULL
)
517 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerApp
);
518 ptrToDestroy
->containerApp
= NULL
;
521 if (ptrToDestroy
->containerObj
!=NULL
)
523 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerObj
);
524 ptrToDestroy
->containerObj
= NULL
;
528 * Release our reference to the data cache.
530 if (ptrToDestroy
->dataCache
!=NULL
)
532 IUnknown_Release(ptrToDestroy
->dataCache
);
533 ptrToDestroy
->dataCache
= NULL
;
537 * Same thing for the client site.
539 if (ptrToDestroy
->clientSite
!=NULL
)
541 IOleClientSite_Release(ptrToDestroy
->clientSite
);
542 ptrToDestroy
->clientSite
= NULL
;
546 * And the advise holder.
548 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
550 IOleAdviseHolder_Release(ptrToDestroy
->oleAdviseHolder
);
551 ptrToDestroy
->oleAdviseHolder
= NULL
;
555 * And the data advise holder.
557 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
559 IDataAdviseHolder_Release(ptrToDestroy
->dataAdviseHolder
);
560 ptrToDestroy
->dataAdviseHolder
= NULL
;
565 * Free the actual default handler structure.
567 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
570 /*********************************************************
571 * Method implementation for the non delegating IUnknown
572 * part of the DefaultHandler class.
575 /************************************************************************
576 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
578 * See Windows documentation for more details on IUnknown methods.
580 * This version of QueryInterface will not delegate it's implementation
581 * to the outer unknown.
583 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
588 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
591 * Perform a sanity check on the parameters.
593 if ( (this==0) || (ppvObject
==0) )
597 * Initialize the return parameter.
602 * Compare the riid with the interface IDs implemented by this object.
604 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
608 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
610 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
612 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
614 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
616 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
618 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
623 * Blind aggregate the data cache to "inherit" it's interfaces.
625 if (IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
) == S_OK
)
630 * Check that we obtained an interface.
634 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid
));
635 return E_NOINTERFACE
;
639 * Query Interface always increases the reference count by one when it is
642 IUnknown_AddRef((IUnknown
*)*ppvObject
);
647 /************************************************************************
648 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
650 * See Windows documentation for more details on IUnknown methods.
652 * This version of QueryInterface will not delegate it's implementation
653 * to the outer unknown.
655 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
658 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
659 return InterlockedIncrement(&this->ref
);
662 /************************************************************************
663 * DefaultHandler_NDIUnknown_Release (IUnknown)
665 * See Windows documentation for more details on IUnknown methods.
667 * This version of QueryInterface will not delegate it's implementation
668 * to the outer unknown.
670 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
673 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
677 * Decrease the reference count on this object.
679 ref
= InterlockedDecrement(&this->ref
);
682 * If the reference count goes down to 0, perform suicide.
684 if (ref
== 0) DefaultHandler_Destroy(this);
689 /*********************************************************
690 * Methods implementation for the IOleObject part of
691 * the DefaultHandler class.
694 /************************************************************************
695 * DefaultHandler_QueryInterface (IUnknown)
697 * See Windows documentation for more details on IUnknown methods.
699 static HRESULT WINAPI
DefaultHandler_QueryInterface(
704 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
706 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
709 /************************************************************************
710 * DefaultHandler_AddRef (IUnknown)
712 * See Windows documentation for more details on IUnknown methods.
714 static ULONG WINAPI
DefaultHandler_AddRef(
717 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
719 return IUnknown_AddRef(this->outerUnknown
);
722 /************************************************************************
723 * DefaultHandler_Release (IUnknown)
725 * See Windows documentation for more details on IUnknown methods.
727 static ULONG WINAPI
DefaultHandler_Release(
730 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
732 return IUnknown_Release(this->outerUnknown
);
735 /************************************************************************
736 * DefaultHandler_SetClientSite (IOleObject)
738 * The default handler's implementation of this method only keeps the
739 * client site pointer for future reference.
741 * See Windows documentation for more details on IOleObject methods.
743 static HRESULT WINAPI
DefaultHandler_SetClientSite(
745 IOleClientSite
* pClientSite
)
747 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
749 TRACE("(%p, %p)\n", iface
, pClientSite
);
752 * Make sure we release the previous client site if there
755 if (this->clientSite
!=NULL
)
757 IOleClientSite_Release(this->clientSite
);
760 this->clientSite
= pClientSite
;
762 if (this->clientSite
!=NULL
)
764 IOleClientSite_AddRef(this->clientSite
);
770 /************************************************************************
771 * DefaultHandler_GetClientSite (IOleObject)
773 * The default handler's implementation of this method returns the
774 * last pointer set in IOleObject_SetClientSite.
776 * See Windows documentation for more details on IOleObject methods.
778 static HRESULT WINAPI
DefaultHandler_GetClientSite(
780 IOleClientSite
** ppClientSite
)
782 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
787 if (ppClientSite
== NULL
)
790 *ppClientSite
= this->clientSite
;
792 if (this->clientSite
!= NULL
)
794 IOleClientSite_AddRef(this->clientSite
);
800 /************************************************************************
801 * DefaultHandler_SetHostNames (IOleObject)
803 * The default handler's implementation of this method just stores
804 * the strings and returns S_OK.
806 * See Windows documentation for more details on IOleObject methods.
808 static HRESULT WINAPI
DefaultHandler_SetHostNames(
810 LPCOLESTR szContainerApp
,
811 LPCOLESTR szContainerObj
)
813 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
815 TRACE("(%p, %s, %s)\n",
817 debugstr_w(szContainerApp
),
818 debugstr_w(szContainerObj
));
821 * Be sure to cleanup before re-assinging the strings.
823 if (this->containerApp
!=NULL
)
825 HeapFree( GetProcessHeap(), 0, this->containerApp
);
826 this->containerApp
= NULL
;
829 if (this->containerObj
!=NULL
)
831 HeapFree( GetProcessHeap(), 0, this->containerObj
);
832 this->containerObj
= NULL
;
836 * Copy the string supplied.
838 if (szContainerApp
!= NULL
)
840 if ((this->containerApp
= HeapAlloc( GetProcessHeap(), 0,
841 (lstrlenW(szContainerApp
) + 1) * sizeof(WCHAR
) )))
842 strcpyW( this->containerApp
, szContainerApp
);
845 if (szContainerObj
!= NULL
)
847 if ((this->containerObj
= HeapAlloc( GetProcessHeap(), 0,
848 (lstrlenW(szContainerObj
) + 1) * sizeof(WCHAR
) )))
849 strcpyW( this->containerObj
, szContainerObj
);
854 /************************************************************************
855 * DefaultHandler_Close (IOleObject)
857 * The default handler's implementation of this method is meaningless
858 * without a running server so it does nothing.
860 * See Windows documentation for more details on IOleObject methods.
862 static HRESULT WINAPI
DefaultHandler_Close(
870 /************************************************************************
871 * DefaultHandler_SetMoniker (IOleObject)
873 * The default handler's implementation of this method does nothing.
875 * See Windows documentation for more details on IOleObject methods.
877 static HRESULT WINAPI
DefaultHandler_SetMoniker(
879 DWORD dwWhichMoniker
,
882 TRACE("(%p, %ld, %p)\n",
890 /************************************************************************
891 * DefaultHandler_GetMoniker (IOleObject)
893 * Delegate this request to the client site if we have one.
895 * See Windows documentation for more details on IOleObject methods.
897 static HRESULT WINAPI
DefaultHandler_GetMoniker(
900 DWORD dwWhichMoniker
,
903 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
905 TRACE("(%p, %ld, %ld, %p)\n",
906 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
908 if (this->clientSite
)
910 return IOleClientSite_GetMoniker(this->clientSite
,
920 /************************************************************************
921 * DefaultHandler_InitFromData (IOleObject)
923 * This method is meaningless if the server is not running
925 * See Windows documentation for more details on IOleObject methods.
927 static HRESULT WINAPI
DefaultHandler_InitFromData(
929 IDataObject
* pDataObject
,
933 TRACE("(%p, %p, %d, %ld)\n",
934 iface
, pDataObject
, fCreation
, dwReserved
);
936 return OLE_E_NOTRUNNING
;
939 /************************************************************************
940 * DefaultHandler_GetClipboardData (IOleObject)
942 * This method is meaningless if the server is not running
944 * See Windows documentation for more details on IOleObject methods.
946 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
949 IDataObject
** ppDataObject
)
951 TRACE("(%p, %ld, %p)\n",
952 iface
, dwReserved
, ppDataObject
);
954 return OLE_E_NOTRUNNING
;
957 static HRESULT WINAPI
DefaultHandler_DoVerb(
960 struct tagMSG
* lpmsg
,
961 IOleClientSite
* pActiveSite
,
970 /************************************************************************
971 * DefaultHandler_EnumVerbs (IOleObject)
973 * The default handler implementation of this method simply delegates
976 * See Windows documentation for more details on IOleObject methods.
978 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
980 IEnumOLEVERB
** ppEnumOleVerb
)
982 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
984 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
986 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
989 static HRESULT WINAPI
DefaultHandler_Update(
996 /************************************************************************
997 * DefaultHandler_IsUpToDate (IOleObject)
999 * This method is meaningless if the server is not running
1001 * See Windows documentation for more details on IOleObject methods.
1003 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
1006 TRACE("(%p)\n", iface
);
1008 return OLE_E_NOTRUNNING
;
1011 /************************************************************************
1012 * DefaultHandler_GetUserClassID (IOleObject)
1014 * TODO: Map to a new class ID if emulation is active.
1016 * See Windows documentation for more details on IOleObject methods.
1018 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1022 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1024 TRACE("(%p, %p)\n", iface
, pClsid
);
1032 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1037 /************************************************************************
1038 * DefaultHandler_GetUserType (IOleObject)
1040 * The default handler implementation of this method simply delegates
1041 * to OleRegGetUserType
1043 * See Windows documentation for more details on IOleObject methods.
1045 static HRESULT WINAPI
DefaultHandler_GetUserType(
1048 LPOLESTR
* pszUserType
)
1050 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1052 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1054 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1057 /************************************************************************
1058 * DefaultHandler_SetExtent (IOleObject)
1060 * This method is meaningless if the server is not running
1062 * See Windows documentation for more details on IOleObject methods.
1064 static HRESULT WINAPI
DefaultHandler_SetExtent(
1069 TRACE("(%p, %lx, (%ld x %ld))\n", iface
,
1070 dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1071 return OLE_E_NOTRUNNING
;
1074 /************************************************************************
1075 * DefaultHandler_GetExtent (IOleObject)
1077 * The default handler's implementation of this method returns uses
1078 * the cache to locate the aspect and extract the extent from it.
1080 * See Windows documentation for more details on IOleObject methods.
1082 static HRESULT WINAPI
DefaultHandler_GetExtent(
1087 DVTARGETDEVICE
* targetDevice
;
1088 IViewObject2
* cacheView
= NULL
;
1091 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1093 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1095 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1098 return E_UNEXPECTED
;
1101 * Prepare the call to the cache's GetExtent method.
1103 * Here we would build a valid DVTARGETDEVICE structure
1104 * but, since we are calling into the data cache, we
1105 * know it's implementation and we'll skip this
1106 * extra work until later.
1108 targetDevice
= NULL
;
1110 hres
= IViewObject2_GetExtent(cacheView
,
1119 IViewObject2_Release(cacheView
);
1124 /************************************************************************
1125 * DefaultHandler_Advise (IOleObject)
1127 * The default handler's implementation of this method simply
1128 * delegates to the OleAdviseHolder.
1130 * See Windows documentation for more details on IOleObject methods.
1132 static HRESULT WINAPI
DefaultHandler_Advise(
1134 IAdviseSink
* pAdvSink
,
1135 DWORD
* pdwConnection
)
1137 HRESULT hres
= S_OK
;
1138 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1140 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1143 * Make sure we have an advise holder before we start.
1145 if (this->oleAdviseHolder
==NULL
)
1147 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1150 if (SUCCEEDED(hres
))
1152 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1160 /************************************************************************
1161 * DefaultHandler_Unadvise (IOleObject)
1163 * The default handler's implementation of this method simply
1164 * delegates to the OleAdviseHolder.
1166 * See Windows documentation for more details on IOleObject methods.
1168 static HRESULT WINAPI
DefaultHandler_Unadvise(
1172 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1174 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1177 * If we don't have an advise holder yet, it means we don't have
1180 if (this->oleAdviseHolder
==NULL
)
1181 return OLE_E_NOCONNECTION
;
1183 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1187 /************************************************************************
1188 * DefaultHandler_EnumAdvise (IOleObject)
1190 * The default handler's implementation of this method simply
1191 * delegates to the OleAdviseHolder.
1193 * See Windows documentation for more details on IOleObject methods.
1195 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1197 IEnumSTATDATA
** ppenumAdvise
)
1199 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1201 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1206 if (ppenumAdvise
==NULL
)
1210 * Initialize the out parameter.
1212 *ppenumAdvise
= NULL
;
1214 if (this->oleAdviseHolder
==NULL
)
1215 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1221 /************************************************************************
1222 * DefaultHandler_GetMiscStatus (IOleObject)
1224 * The default handler's implementation of this method simply delegates
1225 * to OleRegGetMiscStatus.
1227 * See Windows documentation for more details on IOleObject methods.
1229 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1235 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1237 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1239 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1247 /************************************************************************
1248 * DefaultHandler_SetExtent (IOleObject)
1250 * This method is meaningless if the server is not running
1252 * See Windows documentation for more details on IOleObject methods.
1254 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1256 struct tagLOGPALETTE
* pLogpal
)
1258 TRACE("(%p, %p))\n", iface
, pLogpal
);
1259 return OLE_E_NOTRUNNING
;
1262 /*********************************************************
1263 * Methods implementation for the IDataObject part of
1264 * the DefaultHandler class.
1267 /************************************************************************
1268 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1270 * See Windows documentation for more details on IUnknown methods.
1272 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1277 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1279 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1282 /************************************************************************
1283 * DefaultHandler_IDataObject_AddRef (IUnknown)
1285 * See Windows documentation for more details on IUnknown methods.
1287 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1290 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1292 return IUnknown_AddRef(this->outerUnknown
);
1295 /************************************************************************
1296 * DefaultHandler_IDataObject_Release (IUnknown)
1298 * See Windows documentation for more details on IUnknown methods.
1300 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1303 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1305 return IUnknown_Release(this->outerUnknown
);
1308 /************************************************************************
1309 * DefaultHandler_GetData
1311 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1312 * See Windows documentation for more details on GetData.
1313 * Default handler's implementation of this method delegates to the cache.
1315 static HRESULT WINAPI
DefaultHandler_GetData(
1317 LPFORMATETC pformatetcIn
,
1320 IDataObject
* cacheDataObject
= NULL
;
1323 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1325 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1327 hres
= IUnknown_QueryInterface(this->dataCache
,
1329 (void**)&cacheDataObject
);
1332 return E_UNEXPECTED
;
1334 hres
= IDataObject_GetData(cacheDataObject
,
1338 IDataObject_Release(cacheDataObject
);
1343 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1345 LPFORMATETC pformatetc
,
1352 /************************************************************************
1353 * DefaultHandler_QueryGetData (IDataObject)
1355 * The default handler's implementation of this method delegates to
1358 * See Windows documentation for more details on IDataObject methods.
1360 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1362 LPFORMATETC pformatetc
)
1364 IDataObject
* cacheDataObject
= NULL
;
1367 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1369 TRACE("(%p, %p)\n", iface
, pformatetc
);
1371 hres
= IUnknown_QueryInterface(this->dataCache
,
1373 (void**)&cacheDataObject
);
1376 return E_UNEXPECTED
;
1378 hres
= IDataObject_QueryGetData(cacheDataObject
,
1381 IDataObject_Release(cacheDataObject
);
1386 /************************************************************************
1387 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1389 * This method is meaningless if the server is not running
1391 * See Windows documentation for more details on IDataObject methods.
1393 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1395 LPFORMATETC pformatectIn
,
1396 LPFORMATETC pformatetcOut
)
1398 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1400 return OLE_E_NOTRUNNING
;
1403 /************************************************************************
1404 * DefaultHandler_SetData (IDataObject)
1406 * The default handler's implementation of this method delegates to
1409 * See Windows documentation for more details on IDataObject methods.
1411 static HRESULT WINAPI
DefaultHandler_SetData(
1413 LPFORMATETC pformatetc
,
1417 IDataObject
* cacheDataObject
= NULL
;
1420 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1422 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1424 hres
= IUnknown_QueryInterface(this->dataCache
,
1426 (void**)&cacheDataObject
);
1429 return E_UNEXPECTED
;
1431 hres
= IDataObject_SetData(cacheDataObject
,
1436 IDataObject_Release(cacheDataObject
);
1441 /************************************************************************
1442 * DefaultHandler_EnumFormatEtc (IDataObject)
1444 * The default handler's implementation of this method simply delegates
1445 * to OleRegEnumFormatEtc.
1447 * See Windows documentation for more details on IDataObject methods.
1449 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1452 IEnumFORMATETC
** ppenumFormatEtc
)
1455 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1457 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1459 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1464 /************************************************************************
1465 * DefaultHandler_DAdvise (IDataObject)
1467 * The default handler's implementation of this method simply
1468 * delegates to the DataAdviseHolder.
1470 * See Windows documentation for more details on IDataObject methods.
1472 static HRESULT WINAPI
DefaultHandler_DAdvise(
1474 FORMATETC
* pformatetc
,
1476 IAdviseSink
* pAdvSink
,
1477 DWORD
* pdwConnection
)
1479 HRESULT hres
= S_OK
;
1480 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1482 TRACE("(%p, %p, %ld, %p, %p)\n",
1483 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1486 * Make sure we have a data advise holder before we start.
1488 if (this->dataAdviseHolder
==NULL
)
1490 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1493 if (SUCCEEDED(hres
))
1495 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1506 /************************************************************************
1507 * DefaultHandler_DUnadvise (IDataObject)
1509 * The default handler's implementation of this method simply
1510 * delegates to the DataAdviseHolder.
1512 * See Windows documentation for more details on IDataObject methods.
1514 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1518 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1520 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1523 * If we don't have a data advise holder yet, it means that
1524 * we don't have any connections..
1526 if (this->dataAdviseHolder
==NULL
)
1528 return OLE_E_NOCONNECTION
;
1531 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1535 /************************************************************************
1536 * DefaultHandler_EnumDAdvise (IDataObject)
1538 * The default handler's implementation of this method simply
1539 * delegates to the DataAdviseHolder.
1541 * See Windows documentation for more details on IDataObject methods.
1543 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1545 IEnumSTATDATA
** ppenumAdvise
)
1547 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1549 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1554 if (ppenumAdvise
== NULL
)
1558 * Initialize the out parameter.
1560 *ppenumAdvise
= NULL
;
1563 * If we have a data advise holder object, delegate.
1565 if (this->dataAdviseHolder
!=NULL
)
1567 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1574 /*********************************************************
1575 * Methods implementation for the IRunnableObject part
1576 * of the DefaultHandler class.
1579 /************************************************************************
1580 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1582 * See Windows documentation for more details on IUnknown methods.
1584 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1585 IRunnableObject
* iface
,
1589 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1591 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1594 /************************************************************************
1595 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1597 * See Windows documentation for more details on IUnknown methods.
1599 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1600 IRunnableObject
* iface
)
1602 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1604 return IUnknown_AddRef(this->outerUnknown
);
1607 /************************************************************************
1608 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1610 * See Windows documentation for more details on IUnknown methods.
1612 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1613 IRunnableObject
* iface
)
1615 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1617 return IUnknown_Release(this->outerUnknown
);
1620 /************************************************************************
1621 * DefaultHandler_GetRunningClass (IRunnableObject)
1623 * According to Brockscmidt, Chapter 19, the default handler's
1624 * implementation of IRunnableobject does nothing until the object
1625 * is actually running.
1627 * See Windows documentation for more details on IRunnableObject methods.
1629 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1630 IRunnableObject
* iface
,
1637 static HRESULT WINAPI
DefaultHandler_Run(
1638 IRunnableObject
* iface
,
1645 /************************************************************************
1646 * DefaultHandler_IsRunning (IRunnableObject)
1648 * According to Brockscmidt, Chapter 19, the default handler's
1649 * implementation of IRunnableobject does nothing until the object
1650 * is actually running.
1652 * See Windows documentation for more details on IRunnableObject methods.
1654 static BOOL WINAPI
DefaultHandler_IsRunning(
1655 IRunnableObject
* iface
)
1661 /************************************************************************
1662 * DefaultHandler_LockRunning (IRunnableObject)
1664 * According to Brockscmidt, Chapter 19, the default handler's
1665 * implementation of IRunnableobject does nothing until the object
1666 * is actually running.
1668 * See Windows documentation for more details on IRunnableObject methods.
1670 static HRESULT WINAPI
DefaultHandler_LockRunning(
1671 IRunnableObject
* iface
,
1673 BOOL fLastUnlockCloses
)
1679 /************************************************************************
1680 * DefaultHandler_SetContainedObject (IRunnableObject)
1682 * According to Brockscmidt, Chapter 19, the default handler's
1683 * implementation of IRunnableobject does nothing until the object
1684 * is actually running.
1686 * See Windows documentation for more details on IRunnableObject methods.
1688 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1689 IRunnableObject
* iface
,