source: trunk/src/ole32/defaulthandler.c@ 6648

Last change on this file since 6648 was 6648, checked in by bird, 24 years ago

Added $Id:$ keyword.

File size: 47.3 KB
Line 
1/* $Id: defaulthandler.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */
2/*
3 * OLE 2 default object handler
4 *
5 * Copyright 1999 Francis Beaudet
6 * Copyright 2000 Abey George
7 *
8 * NOTES:
9 * The OLE2 default object handler supports a whole whack of
10 * interfaces including:
11 * IOleObject, IDataObject, IPersistStorage, IViewObject2,
12 * IRunnableObject, IOleCache2, IOleCacheControl and much more.
13 *
14 * All the implementation details are taken from: Inside OLE
15 * second edition by Kraig Brockschmidt,
16 *
17 * TODO
18 * - This implementation of the default handler does not launch the
19 * server in the DoVerb, Update, GetData, GetDataHere and Run
20 * methods. When it is fixed to do so, all the methods will have
21 * to be revisited to allow delegating to the running object
22 *
23 * - All methods in the class that use the class ID should be
24 * aware that it is possible for a class to be treated as
25 * another one and go into emulation mode. Nothing has been
26 * done in this area.
27 *
28 * - Some functions still return E_NOTIMPL they have to be
29 * implemented. Most of those are related to the running of the
30 * actual server.
31 *
32 * - All the methods related to notification and advise sinks are
33 * in place but no notifications are sent to the sinks yet.
34 */
35#include <assert.h>
36#include <string.h>
37
38#include "winbase.h"
39#include "winerror.h"
40#include "wine/unicode.h"
41#include "ole2.h"
42#include "wine/obj_oleview.h"
43#include "debugtools.h"
44
45DEFAULT_DEBUG_CHANNEL(ole);
46
47/****************************************************************************
48 * DefaultHandler
49 *
50 */
51struct DefaultHandler
52{
53 /*
54 * List all interface VTables here
55 */
56 ICOM_VTABLE(IOleObject)* lpvtbl1;
57 ICOM_VTABLE(IUnknown)* lpvtbl2;
58 ICOM_VTABLE(IDataObject)* lpvtbl3;
59 ICOM_VTABLE(IRunnableObject)* lpvtbl4;
60
61 /*
62 * Reference count of this object
63 */
64 ULONG ref;
65
66 /*
67 * IUnknown implementation of the outer object.
68 */
69 IUnknown* outerUnknown;
70
71 /*
72 * Class Id that this handler object represents.
73 */
74 CLSID clsid;
75
76 /*
77 * IUnknown implementation of the datacache.
78 */
79 IUnknown* dataCache;
80
81 /*
82 * Client site for the embedded object.
83 */
84 IOleClientSite* clientSite;
85
86 /*
87 * The IOleAdviseHolder maintains the connections
88 * on behalf of the default handler.
89 */
90 IOleAdviseHolder* oleAdviseHolder;
91
92 /*
93 * The IDataAdviseHolder maintains the data
94 * connections on behalf of the default handler.
95 */
96 IDataAdviseHolder* dataAdviseHolder;
97
98 /*
99 * Name of the container and object contained
100 */
101 LPWSTR containerApp;
102 LPWSTR containerObj;
103
104};
105
106typedef struct DefaultHandler DefaultHandler;
107
108/*
109 * Here, I define utility macros to help with the casting of the
110 * "this" parameter.
111 * There is a version to accomodate all of the VTables implemented
112 * by this object.
113 */
114#define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
115#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
116#define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
117#define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
118
119/*
120 * Prototypes for the methods of the DefaultHandler class.
121 */
122static DefaultHandler* DefaultHandler_Construct(REFCLSID clsid,
123 LPUNKNOWN pUnkOuter);
124static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
125
126/*
127 * Prototypes for the methods of the DefaultHandler class
128 * that implement non delegating IUnknown methods.
129 */
130static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
131 IUnknown* iface,
132 REFIID riid,
133 void** ppvObject);
134static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
135 IUnknown* iface);
136static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
137 IUnknown* iface);
138
139/*
140 * Prototypes for the methods of the DefaultHandler class
141 * that implement IOleObject methods.
142 */
143static HRESULT WINAPI DefaultHandler_QueryInterface(
144 IOleObject* iface,
145 REFIID riid,
146 void** ppvObject);
147static ULONG WINAPI DefaultHandler_AddRef(
148 IOleObject* iface);
149static ULONG WINAPI DefaultHandler_Release(
150 IOleObject* iface);
151static HRESULT WINAPI DefaultHandler_SetClientSite(
152 IOleObject* iface,
153 IOleClientSite* pClientSite);
154static HRESULT WINAPI DefaultHandler_GetClientSite(
155 IOleObject* iface,
156 IOleClientSite** ppClientSite);
157static HRESULT WINAPI DefaultHandler_SetHostNames(
158 IOleObject* iface,
159 LPCOLESTR szContainerApp,
160 LPCOLESTR szContainerObj);
161static HRESULT WINAPI DefaultHandler_Close(
162 IOleObject* iface,
163 DWORD dwSaveOption);
164static HRESULT WINAPI DefaultHandler_SetMoniker(
165 IOleObject* iface,
166 DWORD dwWhichMoniker,
167 IMoniker* pmk);
168static HRESULT WINAPI DefaultHandler_GetMoniker(
169 IOleObject* iface,
170 DWORD dwAssign,
171 DWORD dwWhichMoniker,
172 IMoniker** ppmk);
173static HRESULT WINAPI DefaultHandler_InitFromData(
174 IOleObject* iface,
175 IDataObject* pDataObject,
176 BOOL fCreation,
177 DWORD dwReserved);
178static HRESULT WINAPI DefaultHandler_GetClipboardData(
179 IOleObject* iface,
180 DWORD dwReserved,
181 IDataObject** ppDataObject);
182static HRESULT WINAPI DefaultHandler_DoVerb(
183 IOleObject* iface,
184 LONG iVerb,
185#ifdef __WIN32OS2__
186 LPMSG lpmsg,
187#else
188 struct tagMSG* lpmsg,
189#endif
190 IOleClientSite* pActiveSite,
191 LONG lindex,
192 HWND hwndParent,
193 LPCRECT lprcPosRect);
194static HRESULT WINAPI DefaultHandler_EnumVerbs(
195 IOleObject* iface,
196 IEnumOLEVERB** ppEnumOleVerb);
197static HRESULT WINAPI DefaultHandler_Update(
198 IOleObject* iface);
199static HRESULT WINAPI DefaultHandler_IsUpToDate(
200 IOleObject* iface);
201static HRESULT WINAPI DefaultHandler_GetUserClassID(
202 IOleObject* iface,
203 CLSID* pClsid);
204static HRESULT WINAPI DefaultHandler_GetUserType(
205 IOleObject* iface,
206 DWORD dwFormOfType,
207 LPOLESTR* pszUserType);
208static HRESULT WINAPI DefaultHandler_SetExtent(
209 IOleObject* iface,
210 DWORD dwDrawAspect,
211 SIZEL* psizel);
212static HRESULT WINAPI DefaultHandler_GetExtent(
213 IOleObject* iface,
214 DWORD dwDrawAspect,
215 SIZEL* psizel);
216static HRESULT WINAPI DefaultHandler_Advise(
217 IOleObject* iface,
218 IAdviseSink* pAdvSink,
219 DWORD* pdwConnection);
220static HRESULT WINAPI DefaultHandler_Unadvise(
221 IOleObject* iface,
222 DWORD dwConnection);
223static HRESULT WINAPI DefaultHandler_EnumAdvise(
224 IOleObject* iface,
225 IEnumSTATDATA** ppenumAdvise);
226static HRESULT WINAPI DefaultHandler_GetMiscStatus(
227 IOleObject* iface,
228 DWORD dwAspect,
229 DWORD* pdwStatus);
230static HRESULT WINAPI DefaultHandler_SetColorScheme(
231 IOleObject* iface,
232 struct tagLOGPALETTE* pLogpal);
233
234/*
235 * Prototypes for the methods of the DefaultHandler class
236 * that implement IDataObject methods.
237 */
238static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
239 IDataObject* iface,
240 REFIID riid,
241 void** ppvObject);
242static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
243 IDataObject* iface);
244static ULONG WINAPI DefaultHandler_IDataObject_Release(
245 IDataObject* iface);
246static HRESULT WINAPI DefaultHandler_GetData(
247 IDataObject* iface,
248 LPFORMATETC pformatetcIn,
249 STGMEDIUM* pmedium);
250static HRESULT WINAPI DefaultHandler_GetDataHere(
251 IDataObject* iface,
252 LPFORMATETC pformatetc,
253 STGMEDIUM* pmedium);
254static HRESULT WINAPI DefaultHandler_QueryGetData(
255 IDataObject* iface,
256 LPFORMATETC pformatetc);
257static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
258 IDataObject* iface,
259 LPFORMATETC pformatectIn,
260 LPFORMATETC pformatetcOut);
261static HRESULT WINAPI DefaultHandler_SetData(
262 IDataObject* iface,
263 LPFORMATETC pformatetc,
264 STGMEDIUM* pmedium,
265 BOOL fRelease);
266static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
267 IDataObject* iface,
268 DWORD dwDirection,
269 IEnumFORMATETC** ppenumFormatEtc);
270static HRESULT WINAPI DefaultHandler_DAdvise(
271 IDataObject* iface,
272 FORMATETC* pformatetc,
273 DWORD advf,
274 IAdviseSink* pAdvSink,
275 DWORD* pdwConnection);
276static HRESULT WINAPI DefaultHandler_DUnadvise(
277 IDataObject* iface,
278 DWORD dwConnection);
279static HRESULT WINAPI DefaultHandler_EnumDAdvise(
280 IDataObject* iface,
281 IEnumSTATDATA** ppenumAdvise);
282
283/*
284 * Prototypes for the methods of the DefaultHandler class
285 * that implement IRunnableObject methods.
286 */
287static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
288 IRunnableObject* iface,
289 REFIID riid,
290 void** ppvObject);
291static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
292 IRunnableObject* iface);
293static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
294 IRunnableObject* iface);
295static HRESULT WINAPI DefaultHandler_GetRunningClass(
296 IRunnableObject* iface,
297 LPCLSID lpClsid);
298static HRESULT WINAPI DefaultHandler_Run(
299 IRunnableObject* iface,
300 IBindCtx* pbc);
301static BOOL WINAPI DefaultHandler_IsRunning(
302 IRunnableObject* iface);
303static HRESULT WINAPI DefaultHandler_LockRunning(
304 IRunnableObject* iface,
305 BOOL fLock,
306 BOOL fLastUnlockCloses);
307static HRESULT WINAPI DefaultHandler_SetContainedObject(
308 IRunnableObject* iface,
309 BOOL fContained);
310
311
312/*
313 * Virtual function tables for the DefaultHandler class.
314 */
315static ICOM_VTABLE(IOleObject) DefaultHandler_IOleObject_VTable =
316{
317 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
318 DefaultHandler_QueryInterface,
319 DefaultHandler_AddRef,
320 DefaultHandler_Release,
321 DefaultHandler_SetClientSite,
322 DefaultHandler_GetClientSite,
323 DefaultHandler_SetHostNames,
324 DefaultHandler_Close,
325 DefaultHandler_SetMoniker,
326 DefaultHandler_GetMoniker,
327 DefaultHandler_InitFromData,
328 DefaultHandler_GetClipboardData,
329 DefaultHandler_DoVerb,
330 DefaultHandler_EnumVerbs,
331 DefaultHandler_Update,
332 DefaultHandler_IsUpToDate,
333 DefaultHandler_GetUserClassID,
334 DefaultHandler_GetUserType,
335 DefaultHandler_SetExtent,
336 DefaultHandler_GetExtent,
337 DefaultHandler_Advise,
338 DefaultHandler_Unadvise,
339 DefaultHandler_EnumAdvise,
340 DefaultHandler_GetMiscStatus,
341 DefaultHandler_SetColorScheme
342};
343
344static ICOM_VTABLE(IUnknown) DefaultHandler_NDIUnknown_VTable =
345{
346 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
347 DefaultHandler_NDIUnknown_QueryInterface,
348 DefaultHandler_NDIUnknown_AddRef,
349 DefaultHandler_NDIUnknown_Release,
350};
351
352static ICOM_VTABLE(IDataObject) DefaultHandler_IDataObject_VTable =
353{
354 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
355 DefaultHandler_IDataObject_QueryInterface,
356 DefaultHandler_IDataObject_AddRef,
357 DefaultHandler_IDataObject_Release,
358 DefaultHandler_GetData,
359 DefaultHandler_GetDataHere,
360 DefaultHandler_QueryGetData,
361 DefaultHandler_GetCanonicalFormatEtc,
362 DefaultHandler_SetData,
363 DefaultHandler_EnumFormatEtc,
364 DefaultHandler_DAdvise,
365 DefaultHandler_DUnadvise,
366 DefaultHandler_EnumDAdvise
367};
368
369static ICOM_VTABLE(IRunnableObject) DefaultHandler_IRunnableObject_VTable =
370{
371 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
372 DefaultHandler_IRunnableObject_QueryInterface,
373 DefaultHandler_IRunnableObject_AddRef,
374 DefaultHandler_IRunnableObject_Release,
375 DefaultHandler_GetRunningClass,
376 DefaultHandler_Run,
377 DefaultHandler_IsRunning,
378 DefaultHandler_LockRunning,
379 DefaultHandler_SetContainedObject
380};
381
382/******************************************************************************
383 * OleCreateDefaultHandler [OLE32.90]
384 */
385HRESULT WINAPI OleCreateDefaultHandler(
386 REFCLSID clsid,
387 LPUNKNOWN pUnkOuter,
388 REFIID riid,
389 LPVOID* ppvObj)
390{
391 DefaultHandler* newHandler = NULL;
392 HRESULT hr = S_OK;
393
394 TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter, debugstr_guid(riid), ppvObj);
395
396 /*
397 * Sanity check
398 */
399 if (ppvObj==0)
400 return E_POINTER;
401
402 *ppvObj = 0;
403
404 /*
405 * If this handler is constructed for aggregation, make sure
406 * the caller is requesting the IUnknown interface.
407 * This is necessary because it's the only time the non-delegating
408 * IUnknown pointer can be returned to the outside.
409 */
410 if ( (pUnkOuter!=NULL) &&
411 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
412 return CLASS_E_NOAGGREGATION;
413
414 /*
415 * Try to construct a new instance of the class.
416 */
417 newHandler = DefaultHandler_Construct(clsid,
418 pUnkOuter);
419
420 if (newHandler == 0)
421 return E_OUTOFMEMORY;
422
423 /*
424 * Make sure it supports the interface required by the caller.
425 */
426 hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtbl2), riid, ppvObj);
427
428 /*
429 * Release the reference obtained in the constructor. If
430 * the QueryInterface was unsuccessful, it will free the class.
431 */
432 IUnknown_Release((IUnknown*)&(newHandler->lpvtbl2));
433
434 return hr;
435}
436
437/*********************************************************
438 * Methods implementation for the DefaultHandler class.
439 */
440static DefaultHandler* DefaultHandler_Construct(
441 REFCLSID clsid,
442 LPUNKNOWN pUnkOuter)
443{
444 DefaultHandler* newObject = 0;
445
446 /*
447 * Allocate space for the object.
448 */
449 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
450
451 if (newObject==0)
452 return newObject;
453
454 /*
455 * Initialize the virtual function table.
456 */
457 newObject->lpvtbl1 = &DefaultHandler_IOleObject_VTable;
458 newObject->lpvtbl2 = &DefaultHandler_NDIUnknown_VTable;
459 newObject->lpvtbl3 = &DefaultHandler_IDataObject_VTable;
460 newObject->lpvtbl4 = &DefaultHandler_IRunnableObject_VTable;
461
462 /*
463 * Start with one reference count. The caller of this function
464 * must release the interface pointer when it is done.
465 */
466 newObject->ref = 1;
467
468 /*
469 * Initialize the outer unknown
470 * We don't keep a reference on the outer unknown since, the way
471 * aggregation works, our lifetime is at least as large as it's
472 * lifetime.
473 */
474 if (pUnkOuter==NULL)
475 pUnkOuter = (IUnknown*)&(newObject->lpvtbl2);
476
477 newObject->outerUnknown = pUnkOuter;
478
479 /*
480 * Create a datacache object.
481 * We aggregate with the datacache. Make sure we pass our outer
482 * unknown as the datacache's outer unknown.
483 */
484 CreateDataCache(newObject->outerUnknown,
485 clsid,
486 &IID_IUnknown,
487 (void**)&newObject->dataCache);
488
489 /*
490 * Initialize the other data members of the class.
491 */
492 memcpy(&(newObject->clsid), clsid, sizeof(CLSID));
493 newObject->clientSite = NULL;
494 newObject->oleAdviseHolder = NULL;
495 newObject->dataAdviseHolder = NULL;
496 newObject->containerApp = NULL;
497 newObject->containerObj = NULL;
498
499 return newObject;
500}
501
502static void DefaultHandler_Destroy(
503 DefaultHandler* ptrToDestroy)
504{
505 /*
506 * Free the strings idenfitying the object
507 */
508 if (ptrToDestroy->containerApp!=NULL)
509 {
510 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerApp );
511 ptrToDestroy->containerApp = NULL;
512 }
513
514 if (ptrToDestroy->containerObj!=NULL)
515 {
516 HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerObj );
517 ptrToDestroy->containerObj = NULL;
518 }
519
520 /*
521 * Release our reference to the data cache.
522 */
523 if (ptrToDestroy->dataCache!=NULL)
524 {
525 IUnknown_Release(ptrToDestroy->dataCache);
526 ptrToDestroy->dataCache = NULL;
527 }
528
529 /*
530 * Same thing for the client site.
531 */
532 if (ptrToDestroy->clientSite!=NULL)
533 {
534 IOleClientSite_Release(ptrToDestroy->clientSite);
535 ptrToDestroy->clientSite = NULL;
536 }
537
538 /*
539 * And the advise holder.
540 */
541 if (ptrToDestroy->oleAdviseHolder!=NULL)
542 {
543 IOleAdviseHolder_Release(ptrToDestroy->oleAdviseHolder);
544 ptrToDestroy->oleAdviseHolder = NULL;
545 }
546
547 /*
548 * And the data advise holder.
549 */
550 if (ptrToDestroy->dataAdviseHolder!=NULL)
551 {
552 IDataAdviseHolder_Release(ptrToDestroy->dataAdviseHolder);
553 ptrToDestroy->dataAdviseHolder = NULL;
554 }
555
556
557 /*
558 * Free the actual default handler structure.
559 */
560 HeapFree(GetProcessHeap(), 0, ptrToDestroy);
561}
562
563/*********************************************************
564 * Method implementation for the non delegating IUnknown
565 * part of the DefaultHandler class.
566 */
567
568/************************************************************************
569 * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
570 *
571 * See Windows documentation for more details on IUnknown methods.
572 *
573 * This version of QueryInterface will not delegate it's implementation
574 * to the outer unknown.
575 */
576static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
577 IUnknown* iface,
578 REFIID riid,
579 void** ppvObject)
580{
581 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
582
583 /*
584 * Perform a sanity check on the parameters.
585 */
586 if ( (this==0) || (ppvObject==0) )
587 return E_INVALIDARG;
588
589 /*
590 * Initialize the return parameter.
591 */
592 *ppvObject = 0;
593
594 /*
595 * Compare the riid with the interface IDs implemented by this object.
596 */
597 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
598 {
599 *ppvObject = iface;
600 }
601 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
602 {
603 *ppvObject = (IOleObject*)&(this->lpvtbl1);
604 }
605 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
606 {
607 *ppvObject = (IDataObject*)&(this->lpvtbl3);
608 }
609 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
610 {
611 *ppvObject = (IRunnableObject*)&(this->lpvtbl4);
612 }
613 else
614 {
615 /*
616 * Blind aggregate the data cache to "inherit" it's interfaces.
617 */
618 if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK)
619 return S_OK;
620 }
621
622 /*
623 * Check that we obtained an interface.
624 */
625 if ((*ppvObject)==0)
626 {
627 WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid));
628 return E_NOINTERFACE;
629 }
630
631 /*
632 * Query Interface always increases the reference count by one when it is
633 * successful.
634 */
635 IUnknown_AddRef((IUnknown*)*ppvObject);
636
637 return S_OK;;
638}
639
640/************************************************************************
641 * DefaultHandler_NDIUnknown_AddRef (IUnknown)
642 *
643 * See Windows documentation for more details on IUnknown methods.
644 *
645 * This version of QueryInterface will not delegate it's implementation
646 * to the outer unknown.
647 */
648static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
649 IUnknown* iface)
650{
651 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
652
653 this->ref++;
654
655 return this->ref;
656}
657
658/************************************************************************
659 * DefaultHandler_NDIUnknown_Release (IUnknown)
660 *
661 * See Windows documentation for more details on IUnknown methods.
662 *
663 * This version of QueryInterface will not delegate it's implementation
664 * to the outer unknown.
665 */
666static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
667 IUnknown* iface)
668{
669 _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
670
671 /*
672 * Decrease the reference count on this object.
673 */
674 this->ref--;
675
676 /*
677 * If the reference count goes down to 0, perform suicide.
678 */
679 if (this->ref==0)
680 {
681 DefaultHandler_Destroy(this);
682
683 return 0;
684 }
685
686 return this->ref;
687}
688
689/*********************************************************
690 * Methods implementation for the IOleObject part of
691 * the DefaultHandler class.
692 */
693
694/************************************************************************
695 * DefaultHandler_QueryInterface (IUnknown)
696 *
697 * See Windows documentation for more details on IUnknown methods.
698 */
699static HRESULT WINAPI DefaultHandler_QueryInterface(
700 IOleObject* iface,
701 REFIID riid,
702 void** ppvObject)
703{
704 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
705
706 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
707}
708
709/************************************************************************
710 * DefaultHandler_AddRef (IUnknown)
711 *
712 * See Windows documentation for more details on IUnknown methods.
713 */
714static ULONG WINAPI DefaultHandler_AddRef(
715 IOleObject* iface)
716{
717 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
718
719 return IUnknown_AddRef(this->outerUnknown);
720}
721
722/************************************************************************
723 * DefaultHandler_Release (IUnknown)
724 *
725 * See Windows documentation for more details on IUnknown methods.
726 */
727static ULONG WINAPI DefaultHandler_Release(
728 IOleObject* iface)
729{
730 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
731
732 return IUnknown_Release(this->outerUnknown);
733}
734
735/************************************************************************
736 * DefaultHandler_SetClientSite (IOleObject)
737 *
738 * The default handler's implementation of this method only keeps the
739 * client site pointer for future reference.
740 *
741 * See Windows documentation for more details on IOleObject methods.
742 */
743static HRESULT WINAPI DefaultHandler_SetClientSite(
744 IOleObject* iface,
745 IOleClientSite* pClientSite)
746{
747 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
748
749 TRACE("(%p, %p)\n", iface, pClientSite);
750
751 /*
752 * Make sure we release the previous client site if there
753 * was one.
754 */
755 if (this->clientSite!=NULL)
756 {
757 IOleClientSite_Release(this->clientSite);
758 }
759
760 this->clientSite = pClientSite;
761
762 if (this->clientSite!=NULL)
763 {
764 IOleClientSite_AddRef(this->clientSite);
765 }
766
767 return S_OK;
768}
769
770/************************************************************************
771 * DefaultHandler_GetClientSite (IOleObject)
772 *
773 * The default handler's implementation of this method returns the
774 * last pointer set in IOleObject_SetClientSite.
775 *
776 * See Windows documentation for more details on IOleObject methods.
777 */
778static HRESULT WINAPI DefaultHandler_GetClientSite(
779 IOleObject* iface,
780 IOleClientSite** ppClientSite)
781{
782 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
783
784 /*
785 * Sanity check.
786 */
787 if (ppClientSite == NULL)
788 return E_POINTER;
789
790 *ppClientSite = this->clientSite;
791
792 if (this->clientSite != NULL)
793 {
794 IOleClientSite_AddRef(this->clientSite);
795 }
796
797 return S_OK;
798}
799
800/************************************************************************
801 * DefaultHandler_SetHostNames (IOleObject)
802 *
803 * The default handler's implementation of this method just stores
804 * the strings and returns S_OK.
805 *
806 * See Windows documentation for more details on IOleObject methods.
807 */
808static HRESULT WINAPI DefaultHandler_SetHostNames(
809 IOleObject* iface,
810 LPCOLESTR szContainerApp,
811 LPCOLESTR szContainerObj)
812{
813 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
814
815 TRACE("(%p, %s, %s)\n",
816 iface,
817 debugstr_w(szContainerApp),
818 debugstr_w(szContainerObj));
819
820 /*
821 * Be sure to cleanup before re-assinging the strings.
822 */
823 if (this->containerApp!=NULL)
824 {
825 HeapFree( GetProcessHeap(), 0, this->containerApp );
826 this->containerApp = NULL;
827 }
828
829 if (this->containerObj!=NULL)
830 {
831 HeapFree( GetProcessHeap(), 0, this->containerObj );
832 this->containerObj = NULL;
833 }
834
835 /*
836 * Copy the string supplied.
837 */
838 if (szContainerApp != NULL)
839 {
840 if ((this->containerApp = HeapAlloc( GetProcessHeap(), 0,
841 (lstrlenW(szContainerApp) + 1) * sizeof(WCHAR) )))
842 strcpyW( this->containerApp, szContainerApp );
843 }
844
845 if (szContainerObj != NULL)
846 {
847 if ((this->containerObj = HeapAlloc( GetProcessHeap(), 0,
848 (lstrlenW(szContainerObj) + 1) * sizeof(WCHAR) )))
849 strcpyW( this->containerObj, szContainerObj );
850 }
851 return S_OK;
852}
853
854/************************************************************************
855 * DefaultHandler_Close (IOleObject)
856 *
857 * The default handler's implementation of this method is meaningless
858 * without a running server so it does nothing.
859 *
860 * See Windows documentation for more details on IOleObject methods.
861 */
862static HRESULT WINAPI DefaultHandler_Close(
863 IOleObject* iface,
864 DWORD dwSaveOption)
865{
866 TRACE("()\n");
867 return S_OK;
868}
869
870/************************************************************************
871 * DefaultHandler_SetMoniker (IOleObject)
872 *
873 * The default handler's implementation of this method does nothing.
874 *
875 * See Windows documentation for more details on IOleObject methods.
876 */
877static HRESULT WINAPI DefaultHandler_SetMoniker(
878 IOleObject* iface,
879 DWORD dwWhichMoniker,
880 IMoniker* pmk)
881{
882 TRACE("(%p, %ld, %p)\n",
883 iface,
884 dwWhichMoniker,
885 pmk);
886
887 return S_OK;
888}
889
890/************************************************************************
891 * DefaultHandler_GetMoniker (IOleObject)
892 *
893 * Delegate this request to the client site if we have one.
894 *
895 * See Windows documentation for more details on IOleObject methods.
896 */
897static HRESULT WINAPI DefaultHandler_GetMoniker(
898 IOleObject* iface,
899 DWORD dwAssign,
900 DWORD dwWhichMoniker,
901 IMoniker** ppmk)
902{
903 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
904
905 TRACE("(%p, %ld, %ld, %p)\n",
906 iface, dwAssign, dwWhichMoniker, ppmk);
907
908 if (this->clientSite)
909 {
910 return IOleClientSite_GetMoniker(this->clientSite,
911 dwAssign,
912 dwWhichMoniker,
913 ppmk);
914
915 }
916
917 return E_UNSPEC;
918}
919
920/************************************************************************
921 * DefaultHandler_InitFromData (IOleObject)
922 *
923 * This method is meaningless if the server is not running
924 *
925 * See Windows documentation for more details on IOleObject methods.
926 */
927static HRESULT WINAPI DefaultHandler_InitFromData(
928 IOleObject* iface,
929 IDataObject* pDataObject,
930 BOOL fCreation,
931 DWORD dwReserved)
932{
933 TRACE("(%p, %p, %d, %ld)\n",
934 iface, pDataObject, fCreation, dwReserved);
935
936 return OLE_E_NOTRUNNING;
937}
938
939/************************************************************************
940 * DefaultHandler_GetClipboardData (IOleObject)
941 *
942 * This method is meaningless if the server is not running
943 *
944 * See Windows documentation for more details on IOleObject methods.
945 */
946static HRESULT WINAPI DefaultHandler_GetClipboardData(
947 IOleObject* iface,
948 DWORD dwReserved,
949 IDataObject** ppDataObject)
950{
951 TRACE("(%p, %ld, %p)\n",
952 iface, dwReserved, ppDataObject);
953
954 return OLE_E_NOTRUNNING;
955}
956
957static HRESULT WINAPI DefaultHandler_DoVerb(
958 IOleObject* iface,
959 LONG iVerb,
960#ifdef __WIN32OS2__
961 LPMSG lpmsg,
962#else
963 struct tagMSG* lpmsg,
964#endif
965 IOleClientSite* pActiveSite,
966 LONG lindex,
967 HWND hwndParent,
968 LPCRECT lprcPosRect)
969{
970 FIXME(": Stub\n");
971 return E_NOTIMPL;
972}
973
974/************************************************************************
975 * DefaultHandler_EnumVerbs (IOleObject)
976 *
977 * The default handler implementation of this method simply delegates
978 * to OleRegEnumVerbs
979 *
980 * See Windows documentation for more details on IOleObject methods.
981 */
982static HRESULT WINAPI DefaultHandler_EnumVerbs(
983 IOleObject* iface,
984 IEnumOLEVERB** ppEnumOleVerb)
985{
986 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
987
988 TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
989
990 return OleRegEnumVerbs(&this->clsid, ppEnumOleVerb);
991}
992
993static HRESULT WINAPI DefaultHandler_Update(
994 IOleObject* iface)
995{
996 FIXME(": Stub\n");
997 return E_NOTIMPL;
998}
999
1000/************************************************************************
1001 * DefaultHandler_IsUpToDate (IOleObject)
1002 *
1003 * This method is meaningless if the server is not running
1004 *
1005 * See Windows documentation for more details on IOleObject methods.
1006 */
1007static HRESULT WINAPI DefaultHandler_IsUpToDate(
1008 IOleObject* iface)
1009{
1010 TRACE("(%p)\n", iface);
1011
1012 return OLE_E_NOTRUNNING;
1013}
1014
1015/************************************************************************
1016 * DefaultHandler_GetUserClassID (IOleObject)
1017 *
1018 * TODO: Map to a new class ID if emulation is active.
1019 *
1020 * See Windows documentation for more details on IOleObject methods.
1021 */
1022static HRESULT WINAPI DefaultHandler_GetUserClassID(
1023 IOleObject* iface,
1024 CLSID* pClsid)
1025{
1026 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1027
1028 TRACE("(%p, %p)\n", iface, pClsid);
1029
1030 /*
1031 * Sanity check.
1032 */
1033 if (pClsid==NULL)
1034 return E_POINTER;
1035
1036 memcpy(pClsid, &this->clsid, sizeof(CLSID));
1037
1038 return S_OK;
1039}
1040
1041/************************************************************************
1042 * DefaultHandler_GetUserType (IOleObject)
1043 *
1044 * The default handler implementation of this method simply delegates
1045 * to OleRegGetUserType
1046 *
1047 * See Windows documentation for more details on IOleObject methods.
1048 */
1049static HRESULT WINAPI DefaultHandler_GetUserType(
1050 IOleObject* iface,
1051 DWORD dwFormOfType,
1052 LPOLESTR* pszUserType)
1053{
1054 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1055
1056 TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
1057
1058 return OleRegGetUserType(&this->clsid, dwFormOfType, pszUserType);
1059}
1060
1061/************************************************************************
1062 * DefaultHandler_SetExtent (IOleObject)
1063 *
1064 * This method is meaningless if the server is not running
1065 *
1066 * See Windows documentation for more details on IOleObject methods.
1067 */
1068static HRESULT WINAPI DefaultHandler_SetExtent(
1069 IOleObject* iface,
1070 DWORD dwDrawAspect,
1071 SIZEL* psizel)
1072{
1073 TRACE("(%p, %lx, (%ld x %ld))\n", iface,
1074 dwDrawAspect, psizel->cx, psizel->cy);
1075 return OLE_E_NOTRUNNING;
1076}
1077
1078/************************************************************************
1079 * DefaultHandler_GetExtent (IOleObject)
1080 *
1081 * The default handler's implementation of this method returns uses
1082 * the cache to locate the aspect and extract the extent from it.
1083 *
1084 * See Windows documentation for more details on IOleObject methods.
1085 */
1086static HRESULT WINAPI DefaultHandler_GetExtent(
1087 IOleObject* iface,
1088 DWORD dwDrawAspect,
1089 SIZEL* psizel)
1090{
1091 DVTARGETDEVICE* targetDevice;
1092 IViewObject2* cacheView = NULL;
1093 HRESULT hres;
1094
1095 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1096
1097 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
1098
1099 hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
1100
1101 if (FAILED(hres))
1102 return E_UNEXPECTED;
1103
1104 /*
1105 * Prepare the call to the cache's GetExtent method.
1106 *
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.
1111 */
1112 targetDevice = NULL;
1113
1114 hres = IViewObject2_GetExtent(cacheView,
1115 dwDrawAspect,
1116 -1,
1117 targetDevice,
1118 psizel);
1119
1120 /*
1121 * Cleanup
1122 */
1123 IViewObject2_Release(cacheView);
1124
1125 return hres;
1126}
1127
1128/************************************************************************
1129 * DefaultHandler_Advise (IOleObject)
1130 *
1131 * The default handler's implementation of this method simply
1132 * delegates to the OleAdviseHolder.
1133 *
1134 * See Windows documentation for more details on IOleObject methods.
1135 */
1136static HRESULT WINAPI DefaultHandler_Advise(
1137 IOleObject* iface,
1138 IAdviseSink* pAdvSink,
1139 DWORD* pdwConnection)
1140{
1141 HRESULT hres = S_OK;
1142 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1143
1144 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
1145
1146 /*
1147 * Make sure we have an advise holder before we start.
1148 */
1149 if (this->oleAdviseHolder==NULL)
1150 {
1151 hres = CreateOleAdviseHolder(&this->oleAdviseHolder);
1152 }
1153
1154 if (SUCCEEDED(hres))
1155 {
1156 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
1157 pAdvSink,
1158 pdwConnection);
1159 }
1160
1161 return hres;
1162}
1163
1164/************************************************************************
1165 * DefaultHandler_Unadvise (IOleObject)
1166 *
1167 * The default handler's implementation of this method simply
1168 * delegates to the OleAdviseHolder.
1169 *
1170 * See Windows documentation for more details on IOleObject methods.
1171 */
1172static HRESULT WINAPI DefaultHandler_Unadvise(
1173 IOleObject* iface,
1174 DWORD dwConnection)
1175{
1176 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1177
1178 TRACE("(%p, %ld)\n", iface, dwConnection);
1179
1180 /*
1181 * If we don't have an advise holder yet, it means we don't have
1182 * a connection.
1183 */
1184 if (this->oleAdviseHolder==NULL)
1185 return OLE_E_NOCONNECTION;
1186
1187 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
1188 dwConnection);
1189}
1190
1191/************************************************************************
1192 * DefaultHandler_EnumAdvise (IOleObject)
1193 *
1194 * The default handler's implementation of this method simply
1195 * delegates to the OleAdviseHolder.
1196 *
1197 * See Windows documentation for more details on IOleObject methods.
1198 */
1199static HRESULT WINAPI DefaultHandler_EnumAdvise(
1200 IOleObject* iface,
1201 IEnumSTATDATA** ppenumAdvise)
1202{
1203 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1204
1205 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1206
1207 /*
1208 * Sanity check
1209 */
1210 if (ppenumAdvise==NULL)
1211 return E_POINTER;
1212
1213 /*
1214 * Initialize the out parameter.
1215 */
1216 *ppenumAdvise = NULL;
1217
1218 if (this->oleAdviseHolder==NULL)
1219 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
1220 ppenumAdvise);
1221
1222 return S_OK;
1223}
1224
1225/************************************************************************
1226 * DefaultHandler_GetMiscStatus (IOleObject)
1227 *
1228 * The default handler's implementation of this method simply delegates
1229 * to OleRegGetMiscStatus.
1230 *
1231 * See Windows documentation for more details on IOleObject methods.
1232 */
1233static HRESULT WINAPI DefaultHandler_GetMiscStatus(
1234 IOleObject* iface,
1235 DWORD dwAspect,
1236 DWORD* pdwStatus)
1237{
1238 HRESULT hres;
1239 _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
1240
1241 TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
1242
1243 hres = OleRegGetMiscStatus(&(this->clsid), dwAspect, pdwStatus);
1244
1245 if (FAILED(hres))
1246 *pdwStatus = 0;
1247
1248 return S_OK;
1249}
1250
1251/************************************************************************
1252 * DefaultHandler_SetExtent (IOleObject)
1253 *
1254 * This method is meaningless if the server is not running
1255 *
1256 * See Windows documentation for more details on IOleObject methods.
1257 */
1258static HRESULT WINAPI DefaultHandler_SetColorScheme(
1259 IOleObject* iface,
1260 struct tagLOGPALETTE* pLogpal)
1261{
1262 TRACE("(%p, %p))\n", iface, pLogpal);
1263 return OLE_E_NOTRUNNING;
1264}
1265
1266/*********************************************************
1267 * Methods implementation for the IDataObject part of
1268 * the DefaultHandler class.
1269 */
1270
1271/************************************************************************
1272 * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1273 *
1274 * See Windows documentation for more details on IUnknown methods.
1275 */
1276static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
1277 IDataObject* iface,
1278 REFIID riid,
1279 void** ppvObject)
1280{
1281 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1282
1283 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1284}
1285
1286/************************************************************************
1287 * DefaultHandler_IDataObject_AddRef (IUnknown)
1288 *
1289 * See Windows documentation for more details on IUnknown methods.
1290 */
1291static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
1292 IDataObject* iface)
1293{
1294 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1295
1296 return IUnknown_AddRef(this->outerUnknown);
1297}
1298
1299/************************************************************************
1300 * DefaultHandler_IDataObject_Release (IUnknown)
1301 *
1302 * See Windows documentation for more details on IUnknown methods.
1303 */
1304static ULONG WINAPI DefaultHandler_IDataObject_Release(
1305 IDataObject* iface)
1306{
1307 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1308
1309 return IUnknown_Release(this->outerUnknown);
1310}
1311
1312/************************************************************************
1313 * DefaultHandler_GetData
1314 *
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.
1318 */
1319static HRESULT WINAPI DefaultHandler_GetData(
1320 IDataObject* iface,
1321 LPFORMATETC pformatetcIn,
1322 STGMEDIUM* pmedium)
1323{
1324 IDataObject* cacheDataObject = NULL;
1325 HRESULT hres;
1326
1327 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1328
1329 TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
1330
1331 hres = IUnknown_QueryInterface(this->dataCache,
1332 &IID_IDataObject,
1333 (void**)&cacheDataObject);
1334
1335 if (FAILED(hres))
1336 return E_UNEXPECTED;
1337
1338 hres = IDataObject_GetData(cacheDataObject,
1339 pformatetcIn,
1340 pmedium);
1341
1342 IDataObject_Release(cacheDataObject);
1343
1344 return hres;
1345}
1346
1347static HRESULT WINAPI DefaultHandler_GetDataHere(
1348 IDataObject* iface,
1349 LPFORMATETC pformatetc,
1350 STGMEDIUM* pmedium)
1351{
1352 FIXME(": Stub\n");
1353 return E_NOTIMPL;
1354}
1355
1356/************************************************************************
1357 * DefaultHandler_QueryGetData (IDataObject)
1358 *
1359 * The default handler's implementation of this method delegates to
1360 * the cache.
1361 *
1362 * See Windows documentation for more details on IDataObject methods.
1363 */
1364static HRESULT WINAPI DefaultHandler_QueryGetData(
1365 IDataObject* iface,
1366 LPFORMATETC pformatetc)
1367{
1368 IDataObject* cacheDataObject = NULL;
1369 HRESULT hres;
1370
1371 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1372
1373 TRACE("(%p, %p)\n", iface, pformatetc);
1374
1375 hres = IUnknown_QueryInterface(this->dataCache,
1376 &IID_IDataObject,
1377 (void**)&cacheDataObject);
1378
1379 if (FAILED(hres))
1380 return E_UNEXPECTED;
1381
1382 hres = IDataObject_QueryGetData(cacheDataObject,
1383 pformatetc);
1384
1385 IDataObject_Release(cacheDataObject);
1386
1387 return hres;
1388}
1389
1390/************************************************************************
1391 * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1392 *
1393 * This method is meaningless if the server is not running
1394 *
1395 * See Windows documentation for more details on IDataObject methods.
1396 */
1397static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
1398 IDataObject* iface,
1399 LPFORMATETC pformatectIn,
1400 LPFORMATETC pformatetcOut)
1401{
1402 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
1403
1404 return OLE_E_NOTRUNNING;
1405}
1406
1407/************************************************************************
1408 * DefaultHandler_SetData (IDataObject)
1409 *
1410 * The default handler's implementation of this method delegates to
1411 * the cache.
1412 *
1413 * See Windows documentation for more details on IDataObject methods.
1414 */
1415static HRESULT WINAPI DefaultHandler_SetData(
1416 IDataObject* iface,
1417 LPFORMATETC pformatetc,
1418 STGMEDIUM* pmedium,
1419 BOOL fRelease)
1420{
1421 IDataObject* cacheDataObject = NULL;
1422 HRESULT hres;
1423
1424 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1425
1426 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1427
1428 hres = IUnknown_QueryInterface(this->dataCache,
1429 &IID_IDataObject,
1430 (void**)&cacheDataObject);
1431
1432 if (FAILED(hres))
1433 return E_UNEXPECTED;
1434
1435 hres = IDataObject_SetData(cacheDataObject,
1436 pformatetc,
1437 pmedium,
1438 fRelease);
1439
1440 IDataObject_Release(cacheDataObject);
1441
1442 return hres;
1443}
1444
1445/************************************************************************
1446 * DefaultHandler_EnumFormatEtc (IDataObject)
1447 *
1448 * The default handler's implementation of this method simply delegates
1449 * to OleRegEnumFormatEtc.
1450 *
1451 * See Windows documentation for more details on IDataObject methods.
1452 */
1453static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
1454 IDataObject* iface,
1455 DWORD dwDirection,
1456 IEnumFORMATETC** ppenumFormatEtc)
1457{
1458 HRESULT hres;
1459 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1460
1461 TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
1462
1463 hres = OleRegEnumFormatEtc(&(this->clsid), dwDirection, ppenumFormatEtc);
1464
1465 return hres;
1466}
1467
1468/************************************************************************
1469 * DefaultHandler_DAdvise (IDataObject)
1470 *
1471 * The default handler's implementation of this method simply
1472 * delegates to the DataAdviseHolder.
1473 *
1474 * See Windows documentation for more details on IDataObject methods.
1475 */
1476static HRESULT WINAPI DefaultHandler_DAdvise(
1477 IDataObject* iface,
1478 FORMATETC* pformatetc,
1479 DWORD advf,
1480 IAdviseSink* pAdvSink,
1481 DWORD* pdwConnection)
1482{
1483 HRESULT hres = S_OK;
1484 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1485
1486 TRACE("(%p, %p, %ld, %p, %p)\n",
1487 iface, pformatetc, advf, pAdvSink, pdwConnection);
1488
1489 /*
1490 * Make sure we have a data advise holder before we start.
1491 */
1492 if (this->dataAdviseHolder==NULL)
1493 {
1494 hres = CreateDataAdviseHolder(&this->dataAdviseHolder);
1495 }
1496
1497 if (SUCCEEDED(hres))
1498 {
1499 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
1500 iface,
1501 pformatetc,
1502 advf,
1503 pAdvSink,
1504 pdwConnection);
1505 }
1506
1507 return hres;
1508}
1509
1510/************************************************************************
1511 * DefaultHandler_DUnadvise (IDataObject)
1512 *
1513 * The default handler's implementation of this method simply
1514 * delegates to the DataAdviseHolder.
1515 *
1516 * See Windows documentation for more details on IDataObject methods.
1517 */
1518static HRESULT WINAPI DefaultHandler_DUnadvise(
1519 IDataObject* iface,
1520 DWORD dwConnection)
1521{
1522 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1523
1524 TRACE("(%p, %ld)\n", iface, dwConnection);
1525
1526 /*
1527 * If we don't have a data advise holder yet, it means that
1528 * we don't have any connections..
1529 */
1530 if (this->dataAdviseHolder==NULL)
1531 {
1532 return OLE_E_NOCONNECTION;
1533 }
1534
1535 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
1536 dwConnection);
1537}
1538
1539/************************************************************************
1540 * DefaultHandler_EnumDAdvise (IDataObject)
1541 *
1542 * The default handler's implementation of this method simply
1543 * delegates to the DataAdviseHolder.
1544 *
1545 * See Windows documentation for more details on IDataObject methods.
1546 */
1547static HRESULT WINAPI DefaultHandler_EnumDAdvise(
1548 IDataObject* iface,
1549 IEnumSTATDATA** ppenumAdvise)
1550{
1551 _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
1552
1553 TRACE("(%p, %p)\n", iface, ppenumAdvise);
1554
1555 /*
1556 * Sanity check
1557 */
1558 if (ppenumAdvise == NULL)
1559 return E_POINTER;
1560
1561 /*
1562 * Initialize the out parameter.
1563 */
1564 *ppenumAdvise = NULL;
1565
1566 /*
1567 * If we have a data advise holder object, delegate.
1568 */
1569 if (this->dataAdviseHolder!=NULL)
1570 {
1571 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
1572 ppenumAdvise);
1573 }
1574
1575 return S_OK;
1576}
1577
1578/*********************************************************
1579 * Methods implementation for the IRunnableObject part
1580 * of the DefaultHandler class.
1581 */
1582
1583/************************************************************************
1584 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1585 *
1586 * See Windows documentation for more details on IUnknown methods.
1587 */
1588static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
1589 IRunnableObject* iface,
1590 REFIID riid,
1591 void** ppvObject)
1592{
1593 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1594
1595 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
1596}
1597
1598/************************************************************************
1599 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1600 *
1601 * See Windows documentation for more details on IUnknown methods.
1602 */
1603static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
1604 IRunnableObject* iface)
1605{
1606 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1607
1608 return IUnknown_AddRef(this->outerUnknown);
1609}
1610
1611/************************************************************************
1612 * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1613 *
1614 * See Windows documentation for more details on IUnknown methods.
1615 */
1616static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
1617 IRunnableObject* iface)
1618{
1619 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
1620
1621 return IUnknown_Release(this->outerUnknown);
1622}
1623
1624/************************************************************************
1625 * DefaultHandler_GetRunningClass (IRunnableObject)
1626 *
1627 * According to Brockscmidt, Chapter 19, the default handler's
1628 * implementation of IRunnableobject does nothing until the object
1629 * is actually running.
1630 *
1631 * See Windows documentation for more details on IRunnableObject methods.
1632 */
1633static HRESULT WINAPI DefaultHandler_GetRunningClass(
1634 IRunnableObject* iface,
1635 LPCLSID lpClsid)
1636{
1637 TRACE("()\n");
1638 return S_OK;
1639}
1640
1641static HRESULT WINAPI DefaultHandler_Run(
1642 IRunnableObject* iface,
1643 IBindCtx* pbc)
1644{
1645 FIXME(": Stub\n");
1646 return E_NOTIMPL;
1647}
1648
1649/************************************************************************
1650 * DefaultHandler_IsRunning (IRunnableObject)
1651 *
1652 * According to Brockscmidt, Chapter 19, the default handler's
1653 * implementation of IRunnableobject does nothing until the object
1654 * is actually running.
1655 *
1656 * See Windows documentation for more details on IRunnableObject methods.
1657 */
1658static BOOL WINAPI DefaultHandler_IsRunning(
1659 IRunnableObject* iface)
1660{
1661 TRACE("()\n");
1662 return S_FALSE;
1663}
1664
1665/************************************************************************
1666 * DefaultHandler_LockRunning (IRunnableObject)
1667 *
1668 * According to Brockscmidt, Chapter 19, the default handler's
1669 * implementation of IRunnableobject does nothing until the object
1670 * is actually running.
1671 *
1672 * See Windows documentation for more details on IRunnableObject methods.
1673 */
1674static HRESULT WINAPI DefaultHandler_LockRunning(
1675 IRunnableObject* iface,
1676 BOOL fLock,
1677 BOOL fLastUnlockCloses)
1678{
1679 TRACE("()\n");
1680 return S_OK;
1681}
1682
1683/************************************************************************
1684 * DefaultHandler_SetContainedObject (IRunnableObject)
1685 *
1686 * According to Brockscmidt, Chapter 19, the default handler's
1687 * implementation of IRunnableobject does nothing until the object
1688 * is actually running.
1689 *
1690 * See Windows documentation for more details on IRunnableObject methods.
1691 */
1692static HRESULT WINAPI DefaultHandler_SetContainedObject(
1693 IRunnableObject* iface,
1694 BOOL fContained)
1695{
1696 TRACE("()\n");
1697 return S_OK;
1698}
1699
Note: See TracBrowser for help on using the repository browser.