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

Last change on this file since 6502 was 5602, checked in by sandervl, 24 years ago

resync with Wine 20010418

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