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 const IOleObjectVtbl* lpVtbl;
74 const IUnknownVtbl* lpvtblIUnknown;
75 const IDataObjectVtbl* lpvtblIDataObject;
76 const IRunnableObjectVtbl* lpvtblIRunnableObject;
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 functions to help with the casting of the
128 * There is a version to accommodate all of the VTables implemented
131 static inline DefaultHandler *impl_from_IOleObject( IOleObject *iface )
133 return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpVtbl));
136 static inline DefaultHandler *impl_from_NDIUnknown( IUnknown *iface )
138 return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIUnknown));
141 static inline DefaultHandler *impl_from_IDataObject( IDataObject *iface )
143 return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIDataObject));
146 static inline DefaultHandler *impl_from_IRunnableObject( IRunnableObject *iface )
148 return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIRunnableObject));
153 * Prototypes for the methods of the DefaultHandler class.
155 static DefaultHandler* DefaultHandler_Construct(REFCLSID clsid,
156 LPUNKNOWN pUnkOuter);
157 static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
160 * Prototypes for the methods of the DefaultHandler class
161 * that implement non delegating IUnknown methods.
163 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
167 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
169 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
173 * Prototypes for the methods of the DefaultHandler class
174 * that implement IOleObject methods.
176 static HRESULT WINAPI DefaultHandler_QueryInterface(
180 static ULONG WINAPI DefaultHandler_AddRef(
182 static ULONG WINAPI DefaultHandler_Release(
184 static HRESULT WINAPI DefaultHandler_SetClientSite(
186 IOleClientSite* pClientSite);
187 static HRESULT WINAPI DefaultHandler_GetClientSite(
189 IOleClientSite** ppClientSite);
190 static HRESULT WINAPI DefaultHandler_SetHostNames(
192 LPCOLESTR szContainerApp,
193 LPCOLESTR szContainerObj);
194 static HRESULT WINAPI DefaultHandler_Close(
197 static HRESULT WINAPI DefaultHandler_SetMoniker(
199 DWORD dwWhichMoniker,
201 static HRESULT WINAPI DefaultHandler_GetMoniker(
204 DWORD dwWhichMoniker,
206 static HRESULT WINAPI DefaultHandler_InitFromData(
208 IDataObject* pDataObject,
211 static HRESULT WINAPI DefaultHandler_GetClipboardData(
214 IDataObject** ppDataObject);
215 static HRESULT WINAPI DefaultHandler_DoVerb(
218 struct tagMSG* lpmsg,
219 IOleClientSite* pActiveSite,
222 LPCRECT lprcPosRect);
223 static HRESULT WINAPI DefaultHandler_EnumVerbs(
225 IEnumOLEVERB** ppEnumOleVerb);
226 static HRESULT WINAPI DefaultHandler_Update(
228 static HRESULT WINAPI DefaultHandler_IsUpToDate(
230 static HRESULT WINAPI DefaultHandler_GetUserClassID(
233 static HRESULT WINAPI DefaultHandler_GetUserType(
236 LPOLESTR* pszUserType);
237 static HRESULT WINAPI DefaultHandler_SetExtent(
241 static HRESULT WINAPI DefaultHandler_GetExtent(
245 static HRESULT WINAPI DefaultHandler_Advise(
247 IAdviseSink* pAdvSink,
248 DWORD* pdwConnection);
249 static HRESULT WINAPI DefaultHandler_Unadvise(
252 static HRESULT WINAPI DefaultHandler_EnumAdvise(
254 IEnumSTATDATA** ppenumAdvise);
255 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
259 static HRESULT WINAPI DefaultHandler_SetColorScheme(
261 struct tagLOGPALETTE* pLogpal);
264 * Prototypes for the methods of the DefaultHandler class
265 * that implement IDataObject methods.
267 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
271 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
273 static ULONG WINAPI DefaultHandler_IDataObject_Release(
275 static HRESULT WINAPI DefaultHandler_GetData(
277 LPFORMATETC pformatetcIn,
279 static HRESULT WINAPI DefaultHandler_GetDataHere(
281 LPFORMATETC pformatetc,
283 static HRESULT WINAPI DefaultHandler_QueryGetData(
285 LPFORMATETC pformatetc);
286 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
288 LPFORMATETC pformatectIn,
289 LPFORMATETC pformatetcOut);
290 static HRESULT WINAPI DefaultHandler_SetData(
292 LPFORMATETC pformatetc,
295 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
298 IEnumFORMATETC** ppenumFormatEtc);
299 static HRESULT WINAPI DefaultHandler_DAdvise(
301 FORMATETC* pformatetc,
303 IAdviseSink* pAdvSink,
304 DWORD* pdwConnection);
305 static HRESULT WINAPI DefaultHandler_DUnadvise(
308 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
310 IEnumSTATDATA** ppenumAdvise);
313 * Prototypes for the methods of the DefaultHandler class
314 * that implement IRunnableObject methods.
316 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
317 IRunnableObject* iface,
320 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
321 IRunnableObject* iface);
322 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
323 IRunnableObject* iface);
324 static HRESULT WINAPI DefaultHandler_GetRunningClass(
325 IRunnableObject* iface,
327 static HRESULT WINAPI DefaultHandler_Run(
328 IRunnableObject* iface,
330 static BOOL WINAPI DefaultHandler_IsRunning(
331 IRunnableObject* iface);
332 static HRESULT WINAPI DefaultHandler_LockRunning(
333 IRunnableObject* iface,
335 BOOL fLastUnlockCloses);
336 static HRESULT WINAPI DefaultHandler_SetContainedObject(
337 IRunnableObject* iface,
342 * Virtual function tables for the DefaultHandler class.
344 static const IOleObjectVtbl DefaultHandler_IOleObject_VTable =
346 DefaultHandler_QueryInterface,
347 DefaultHandler_AddRef,
348 DefaultHandler_Release,
349 DefaultHandler_SetClientSite,
350 DefaultHandler_GetClientSite,
351 DefaultHandler_SetHostNames,
352 DefaultHandler_Close,
353 DefaultHandler_SetMoniker,
354 DefaultHandler_GetMoniker,
355 DefaultHandler_InitFromData,
356 DefaultHandler_GetClipboardData,
357 DefaultHandler_DoVerb,
358 DefaultHandler_EnumVerbs,
359 DefaultHandler_Update,
360 DefaultHandler_IsUpToDate,
361 DefaultHandler_GetUserClassID,
362 DefaultHandler_GetUserType,
363 DefaultHandler_SetExtent,
364 DefaultHandler_GetExtent,
365 DefaultHandler_Advise,
366 DefaultHandler_Unadvise,
367 DefaultHandler_EnumAdvise,
368 DefaultHandler_GetMiscStatus,
369 DefaultHandler_SetColorScheme
372 static const IUnknownVtbl DefaultHandler_NDIUnknown_VTable =
374 DefaultHandler_NDIUnknown_QueryInterface,
375 DefaultHandler_NDIUnknown_AddRef,
376 DefaultHandler_NDIUnknown_Release,
379 static const IDataObjectVtbl DefaultHandler_IDataObject_VTable =
381 DefaultHandler_IDataObject_QueryInterface,
382 DefaultHandler_IDataObject_AddRef,
383 DefaultHandler_IDataObject_Release,
384 DefaultHandler_GetData,
385 DefaultHandler_GetDataHere,
386 DefaultHandler_QueryGetData,
387 DefaultHandler_GetCanonicalFormatEtc,
388 DefaultHandler_SetData,
389 DefaultHandler_EnumFormatEtc,
390 DefaultHandler_DAdvise,
391 DefaultHandler_DUnadvise,
392 DefaultHandler_EnumDAdvise
395 static const IRunnableObjectVtbl DefaultHandler_IRunnableObject_VTable =
397 DefaultHandler_IRunnableObject_QueryInterface,
398 DefaultHandler_IRunnableObject_AddRef,
399 DefaultHandler_IRunnableObject_Release,
400 DefaultHandler_GetRunningClass,
402 DefaultHandler_IsRunning,
403 DefaultHandler_LockRunning,
404 DefaultHandler_SetContainedObject
407 /******************************************************************************
408 * OleCreateDefaultHandler [OLE32.@]
410 HRESULT WINAPI OleCreateDefaultHandler(
416 DefaultHandler* newHandler = NULL;
419 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter, debugstr_guid(riid), ppvObj);
430 * If this handler is constructed for aggregation, make sure
431 * the caller is requesting the IUnknown interface.
432 * This is necessary because it's the only time the non-delegating
433 * IUnknown pointer can be returned to the outside.
435 if ( (pUnkOuter!=NULL) &&
436 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
437 return CLASS_E_NOAGGREGATION;
440 * Try to construct a new instance of the class.
442 newHandler = DefaultHandler_Construct(clsid,
446 return E_OUTOFMEMORY;
449 * Make sure it supports the interface required by the caller.
451 hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtblIUnknown), riid, ppvObj);
454 * Release the reference obtained in the constructor. If
455 * the QueryInterface was unsuccessful, it will free the class.
457 IUnknown_Release((IUnknown*)&(newHandler->lpvtblIUnknown));
462 /*********************************************************
463 * Methods implementation for the DefaultHandler class.
465 static DefaultHandler* DefaultHandler_Construct(
469 DefaultHandler* newObject = 0;
472 * Allocate space for the object.
474 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
480 * Initialize the virtual function table.
482 newObject->lpVtbl = &DefaultHandler_IOleObject_VTable;
483 newObject->lpvtblIUnknown = &DefaultHandler_NDIUnknown_VTable;
484 newObject->lpvtblIDataObject = &DefaultHandler_IDataObject_VTable;
485 newObject->lpvtblIRunnableObject = &DefaultHandler_IRunnableObject_VTable;
488 * Start with one reference count. The caller of this function
489 * must release the interface pointer when it is done.
494 * Initialize the outer unknown
495 * We don't keep a reference on the outer unknown since, the way
496 * aggregation works, our lifetime is at least as large as it's
500 pUnkOuter = (IUnknown*)&(newObject->lpvtblIUnknown);
502 newObject->outerUnknown = pUnkOuter;
505 * Create a datacache object.
506 * We aggregate with the datacache. Make sure we pass our outer
507 * unknown as the datacache's outer unknown.
509 CreateDataCache(newObject->outerUnknown,
512 (void**)&newObject->dataCache);
515 * Initialize the other data members of the class.
517 memcpy(&(newObject->clsid), clsid, sizeof(CLSID));
518 newObject->clientSite = NULL;
519 newObject->oleAdviseHolder = NULL;
520 newObject->dataAdviseHolder = NULL;
521 newObject->containerApp = NULL;
522 newObject->containerObj = NULL;
527 static void DefaultHandler_Destroy(
528 DefaultHandler* ptrToDestroy)
531 * Free the strings idenfitying the object
533 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerApp );
534 ptrToDestroy->containerApp = NULL;
535 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerObj );
536 ptrToDestroy->containerObj = NULL;
539 * Release our reference to the data cache.
541 if (ptrToDestroy->dataCache!=NULL)
543 IUnknown_Release(ptrToDestroy->dataCache);
544 ptrToDestroy->dataCache = NULL;
548 * Same thing for the client site.
550 if (ptrToDestroy->clientSite!=NULL)
552 IOleClientSite_Release(ptrToDestroy->clientSite);
553 ptrToDestroy->clientSite = NULL;
557 * And the advise holder.
559 if (ptrToDestroy->oleAdviseHolder!=NULL)
561 IOleAdviseHolder_Release(ptrToDestroy->oleAdviseHolder);
562 ptrToDestroy->oleAdviseHolder = NULL;
566 * And the data advise holder.
568 if (ptrToDestroy->dataAdviseHolder!=NULL)
570 IDataAdviseHolder_Release(ptrToDestroy->dataAdviseHolder);
571 ptrToDestroy->dataAdviseHolder = NULL;
576 * Free the actual default handler structure.
578 HeapFree(GetProcessHeap(), 0, ptrToDestroy);
581 /*********************************************************
582 * Method implementation for the non delegating IUnknown
583 * part of the DefaultHandler class.
586 /************************************************************************
587 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
589 * See Windows documentation for more details on IUnknown methods.
591 * This version of QueryInterface will not delegate it's implementation
592 * to the outer unknown.
594 static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
599 DefaultHandler *this = impl_from_NDIUnknown(iface);
602 * Perform a sanity check on the parameters.
604 if ( (this==0) || (ppvObject==0) )
608 * Initialize the return parameter.
613 * Compare the riid with the interface IDs implemented by this object.
615 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
619 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
621 *ppvObject = (IOleObject*)&(this->lpVtbl);
623 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
625 *ppvObject = (IDataObject*)&(this->lpvtblIDataObject);
627 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
629 *ppvObject = (IRunnableObject*)&(this->lpvtblIRunnableObject);
634 * Blind aggregate the data cache to "inherit" it's interfaces.
636 if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK)
641 * Check that we obtained an interface.
645 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid));
646 return E_NOINTERFACE;
650 * Query Interface always increases the reference count by one when it is
653 IUnknown_AddRef((IUnknown*)*ppvObject);
658 /************************************************************************
659 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
661 * See Windows documentation for more details on IUnknown methods.
663 * This version of QueryInterface will not delegate it's implementation
664 * to the outer unknown.
666 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
669 DefaultHandler *this = impl_from_NDIUnknown(iface);
670 return InterlockedIncrement(&this->ref);
673 /************************************************************************
674 * DefaultHandler_NDIUnknown_Release (IUnknown)
676 * See Windows documentation for more details on IUnknown methods.
678 * This version of QueryInterface will not delegate it's implementation
679 * to the outer unknown.
681 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
684 DefaultHandler *this = impl_from_NDIUnknown(iface);
688 * Decrease the reference count on this object.
690 ref = InterlockedDecrement(&this->ref);
693 * If the reference count goes down to 0, perform suicide.
695 if (ref == 0) DefaultHandler_Destroy(this);
700 /*********************************************************
701 * Methods implementation for the IOleObject part of
702 * the DefaultHandler class.
705 /************************************************************************
706 * DefaultHandler_QueryInterface (IUnknown)
708 * See Windows documentation for more details on IUnknown methods.
710 static HRESULT WINAPI DefaultHandler_QueryInterface(
715 DefaultHandler *this = impl_from_IOleObject(iface);
717 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
720 /************************************************************************
721 * DefaultHandler_AddRef (IUnknown)
723 * See Windows documentation for more details on IUnknown methods.
725 static ULONG WINAPI DefaultHandler_AddRef(
728 DefaultHandler *this = impl_from_IOleObject(iface);
730 return IUnknown_AddRef(this->outerUnknown);
733 /************************************************************************
734 * DefaultHandler_Release (IUnknown)
736 * See Windows documentation for more details on IUnknown methods.
738 static ULONG WINAPI DefaultHandler_Release(
741 DefaultHandler *this = impl_from_IOleObject(iface);
743 return IUnknown_Release(this->outerUnknown);
746 /************************************************************************
747 * DefaultHandler_SetClientSite (IOleObject)
749 * The default handler's implementation of this method only keeps the
750 * client site pointer for future reference.
752 * See Windows documentation for more details on IOleObject methods.
754 static HRESULT WINAPI DefaultHandler_SetClientSite(
756 IOleClientSite* pClientSite)
758 DefaultHandler *this = impl_from_IOleObject(iface);
760 TRACE("(%p, %p)\n", iface, pClientSite);
763 * Make sure we release the previous client site if there
766 if (this->clientSite!=NULL)
768 IOleClientSite_Release(this->clientSite);
771 this->clientSite = pClientSite;
773 if (this->clientSite!=NULL)
775 IOleClientSite_AddRef(this->clientSite);
781 /************************************************************************
782 * DefaultHandler_GetClientSite (IOleObject)
784 * The default handler's implementation of this method returns the
785 * last pointer set in IOleObject_SetClientSite.
787 * See Windows documentation for more details on IOleObject methods.
789 static HRESULT WINAPI DefaultHandler_GetClientSite(
791 IOleClientSite** ppClientSite)
793 DefaultHandler *this = impl_from_IOleObject(iface);
798 if (ppClientSite == NULL)
801 *ppClientSite = this->clientSite;
803 if (this->clientSite != NULL)
805 IOleClientSite_AddRef(this->clientSite);
811 /************************************************************************
812 * DefaultHandler_SetHostNames (IOleObject)
814 * The default handler's implementation of this method just stores
815 * the strings and returns S_OK.
817 * See Windows documentation for more details on IOleObject methods.
819 static HRESULT WINAPI DefaultHandler_SetHostNames(
821 LPCOLESTR szContainerApp,
822 LPCOLESTR szContainerObj)
824 DefaultHandler *this = impl_from_IOleObject(iface);
826 TRACE("(%p, %s, %s)\n",
828 debugstr_w(szContainerApp),
829 debugstr_w(szContainerObj));
832 * Be sure to cleanup before re-assinging the strings.
834 HeapFree( GetProcessHeap(), 0, this->containerApp );
835 this->containerApp = NULL;
836 HeapFree( GetProcessHeap(), 0, this->containerObj );
837 this->containerObj = NULL;
840 * Copy the string supplied.
842 if (szContainerApp != NULL)
844 if ((this->containerApp = HeapAlloc( GetProcessHeap(), 0,
845 (lstrlenW(szContainerApp) + 1) * sizeof(WCHAR) )))
846 strcpyW( this->containerApp, szContainerApp );
849 if (szContainerObj != NULL)
851 if ((this->containerObj = HeapAlloc( GetProcessHeap(), 0,
852 (lstrlenW(szContainerObj) + 1) * sizeof(WCHAR) )))
853 strcpyW( this->containerObj, szContainerObj );
858 /************************************************************************
859 * DefaultHandler_Close (IOleObject)
861 * The default handler's implementation of this method is meaningless
862 * without a running server so it does nothing.
864 * See Windows documentation for more details on IOleObject methods.
866 static HRESULT WINAPI DefaultHandler_Close(
874 /************************************************************************
875 * DefaultHandler_SetMoniker (IOleObject)
877 * The default handler's implementation of this method does nothing.
879 * See Windows documentation for more details on IOleObject methods.
881 static HRESULT WINAPI DefaultHandler_SetMoniker(
883 DWORD dwWhichMoniker,
886 TRACE("(%p, %ld, %p)\n",
894 /************************************************************************
895 * DefaultHandler_GetMoniker (IOleObject)
897 * Delegate this request to the client site if we have one.
899 * See Windows documentation for more details on IOleObject methods.
901 static HRESULT WINAPI DefaultHandler_GetMoniker(
904 DWORD dwWhichMoniker,
907 DefaultHandler *this = impl_from_IOleObject(iface);
909 TRACE("(%p, %ld, %ld, %p)\n",
910 iface, dwAssign, dwWhichMoniker, ppmk);
912 if (this->clientSite)
914 return IOleClientSite_GetMoniker(this->clientSite,
924 /************************************************************************
925 * DefaultHandler_InitFromData (IOleObject)
927 * This method is meaningless if the server is not running
929 * See Windows documentation for more details on IOleObject methods.
931 static HRESULT WINAPI DefaultHandler_InitFromData(
933 IDataObject* pDataObject,
937 TRACE("(%p, %p, %d, %ld)\n",
938 iface, pDataObject, fCreation, dwReserved);
940 return OLE_E_NOTRUNNING;
943 /************************************************************************
944 * DefaultHandler_GetClipboardData (IOleObject)
946 * This method is meaningless if the server is not running
948 * See Windows documentation for more details on IOleObject methods.
950 static HRESULT WINAPI DefaultHandler_GetClipboardData(
953 IDataObject** ppDataObject)
955 TRACE("(%p, %ld, %p)\n",
956 iface, dwReserved, ppDataObject);
958 return OLE_E_NOTRUNNING;
961 static HRESULT WINAPI DefaultHandler_DoVerb(
964 struct tagMSG* lpmsg,
965 IOleClientSite* pActiveSite,
974 /************************************************************************
975 * DefaultHandler_EnumVerbs (IOleObject)
977 * The default handler implementation of this method simply delegates
980 * See Windows documentation for more details on IOleObject methods.
982 static HRESULT WINAPI DefaultHandler_EnumVerbs(
984 IEnumOLEVERB** ppEnumOleVerb)
986 DefaultHandler *this = impl_from_IOleObject(iface);
988 TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
990 return OleRegEnumVerbs(&this->clsid, ppEnumOleVerb);
993 static HRESULT WINAPI DefaultHandler_Update(
1000 /************************************************************************
1001 * DefaultHandler_IsUpToDate (IOleObject)
1003 * This method is meaningless if the server is not running
1005 * See Windows documentation for more details on IOleObject methods.
1007 static HRESULT WINAPI DefaultHandler_IsUpToDate(
1010 TRACE("(%p)\n", iface);
1012 return OLE_E_NOTRUNNING;
1015 /************************************************************************
1016 * DefaultHandler_GetUserClassID (IOleObject)
1018 * TODO: Map to a new class ID if emulation is active.
1020 * See Windows documentation for more details on IOleObject methods.
1022 static HRESULT WINAPI DefaultHandler_GetUserClassID(
1026 DefaultHandler *this = impl_from_IOleObject(iface);
1028 TRACE("(%p, %p)\n", iface, pClsid);
1036 memcpy(pClsid, &this->clsid, sizeof(CLSID));
1041 /************************************************************************
1042 * DefaultHandler_GetUserType (IOleObject)
1044 * The default handler implementation of this method simply delegates
1045 * to OleRegGetUserType
1047 * See Windows documentation for more details on IOleObject methods.
1049 static HRESULT WINAPI DefaultHandler_GetUserType(
1052 LPOLESTR* pszUserType)
1054 DefaultHandler *this = impl_from_IOleObject(iface);
1056 TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
1058 return OleRegGetUserType(&this->clsid, dwFormOfType, pszUserType);
1061 /************************************************************************
1062 * DefaultHandler_SetExtent (IOleObject)
1064 * This method is meaningless if the server is not running
1066 * See Windows documentation for more details on IOleObject methods.
1068 static HRESULT WINAPI DefaultHandler_SetExtent(
1073 TRACE("(%p, %lx, (%ld x %ld))\n", iface,
1074 dwDrawAspect, psizel->cx, psizel->cy);
1075 return OLE_E_NOTRUNNING;
1078 /************************************************************************
1079 * DefaultHandler_GetExtent (IOleObject)
1081 * The default handler's implementation of this method returns uses
1082 * the cache to locate the aspect and extract the extent from it.
1084 * See Windows documentation for more details on IOleObject methods.
1086 static HRESULT WINAPI DefaultHandler_GetExtent(
1091 DVTARGETDEVICE* targetDevice;
1092 IViewObject2* cacheView = NULL;
1095 DefaultHandler *this = impl_from_IOleObject(iface);
1097 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
1099 hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
1102 return E_UNEXPECTED;
1105 * Prepare the call to the cache's GetExtent method.
1107 * Here we would build a valid DVTARGETDEVICE structure
1108 * but, since we are calling into the data cache, we
1109 * know it's implementation and we'll skip this
1110 * extra work until later.
1112 targetDevice = NULL;
1114 hres = IViewObject2_GetExtent(cacheView,
1123 IViewObject2_Release(cacheView);
1128 /************************************************************************
1129 * DefaultHandler_Advise (IOleObject)
1131 * The default handler's implementation of this method simply
1132 * delegates to the OleAdviseHolder.
1134 * See Windows documentation for more details on IOleObject methods.
1136 static HRESULT WINAPI DefaultHandler_Advise(
1138 IAdviseSink* pAdvSink,
1139 DWORD* pdwConnection)
1141 HRESULT hres = S_OK;
1142 DefaultHandler *this = impl_from_IOleObject(iface);
1144 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
1147 * Make sure we have an advise holder before we start.
1149 if (this->oleAdviseHolder==NULL)
1151 hres = CreateOleAdviseHolder(&this->oleAdviseHolder);
1154 if (SUCCEEDED(hres))
1156 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
1164 /************************************************************************
1165 * DefaultHandler_Unadvise (IOleObject)
1167 * The default handler's implementation of this method simply
1168 * delegates to the OleAdviseHolder.
1170 * See Windows documentation for more details on IOleObject methods.
1172 static HRESULT WINAPI DefaultHandler_Unadvise(
1176 DefaultHandler *this = impl_from_IOleObject(iface);
1178 TRACE("(%p, %ld)\n", iface, dwConnection);
1181 * If we don't have an advise holder yet, it means we don't have
1184 if (this->oleAdviseHolder==NULL)
1185 return OLE_E_NOCONNECTION;
1187 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
1191 /************************************************************************
1192 * DefaultHandler_EnumAdvise (IOleObject)
1194 * The default handler's implementation of this method simply
1195 * delegates to the OleAdviseHolder.
1197 * See Windows documentation for more details on IOleObject methods.
1199 static HRESULT WINAPI DefaultHandler_EnumAdvise(
1201 IEnumSTATDATA** ppenumAdvise)
1203 DefaultHandler *this = impl_from_IOleObject(iface);
1205 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1210 if (ppenumAdvise==NULL)
1214 * Initialize the out parameter.
1216 *ppenumAdvise = NULL;
1218 if (this->oleAdviseHolder==NULL)
1219 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
1225 /************************************************************************
1226 * DefaultHandler_GetMiscStatus (IOleObject)
1228 * The default handler's implementation of this method simply delegates
1229 * to OleRegGetMiscStatus.
1231 * See Windows documentation for more details on IOleObject methods.
1233 static HRESULT WINAPI DefaultHandler_GetMiscStatus(
1239 DefaultHandler *this = impl_from_IOleObject(iface);
1241 TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
1243 hres = OleRegGetMiscStatus(&(this->clsid), dwAspect, pdwStatus);
1251 /************************************************************************
1252 * DefaultHandler_SetExtent (IOleObject)
1254 * This method is meaningless if the server is not running
1256 * See Windows documentation for more details on IOleObject methods.
1258 static HRESULT WINAPI DefaultHandler_SetColorScheme(
1260 struct tagLOGPALETTE* pLogpal)
1262 TRACE("(%p, %p))\n", iface, pLogpal);
1263 return OLE_E_NOTRUNNING;
1266 /*********************************************************
1267 * Methods implementation for the IDataObject part of
1268 * the DefaultHandler class.
1271 /************************************************************************
1272 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1274 * See Windows documentation for more details on IUnknown methods.
1276 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
1281 DefaultHandler *this = impl_from_IDataObject(iface);
1283 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1286 /************************************************************************
1287 * DefaultHandler_IDataObject_AddRef (IUnknown)
1289 * See Windows documentation for more details on IUnknown methods.
1291 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
1294 DefaultHandler *this = impl_from_IDataObject(iface);
1296 return IUnknown_AddRef(this->outerUnknown);
1299 /************************************************************************
1300 * DefaultHandler_IDataObject_Release (IUnknown)
1302 * See Windows documentation for more details on IUnknown methods.
1304 static ULONG WINAPI DefaultHandler_IDataObject_Release(
1307 DefaultHandler *this = impl_from_IDataObject(iface);
1309 return IUnknown_Release(this->outerUnknown);
1312 /************************************************************************
1313 * DefaultHandler_GetData
1315 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1316 * See Windows documentation for more details on GetData.
1317 * Default handler's implementation of this method delegates to the cache.
1319 static HRESULT WINAPI DefaultHandler_GetData(
1321 LPFORMATETC pformatetcIn,
1324 IDataObject* cacheDataObject = NULL;
1327 DefaultHandler *this = impl_from_IDataObject(iface);
1329 TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
1331 hres = IUnknown_QueryInterface(this->dataCache,
1333 (void**)&cacheDataObject);
1336 return E_UNEXPECTED;
1338 hres = IDataObject_GetData(cacheDataObject,
1342 IDataObject_Release(cacheDataObject);
1347 static HRESULT WINAPI DefaultHandler_GetDataHere(
1349 LPFORMATETC pformatetc,
1356 /************************************************************************
1357 * DefaultHandler_QueryGetData (IDataObject)
1359 * The default handler's implementation of this method delegates to
1362 * See Windows documentation for more details on IDataObject methods.
1364 static HRESULT WINAPI DefaultHandler_QueryGetData(
1366 LPFORMATETC pformatetc)
1368 IDataObject* cacheDataObject = NULL;
1371 DefaultHandler *this = impl_from_IDataObject(iface);
1373 TRACE("(%p, %p)\n", iface, pformatetc);
1375 hres = IUnknown_QueryInterface(this->dataCache,
1377 (void**)&cacheDataObject);
1380 return E_UNEXPECTED;
1382 hres = IDataObject_QueryGetData(cacheDataObject,
1385 IDataObject_Release(cacheDataObject);
1390 /************************************************************************
1391 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1393 * This method is meaningless if the server is not running
1395 * See Windows documentation for more details on IDataObject methods.
1397 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
1399 LPFORMATETC pformatectIn,
1400 LPFORMATETC pformatetcOut)
1402 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
1404 return OLE_E_NOTRUNNING;
1407 /************************************************************************
1408 * DefaultHandler_SetData (IDataObject)
1410 * The default handler's implementation of this method delegates to
1413 * See Windows documentation for more details on IDataObject methods.
1415 static HRESULT WINAPI DefaultHandler_SetData(
1417 LPFORMATETC pformatetc,
1421 IDataObject* cacheDataObject = NULL;
1424 DefaultHandler *this = impl_from_IDataObject(iface);
1426 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1428 hres = IUnknown_QueryInterface(this->dataCache,
1430 (void**)&cacheDataObject);
1433 return E_UNEXPECTED;
1435 hres = IDataObject_SetData(cacheDataObject,
1440 IDataObject_Release(cacheDataObject);
1445 /************************************************************************
1446 * DefaultHandler_EnumFormatEtc (IDataObject)
1448 * The default handler's implementation of this method simply delegates
1449 * to OleRegEnumFormatEtc.
1451 * See Windows documentation for more details on IDataObject methods.
1453 static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
1456 IEnumFORMATETC** ppenumFormatEtc)
1459 DefaultHandler *this = impl_from_IDataObject(iface);
1461 TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
1463 hres = OleRegEnumFormatEtc(&(this->clsid), dwDirection, ppenumFormatEtc);
1468 /************************************************************************
1469 * DefaultHandler_DAdvise (IDataObject)
1471 * The default handler's implementation of this method simply
1472 * delegates to the DataAdviseHolder.
1474 * See Windows documentation for more details on IDataObject methods.
1476 static HRESULT WINAPI DefaultHandler_DAdvise(
1478 FORMATETC* pformatetc,
1480 IAdviseSink* pAdvSink,
1481 DWORD* pdwConnection)
1483 HRESULT hres = S_OK;
1484 DefaultHandler *this = impl_from_IDataObject(iface);
1486 TRACE("(%p, %p, %ld, %p, %p)\n",
1487 iface, pformatetc, advf, pAdvSink, pdwConnection);
1490 * Make sure we have a data advise holder before we start.
1492 if (this->dataAdviseHolder==NULL)
1494 hres = CreateDataAdviseHolder(&this->dataAdviseHolder);
1497 if (SUCCEEDED(hres))
1499 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
1510 /************************************************************************
1511 * DefaultHandler_DUnadvise (IDataObject)
1513 * The default handler's implementation of this method simply
1514 * delegates to the DataAdviseHolder.
1516 * See Windows documentation for more details on IDataObject methods.
1518 static HRESULT WINAPI DefaultHandler_DUnadvise(
1522 DefaultHandler *this = impl_from_IDataObject(iface);
1524 TRACE("(%p, %ld)\n", iface, dwConnection);
1527 * If we don't have a data advise holder yet, it means that
1528 * we don't have any connections..
1530 if (this->dataAdviseHolder==NULL)
1532 return OLE_E_NOCONNECTION;
1535 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
1539 /************************************************************************
1540 * DefaultHandler_EnumDAdvise (IDataObject)
1542 * The default handler's implementation of this method simply
1543 * delegates to the DataAdviseHolder.
1545 * See Windows documentation for more details on IDataObject methods.
1547 static HRESULT WINAPI DefaultHandler_EnumDAdvise(
1549 IEnumSTATDATA** ppenumAdvise)
1551 DefaultHandler *this = impl_from_IDataObject(iface);
1553 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1558 if (ppenumAdvise == NULL)
1562 * Initialize the out parameter.
1564 *ppenumAdvise = NULL;
1567 * If we have a data advise holder object, delegate.
1569 if (this->dataAdviseHolder!=NULL)
1571 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
1578 /*********************************************************
1579 * Methods implementation for the IRunnableObject part
1580 * of the DefaultHandler class.
1583 /************************************************************************
1584 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1586 * See Windows documentation for more details on IUnknown methods.
1588 static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
1589 IRunnableObject* iface,
1593 DefaultHandler *this = impl_from_IRunnableObject(iface);
1595 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1598 /************************************************************************
1599 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1601 * See Windows documentation for more details on IUnknown methods.
1603 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
1604 IRunnableObject* iface)
1606 DefaultHandler *this = impl_from_IRunnableObject(iface);
1608 return IUnknown_AddRef(this->outerUnknown);
1611 /************************************************************************
1612 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1614 * See Windows documentation for more details on IUnknown methods.
1616 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
1617 IRunnableObject* iface)
1619 DefaultHandler *this = impl_from_IRunnableObject(iface);
1621 return IUnknown_Release(this->outerUnknown);
1624 /************************************************************************
1625 * DefaultHandler_GetRunningClass (IRunnableObject)
1627 * According to Brockscmidt, Chapter 19, the default handler's
1628 * implementation of IRunnableobject does nothing until the object
1629 * is actually running.
1631 * See Windows documentation for more details on IRunnableObject methods.
1633 static HRESULT WINAPI DefaultHandler_GetRunningClass(
1634 IRunnableObject* iface,
1641 static HRESULT WINAPI DefaultHandler_Run(
1642 IRunnableObject* iface,
1649 /************************************************************************
1650 * DefaultHandler_IsRunning (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 BOOL WINAPI DefaultHandler_IsRunning(
1659 IRunnableObject* iface)
1665 /************************************************************************
1666 * DefaultHandler_LockRunning (IRunnableObject)
1668 * According to Brockscmidt, Chapter 19, the default handler's
1669 * implementation of IRunnableobject does nothing until the object
1670 * is actually running.
1672 * See Windows documentation for more details on IRunnableObject methods.
1674 static HRESULT WINAPI DefaultHandler_LockRunning(
1675 IRunnableObject* iface,
1677 BOOL fLastUnlockCloses)
1683 /************************************************************************
1684 * DefaultHandler_SetContainedObject (IRunnableObject)
1686 * According to Brockscmidt, Chapter 19, the default handler's
1687 * implementation of IRunnableobject does nothing until the object
1688 * is actually running.
1690 * See Windows documentation for more details on IRunnableObject methods.
1692 static HRESULT WINAPI DefaultHandler_SetContainedObject(
1693 IRunnableObject* iface,