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.
58 #include "wine/unicode.h"
60 #include "wine/debug.h"
62 WINE_DEFAULT_DEBUG_CHANNEL(ole);
64 /****************************************************************************
71 * List all interface VTables here
73 IOleObjectVtbl* lpvtbl1;
74 IUnknownVtbl* lpvtbl2;
75 IDataObjectVtbl* lpvtbl3;
76 IRunnableObjectVtbl* lpvtbl4;
79 * Reference count of this object
84 * IUnknown implementation of the outer object.
86 IUnknown* outerUnknown;
89 * Class Id that this handler object represents.
94 * IUnknown implementation of the datacache.
99 * Client site for the embedded object.
101 IOleClientSite* clientSite;
104 * The IOleAdviseHolder maintains the connections
105 * on behalf of the default handler.
107 IOleAdviseHolder* oleAdviseHolder;
110 * The IDataAdviseHolder maintains the data
111 * connections on behalf of the default handler.
113 IDataAdviseHolder* dataAdviseHolder;
116 * Name of the container and object contained
123 typedef struct DefaultHandler DefaultHandler;
126 * Here, I define utility macros to help with the casting of the
128 * There is a version to accommodate all of the VTables implemented
131 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name
132 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
133 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
134 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
137 * Prototypes for the methods of the DefaultHandler class.
139 static DefaultHandler* DefaultHandler_Construct(REFCLSID clsid,
140 LPUNKNOWN pUnkOuter);
141 static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
144 * Prototypes for the methods of the DefaultHandler class
145 * that implement non delegating IUnknown methods.
147 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
151 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
153 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
157 * Prototypes for the methods of the DefaultHandler class
158 * that implement IOleObject methods.
160 static HRESULT WINAPI DefaultHandler_QueryInterface(
164 static ULONG WINAPI DefaultHandler_AddRef(
166 static ULONG WINAPI DefaultHandler_Release(
168 static HRESULT WINAPI DefaultHandler_SetClientSite(
170 IOleClientSite* pClientSite);
171 static HRESULT WINAPI DefaultHandler_GetClientSite(
173 IOleClientSite** ppClientSite);
174 static HRESULT WINAPI DefaultHandler_SetHostNames(
176 LPCOLESTR szContainerApp,
177 LPCOLESTR szContainerObj);
178 static HRESULT WINAPI DefaultHandler_Close(
181 static HRESULT WINAPI DefaultHandler_SetMoniker(
183 DWORD dwWhichMoniker,
185 static HRESULT WINAPI DefaultHandler_GetMoniker(
188 DWORD dwWhichMoniker,
190 static HRESULT WINAPI DefaultHandler_InitFromData(
192 IDataObject* pDataObject,
195 static HRESULT WINAPI DefaultHandler_GetClipboardData(
198 IDataObject** ppDataObject);
199 static HRESULT WINAPI DefaultHandler_DoVerb(
202 struct tagMSG* lpmsg,
203 IOleClientSite* pActiveSite,
206 LPCRECT lprcPosRect);
207 static HRESULT WINAPI DefaultHandler_EnumVerbs(
209 IEnumOLEVERB** ppEnumOleVerb);
210 static HRESULT WINAPI DefaultHandler_Update(
212 static HRESULT WINAPI DefaultHandler_IsUpToDate(
214 static HRESULT WINAPI DefaultHandler_GetUserClassID(
217 static HRESULT WINAPI DefaultHandler_GetUserType(
220 LPOLESTR* pszUserType);
221 static HRESULT WINAPI DefaultHandler_SetExtent(
225 static HRESULT WINAPI DefaultHandler_GetExtent(
229 static HRESULT WINAPI DefaultHandler_Advise(
231 IAdviseSink* pAdvSink,
232 DWORD* pdwConnection);
233 static HRESULT WINAPI DefaultHandler_Unadvise(
236 static HRESULT WINAPI DefaultHandler_EnumAdvise(
238 IEnumSTATDATA** ppenumAdvise);
239 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
243 static HRESULT WINAPI DefaultHandler_SetColorScheme(
245 struct tagLOGPALETTE* pLogpal);
248 * Prototypes for the methods of the DefaultHandler class
249 * that implement IDataObject methods.
251 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
255 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
257 static ULONG WINAPI DefaultHandler_IDataObject_Release(
259 static HRESULT WINAPI DefaultHandler_GetData(
261 LPFORMATETC pformatetcIn,
263 static HRESULT WINAPI DefaultHandler_GetDataHere(
265 LPFORMATETC pformatetc,
267 static HRESULT WINAPI DefaultHandler_QueryGetData(
269 LPFORMATETC pformatetc);
270 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
272 LPFORMATETC pformatectIn,
273 LPFORMATETC pformatetcOut);
274 static HRESULT WINAPI DefaultHandler_SetData(
276 LPFORMATETC pformatetc,
279 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
282 IEnumFORMATETC** ppenumFormatEtc);
283 static HRESULT WINAPI DefaultHandler_DAdvise(
285 FORMATETC* pformatetc,
287 IAdviseSink* pAdvSink,
288 DWORD* pdwConnection);
289 static HRESULT WINAPI DefaultHandler_DUnadvise(
292 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
294 IEnumSTATDATA** ppenumAdvise);
297 * Prototypes for the methods of the DefaultHandler class
298 * that implement IRunnableObject methods.
300 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
301 IRunnableObject* iface,
304 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
305 IRunnableObject* iface);
306 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
307 IRunnableObject* iface);
308 static HRESULT WINAPI DefaultHandler_GetRunningClass(
309 IRunnableObject* iface,
311 static HRESULT WINAPI DefaultHandler_Run(
312 IRunnableObject* iface,
314 static BOOL WINAPI DefaultHandler_IsRunning(
315 IRunnableObject* iface);
316 static HRESULT WINAPI DefaultHandler_LockRunning(
317 IRunnableObject* iface,
319 BOOL fLastUnlockCloses);
320 static HRESULT WINAPI DefaultHandler_SetContainedObject(
321 IRunnableObject* iface,
326 * Virtual function tables for the DefaultHandler class.
328 static IOleObjectVtbl DefaultHandler_IOleObject_VTable =
330 DefaultHandler_QueryInterface,
331 DefaultHandler_AddRef,
332 DefaultHandler_Release,
333 DefaultHandler_SetClientSite,
334 DefaultHandler_GetClientSite,
335 DefaultHandler_SetHostNames,
336 DefaultHandler_Close,
337 DefaultHandler_SetMoniker,
338 DefaultHandler_GetMoniker,
339 DefaultHandler_InitFromData,
340 DefaultHandler_GetClipboardData,
341 DefaultHandler_DoVerb,
342 DefaultHandler_EnumVerbs,
343 DefaultHandler_Update,
344 DefaultHandler_IsUpToDate,
345 DefaultHandler_GetUserClassID,
346 DefaultHandler_GetUserType,
347 DefaultHandler_SetExtent,
348 DefaultHandler_GetExtent,
349 DefaultHandler_Advise,
350 DefaultHandler_Unadvise,
351 DefaultHandler_EnumAdvise,
352 DefaultHandler_GetMiscStatus,
353 DefaultHandler_SetColorScheme
356 static IUnknownVtbl DefaultHandler_NDIUnknown_VTable =
358 DefaultHandler_NDIUnknown_QueryInterface,
359 DefaultHandler_NDIUnknown_AddRef,
360 DefaultHandler_NDIUnknown_Release,
363 static IDataObjectVtbl DefaultHandler_IDataObject_VTable =
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 IRunnableObjectVtbl DefaultHandler_IRunnableObject_VTable =
381 DefaultHandler_IRunnableObject_QueryInterface,
382 DefaultHandler_IRunnableObject_AddRef,
383 DefaultHandler_IRunnableObject_Release,
384 DefaultHandler_GetRunningClass,
386 DefaultHandler_IsRunning,
387 DefaultHandler_LockRunning,
388 DefaultHandler_SetContainedObject
391 /******************************************************************************
392 * OleCreateDefaultHandler [OLE32.@]
394 HRESULT WINAPI OleCreateDefaultHandler(
400 DefaultHandler* newHandler = NULL;
403 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter, debugstr_guid(riid), ppvObj);
414 * If this handler is constructed for aggregation, make sure
415 * the caller is requesting the IUnknown interface.
416 * This is necessary because it's the only time the non-delegating
417 * IUnknown pointer can be returned to the outside.
419 if ( (pUnkOuter!=NULL) &&
420 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
421 return CLASS_E_NOAGGREGATION;
424 * Try to construct a new instance of the class.
426 newHandler = DefaultHandler_Construct(clsid,
430 return E_OUTOFMEMORY;
433 * Make sure it supports the interface required by the caller.
435 hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtbl2), riid, ppvObj);
438 * Release the reference obtained in the constructor. If
439 * the QueryInterface was unsuccessful, it will free the class.
441 IUnknown_Release((IUnknown*)&(newHandler->lpvtbl2));
446 /*********************************************************
447 * Methods implementation for the DefaultHandler class.
449 static DefaultHandler* DefaultHandler_Construct(
453 DefaultHandler* newObject = 0;
456 * Allocate space for the object.
458 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
464 * Initialize the virtual function table.
466 newObject->lpvtbl1 = &DefaultHandler_IOleObject_VTable;
467 newObject->lpvtbl2 = &DefaultHandler_NDIUnknown_VTable;
468 newObject->lpvtbl3 = &DefaultHandler_IDataObject_VTable;
469 newObject->lpvtbl4 = &DefaultHandler_IRunnableObject_VTable;
472 * Start with one reference count. The caller of this function
473 * must release the interface pointer when it is done.
478 * Initialize the outer unknown
479 * We don't keep a reference on the outer unknown since, the way
480 * aggregation works, our lifetime is at least as large as it's
484 pUnkOuter = (IUnknown*)&(newObject->lpvtbl2);
486 newObject->outerUnknown = pUnkOuter;
489 * Create a datacache object.
490 * We aggregate with the datacache. Make sure we pass our outer
491 * unknown as the datacache's outer unknown.
493 CreateDataCache(newObject->outerUnknown,
496 (void**)&newObject->dataCache);
499 * Initialize the other data members of the class.
501 memcpy(&(newObject->clsid), clsid, sizeof(CLSID));
502 newObject->clientSite = NULL;
503 newObject->oleAdviseHolder = NULL;
504 newObject->dataAdviseHolder = NULL;
505 newObject->containerApp = NULL;
506 newObject->containerObj = NULL;
511 static void DefaultHandler_Destroy(
512 DefaultHandler* ptrToDestroy)
515 * Free the strings idenfitying the object
517 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerApp );
518 ptrToDestroy->containerApp = NULL;
519 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerObj );
520 ptrToDestroy->containerObj = NULL;
523 * Release our reference to the data cache.
525 if (ptrToDestroy->dataCache!=NULL)
527 IUnknown_Release(ptrToDestroy->dataCache);
528 ptrToDestroy->dataCache = NULL;
532 * Same thing for the client site.
534 if (ptrToDestroy->clientSite!=NULL)
536 IOleClientSite_Release(ptrToDestroy->clientSite);
537 ptrToDestroy->clientSite = NULL;
541 * And the advise holder.
543 if (ptrToDestroy->oleAdviseHolder!=NULL)
545 IOleAdviseHolder_Release(ptrToDestroy->oleAdviseHolder);
546 ptrToDestroy->oleAdviseHolder = NULL;
550 * And the data advise holder.
552 if (ptrToDestroy->dataAdviseHolder!=NULL)
554 IDataAdviseHolder_Release(ptrToDestroy->dataAdviseHolder);
555 ptrToDestroy->dataAdviseHolder = NULL;
560 * Free the actual default handler structure.
562 HeapFree(GetProcessHeap(), 0, ptrToDestroy);
565 /*********************************************************
566 * Method implementation for the non delegating IUnknown
567 * part of the DefaultHandler class.
570 /************************************************************************
571 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
573 * See Windows documentation for more details on IUnknown methods.
575 * This version of QueryInterface will not delegate it's implementation
576 * to the outer unknown.
578 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
583 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
586 * Perform a sanity check on the parameters.
588 if ( (this==0) || (ppvObject==0) )
592 * Initialize the return parameter.
597 * Compare the riid with the interface IDs implemented by this object.
599 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
603 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
605 *ppvObject = (IOleObject*)&(this->lpvtbl1);
607 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
609 *ppvObject = (IDataObject*)&(this->lpvtbl3);
611 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
613 *ppvObject = (IRunnableObject*)&(this->lpvtbl4);
618 * Blind aggregate the data cache to "inherit" it's interfaces.
620 if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK)
625 * Check that we obtained an interface.
629 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid));
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);
654 return InterlockedIncrement(&this->ref);
657 /************************************************************************
658 * DefaultHandler_NDIUnknown_Release (IUnknown)
660 * See Windows documentation for more details on IUnknown methods.
662 * This version of QueryInterface will not delegate it's implementation
663 * to the outer unknown.
665 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
668 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
672 * Decrease the reference count on this object.
674 ref = InterlockedDecrement(&this->ref);
677 * If the reference count goes down to 0, perform suicide.
679 if (ref == 0) DefaultHandler_Destroy(this);
684 /*********************************************************
685 * Methods implementation for the IOleObject part of
686 * the DefaultHandler class.
689 /************************************************************************
690 * DefaultHandler_QueryInterface (IUnknown)
692 * See Windows documentation for more details on IUnknown methods.
694 static HRESULT WINAPI DefaultHandler_QueryInterface(
699 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
701 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
704 /************************************************************************
705 * DefaultHandler_AddRef (IUnknown)
707 * See Windows documentation for more details on IUnknown methods.
709 static ULONG WINAPI DefaultHandler_AddRef(
712 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
714 return IUnknown_AddRef(this->outerUnknown);
717 /************************************************************************
718 * DefaultHandler_Release (IUnknown)
720 * See Windows documentation for more details on IUnknown methods.
722 static ULONG WINAPI DefaultHandler_Release(
725 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
727 return IUnknown_Release(this->outerUnknown);
730 /************************************************************************
731 * DefaultHandler_SetClientSite (IOleObject)
733 * The default handler's implementation of this method only keeps the
734 * client site pointer for future reference.
736 * See Windows documentation for more details on IOleObject methods.
738 static HRESULT WINAPI DefaultHandler_SetClientSite(
740 IOleClientSite* pClientSite)
742 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
744 TRACE("(%p, %p)\n", iface, pClientSite);
747 * Make sure we release the previous client site if there
750 if (this->clientSite!=NULL)
752 IOleClientSite_Release(this->clientSite);
755 this->clientSite = pClientSite;
757 if (this->clientSite!=NULL)
759 IOleClientSite_AddRef(this->clientSite);
765 /************************************************************************
766 * DefaultHandler_GetClientSite (IOleObject)
768 * The default handler's implementation of this method returns the
769 * last pointer set in IOleObject_SetClientSite.
771 * See Windows documentation for more details on IOleObject methods.
773 static HRESULT WINAPI DefaultHandler_GetClientSite(
775 IOleClientSite** ppClientSite)
777 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
782 if (ppClientSite == NULL)
785 *ppClientSite = this->clientSite;
787 if (this->clientSite != NULL)
789 IOleClientSite_AddRef(this->clientSite);
795 /************************************************************************
796 * DefaultHandler_SetHostNames (IOleObject)
798 * The default handler's implementation of this method just stores
799 * the strings and returns S_OK.
801 * See Windows documentation for more details on IOleObject methods.
803 static HRESULT WINAPI DefaultHandler_SetHostNames(
805 LPCOLESTR szContainerApp,
806 LPCOLESTR szContainerObj)
808 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
810 TRACE("(%p, %s, %s)\n",
812 debugstr_w(szContainerApp),
813 debugstr_w(szContainerObj));
816 * Be sure to cleanup before re-assinging the strings.
818 HeapFree( GetProcessHeap(), 0, this->containerApp );
819 this->containerApp = NULL;
820 HeapFree( GetProcessHeap(), 0, this->containerObj );
821 this->containerObj = NULL;
824 * Copy the string supplied.
826 if (szContainerApp != NULL)
828 if ((this->containerApp = HeapAlloc( GetProcessHeap(), 0,
829 (lstrlenW(szContainerApp) + 1) * sizeof(WCHAR) )))
830 strcpyW( this->containerApp, szContainerApp );
833 if (szContainerObj != NULL)
835 if ((this->containerObj = HeapAlloc( GetProcessHeap(), 0,
836 (lstrlenW(szContainerObj) + 1) * sizeof(WCHAR) )))
837 strcpyW( this->containerObj, szContainerObj );
842 /************************************************************************
843 * DefaultHandler_Close (IOleObject)
845 * The default handler's implementation of this method is meaningless
846 * without a running server so it does nothing.
848 * See Windows documentation for more details on IOleObject methods.
850 static HRESULT WINAPI DefaultHandler_Close(
858 /************************************************************************
859 * DefaultHandler_SetMoniker (IOleObject)
861 * The default handler's implementation of this method does nothing.
863 * See Windows documentation for more details on IOleObject methods.
865 static HRESULT WINAPI DefaultHandler_SetMoniker(
867 DWORD dwWhichMoniker,
870 TRACE("(%p, %ld, %p)\n",
878 /************************************************************************
879 * DefaultHandler_GetMoniker (IOleObject)
881 * Delegate this request to the client site if we have one.
883 * See Windows documentation for more details on IOleObject methods.
885 static HRESULT WINAPI DefaultHandler_GetMoniker(
888 DWORD dwWhichMoniker,
891 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
893 TRACE("(%p, %ld, %ld, %p)\n",
894 iface, dwAssign, dwWhichMoniker, ppmk);
896 if (this->clientSite)
898 return IOleClientSite_GetMoniker(this->clientSite,
908 /************************************************************************
909 * DefaultHandler_InitFromData (IOleObject)
911 * This method is meaningless if the server is not running
913 * See Windows documentation for more details on IOleObject methods.
915 static HRESULT WINAPI DefaultHandler_InitFromData(
917 IDataObject* pDataObject,
921 TRACE("(%p, %p, %d, %ld)\n",
922 iface, pDataObject, fCreation, dwReserved);
924 return OLE_E_NOTRUNNING;
927 /************************************************************************
928 * DefaultHandler_GetClipboardData (IOleObject)
930 * This method is meaningless if the server is not running
932 * See Windows documentation for more details on IOleObject methods.
934 static HRESULT WINAPI DefaultHandler_GetClipboardData(
937 IDataObject** ppDataObject)
939 TRACE("(%p, %ld, %p)\n",
940 iface, dwReserved, ppDataObject);
942 return OLE_E_NOTRUNNING;
945 static HRESULT WINAPI DefaultHandler_DoVerb(
948 struct tagMSG* lpmsg,
949 IOleClientSite* pActiveSite,
958 /************************************************************************
959 * DefaultHandler_EnumVerbs (IOleObject)
961 * The default handler implementation of this method simply delegates
964 * See Windows documentation for more details on IOleObject methods.
966 static HRESULT WINAPI DefaultHandler_EnumVerbs(
968 IEnumOLEVERB** ppEnumOleVerb)
970 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
972 TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
974 return OleRegEnumVerbs(&this->clsid, ppEnumOleVerb);
977 static HRESULT WINAPI DefaultHandler_Update(
984 /************************************************************************
985 * DefaultHandler_IsUpToDate (IOleObject)
987 * This method is meaningless if the server is not running
989 * See Windows documentation for more details on IOleObject methods.
991 static HRESULT WINAPI DefaultHandler_IsUpToDate(
994 TRACE("(%p)\n", iface);
996 return OLE_E_NOTRUNNING;
999 /************************************************************************
1000 * DefaultHandler_GetUserClassID (IOleObject)
1002 * TODO: Map to a new class ID if emulation is active.
1004 * See Windows documentation for more details on IOleObject methods.
1006 static HRESULT WINAPI DefaultHandler_GetUserClassID(
1010 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1012 TRACE("(%p, %p)\n", iface, pClsid);
1020 memcpy(pClsid, &this->clsid, sizeof(CLSID));
1025 /************************************************************************
1026 * DefaultHandler_GetUserType (IOleObject)
1028 * The default handler implementation of this method simply delegates
1029 * to OleRegGetUserType
1031 * See Windows documentation for more details on IOleObject methods.
1033 static HRESULT WINAPI DefaultHandler_GetUserType(
1036 LPOLESTR* pszUserType)
1038 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1040 TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
1042 return OleRegGetUserType(&this->clsid, dwFormOfType, pszUserType);
1045 /************************************************************************
1046 * DefaultHandler_SetExtent (IOleObject)
1048 * This method is meaningless if the server is not running
1050 * See Windows documentation for more details on IOleObject methods.
1052 static HRESULT WINAPI DefaultHandler_SetExtent(
1057 TRACE("(%p, %lx, (%ld x %ld))\n", iface,
1058 dwDrawAspect, psizel->cx, psizel->cy);
1059 return OLE_E_NOTRUNNING;
1062 /************************************************************************
1063 * DefaultHandler_GetExtent (IOleObject)
1065 * The default handler's implementation of this method returns uses
1066 * the cache to locate the aspect and extract the extent from it.
1068 * See Windows documentation for more details on IOleObject methods.
1070 static HRESULT WINAPI DefaultHandler_GetExtent(
1075 DVTARGETDEVICE* targetDevice;
1076 IViewObject2* cacheView = NULL;
1079 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1081 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
1083 hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
1086 return E_UNEXPECTED;
1089 * Prepare the call to the cache's GetExtent method.
1091 * Here we would build a valid DVTARGETDEVICE structure
1092 * but, since we are calling into the data cache, we
1093 * know it's implementation and we'll skip this
1094 * extra work until later.
1096 targetDevice = NULL;
1098 hres = IViewObject2_GetExtent(cacheView,
1107 IViewObject2_Release(cacheView);
1112 /************************************************************************
1113 * DefaultHandler_Advise (IOleObject)
1115 * The default handler's implementation of this method simply
1116 * delegates to the OleAdviseHolder.
1118 * See Windows documentation for more details on IOleObject methods.
1120 static HRESULT WINAPI DefaultHandler_Advise(
1122 IAdviseSink* pAdvSink,
1123 DWORD* pdwConnection)
1125 HRESULT hres = S_OK;
1126 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1128 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
1131 * Make sure we have an advise holder before we start.
1133 if (this->oleAdviseHolder==NULL)
1135 hres = CreateOleAdviseHolder(&this->oleAdviseHolder);
1138 if (SUCCEEDED(hres))
1140 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
1148 /************************************************************************
1149 * DefaultHandler_Unadvise (IOleObject)
1151 * The default handler's implementation of this method simply
1152 * delegates to the OleAdviseHolder.
1154 * See Windows documentation for more details on IOleObject methods.
1156 static HRESULT WINAPI DefaultHandler_Unadvise(
1160 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1162 TRACE("(%p, %ld)\n", iface, dwConnection);
1165 * If we don't have an advise holder yet, it means we don't have
1168 if (this->oleAdviseHolder==NULL)
1169 return OLE_E_NOCONNECTION;
1171 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
1175 /************************************************************************
1176 * DefaultHandler_EnumAdvise (IOleObject)
1178 * The default handler's implementation of this method simply
1179 * delegates to the OleAdviseHolder.
1181 * See Windows documentation for more details on IOleObject methods.
1183 static HRESULT WINAPI DefaultHandler_EnumAdvise(
1185 IEnumSTATDATA** ppenumAdvise)
1187 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1189 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1194 if (ppenumAdvise==NULL)
1198 * Initialize the out parameter.
1200 *ppenumAdvise = NULL;
1202 if (this->oleAdviseHolder==NULL)
1203 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
1209 /************************************************************************
1210 * DefaultHandler_GetMiscStatus (IOleObject)
1212 * The default handler's implementation of this method simply delegates
1213 * to OleRegGetMiscStatus.
1215 * See Windows documentation for more details on IOleObject methods.
1217 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
1223 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1225 TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
1227 hres = OleRegGetMiscStatus(&(this->clsid), dwAspect, pdwStatus);
1235 /************************************************************************
1236 * DefaultHandler_SetExtent (IOleObject)
1238 * This method is meaningless if the server is not running
1240 * See Windows documentation for more details on IOleObject methods.
1242 static HRESULT WINAPI DefaultHandler_SetColorScheme(
1244 struct tagLOGPALETTE* pLogpal)
1246 TRACE("(%p, %p))\n", iface, pLogpal);
1247 return OLE_E_NOTRUNNING;
1250 /*********************************************************
1251 * Methods implementation for the IDataObject part of
1252 * the DefaultHandler class.
1255 /************************************************************************
1256 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1258 * See Windows documentation for more details on IUnknown methods.
1260 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
1265 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1267 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1270 /************************************************************************
1271 * DefaultHandler_IDataObject_AddRef (IUnknown)
1273 * See Windows documentation for more details on IUnknown methods.
1275 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
1278 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1280 return IUnknown_AddRef(this->outerUnknown);
1283 /************************************************************************
1284 * DefaultHandler_IDataObject_Release (IUnknown)
1286 * See Windows documentation for more details on IUnknown methods.
1288 static ULONG WINAPI DefaultHandler_IDataObject_Release(
1291 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1293 return IUnknown_Release(this->outerUnknown);
1296 /************************************************************************
1297 * DefaultHandler_GetData
1299 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1300 * See Windows documentation for more details on GetData.
1301 * Default handler's implementation of this method delegates to the cache.
1303 static HRESULT WINAPI DefaultHandler_GetData(
1305 LPFORMATETC pformatetcIn,
1308 IDataObject* cacheDataObject = NULL;
1311 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1313 TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
1315 hres = IUnknown_QueryInterface(this->dataCache,
1317 (void**)&cacheDataObject);
1320 return E_UNEXPECTED;
1322 hres = IDataObject_GetData(cacheDataObject,
1326 IDataObject_Release(cacheDataObject);
1331 static HRESULT WINAPI DefaultHandler_GetDataHere(
1333 LPFORMATETC pformatetc,
1340 /************************************************************************
1341 * DefaultHandler_QueryGetData (IDataObject)
1343 * The default handler's implementation of this method delegates to
1346 * See Windows documentation for more details on IDataObject methods.
1348 static HRESULT WINAPI DefaultHandler_QueryGetData(
1350 LPFORMATETC pformatetc)
1352 IDataObject* cacheDataObject = NULL;
1355 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1357 TRACE("(%p, %p)\n", iface, pformatetc);
1359 hres = IUnknown_QueryInterface(this->dataCache,
1361 (void**)&cacheDataObject);
1364 return E_UNEXPECTED;
1366 hres = IDataObject_QueryGetData(cacheDataObject,
1369 IDataObject_Release(cacheDataObject);
1374 /************************************************************************
1375 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1377 * This method is meaningless if the server is not running
1379 * See Windows documentation for more details on IDataObject methods.
1381 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
1383 LPFORMATETC pformatectIn,
1384 LPFORMATETC pformatetcOut)
1386 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
1388 return OLE_E_NOTRUNNING;
1391 /************************************************************************
1392 * DefaultHandler_SetData (IDataObject)
1394 * The default handler's implementation of this method delegates to
1397 * See Windows documentation for more details on IDataObject methods.
1399 static HRESULT WINAPI DefaultHandler_SetData(
1401 LPFORMATETC pformatetc,
1405 IDataObject* cacheDataObject = NULL;
1408 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1410 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1412 hres = IUnknown_QueryInterface(this->dataCache,
1414 (void**)&cacheDataObject);
1417 return E_UNEXPECTED;
1419 hres = IDataObject_SetData(cacheDataObject,
1424 IDataObject_Release(cacheDataObject);
1429 /************************************************************************
1430 * DefaultHandler_EnumFormatEtc (IDataObject)
1432 * The default handler's implementation of this method simply delegates
1433 * to OleRegEnumFormatEtc.
1435 * See Windows documentation for more details on IDataObject methods.
1437 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
1440 IEnumFORMATETC** ppenumFormatEtc)
1443 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1445 TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
1447 hres = OleRegEnumFormatEtc(&(this->clsid), dwDirection, ppenumFormatEtc);
1452 /************************************************************************
1453 * DefaultHandler_DAdvise (IDataObject)
1455 * The default handler's implementation of this method simply
1456 * delegates to the DataAdviseHolder.
1458 * See Windows documentation for more details on IDataObject methods.
1460 static HRESULT WINAPI DefaultHandler_DAdvise(
1462 FORMATETC* pformatetc,
1464 IAdviseSink* pAdvSink,
1465 DWORD* pdwConnection)
1467 HRESULT hres = S_OK;
1468 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1470 TRACE("(%p, %p, %ld, %p, %p)\n",
1471 iface, pformatetc, advf, pAdvSink, pdwConnection);
1474 * Make sure we have a data advise holder before we start.
1476 if (this->dataAdviseHolder==NULL)
1478 hres = CreateDataAdviseHolder(&this->dataAdviseHolder);
1481 if (SUCCEEDED(hres))
1483 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
1494 /************************************************************************
1495 * DefaultHandler_DUnadvise (IDataObject)
1497 * The default handler's implementation of this method simply
1498 * delegates to the DataAdviseHolder.
1500 * See Windows documentation for more details on IDataObject methods.
1502 static HRESULT WINAPI DefaultHandler_DUnadvise(
1506 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1508 TRACE("(%p, %ld)\n", iface, dwConnection);
1511 * If we don't have a data advise holder yet, it means that
1512 * we don't have any connections..
1514 if (this->dataAdviseHolder==NULL)
1516 return OLE_E_NOCONNECTION;
1519 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
1523 /************************************************************************
1524 * DefaultHandler_EnumDAdvise (IDataObject)
1526 * The default handler's implementation of this method simply
1527 * delegates to the DataAdviseHolder.
1529 * See Windows documentation for more details on IDataObject methods.
1531 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
1533 IEnumSTATDATA** ppenumAdvise)
1535 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1537 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1542 if (ppenumAdvise == NULL)
1546 * Initialize the out parameter.
1548 *ppenumAdvise = NULL;
1551 * If we have a data advise holder object, delegate.
1553 if (this->dataAdviseHolder!=NULL)
1555 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
1562 /*********************************************************
1563 * Methods implementation for the IRunnableObject part
1564 * of the DefaultHandler class.
1567 /************************************************************************
1568 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1570 * See Windows documentation for more details on IUnknown methods.
1572 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
1573 IRunnableObject* iface,
1577 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1579 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1582 /************************************************************************
1583 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1585 * See Windows documentation for more details on IUnknown methods.
1587 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
1588 IRunnableObject* iface)
1590 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1592 return IUnknown_AddRef(this->outerUnknown);
1595 /************************************************************************
1596 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1598 * See Windows documentation for more details on IUnknown methods.
1600 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
1601 IRunnableObject* iface)
1603 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1605 return IUnknown_Release(this->outerUnknown);
1608 /************************************************************************
1609 * DefaultHandler_GetRunningClass (IRunnableObject)
1611 * According to Brockscmidt, Chapter 19, the default handler's
1612 * implementation of IRunnableobject does nothing until the object
1613 * is actually running.
1615 * See Windows documentation for more details on IRunnableObject methods.
1617 static HRESULT WINAPI DefaultHandler_GetRunningClass(
1618 IRunnableObject* iface,
1625 static HRESULT WINAPI DefaultHandler_Run(
1626 IRunnableObject* iface,
1633 /************************************************************************
1634 * DefaultHandler_IsRunning (IRunnableObject)
1636 * According to Brockscmidt, Chapter 19, the default handler's
1637 * implementation of IRunnableobject does nothing until the object
1638 * is actually running.
1640 * See Windows documentation for more details on IRunnableObject methods.
1642 static BOOL WINAPI DefaultHandler_IsRunning(
1643 IRunnableObject* iface)
1649 /************************************************************************
1650 * DefaultHandler_LockRunning (IRunnableObject)
1652 * According to Brockscmidt, Chapter 19, the default handler's
1653 * implementation of IRunnableobject does nothing until the object
1654 * is actually running.
1656 * See Windows documentation for more details on IRunnableObject methods.
1658 static HRESULT WINAPI DefaultHandler_LockRunning(
1659 IRunnableObject* iface,
1661 BOOL fLastUnlockCloses)
1667 /************************************************************************
1668 * DefaultHandler_SetContainedObject (IRunnableObject)
1670 * According to Brockscmidt, Chapter 19, the default handler's
1671 * implementation of IRunnableobject does nothing until the object
1672 * is actually running.
1674 * See Windows documentation for more details on IRunnableObject methods.
1676 static HRESULT WINAPI DefaultHandler_SetContainedObject(
1677 IRunnableObject* iface,