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.
53 #include "wine/unicode.h"
55 #include "wine/obj_oleview.h"
56 #include "wine/debug.h"
58 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
60 /****************************************************************************
67 * List all interface VTables here
69 ICOM_VTABLE(IOleObject
)* lpvtbl1
;
70 ICOM_VTABLE(IUnknown
)* lpvtbl2
;
71 ICOM_VTABLE(IDataObject
)* lpvtbl3
;
72 ICOM_VTABLE(IRunnableObject
)* lpvtbl4
;
75 * Reference count of this object
80 * IUnknown implementation of the outer object.
82 IUnknown
* outerUnknown
;
85 * Class Id that this handler object represents.
90 * IUnknown implementation of the datacache.
95 * Client site for the embedded object.
97 IOleClientSite
* clientSite
;
100 * The IOleAdviseHolder maintains the connections
101 * on behalf of the default handler.
103 IOleAdviseHolder
* oleAdviseHolder
;
106 * The IDataAdviseHolder maintains the data
107 * connections on behalf of the default handler.
109 IDataAdviseHolder
* dataAdviseHolder
;
112 * Name of the container and object contained
119 typedef struct DefaultHandler DefaultHandler
;
122 * Here, I define utility macros to help with the casting of the
124 * There is a version to accomodate all of the VTables implemented
127 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
128 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
129 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
130 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
133 * Prototypes for the methods of the DefaultHandler class.
135 static DefaultHandler
* DefaultHandler_Construct(REFCLSID clsid
,
136 LPUNKNOWN pUnkOuter
);
137 static void DefaultHandler_Destroy(DefaultHandler
* ptrToDestroy
);
140 * Prototypes for the methods of the DefaultHandler class
141 * that implement non delegating IUnknown methods.
143 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
147 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
149 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
153 * Prototypes for the methods of the DefaultHandler class
154 * that implement IOleObject methods.
156 static HRESULT WINAPI
DefaultHandler_QueryInterface(
160 static ULONG WINAPI
DefaultHandler_AddRef(
162 static ULONG WINAPI
DefaultHandler_Release(
164 static HRESULT WINAPI
DefaultHandler_SetClientSite(
166 IOleClientSite
* pClientSite
);
167 static HRESULT WINAPI
DefaultHandler_GetClientSite(
169 IOleClientSite
** ppClientSite
);
170 static HRESULT WINAPI
DefaultHandler_SetHostNames(
172 LPCOLESTR szContainerApp
,
173 LPCOLESTR szContainerObj
);
174 static HRESULT WINAPI
DefaultHandler_Close(
177 static HRESULT WINAPI
DefaultHandler_SetMoniker(
179 DWORD dwWhichMoniker
,
181 static HRESULT WINAPI
DefaultHandler_GetMoniker(
184 DWORD dwWhichMoniker
,
186 static HRESULT WINAPI
DefaultHandler_InitFromData(
188 IDataObject
* pDataObject
,
191 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
194 IDataObject
** ppDataObject
);
195 static HRESULT WINAPI
DefaultHandler_DoVerb(
198 struct tagMSG
* lpmsg
,
199 IOleClientSite
* pActiveSite
,
202 LPCRECT lprcPosRect
);
203 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
205 IEnumOLEVERB
** ppEnumOleVerb
);
206 static HRESULT WINAPI
DefaultHandler_Update(
208 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
210 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
213 static HRESULT WINAPI
DefaultHandler_GetUserType(
216 LPOLESTR
* pszUserType
);
217 static HRESULT WINAPI
DefaultHandler_SetExtent(
221 static HRESULT WINAPI
DefaultHandler_GetExtent(
225 static HRESULT WINAPI
DefaultHandler_Advise(
227 IAdviseSink
* pAdvSink
,
228 DWORD
* pdwConnection
);
229 static HRESULT WINAPI
DefaultHandler_Unadvise(
232 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
234 IEnumSTATDATA
** ppenumAdvise
);
235 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
239 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
241 struct tagLOGPALETTE
* pLogpal
);
244 * Prototypes for the methods of the DefaultHandler class
245 * that implement IDataObject methods.
247 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
251 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
253 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
255 static HRESULT WINAPI
DefaultHandler_GetData(
257 LPFORMATETC pformatetcIn
,
259 static HRESULT WINAPI
DefaultHandler_GetDataHere(
261 LPFORMATETC pformatetc
,
263 static HRESULT WINAPI
DefaultHandler_QueryGetData(
265 LPFORMATETC pformatetc
);
266 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
268 LPFORMATETC pformatectIn
,
269 LPFORMATETC pformatetcOut
);
270 static HRESULT WINAPI
DefaultHandler_SetData(
272 LPFORMATETC pformatetc
,
275 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
278 IEnumFORMATETC
** ppenumFormatEtc
);
279 static HRESULT WINAPI
DefaultHandler_DAdvise(
281 FORMATETC
* pformatetc
,
283 IAdviseSink
* pAdvSink
,
284 DWORD
* pdwConnection
);
285 static HRESULT WINAPI
DefaultHandler_DUnadvise(
288 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
290 IEnumSTATDATA
** ppenumAdvise
);
293 * Prototypes for the methods of the DefaultHandler class
294 * that implement IRunnableObject methods.
296 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
297 IRunnableObject
* iface
,
300 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
301 IRunnableObject
* iface
);
302 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
303 IRunnableObject
* iface
);
304 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
305 IRunnableObject
* iface
,
307 static HRESULT WINAPI
DefaultHandler_Run(
308 IRunnableObject
* iface
,
310 static BOOL WINAPI
DefaultHandler_IsRunning(
311 IRunnableObject
* iface
);
312 static HRESULT WINAPI
DefaultHandler_LockRunning(
313 IRunnableObject
* iface
,
315 BOOL fLastUnlockCloses
);
316 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
317 IRunnableObject
* iface
,
322 * Virtual function tables for the DefaultHandler class.
324 static ICOM_VTABLE(IOleObject
) DefaultHandler_IOleObject_VTable
=
326 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
327 DefaultHandler_QueryInterface
,
328 DefaultHandler_AddRef
,
329 DefaultHandler_Release
,
330 DefaultHandler_SetClientSite
,
331 DefaultHandler_GetClientSite
,
332 DefaultHandler_SetHostNames
,
333 DefaultHandler_Close
,
334 DefaultHandler_SetMoniker
,
335 DefaultHandler_GetMoniker
,
336 DefaultHandler_InitFromData
,
337 DefaultHandler_GetClipboardData
,
338 DefaultHandler_DoVerb
,
339 DefaultHandler_EnumVerbs
,
340 DefaultHandler_Update
,
341 DefaultHandler_IsUpToDate
,
342 DefaultHandler_GetUserClassID
,
343 DefaultHandler_GetUserType
,
344 DefaultHandler_SetExtent
,
345 DefaultHandler_GetExtent
,
346 DefaultHandler_Advise
,
347 DefaultHandler_Unadvise
,
348 DefaultHandler_EnumAdvise
,
349 DefaultHandler_GetMiscStatus
,
350 DefaultHandler_SetColorScheme
353 static ICOM_VTABLE(IUnknown
) DefaultHandler_NDIUnknown_VTable
=
355 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
356 DefaultHandler_NDIUnknown_QueryInterface
,
357 DefaultHandler_NDIUnknown_AddRef
,
358 DefaultHandler_NDIUnknown_Release
,
361 static ICOM_VTABLE(IDataObject
) DefaultHandler_IDataObject_VTable
=
363 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
364 DefaultHandler_IDataObject_QueryInterface
,
365 DefaultHandler_IDataObject_AddRef
,
366 DefaultHandler_IDataObject_Release
,
367 DefaultHandler_GetData
,
368 DefaultHandler_GetDataHere
,
369 DefaultHandler_QueryGetData
,
370 DefaultHandler_GetCanonicalFormatEtc
,
371 DefaultHandler_SetData
,
372 DefaultHandler_EnumFormatEtc
,
373 DefaultHandler_DAdvise
,
374 DefaultHandler_DUnadvise
,
375 DefaultHandler_EnumDAdvise
378 static ICOM_VTABLE(IRunnableObject
) DefaultHandler_IRunnableObject_VTable
=
380 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
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.90]
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 if (ptrToDestroy
->containerApp
!=NULL
)
519 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerApp
);
520 ptrToDestroy
->containerApp
= NULL
;
523 if (ptrToDestroy
->containerObj
!=NULL
)
525 HeapFree( GetProcessHeap(), 0, ptrToDestroy
->containerObj
);
526 ptrToDestroy
->containerObj
= NULL
;
530 * Release our reference to the data cache.
532 if (ptrToDestroy
->dataCache
!=NULL
)
534 IUnknown_Release(ptrToDestroy
->dataCache
);
535 ptrToDestroy
->dataCache
= NULL
;
539 * Same thing for the client site.
541 if (ptrToDestroy
->clientSite
!=NULL
)
543 IOleClientSite_Release(ptrToDestroy
->clientSite
);
544 ptrToDestroy
->clientSite
= NULL
;
548 * And the advise holder.
550 if (ptrToDestroy
->oleAdviseHolder
!=NULL
)
552 IOleAdviseHolder_Release(ptrToDestroy
->oleAdviseHolder
);
553 ptrToDestroy
->oleAdviseHolder
= NULL
;
557 * And the data advise holder.
559 if (ptrToDestroy
->dataAdviseHolder
!=NULL
)
561 IDataAdviseHolder_Release(ptrToDestroy
->dataAdviseHolder
);
562 ptrToDestroy
->dataAdviseHolder
= NULL
;
567 * Free the actual default handler structure.
569 HeapFree(GetProcessHeap(), 0, ptrToDestroy
);
572 /*********************************************************
573 * Method implementation for the non delegating IUnknown
574 * part of the DefaultHandler class.
577 /************************************************************************
578 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
580 * See Windows documentation for more details on IUnknown methods.
582 * This version of QueryInterface will not delegate it's implementation
583 * to the outer unknown.
585 static HRESULT WINAPI
DefaultHandler_NDIUnknown_QueryInterface(
590 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
593 * Perform a sanity check on the parameters.
595 if ( (this==0) || (ppvObject
==0) )
599 * Initialize the return parameter.
604 * Compare the riid with the interface IDs implemented by this object.
606 if (memcmp(&IID_IUnknown
, riid
, sizeof(IID_IUnknown
)) == 0)
610 else if (memcmp(&IID_IOleObject
, riid
, sizeof(IID_IOleObject
)) == 0)
612 *ppvObject
= (IOleObject
*)&(this->lpvtbl1
);
614 else if (memcmp(&IID_IDataObject
, riid
, sizeof(IID_IDataObject
)) == 0)
616 *ppvObject
= (IDataObject
*)&(this->lpvtbl3
);
618 else if (memcmp(&IID_IRunnableObject
, riid
, sizeof(IID_IRunnableObject
)) == 0)
620 *ppvObject
= (IRunnableObject
*)&(this->lpvtbl4
);
625 * Blind aggregate the data cache to "inherit" it's interfaces.
627 if (IUnknown_QueryInterface(this->dataCache
, riid
, ppvObject
) == S_OK
)
632 * Check that we obtained an interface.
636 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid
));
637 return E_NOINTERFACE
;
641 * Query Interface always increases the reference count by one when it is
644 IUnknown_AddRef((IUnknown
*)*ppvObject
);
649 /************************************************************************
650 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
652 * See Windows documentation for more details on IUnknown methods.
654 * This version of QueryInterface will not delegate it's implementation
655 * to the outer unknown.
657 static ULONG WINAPI
DefaultHandler_NDIUnknown_AddRef(
660 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
667 /************************************************************************
668 * DefaultHandler_NDIUnknown_Release (IUnknown)
670 * See Windows documentation for more details on IUnknown methods.
672 * This version of QueryInterface will not delegate it's implementation
673 * to the outer unknown.
675 static ULONG WINAPI
DefaultHandler_NDIUnknown_Release(
678 _ICOM_THIS_From_NDIUnknown(DefaultHandler
, iface
);
681 * Decrease the reference count on this object.
686 * If the reference count goes down to 0, perform suicide.
690 DefaultHandler_Destroy(this);
698 /*********************************************************
699 * Methods implementation for the IOleObject part of
700 * the DefaultHandler class.
703 /************************************************************************
704 * DefaultHandler_QueryInterface (IUnknown)
706 * See Windows documentation for more details on IUnknown methods.
708 static HRESULT WINAPI
DefaultHandler_QueryInterface(
713 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
715 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
718 /************************************************************************
719 * DefaultHandler_AddRef (IUnknown)
721 * See Windows documentation for more details on IUnknown methods.
723 static ULONG WINAPI
DefaultHandler_AddRef(
726 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
728 return IUnknown_AddRef(this->outerUnknown
);
731 /************************************************************************
732 * DefaultHandler_Release (IUnknown)
734 * See Windows documentation for more details on IUnknown methods.
736 static ULONG WINAPI
DefaultHandler_Release(
739 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
741 return IUnknown_Release(this->outerUnknown
);
744 /************************************************************************
745 * DefaultHandler_SetClientSite (IOleObject)
747 * The default handler's implementation of this method only keeps the
748 * client site pointer for future reference.
750 * See Windows documentation for more details on IOleObject methods.
752 static HRESULT WINAPI
DefaultHandler_SetClientSite(
754 IOleClientSite
* pClientSite
)
756 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
758 TRACE("(%p, %p)\n", iface
, pClientSite
);
761 * Make sure we release the previous client site if there
764 if (this->clientSite
!=NULL
)
766 IOleClientSite_Release(this->clientSite
);
769 this->clientSite
= pClientSite
;
771 if (this->clientSite
!=NULL
)
773 IOleClientSite_AddRef(this->clientSite
);
779 /************************************************************************
780 * DefaultHandler_GetClientSite (IOleObject)
782 * The default handler's implementation of this method returns the
783 * last pointer set in IOleObject_SetClientSite.
785 * See Windows documentation for more details on IOleObject methods.
787 static HRESULT WINAPI
DefaultHandler_GetClientSite(
789 IOleClientSite
** ppClientSite
)
791 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
796 if (ppClientSite
== NULL
)
799 *ppClientSite
= this->clientSite
;
801 if (this->clientSite
!= NULL
)
803 IOleClientSite_AddRef(this->clientSite
);
809 /************************************************************************
810 * DefaultHandler_SetHostNames (IOleObject)
812 * The default handler's implementation of this method just stores
813 * the strings and returns S_OK.
815 * See Windows documentation for more details on IOleObject methods.
817 static HRESULT WINAPI
DefaultHandler_SetHostNames(
819 LPCOLESTR szContainerApp
,
820 LPCOLESTR szContainerObj
)
822 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
824 TRACE("(%p, %s, %s)\n",
826 debugstr_w(szContainerApp
),
827 debugstr_w(szContainerObj
));
830 * Be sure to cleanup before re-assinging the strings.
832 if (this->containerApp
!=NULL
)
834 HeapFree( GetProcessHeap(), 0, this->containerApp
);
835 this->containerApp
= NULL
;
838 if (this->containerObj
!=NULL
)
840 HeapFree( GetProcessHeap(), 0, this->containerObj
);
841 this->containerObj
= NULL
;
845 * Copy the string supplied.
847 if (szContainerApp
!= NULL
)
849 if ((this->containerApp
= HeapAlloc( GetProcessHeap(), 0,
850 (lstrlenW(szContainerApp
) + 1) * sizeof(WCHAR
) )))
851 strcpyW( this->containerApp
, szContainerApp
);
854 if (szContainerObj
!= NULL
)
856 if ((this->containerObj
= HeapAlloc( GetProcessHeap(), 0,
857 (lstrlenW(szContainerObj
) + 1) * sizeof(WCHAR
) )))
858 strcpyW( this->containerObj
, szContainerObj
);
863 /************************************************************************
864 * DefaultHandler_Close (IOleObject)
866 * The default handler's implementation of this method is meaningless
867 * without a running server so it does nothing.
869 * See Windows documentation for more details on IOleObject methods.
871 static HRESULT WINAPI
DefaultHandler_Close(
879 /************************************************************************
880 * DefaultHandler_SetMoniker (IOleObject)
882 * The default handler's implementation of this method does nothing.
884 * See Windows documentation for more details on IOleObject methods.
886 static HRESULT WINAPI
DefaultHandler_SetMoniker(
888 DWORD dwWhichMoniker
,
891 TRACE("(%p, %ld, %p)\n",
899 /************************************************************************
900 * DefaultHandler_GetMoniker (IOleObject)
902 * Delegate this request to the client site if we have one.
904 * See Windows documentation for more details on IOleObject methods.
906 static HRESULT WINAPI
DefaultHandler_GetMoniker(
909 DWORD dwWhichMoniker
,
912 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
914 TRACE("(%p, %ld, %ld, %p)\n",
915 iface
, dwAssign
, dwWhichMoniker
, ppmk
);
917 if (this->clientSite
)
919 return IOleClientSite_GetMoniker(this->clientSite
,
929 /************************************************************************
930 * DefaultHandler_InitFromData (IOleObject)
932 * This method is meaningless if the server is not running
934 * See Windows documentation for more details on IOleObject methods.
936 static HRESULT WINAPI
DefaultHandler_InitFromData(
938 IDataObject
* pDataObject
,
942 TRACE("(%p, %p, %d, %ld)\n",
943 iface
, pDataObject
, fCreation
, dwReserved
);
945 return OLE_E_NOTRUNNING
;
948 /************************************************************************
949 * DefaultHandler_GetClipboardData (IOleObject)
951 * This method is meaningless if the server is not running
953 * See Windows documentation for more details on IOleObject methods.
955 static HRESULT WINAPI
DefaultHandler_GetClipboardData(
958 IDataObject
** ppDataObject
)
960 TRACE("(%p, %ld, %p)\n",
961 iface
, dwReserved
, ppDataObject
);
963 return OLE_E_NOTRUNNING
;
966 static HRESULT WINAPI
DefaultHandler_DoVerb(
969 struct tagMSG
* lpmsg
,
970 IOleClientSite
* pActiveSite
,
979 /************************************************************************
980 * DefaultHandler_EnumVerbs (IOleObject)
982 * The default handler implementation of this method simply delegates
985 * See Windows documentation for more details on IOleObject methods.
987 static HRESULT WINAPI
DefaultHandler_EnumVerbs(
989 IEnumOLEVERB
** ppEnumOleVerb
)
991 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
993 TRACE("(%p, %p)\n", iface
, ppEnumOleVerb
);
995 return OleRegEnumVerbs(&this->clsid
, ppEnumOleVerb
);
998 static HRESULT WINAPI
DefaultHandler_Update(
1005 /************************************************************************
1006 * DefaultHandler_IsUpToDate (IOleObject)
1008 * This method is meaningless if the server is not running
1010 * See Windows documentation for more details on IOleObject methods.
1012 static HRESULT WINAPI
DefaultHandler_IsUpToDate(
1015 TRACE("(%p)\n", iface
);
1017 return OLE_E_NOTRUNNING
;
1020 /************************************************************************
1021 * DefaultHandler_GetUserClassID (IOleObject)
1023 * TODO: Map to a new class ID if emulation is active.
1025 * See Windows documentation for more details on IOleObject methods.
1027 static HRESULT WINAPI
DefaultHandler_GetUserClassID(
1031 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1033 TRACE("(%p, %p)\n", iface
, pClsid
);
1041 memcpy(pClsid
, &this->clsid
, sizeof(CLSID
));
1046 /************************************************************************
1047 * DefaultHandler_GetUserType (IOleObject)
1049 * The default handler implementation of this method simply delegates
1050 * to OleRegGetUserType
1052 * See Windows documentation for more details on IOleObject methods.
1054 static HRESULT WINAPI
DefaultHandler_GetUserType(
1057 LPOLESTR
* pszUserType
)
1059 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1061 TRACE("(%p, %ld, %p)\n", iface
, dwFormOfType
, pszUserType
);
1063 return OleRegGetUserType(&this->clsid
, dwFormOfType
, pszUserType
);
1066 /************************************************************************
1067 * DefaultHandler_SetExtent (IOleObject)
1069 * This method is meaningless if the server is not running
1071 * See Windows documentation for more details on IOleObject methods.
1073 static HRESULT WINAPI
DefaultHandler_SetExtent(
1078 TRACE("(%p, %lx, (%ld x %ld))\n", iface
,
1079 dwDrawAspect
, psizel
->cx
, psizel
->cy
);
1080 return OLE_E_NOTRUNNING
;
1083 /************************************************************************
1084 * DefaultHandler_GetExtent (IOleObject)
1086 * The default handler's implementation of this method returns uses
1087 * the cache to locate the aspect and extract the extent from it.
1089 * See Windows documentation for more details on IOleObject methods.
1091 static HRESULT WINAPI
DefaultHandler_GetExtent(
1096 DVTARGETDEVICE
* targetDevice
;
1097 IViewObject2
* cacheView
= NULL
;
1100 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1102 TRACE("(%p, %lx, %p)\n", iface
, dwDrawAspect
, psizel
);
1104 hres
= IUnknown_QueryInterface(this->dataCache
, &IID_IViewObject2
, (void**)&cacheView
);
1107 return E_UNEXPECTED
;
1110 * Prepare the call to the cache's GetExtent method.
1112 * Here we would build a valid DVTARGETDEVICE structure
1113 * but, since we are calling into the data cache, we
1114 * know it's implementation and we'll skip this
1115 * extra work until later.
1117 targetDevice
= NULL
;
1119 hres
= IViewObject2_GetExtent(cacheView
,
1128 IViewObject2_Release(cacheView
);
1133 /************************************************************************
1134 * DefaultHandler_Advise (IOleObject)
1136 * The default handler's implementation of this method simply
1137 * delegates to the OleAdviseHolder.
1139 * See Windows documentation for more details on IOleObject methods.
1141 static HRESULT WINAPI
DefaultHandler_Advise(
1143 IAdviseSink
* pAdvSink
,
1144 DWORD
* pdwConnection
)
1146 HRESULT hres
= S_OK
;
1147 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1149 TRACE("(%p, %p, %p)\n", iface
, pAdvSink
, pdwConnection
);
1152 * Make sure we have an advise holder before we start.
1154 if (this->oleAdviseHolder
==NULL
)
1156 hres
= CreateOleAdviseHolder(&this->oleAdviseHolder
);
1159 if (SUCCEEDED(hres
))
1161 hres
= IOleAdviseHolder_Advise(this->oleAdviseHolder
,
1169 /************************************************************************
1170 * DefaultHandler_Unadvise (IOleObject)
1172 * The default handler's implementation of this method simply
1173 * delegates to the OleAdviseHolder.
1175 * See Windows documentation for more details on IOleObject methods.
1177 static HRESULT WINAPI
DefaultHandler_Unadvise(
1181 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1183 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1186 * If we don't have an advise holder yet, it means we don't have
1189 if (this->oleAdviseHolder
==NULL
)
1190 return OLE_E_NOCONNECTION
;
1192 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder
,
1196 /************************************************************************
1197 * DefaultHandler_EnumAdvise (IOleObject)
1199 * The default handler's implementation of this method simply
1200 * delegates to the OleAdviseHolder.
1202 * See Windows documentation for more details on IOleObject methods.
1204 static HRESULT WINAPI
DefaultHandler_EnumAdvise(
1206 IEnumSTATDATA
** ppenumAdvise
)
1208 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1210 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1215 if (ppenumAdvise
==NULL
)
1219 * Initialize the out parameter.
1221 *ppenumAdvise
= NULL
;
1223 if (this->oleAdviseHolder
==NULL
)
1224 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder
,
1230 /************************************************************************
1231 * DefaultHandler_GetMiscStatus (IOleObject)
1233 * The default handler's implementation of this method simply delegates
1234 * to OleRegGetMiscStatus.
1236 * See Windows documentation for more details on IOleObject methods.
1238 static HRESULT WINAPI
DefaultHandler_GetMiscStatus(
1244 _ICOM_THIS_From_IOleObject(DefaultHandler
, iface
);
1246 TRACE("(%p, %lx, %p)\n", iface
, dwAspect
, pdwStatus
);
1248 hres
= OleRegGetMiscStatus(&(this->clsid
), dwAspect
, pdwStatus
);
1256 /************************************************************************
1257 * DefaultHandler_SetExtent (IOleObject)
1259 * This method is meaningless if the server is not running
1261 * See Windows documentation for more details on IOleObject methods.
1263 static HRESULT WINAPI
DefaultHandler_SetColorScheme(
1265 struct tagLOGPALETTE
* pLogpal
)
1267 TRACE("(%p, %p))\n", iface
, pLogpal
);
1268 return OLE_E_NOTRUNNING
;
1271 /*********************************************************
1272 * Methods implementation for the IDataObject part of
1273 * the DefaultHandler class.
1276 /************************************************************************
1277 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1279 * See Windows documentation for more details on IUnknown methods.
1281 static HRESULT WINAPI
DefaultHandler_IDataObject_QueryInterface(
1286 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1288 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1291 /************************************************************************
1292 * DefaultHandler_IDataObject_AddRef (IUnknown)
1294 * See Windows documentation for more details on IUnknown methods.
1296 static ULONG WINAPI
DefaultHandler_IDataObject_AddRef(
1299 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1301 return IUnknown_AddRef(this->outerUnknown
);
1304 /************************************************************************
1305 * DefaultHandler_IDataObject_Release (IUnknown)
1307 * See Windows documentation for more details on IUnknown methods.
1309 static ULONG WINAPI
DefaultHandler_IDataObject_Release(
1312 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1314 return IUnknown_Release(this->outerUnknown
);
1317 /************************************************************************
1318 * DefaultHandler_GetData
1320 * Get Data from a source dataobject using format pformatetcIn->cfFormat
1321 * See Windows documentation for more details on GetData.
1322 * Default handler's implementation of this method delegates to the cache.
1324 static HRESULT WINAPI
DefaultHandler_GetData(
1326 LPFORMATETC pformatetcIn
,
1329 IDataObject
* cacheDataObject
= NULL
;
1332 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1334 TRACE("(%p, %p, %p)\n", iface
, pformatetcIn
, pmedium
);
1336 hres
= IUnknown_QueryInterface(this->dataCache
,
1338 (void**)&cacheDataObject
);
1341 return E_UNEXPECTED
;
1343 hres
= IDataObject_GetData(cacheDataObject
,
1347 IDataObject_Release(cacheDataObject
);
1352 static HRESULT WINAPI
DefaultHandler_GetDataHere(
1354 LPFORMATETC pformatetc
,
1361 /************************************************************************
1362 * DefaultHandler_QueryGetData (IDataObject)
1364 * The default handler's implementation of this method delegates to
1367 * See Windows documentation for more details on IDataObject methods.
1369 static HRESULT WINAPI
DefaultHandler_QueryGetData(
1371 LPFORMATETC pformatetc
)
1373 IDataObject
* cacheDataObject
= NULL
;
1376 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1378 TRACE("(%p, %p)\n", iface
, pformatetc
);
1380 hres
= IUnknown_QueryInterface(this->dataCache
,
1382 (void**)&cacheDataObject
);
1385 return E_UNEXPECTED
;
1387 hres
= IDataObject_QueryGetData(cacheDataObject
,
1390 IDataObject_Release(cacheDataObject
);
1395 /************************************************************************
1396 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1398 * This method is meaningless if the server is not running
1400 * See Windows documentation for more details on IDataObject methods.
1402 static HRESULT WINAPI
DefaultHandler_GetCanonicalFormatEtc(
1404 LPFORMATETC pformatectIn
,
1405 LPFORMATETC pformatetcOut
)
1407 FIXME("(%p, %p, %p)\n", iface
, pformatectIn
, pformatetcOut
);
1409 return OLE_E_NOTRUNNING
;
1412 /************************************************************************
1413 * DefaultHandler_SetData (IDataObject)
1415 * The default handler's implementation of this method delegates to
1418 * See Windows documentation for more details on IDataObject methods.
1420 static HRESULT WINAPI
DefaultHandler_SetData(
1422 LPFORMATETC pformatetc
,
1426 IDataObject
* cacheDataObject
= NULL
;
1429 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1431 TRACE("(%p, %p, %p, %d)\n", iface
, pformatetc
, pmedium
, fRelease
);
1433 hres
= IUnknown_QueryInterface(this->dataCache
,
1435 (void**)&cacheDataObject
);
1438 return E_UNEXPECTED
;
1440 hres
= IDataObject_SetData(cacheDataObject
,
1445 IDataObject_Release(cacheDataObject
);
1450 /************************************************************************
1451 * DefaultHandler_EnumFormatEtc (IDataObject)
1453 * The default handler's implementation of this method simply delegates
1454 * to OleRegEnumFormatEtc.
1456 * See Windows documentation for more details on IDataObject methods.
1458 static HRESULT WINAPI
DefaultHandler_EnumFormatEtc(
1461 IEnumFORMATETC
** ppenumFormatEtc
)
1464 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1466 TRACE("(%p, %lx, %p)\n", iface
, dwDirection
, ppenumFormatEtc
);
1468 hres
= OleRegEnumFormatEtc(&(this->clsid
), dwDirection
, ppenumFormatEtc
);
1473 /************************************************************************
1474 * DefaultHandler_DAdvise (IDataObject)
1476 * The default handler's implementation of this method simply
1477 * delegates to the DataAdviseHolder.
1479 * See Windows documentation for more details on IDataObject methods.
1481 static HRESULT WINAPI
DefaultHandler_DAdvise(
1483 FORMATETC
* pformatetc
,
1485 IAdviseSink
* pAdvSink
,
1486 DWORD
* pdwConnection
)
1488 HRESULT hres
= S_OK
;
1489 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1491 TRACE("(%p, %p, %ld, %p, %p)\n",
1492 iface
, pformatetc
, advf
, pAdvSink
, pdwConnection
);
1495 * Make sure we have a data advise holder before we start.
1497 if (this->dataAdviseHolder
==NULL
)
1499 hres
= CreateDataAdviseHolder(&this->dataAdviseHolder
);
1502 if (SUCCEEDED(hres
))
1504 hres
= IDataAdviseHolder_Advise(this->dataAdviseHolder
,
1515 /************************************************************************
1516 * DefaultHandler_DUnadvise (IDataObject)
1518 * The default handler's implementation of this method simply
1519 * delegates to the DataAdviseHolder.
1521 * See Windows documentation for more details on IDataObject methods.
1523 static HRESULT WINAPI
DefaultHandler_DUnadvise(
1527 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1529 TRACE("(%p, %ld)\n", iface
, dwConnection
);
1532 * If we don't have a data advise holder yet, it means that
1533 * we don't have any connections..
1535 if (this->dataAdviseHolder
==NULL
)
1537 return OLE_E_NOCONNECTION
;
1540 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder
,
1544 /************************************************************************
1545 * DefaultHandler_EnumDAdvise (IDataObject)
1547 * The default handler's implementation of this method simply
1548 * delegates to the DataAdviseHolder.
1550 * See Windows documentation for more details on IDataObject methods.
1552 static HRESULT WINAPI
DefaultHandler_EnumDAdvise(
1554 IEnumSTATDATA
** ppenumAdvise
)
1556 _ICOM_THIS_From_IDataObject(DefaultHandler
, iface
);
1558 TRACE("(%p, %p)\n", iface
, ppenumAdvise
);
1563 if (ppenumAdvise
== NULL
)
1567 * Initialize the out parameter.
1569 *ppenumAdvise
= NULL
;
1572 * If we have a data advise holder object, delegate.
1574 if (this->dataAdviseHolder
!=NULL
)
1576 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder
,
1583 /*********************************************************
1584 * Methods implementation for the IRunnableObject part
1585 * of the DefaultHandler class.
1588 /************************************************************************
1589 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1591 * See Windows documentation for more details on IUnknown methods.
1593 static HRESULT WINAPI
DefaultHandler_IRunnableObject_QueryInterface(
1594 IRunnableObject
* iface
,
1598 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1600 return IUnknown_QueryInterface(this->outerUnknown
, riid
, ppvObject
);
1603 /************************************************************************
1604 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1606 * See Windows documentation for more details on IUnknown methods.
1608 static ULONG WINAPI
DefaultHandler_IRunnableObject_AddRef(
1609 IRunnableObject
* iface
)
1611 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1613 return IUnknown_AddRef(this->outerUnknown
);
1616 /************************************************************************
1617 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1619 * See Windows documentation for more details on IUnknown methods.
1621 static ULONG WINAPI
DefaultHandler_IRunnableObject_Release(
1622 IRunnableObject
* iface
)
1624 _ICOM_THIS_From_IRunnableObject(DefaultHandler
, iface
);
1626 return IUnknown_Release(this->outerUnknown
);
1629 /************************************************************************
1630 * DefaultHandler_GetRunningClass (IRunnableObject)
1632 * According to Brockscmidt, Chapter 19, the default handler's
1633 * implementation of IRunnableobject does nothing until the object
1634 * is actually running.
1636 * See Windows documentation for more details on IRunnableObject methods.
1638 static HRESULT WINAPI
DefaultHandler_GetRunningClass(
1639 IRunnableObject
* iface
,
1646 static HRESULT WINAPI
DefaultHandler_Run(
1647 IRunnableObject
* iface
,
1654 /************************************************************************
1655 * DefaultHandler_IsRunning (IRunnableObject)
1657 * According to Brockscmidt, Chapter 19, the default handler's
1658 * implementation of IRunnableobject does nothing until the object
1659 * is actually running.
1661 * See Windows documentation for more details on IRunnableObject methods.
1663 static BOOL WINAPI
DefaultHandler_IsRunning(
1664 IRunnableObject
* iface
)
1670 /************************************************************************
1671 * DefaultHandler_LockRunning (IRunnableObject)
1673 * According to Brockscmidt, Chapter 19, the default handler's
1674 * implementation of IRunnableobject does nothing until the object
1675 * is actually running.
1677 * See Windows documentation for more details on IRunnableObject methods.
1679 static HRESULT WINAPI
DefaultHandler_LockRunning(
1680 IRunnableObject
* iface
,
1682 BOOL fLastUnlockCloses
)
1688 /************************************************************************
1689 * DefaultHandler_SetContainedObject (IRunnableObject)
1691 * According to Brockscmidt, Chapter 19, the default handler's
1692 * implementation of IRunnableobject does nothing until the object
1693 * is actually running.
1695 * See Windows documentation for more details on IRunnableObject methods.
1697 static HRESULT WINAPI
DefaultHandler_SetContainedObject(
1698 IRunnableObject
* iface
,