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 ICOM_VTABLE(IOleObject
)* lpvtbl1
;
72 ICOM_VTABLE(IUnknown
)* lpvtbl2
;
73 ICOM_VTABLE(IDataObject
)* lpvtbl3
;
74 ICOM_VTABLE(IRunnableObject
)* 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 ICOM_VTABLE(IOleObject
) DefaultHandler_IOleObject_VTable
=
328 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
329 DefaultHandler_QueryInterface
,
330 DefaultHandler_AddRef
,
331 DefaultHandler_Release
,
332 DefaultHandler_SetClientSite
,
333 DefaultHandler_GetClientSite
,
334 DefaultHandler_SetHostNames
,
335 DefaultHandler_Close
,
336 DefaultHandler_SetMoniker
,
337 DefaultHandler_GetMoniker
,
338 DefaultHandler_InitFromData
,
339 DefaultHandler_GetClipboardData
,
340 DefaultHandler_DoVerb
,
341 DefaultHandler_EnumVerbs
,
342 DefaultHandler_Update
,
343 DefaultHandler_IsUpToDate
,
344 DefaultHandler_GetUserClassID
,
345 DefaultHandler_GetUserType
,
346 DefaultHandler_SetExtent
,
347 DefaultHandler_GetExtent
,
348 DefaultHandler_Advise
,
349 DefaultHandler_Unadvise
,
350 DefaultHandler_EnumAdvise
,
351 DefaultHandler_GetMiscStatus
,
352 DefaultHandler_SetColorScheme
355 static ICOM_VTABLE(IUnknown
) DefaultHandler_NDIUnknown_VTable
=
357 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
358 DefaultHandler_NDIUnknown_QueryInterface
,
359 DefaultHandler_NDIUnknown_AddRef
,
360 DefaultHandler_NDIUnknown_Release
,
363 static ICOM_VTABLE(IDataObject
) DefaultHandler_IDataObject_VTable
=
365 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
366 DefaultHandler_IDataObject_QueryInterface
,
367 DefaultHandler_IDataObject_AddRef
,
368 DefaultHandler_IDataObject_Release
,
369 DefaultHandler_GetData
,
370 DefaultHandler_GetDataHere
,
371 DefaultHandler_QueryGetData
,
372 DefaultHandler_GetCanonicalFormatEtc
,
373 DefaultHandler_SetData
,
374 DefaultHandler_EnumFormatEtc
,
375 DefaultHandler_DAdvise
,
376 DefaultHandler_DUnadvise
,
377 DefaultHandler_EnumDAdvise
380 static ICOM_VTABLE(IRunnableObject
) DefaultHandler_IRunnableObject_VTable
=
382 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
383 DefaultHandler_IRunnableObject_QueryInterface
,
384 DefaultHandler_IRunnableObject_AddRef
,
385 DefaultHandler_IRunnableObject_Release
,
386 DefaultHandler_GetRunningClass
,
388 DefaultHandler_IsRunning
,
389 DefaultHandler_LockRunning
,
390 DefaultHandler_SetContainedObject
393 /******************************************************************************
394 * OleCreateDefaultHandler [OLE32.@]
396 HRESULT WINAPI
OleCreateDefaultHandler(
402 DefaultHandler
* newHandler
= NULL
;
405 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid
), pUnkOuter
, debugstr_guid(riid
), ppvObj
);
416 * If this handler is constructed for aggregation, make sure
417 * the caller is requesting the IUnknown interface.
418 * This is necessary because it's the only time the non-delegating
419 * IUnknown pointer can be returned to the outside.
421 if ( (pUnkOuter
!=NULL
) &&
422 (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) != 0) )
423 return CLASS_E_NOAGGREGATION
;
426 * Try to construct a new instance of the class.
428 newHandler
= DefaultHandler_Construct(clsid
,
432 return E_OUTOFMEMORY
;
435 * Make sure it supports the interface required by the caller.
437 hr
= IUnknown_QueryInterface((IUnknown
*)&(newHandler
->lpvtbl2
), riid
, ppvObj
);
440 * Release the reference obtained in the constructor. If
441 * the QueryInterface was unsuccessful, it will free the class.
443 IUnknown_Release((IUnknown
*)&(newHandler
->lpvtbl2
));
448 /*********************************************************
449 * Methods implementation for the DefaultHandler class.
451 static DefaultHandler
* DefaultHandler_Construct(
455 DefaultHandler
* newObject
= 0;
458 * Allocate space for the object.
460 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler
));
466 * Initialize the virtual function table.
468 newObject
->lpvtbl1
= &DefaultHandler_IOleObject_VTable
;
469 newObject
->lpvtbl2
= &DefaultHandler_NDIUnknown_VTable
;
470 newObject
->lpvtbl3
= &DefaultHandler_IDataObject_VTable
;
471 newObject
->lpvtbl4
= &DefaultHandler_IRunnableObject_VTable
;
474 * Start with one reference count. The caller of this function
475 * must release the interface pointer when it is done.
480 * Initialize the outer unknown
481 * We don't keep a reference on the outer unknown since, the way
482 * aggregation works, our lifetime is at least as large as it's
486 pUnkOuter
= (IUnknown
*)&(newObject
->lpvtbl2
);
488 newObject
->outerUnknown
= pUnkOuter
;
491 * Create a datacache object.
492 * We aggregate with the datacache. Make sure we pass our outer
493 * unknown as the datacache's outer unknown.
495 CreateDataCache(newObject
->outerUnknown
,
498 (void**)&newObject
->dataCache
);
501 * Initialize the other data members of the class.
503 memcpy(&(newObject
->clsid
), clsid
, sizeof(CLSID
));
504 newObject
->clientSite
= NULL
;
505 newObject
->oleAdviseHolder
= NULL
;
506 newObject
->dataAdviseHolder
= NULL
;
507 newObject
->containerApp
= NULL
;
508 newObject
->containerObj
= NULL
;
513 static void DefaultHandler_Destroy(
514 DefaultHandler
* ptrToDestroy
)
517 * Free the strings idenfitying the object
519 if (ptrToDestroy
->containerApp
!=NULL
)
521 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerApp
);
522 ptrToDestroy
->containerApp
= NULL
;
525 if (ptrToDestroy
->containerObj
!=NULL
)
527 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerObj
);
528 ptrToDestroy
->containerObj
= NULL
;
532 * Release our reference to the data cache.
534 if (ptrToDestroy
->dataCache
!=NULL
)
536 IUnknown_Release(ptrToDestroy
->dataCache
);
537 ptrToDestroy
->dataCache
= NULL
;
541 * Same thing for the client site.
543 if (ptrToDestroy
->clientSite
!=NULL
)
545 IOleClientSite_Release(ptrToDestroy
->clientSite
);
546 ptrToDestroy
->clientSite
= NULL
;
550 * And the advise holder.
552 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
554 IOleAdviseHolder_Release(ptrToDestroy
->oleAdviseHolder
);
555 ptrToDestroy
->oleAdviseHolder
= NULL
;
559 * And the data advise holder.
561 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
563 IDataAdviseHolder_Release(ptrToDestroy
->dataAdviseHolder
);
564 ptrToDestroy
->dataAdviseHolder
= NULL
;
569 * Free the actual default handler structure.
571 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
574 /*********************************************************
575 * Method implementation for the non delegating IUnknown
576 * part of the DefaultHandler class.
579 /************************************************************************
580 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
582 * See Windows documentation for more details on IUnknown methods.
584 * This version of QueryInterface will not delegate it's implementation
585 * to the outer unknown.
587 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
592 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
595 * Perform a sanity check on the parameters.
597 if ( (this==0) || (ppvObject
==0) )
601 * Initialize the return parameter.
606 * Compare the riid with the interface IDs implemented by this object.
608 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
612 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
614 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
616 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
618 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
620 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
622 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
627 * Blind aggregate the data cache to "inherit" it's interfaces.
629 if (IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
) == S_OK
)
634 * Check that we obtained an interface.
638 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid
));
639 return E_NOINTERFACE
;
643 * Query Interface always increases the reference count by one when it is
646 IUnknown_AddRef((IUnknown
*)*ppvObject
);
651 /************************************************************************
652 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
654 * See Windows documentation for more details on IUnknown methods.
656 * This version of QueryInterface will not delegate it's implementation
657 * to the outer unknown.
659 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
662 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
669 /************************************************************************
670 * DefaultHandler_NDIUnknown_Release (IUnknown)
672 * See Windows documentation for more details on IUnknown methods.
674 * This version of QueryInterface will not delegate it's implementation
675 * to the outer unknown.
677 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
680 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
683 * Decrease the reference count on this object.
688 * If the reference count goes down to 0, perform suicide.
692 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 _ICOM_THIS_From_IOleObject(DefaultHandler
, 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 _ICOM_THIS_From_IOleObject(DefaultHandler
, 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 _ICOM_THIS_From_IOleObject(DefaultHandler
, 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 _ICOM_THIS_From_IOleObject(DefaultHandler
, 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 _ICOM_THIS_From_IOleObject(DefaultHandler
, 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 _ICOM_THIS_From_IOleObject(DefaultHandler
, 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 if (this->containerApp
!=NULL
)
836 HeapFree( GetProcessHeap(), 0, this->containerApp
);
837 this->containerApp
= NULL
;
840 if (this->containerObj
!=NULL
)
842 HeapFree( GetProcessHeap(), 0, this->containerObj
);
843 this->containerObj
= NULL
;
847 * Copy the string supplied.
849 if (szContainerApp
!= NULL
)
851 if ((this->containerApp
= HeapAlloc( GetProcessHeap(), 0,
852 (lstrlenW(szContainerApp
) + 1) * sizeof(WCHAR
) )))
853 strcpyW( this->containerApp
, szContainerApp
);
856 if (szContainerObj
!= NULL
)
858 if ((this->containerObj
= HeapAlloc( GetProcessHeap(), 0,
859 (lstrlenW(szContainerObj
) + 1) * sizeof(WCHAR
) )))
860 strcpyW( this->containerObj
, szContainerObj
);
865 /************************************************************************
866 * DefaultHandler_Close (IOleObject)
868 * The default handler's implementation of this method is meaningless
869 * without a running server so it does nothing.
871 * See Windows documentation for more details on IOleObject methods.
873 static HRESULT WINAPI
DefaultHandler_Close(
881 /************************************************************************
882 * DefaultHandler_SetMoniker (IOleObject)
884 * The default handler's implementation of this method does nothing.
886 * See Windows documentation for more details on IOleObject methods.
888 static HRESULT WINAPI
DefaultHandler_SetMoniker(
890 DWORD dwWhichMoniker
,
893 TRACE("(%p, %ld, %p)\n",
901 /************************************************************************
902 * DefaultHandler_GetMoniker (IOleObject)
904 * Delegate this request to the client site if we have one.
906 * See Windows documentation for more details on IOleObject methods.
908 static HRESULT WINAPI
DefaultHandler_GetMoniker(
911 DWORD dwWhichMoniker
,
914 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
916 TRACE("(%p, %ld, %ld, %p)\n",
917 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
919 if (this->clientSite
)
921 return IOleClientSite_GetMoniker(this->clientSite
,
931 /************************************************************************
932 * DefaultHandler_InitFromData (IOleObject)
934 * This method is meaningless if the server is not running
936 * See Windows documentation for more details on IOleObject methods.
938 static HRESULT WINAPI
DefaultHandler_InitFromData(
940 IDataObject
* pDataObject
,
944 TRACE("(%p, %p, %d, %ld)\n",
945 iface
, pDataObject
, fCreation
, dwReserved
);
947 return OLE_E_NOTRUNNING
;
950 /************************************************************************
951 * DefaultHandler_GetClipboardData (IOleObject)
953 * This method is meaningless if the server is not running
955 * See Windows documentation for more details on IOleObject methods.
957 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
960 IDataObject
** ppDataObject
)
962 TRACE("(%p, %ld, %p)\n",
963 iface
, dwReserved
, ppDataObject
);
965 return OLE_E_NOTRUNNING
;
968 static HRESULT WINAPI
DefaultHandler_DoVerb(
971 struct tagMSG
* lpmsg
,
972 IOleClientSite
* pActiveSite
,
981 /************************************************************************
982 * DefaultHandler_EnumVerbs (IOleObject)
984 * The default handler implementation of this method simply delegates
987 * See Windows documentation for more details on IOleObject methods.
989 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
991 IEnumOLEVERB
** ppEnumOleVerb
)
993 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
995 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
997 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
1000 static HRESULT WINAPI
DefaultHandler_Update(
1007 /************************************************************************
1008 * DefaultHandler_IsUpToDate (IOleObject)
1010 * This method is meaningless if the server is not running
1012 * See Windows documentation for more details on IOleObject methods.
1014 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
1017 TRACE("(%p)\n", iface
);
1019 return OLE_E_NOTRUNNING
;
1022 /************************************************************************
1023 * DefaultHandler_GetUserClassID (IOleObject)
1025 * TODO: Map to a new class ID if emulation is active.
1027 * See Windows documentation for more details on IOleObject methods.
1029 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1033 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1035 TRACE("(%p, %p)\n", iface
, pClsid
);
1043 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1048 /************************************************************************
1049 * DefaultHandler_GetUserType (IOleObject)
1051 * The default handler implementation of this method simply delegates
1052 * to OleRegGetUserType
1054 * See Windows documentation for more details on IOleObject methods.
1056 static HRESULT WINAPI
DefaultHandler_GetUserType(
1059 LPOLESTR
* pszUserType
)
1061 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1063 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1065 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1068 /************************************************************************
1069 * DefaultHandler_SetExtent (IOleObject)
1071 * This method is meaningless if the server is not running
1073 * See Windows documentation for more details on IOleObject methods.
1075 static HRESULT WINAPI
DefaultHandler_SetExtent(
1080 TRACE("(%p, %lx, (%ld x %ld))\n", iface
,
1081 dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1082 return OLE_E_NOTRUNNING
;
1085 /************************************************************************
1086 * DefaultHandler_GetExtent (IOleObject)
1088 * The default handler's implementation of this method returns uses
1089 * the cache to locate the aspect and extract the extent from it.
1091 * See Windows documentation for more details on IOleObject methods.
1093 static HRESULT WINAPI
DefaultHandler_GetExtent(
1098 DVTARGETDEVICE
* targetDevice
;
1099 IViewObject2
* cacheView
= NULL
;
1102 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1104 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1106 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1109 return E_UNEXPECTED
;
1112 * Prepare the call to the cache's GetExtent method.
1114 * Here we would build a valid DVTARGETDEVICE structure
1115 * but, since we are calling into the data cache, we
1116 * know it's implementation and we'll skip this
1117 * extra work until later.
1119 targetDevice
= NULL
;
1121 hres
= IViewObject2_GetExtent(cacheView
,
1130 IViewObject2_Release(cacheView
);
1135 /************************************************************************
1136 * DefaultHandler_Advise (IOleObject)
1138 * The default handler's implementation of this method simply
1139 * delegates to the OleAdviseHolder.
1141 * See Windows documentation for more details on IOleObject methods.
1143 static HRESULT WINAPI
DefaultHandler_Advise(
1145 IAdviseSink
* pAdvSink
,
1146 DWORD
* pdwConnection
)
1148 HRESULT hres
= S_OK
;
1149 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1151 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1154 * Make sure we have an advise holder before we start.
1156 if (this->oleAdviseHolder
==NULL
)
1158 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1161 if (SUCCEEDED(hres
))
1163 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1171 /************************************************************************
1172 * DefaultHandler_Unadvise (IOleObject)
1174 * The default handler's implementation of this method simply
1175 * delegates to the OleAdviseHolder.
1177 * See Windows documentation for more details on IOleObject methods.
1179 static HRESULT WINAPI
DefaultHandler_Unadvise(
1183 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1185 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1188 * If we don't have an advise holder yet, it means we don't have
1191 if (this->oleAdviseHolder
==NULL
)
1192 return OLE_E_NOCONNECTION
;
1194 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1198 /************************************************************************
1199 * DefaultHandler_EnumAdvise (IOleObject)
1201 * The default handler's implementation of this method simply
1202 * delegates to the OleAdviseHolder.
1204 * See Windows documentation for more details on IOleObject methods.
1206 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1208 IEnumSTATDATA
** ppenumAdvise
)
1210 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1212 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1217 if (ppenumAdvise
==NULL
)
1221 * Initialize the out parameter.
1223 *ppenumAdvise
= NULL
;
1225 if (this->oleAdviseHolder
==NULL
)
1226 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1232 /************************************************************************
1233 * DefaultHandler_GetMiscStatus (IOleObject)
1235 * The default handler's implementation of this method simply delegates
1236 * to OleRegGetMiscStatus.
1238 * See Windows documentation for more details on IOleObject methods.
1240 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1246 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1248 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1250 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1258 /************************************************************************
1259 * DefaultHandler_SetExtent (IOleObject)
1261 * This method is meaningless if the server is not running
1263 * See Windows documentation for more details on IOleObject methods.
1265 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1267 struct tagLOGPALETTE
* pLogpal
)
1269 TRACE("(%p, %p))\n", iface
, pLogpal
);
1270 return OLE_E_NOTRUNNING
;
1273 /*********************************************************
1274 * Methods implementation for the IDataObject part of
1275 * the DefaultHandler class.
1278 /************************************************************************
1279 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1281 * See Windows documentation for more details on IUnknown methods.
1283 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1288 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1290 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1293 /************************************************************************
1294 * DefaultHandler_IDataObject_AddRef (IUnknown)
1296 * See Windows documentation for more details on IUnknown methods.
1298 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1301 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1303 return IUnknown_AddRef(this->outerUnknown
);
1306 /************************************************************************
1307 * DefaultHandler_IDataObject_Release (IUnknown)
1309 * See Windows documentation for more details on IUnknown methods.
1311 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1314 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1316 return IUnknown_Release(this->outerUnknown
);
1319 /************************************************************************
1320 * DefaultHandler_GetData
1322 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1323 * See Windows documentation for more details on GetData.
1324 * Default handler's implementation of this method delegates to the cache.
1326 static HRESULT WINAPI
DefaultHandler_GetData(
1328 LPFORMATETC pformatetcIn
,
1331 IDataObject
* cacheDataObject
= NULL
;
1334 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1336 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1338 hres
= IUnknown_QueryInterface(this->dataCache
,
1340 (void**)&cacheDataObject
);
1343 return E_UNEXPECTED
;
1345 hres
= IDataObject_GetData(cacheDataObject
,
1349 IDataObject_Release(cacheDataObject
);
1354 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1356 LPFORMATETC pformatetc
,
1363 /************************************************************************
1364 * DefaultHandler_QueryGetData (IDataObject)
1366 * The default handler's implementation of this method delegates to
1369 * See Windows documentation for more details on IDataObject methods.
1371 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1373 LPFORMATETC pformatetc
)
1375 IDataObject
* cacheDataObject
= NULL
;
1378 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1380 TRACE("(%p, %p)\n", iface
, pformatetc
);
1382 hres
= IUnknown_QueryInterface(this->dataCache
,
1384 (void**)&cacheDataObject
);
1387 return E_UNEXPECTED
;
1389 hres
= IDataObject_QueryGetData(cacheDataObject
,
1392 IDataObject_Release(cacheDataObject
);
1397 /************************************************************************
1398 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1400 * This method is meaningless if the server is not running
1402 * See Windows documentation for more details on IDataObject methods.
1404 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1406 LPFORMATETC pformatectIn
,
1407 LPFORMATETC pformatetcOut
)
1409 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1411 return OLE_E_NOTRUNNING
;
1414 /************************************************************************
1415 * DefaultHandler_SetData (IDataObject)
1417 * The default handler's implementation of this method delegates to
1420 * See Windows documentation for more details on IDataObject methods.
1422 static HRESULT WINAPI
DefaultHandler_SetData(
1424 LPFORMATETC pformatetc
,
1428 IDataObject
* cacheDataObject
= NULL
;
1431 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1433 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1435 hres
= IUnknown_QueryInterface(this->dataCache
,
1437 (void**)&cacheDataObject
);
1440 return E_UNEXPECTED
;
1442 hres
= IDataObject_SetData(cacheDataObject
,
1447 IDataObject_Release(cacheDataObject
);
1452 /************************************************************************
1453 * DefaultHandler_EnumFormatEtc (IDataObject)
1455 * The default handler's implementation of this method simply delegates
1456 * to OleRegEnumFormatEtc.
1458 * See Windows documentation for more details on IDataObject methods.
1460 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1463 IEnumFORMATETC
** ppenumFormatEtc
)
1466 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1468 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1470 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1475 /************************************************************************
1476 * DefaultHandler_DAdvise (IDataObject)
1478 * The default handler's implementation of this method simply
1479 * delegates to the DataAdviseHolder.
1481 * See Windows documentation for more details on IDataObject methods.
1483 static HRESULT WINAPI
DefaultHandler_DAdvise(
1485 FORMATETC
* pformatetc
,
1487 IAdviseSink
* pAdvSink
,
1488 DWORD
* pdwConnection
)
1490 HRESULT hres
= S_OK
;
1491 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1493 TRACE("(%p, %p, %ld, %p, %p)\n",
1494 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1497 * Make sure we have a data advise holder before we start.
1499 if (this->dataAdviseHolder
==NULL
)
1501 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1504 if (SUCCEEDED(hres
))
1506 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1517 /************************************************************************
1518 * DefaultHandler_DUnadvise (IDataObject)
1520 * The default handler's implementation of this method simply
1521 * delegates to the DataAdviseHolder.
1523 * See Windows documentation for more details on IDataObject methods.
1525 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1529 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1531 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1534 * If we don't have a data advise holder yet, it means that
1535 * we don't have any connections..
1537 if (this->dataAdviseHolder
==NULL
)
1539 return OLE_E_NOCONNECTION
;
1542 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1546 /************************************************************************
1547 * DefaultHandler_EnumDAdvise (IDataObject)
1549 * The default handler's implementation of this method simply
1550 * delegates to the DataAdviseHolder.
1552 * See Windows documentation for more details on IDataObject methods.
1554 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1556 IEnumSTATDATA
** ppenumAdvise
)
1558 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1560 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1565 if (ppenumAdvise
== NULL
)
1569 * Initialize the out parameter.
1571 *ppenumAdvise
= NULL
;
1574 * If we have a data advise holder object, delegate.
1576 if (this->dataAdviseHolder
!=NULL
)
1578 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1585 /*********************************************************
1586 * Methods implementation for the IRunnableObject part
1587 * of the DefaultHandler class.
1590 /************************************************************************
1591 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1593 * See Windows documentation for more details on IUnknown methods.
1595 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1596 IRunnableObject
* iface
,
1600 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1602 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1605 /************************************************************************
1606 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1608 * See Windows documentation for more details on IUnknown methods.
1610 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1611 IRunnableObject
* iface
)
1613 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1615 return IUnknown_AddRef(this->outerUnknown
);
1618 /************************************************************************
1619 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1621 * See Windows documentation for more details on IUnknown methods.
1623 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1624 IRunnableObject
* iface
)
1626 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1628 return IUnknown_Release(this->outerUnknown
);
1631 /************************************************************************
1632 * DefaultHandler_GetRunningClass (IRunnableObject)
1634 * According to Brockscmidt, Chapter 19, the default handler's
1635 * implementation of IRunnableobject does nothing until the object
1636 * is actually running.
1638 * See Windows documentation for more details on IRunnableObject methods.
1640 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1641 IRunnableObject
* iface
,
1648 static HRESULT WINAPI
DefaultHandler_Run(
1649 IRunnableObject
* iface
,
1656 /************************************************************************
1657 * DefaultHandler_IsRunning (IRunnableObject)
1659 * According to Brockscmidt, Chapter 19, the default handler's
1660 * implementation of IRunnableobject does nothing until the object
1661 * is actually running.
1663 * See Windows documentation for more details on IRunnableObject methods.
1665 static BOOL WINAPI
DefaultHandler_IsRunning(
1666 IRunnableObject
* iface
)
1672 /************************************************************************
1673 * DefaultHandler_LockRunning (IRunnableObject)
1675 * According to Brockscmidt, Chapter 19, the default handler's
1676 * implementation of IRunnableobject does nothing until the object
1677 * is actually running.
1679 * See Windows documentation for more details on IRunnableObject methods.
1681 static HRESULT WINAPI
DefaultHandler_LockRunning(
1682 IRunnableObject
* iface
,
1684 BOOL fLastUnlockCloses
)
1690 /************************************************************************
1691 * DefaultHandler_SetContainedObject (IRunnableObject)
1693 * According to Brockscmidt, Chapter 19, the default handler's
1694 * implementation of IRunnableobject does nothing until the object
1695 * is actually running.
1697 * See Windows documentation for more details on IRunnableObject methods.
1699 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1700 IRunnableObject
* iface
,