source: trunk/src/ole32/old/defaulthandler.cpp@ 6496

Last change on this file since 6496 was 5601, checked in by sandervl, 24 years ago

created

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