source: trunk/src/ole32/defaulthandler.c

Last change on this file was 8441, checked in by sandervl, 23 years ago

Wine resync

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