ReactOS  0.4.13-dev-92-gf251225
defaulthandler.c
Go to the documentation of this file.
1 /*
2  * OLE 2 default object handler
3  *
4  * Copyright 1999 Francis Beaudet
5  * Copyright 2000 Abey George
6  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  *
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  *
41  * - Some functions still return E_NOTIMPL they have to be
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 <stdarg.h>
50 #include <string.h>
51 
52 #define COBJMACROS
53 
54 #include "windef.h"
55 #include "winbase.h"
56 #include "winuser.h"
57 #include "winerror.h"
58 #include "ole2.h"
59 
60 #include "compobj_private.h"
61 #include "storage32.h"
62 
63 #include "wine/unicode.h"
64 #include "wine/debug.h"
65 
67 
69 {
73 };
74 
76 {
80 };
81 
82 /****************************************************************************
83  * DefaultHandler
84  *
85  */
87 {
94 
95  /* Reference count of this object */
97 
98  /* IUnknown implementation of the outer object. */
100 
101  /* Class Id that this handler object represents. */
103 
104  /* IUnknown implementation of the datacache. */
106  /* IPersistStorage implementation of the datacache. */
108 
109  /* Client site for the embedded object. */
111 
112  /*
113  * The IOleAdviseHolder maintains the connections
114  * on behalf of the default handler.
115  */
117 
118  /*
119  * The IDataAdviseHolder maintains the data
120  * connections on behalf of the default handler.
121  */
123 
124  /* Name of the container and object contained */
127 
128  /* IOleObject delegate */
130  /* IPersistStorage delegate */
132  /* IDataObject delegate */
136 
137  /* connection cookie for the advise on the delegate OLE object */
139 
140  /* storage passed to Load or InitNew */
143 
144  /* optional class factory for object */
146  /* TRUE if acting as an inproc server instead of an inproc handler */
148 };
149 
151 
153 {
155 }
156 
158 {
160 }
161 
163 {
165 }
166 
168 {
170 }
171 
173 {
175 }
176 
178 {
180 }
181 
183 
185 {
186  return IRunnableObject_IsRunning(&This->IRunnableObject_iface);
187 }
188 
190 
192 {
193  This->in_call++;
194 }
195 
196 static inline void end_object_call(DefaultHandler *This)
197 {
198  This->in_call--;
199  if (This->in_call == 0 && This->object_state == object_state_deferred_close)
201 }
202 
203 /*********************************************************
204  * Method implementation for the non delegating IUnknown
205  * part of the DefaultHandler class.
206  */
207 
208 /************************************************************************
209  * DefaultHandler_NDIUnknown_QueryInterface (IUnknown)
210  *
211  * See Windows documentation for more details on IUnknown methods.
212  *
213  * This version of QueryInterface will not delegate its implementation
214  * to the outer unknown.
215  */
217  IUnknown* iface,
218  REFIID riid,
219  void** ppvObject)
220 {
222 
223  if (!ppvObject)
224  return E_INVALIDARG;
225 
226  *ppvObject = NULL;
227 
229  *ppvObject = iface;
230  else if (IsEqualIID(&IID_IOleObject, riid))
231  *ppvObject = &This->IOleObject_iface;
232  else if (IsEqualIID(&IID_IDataObject, riid))
233  *ppvObject = &This->IDataObject_iface;
234  else if (IsEqualIID(&IID_IRunnableObject, riid))
235  *ppvObject = &This->IRunnableObject_iface;
236  else if (IsEqualIID(&IID_IPersist, riid) ||
238  *ppvObject = &This->IPersistStorage_iface;
239  else if (IsEqualIID(&IID_IViewObject, riid) ||
243  {
244  HRESULT hr = IUnknown_QueryInterface(This->dataCache, riid, ppvObject);
245  if (FAILED(hr)) FIXME("interface %s not implemented by data cache\n", debugstr_guid(riid));
246  return hr;
247  }
248  else if (This->inproc_server && This->pOleDelegate)
249  {
250  return IOleObject_QueryInterface(This->pOleDelegate, riid, ppvObject);
251  }
252 
253  /* Check that we obtained an interface. */
254  if (*ppvObject == NULL)
255  {
256  WARN( "() : asking for unsupported interface %s\n", debugstr_guid(riid));
257  return E_NOINTERFACE;
258  }
259 
260  /*
261  * Query Interface always increases the reference count by one when it is
262  * successful.
263  */
264  IUnknown_AddRef((IUnknown*)*ppvObject);
265 
266  return S_OK;
267 }
268 
269 /************************************************************************
270  * DefaultHandler_NDIUnknown_AddRef (IUnknown)
271  *
272  * See Windows documentation for more details on IUnknown methods.
273  *
274  * This version of QueryInterface will not delegate its implementation
275  * to the outer unknown.
276  */
278  IUnknown* iface)
279 {
281  return InterlockedIncrement(&This->ref);
282 }
283 
284 /************************************************************************
285  * DefaultHandler_NDIUnknown_Release (IUnknown)
286  *
287  * See Windows documentation for more details on IUnknown methods.
288  *
289  * This version of QueryInterface will not delegate its implementation
290  * to the outer unknown.
291  */
293  IUnknown* iface)
294 {
296  ULONG ref;
297 
298  ref = InterlockedDecrement(&This->ref);
299 
301 
302  return ref;
303 }
304 
305 /*********************************************************
306  * Methods implementation for the IOleObject part of
307  * the DefaultHandler class.
308  */
309 
310 /************************************************************************
311  * DefaultHandler_QueryInterface (IUnknown)
312  *
313  * See Windows documentation for more details on IUnknown methods.
314  */
316  IOleObject* iface,
317  REFIID riid,
318  void** ppvObject)
319 {
321 
322  return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
323 }
324 
325 /************************************************************************
326  * DefaultHandler_AddRef (IUnknown)
327  *
328  * See Windows documentation for more details on IUnknown methods.
329  */
331  IOleObject* iface)
332 {
334 
335  return IUnknown_AddRef(This->outerUnknown);
336 }
337 
338 /************************************************************************
339  * DefaultHandler_Release (IUnknown)
340  *
341  * See Windows documentation for more details on IUnknown methods.
342  */
344  IOleObject* iface)
345 {
347 
348  return IUnknown_Release(This->outerUnknown);
349 }
350 
351 /************************************************************************
352  * DefaultHandler_SetClientSite (IOleObject)
353  *
354  * The default handler's implementation of this method only keeps the
355  * client site pointer for future reference.
356  *
357  * See Windows documentation for more details on IOleObject methods.
358  */
360  IOleObject* iface,
361  IOleClientSite* pClientSite)
362 {
364  HRESULT hr = S_OK;
365 
366  TRACE("(%p, %p)\n", iface, pClientSite);
367 
368  if (object_is_running(This))
369  {
371  hr = IOleObject_SetClientSite(This->pOleDelegate, pClientSite);
373  }
374 
375  /*
376  * Make sure we release the previous client site if there
377  * was one.
378  */
379  if (This->clientSite)
380  IOleClientSite_Release(This->clientSite);
381 
382  This->clientSite = pClientSite;
383 
384  if (This->clientSite)
385  IOleClientSite_AddRef(This->clientSite);
386 
387  return hr;
388 }
389 
390 /************************************************************************
391  * DefaultHandler_GetClientSite (IOleObject)
392  *
393  * The default handler's implementation of this method returns the
394  * last pointer set in IOleObject_SetClientSite.
395  *
396  * See Windows documentation for more details on IOleObject methods.
397  */
399  IOleObject* iface,
400  IOleClientSite** ppClientSite)
401 {
403 
404  if (!ppClientSite)
405  return E_POINTER;
406 
407  *ppClientSite = This->clientSite;
408 
409  if (This->clientSite)
410  IOleClientSite_AddRef(This->clientSite);
411 
412  return S_OK;
413 }
414 
415 /************************************************************************
416  * DefaultHandler_SetHostNames (IOleObject)
417  *
418  * The default handler's implementation of this method just stores
419  * the strings and returns S_OK.
420  *
421  * See Windows documentation for more details on IOleObject methods.
422  */
424  IOleObject* iface,
425  LPCOLESTR szContainerApp,
426  LPCOLESTR szContainerObj)
427 {
429 
430  TRACE("(%p, %s, %s)\n",
431  iface,
432  debugstr_w(szContainerApp),
433  debugstr_w(szContainerObj));
434 
435  if (object_is_running(This))
436  {
438  IOleObject_SetHostNames(This->pOleDelegate, szContainerApp, szContainerObj);
440  }
441 
442  /* Be sure to cleanup before re-assigning the strings. */
443  HeapFree( GetProcessHeap(), 0, This->containerApp );
444  This->containerApp = NULL;
445  HeapFree( GetProcessHeap(), 0, This->containerObj );
446  This->containerObj = NULL;
447 
448  if (szContainerApp)
449  {
450  if ((This->containerApp = HeapAlloc( GetProcessHeap(), 0,
451  (lstrlenW(szContainerApp) + 1) * sizeof(WCHAR) )))
452  strcpyW( This->containerApp, szContainerApp );
453  }
454 
455  if (szContainerObj)
456  {
457  if ((This->containerObj = HeapAlloc( GetProcessHeap(), 0,
458  (lstrlenW(szContainerObj) + 1) * sizeof(WCHAR) )))
459  strcpyW( This->containerObj, szContainerObj );
460  }
461  return S_OK;
462 }
463 
465 {
466  if (This->pDataDelegate)
467  {
468  IDataObject_Release(This->pDataDelegate);
469  This->pDataDelegate = NULL;
470  }
471  if (This->pPSDelegate)
472  {
473  IPersistStorage_Release(This->pPSDelegate);
474  This->pPSDelegate = NULL;
475  }
476  if (This->pOleDelegate)
477  {
478  IOleObject_Release(This->pOleDelegate);
479  This->pOleDelegate = NULL;
480  }
481 }
482 
483 /* undoes the work done by DefaultHandler_Run */
485 {
486  IOleCacheControl *cache_ctrl;
487  HRESULT hr;
488 
489  if (This->object_state == object_state_not_running)
490  return;
491 
492  hr = IUnknown_QueryInterface( This->dataCache, &IID_IOleCacheControl, (void **)&cache_ctrl );
493  if (SUCCEEDED(hr))
494  {
495  hr = IOleCacheControl_OnStop( cache_ctrl );
496  IOleCacheControl_Release( cache_ctrl );
497  }
498 
499  IOleObject_Unadvise(This->pOleDelegate, This->dwAdvConn);
500 
501  if (This->dataAdviseHolder)
502  DataAdviseHolder_OnDisconnect(This->dataAdviseHolder);
503 
504  This->object_state = object_state_not_running;
506 }
507 
508 /************************************************************************
509  * DefaultHandler_Close (IOleObject)
510  *
511  * The default handler's implementation of this method is meaningless
512  * without a running server so it does nothing.
513  *
514  * See Windows documentation for more details on IOleObject methods.
515  */
517  IOleObject* iface,
518  DWORD dwSaveOption)
519 {
521  HRESULT hr;
522 
523  TRACE("(%d)\n", dwSaveOption);
524 
525  if (!object_is_running(This))
526  return S_OK;
527 
529  hr = IOleObject_Close(This->pOleDelegate, dwSaveOption);
531 
533 
534  return hr;
535 }
536 
537 /************************************************************************
538  * DefaultHandler_SetMoniker (IOleObject)
539  *
540  * The default handler's implementation of this method does nothing.
541  *
542  * See Windows documentation for more details on IOleObject methods.
543  */
545  IOleObject* iface,
546  DWORD dwWhichMoniker,
547  IMoniker* pmk)
548 {
550  HRESULT hr = S_OK;
551 
552  TRACE("(%p, %d, %p)\n", iface, dwWhichMoniker, pmk);
553 
554  if (object_is_running(This))
555  {
557  hr = IOleObject_SetMoniker(This->pOleDelegate, dwWhichMoniker, pmk);
559  }
560 
561  return hr;
562 }
563 
564 /************************************************************************
565  * DefaultHandler_GetMoniker (IOleObject)
566  *
567  * Delegate this request to the client site if we have one.
568  *
569  * See Windows documentation for more details on IOleObject methods.
570  */
572  IOleObject* iface,
573  DWORD dwAssign,
574  DWORD dwWhichMoniker,
575  IMoniker** ppmk)
576 {
578  HRESULT hr;
579 
580  TRACE("(%p, %d, %d, %p)\n",
581  iface, dwAssign, dwWhichMoniker, ppmk);
582 
583  if (object_is_running(This))
584  {
586  hr = IOleObject_GetMoniker(This->pOleDelegate, dwAssign, dwWhichMoniker,
587  ppmk);
589  return hr;
590  }
591 
592  /* FIXME: dwWhichMoniker == OLEWHICHMK_CONTAINER only? */
593  if (This->clientSite)
594  {
595  return IOleClientSite_GetMoniker(This->clientSite,
596  dwAssign,
597  dwWhichMoniker,
598  ppmk);
599 
600  }
601 
602  return E_FAIL;
603 }
604 
605 /************************************************************************
606  * DefaultHandler_InitFromData (IOleObject)
607  *
608  * This method is meaningless if the server is not running
609  *
610  * See Windows documentation for more details on IOleObject methods.
611  */
613  IOleObject* iface,
614  IDataObject* pDataObject,
615  BOOL fCreation,
617 {
620 
621  TRACE("(%p, %p, %d, %d)\n",
622  iface, pDataObject, fCreation, dwReserved);
623 
624  if (object_is_running(This))
625  {
627  hr = IOleObject_InitFromData(This->pOleDelegate, pDataObject, fCreation,
628  dwReserved);
630  }
631 
632  return hr;
633 }
634 
635 /************************************************************************
636  * DefaultHandler_GetClipboardData (IOleObject)
637  *
638  * This method is meaningless if the server is not running
639  *
640  * See Windows documentation for more details on IOleObject methods.
641  */
643  IOleObject* iface,
645  IDataObject** ppDataObject)
646 {
649 
650  TRACE("(%p, %d, %p)\n",
651  iface, dwReserved, ppDataObject);
652 
653  if (object_is_running(This))
654  {
656  hr = IOleObject_GetClipboardData(This->pOleDelegate, dwReserved,
657  ppDataObject);
659  }
660 
661  return hr;
662 }
663 
665  IOleObject* iface,
666  LONG iVerb,
667  struct tagMSG* lpmsg,
668  IOleClientSite* pActiveSite,
669  LONG lindex,
671  LPCRECT lprcPosRect)
672 {
674  IRunnableObject *pRunnableObj = &This->IRunnableObject_iface;
675  HRESULT hr;
676 
677  TRACE("(%d, %p, %p, %d, %p, %s)\n", iVerb, lpmsg, pActiveSite, lindex, hwndParent, wine_dbgstr_rect(lprcPosRect));
678 
679  hr = IRunnableObject_Run(pRunnableObj, NULL);
680  if (FAILED(hr)) return hr;
681 
683  hr = IOleObject_DoVerb(This->pOleDelegate, iVerb, lpmsg, pActiveSite,
684  lindex, hwndParent, lprcPosRect);
686 
687  return hr;
688 }
689 
690 /************************************************************************
691  * DefaultHandler_EnumVerbs (IOleObject)
692  *
693  * The default handler implementation of this method simply delegates
694  * to OleRegEnumVerbs
695  *
696  * See Windows documentation for more details on IOleObject methods.
697  */
699  IOleObject* iface,
700  IEnumOLEVERB** ppEnumOleVerb)
701 {
704 
705  TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
706 
707  if (object_is_running(This))
708  {
710  hr = IOleObject_EnumVerbs(This->pOleDelegate, ppEnumOleVerb);
712  }
713 
714  if (hr == OLE_S_USEREG)
715  return OleRegEnumVerbs(&This->clsid, ppEnumOleVerb);
716  else
717  return hr;
718 }
719 
721  IOleObject* iface)
722 {
724  HRESULT hr;
725 
726  TRACE("(%p)\n", iface);
727 
728  if (!object_is_running(This))
729  {
730  FIXME("Should run object\n");
731  return E_NOTIMPL;
732  }
733 
735  hr = IOleObject_Update(This->pOleDelegate);
737 
738  return hr;
739 }
740 
741 /************************************************************************
742  * DefaultHandler_IsUpToDate (IOleObject)
743  *
744  * This method is meaningless if the server is not running
745  *
746  * See Windows documentation for more details on IOleObject methods.
747  */
749  IOleObject* iface)
750 {
753  TRACE("(%p)\n", iface);
754 
755  if (object_is_running(This))
756  {
758  hr = IOleObject_IsUpToDate(This->pOleDelegate);
760  }
761 
762  return hr;
763 }
764 
765 /************************************************************************
766  * DefaultHandler_GetUserClassID (IOleObject)
767  *
768  * TODO: Map to a new class ID if emulation is active.
769  *
770  * See Windows documentation for more details on IOleObject methods.
771  */
773  IOleObject* iface,
774  CLSID* pClsid)
775 {
777  HRESULT hr;
778 
779  TRACE("(%p, %p)\n", iface, pClsid);
780 
781  if (object_is_running(This))
782  {
784  hr = IOleObject_GetUserClassID(This->pOleDelegate, pClsid);
786  return hr;
787  }
788 
789  if (!pClsid)
790  return E_POINTER;
791 
792  *pClsid = This->clsid;
793 
794  return S_OK;
795 }
796 
797 /************************************************************************
798  * DefaultHandler_GetUserType (IOleObject)
799  *
800  * The default handler implementation of this method simply delegates
801  * to OleRegGetUserType
802  *
803  * See Windows documentation for more details on IOleObject methods.
804  */
806  IOleObject* iface,
807  DWORD dwFormOfType,
808  LPOLESTR* pszUserType)
809 {
811  HRESULT hr;
812 
813  TRACE("(%p, %d, %p)\n", iface, dwFormOfType, pszUserType);
814  if (object_is_running(This))
815  {
817  hr = IOleObject_GetUserType(This->pOleDelegate, dwFormOfType, pszUserType);
819  return hr;
820  }
821 
822  return OleRegGetUserType(&This->clsid, dwFormOfType, pszUserType);
823 }
824 
825 /************************************************************************
826  * DefaultHandler_SetExtent (IOleObject)
827  *
828  * This method is meaningless if the server is not running
829  *
830  * See Windows documentation for more details on IOleObject methods.
831  */
833  IOleObject* iface,
834  DWORD dwDrawAspect,
835  SIZEL* psizel)
836 {
839 
840  TRACE("(%p, %x, (%d x %d))\n", iface,
841  dwDrawAspect, psizel->cx, psizel->cy);
842 
843  if (object_is_running(This))
844  {
846  hr = IOleObject_SetExtent(This->pOleDelegate, dwDrawAspect, psizel);
848  }
849 
850  return hr;
851 }
852 
853 /************************************************************************
854  * DefaultHandler_GetExtent (IOleObject)
855  *
856  * The default handler's implementation of this method returns uses
857  * the cache to locate the aspect and extract the extent from it.
858  *
859  * See Windows documentation for more details on IOleObject methods.
860  */
862  IOleObject* iface,
863  DWORD dwDrawAspect,
864  SIZEL* psizel)
865 {
866  DVTARGETDEVICE* targetDevice;
867  IViewObject2* cacheView = NULL;
868  HRESULT hres;
869 
871 
872  TRACE("(%p, %x, %p)\n", iface, dwDrawAspect, psizel);
873 
874  if (object_is_running(This))
875  {
877  hres = IOleObject_GetExtent(This->pOleDelegate, dwDrawAspect, psizel);
879  return hres;
880  }
881 
882  hres = IUnknown_QueryInterface(This->dataCache, &IID_IViewObject2, (void**)&cacheView);
883  if (FAILED(hres))
884  return E_UNEXPECTED;
885 
886  /*
887  * Prepare the call to the cache's GetExtent method.
888  *
889  * Here we would build a valid DVTARGETDEVICE structure
890  * but, since we are calling into the data cache, we
891  * know its implementation and we'll skip this
892  * extra work until later.
893  */
894  targetDevice = NULL;
895 
896  hres = IViewObject2_GetExtent(cacheView,
897  dwDrawAspect,
898  -1,
899  targetDevice,
900  psizel);
901 
902  IViewObject2_Release(cacheView);
903 
904  return hres;
905 }
906 
907 /************************************************************************
908  * DefaultHandler_Advise (IOleObject)
909  *
910  * The default handler's implementation of this method simply
911  * delegates to the OleAdviseHolder.
912  *
913  * See Windows documentation for more details on IOleObject methods.
914  */
916  IOleObject* iface,
917  IAdviseSink* pAdvSink,
918  DWORD* pdwConnection)
919 {
920  HRESULT hres = S_OK;
922 
923  TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
924 
925  /* Make sure we have an advise holder before we start. */
926  if (!This->oleAdviseHolder)
927  hres = CreateOleAdviseHolder(&This->oleAdviseHolder);
928 
929  if (SUCCEEDED(hres))
930  hres = IOleAdviseHolder_Advise(This->oleAdviseHolder,
931  pAdvSink,
932  pdwConnection);
933 
934  return hres;
935 }
936 
937 /************************************************************************
938  * DefaultHandler_Unadvise (IOleObject)
939  *
940  * The default handler's implementation of this method simply
941  * delegates to the OleAdviseHolder.
942  *
943  * See Windows documentation for more details on IOleObject methods.
944  */
946  IOleObject* iface,
947  DWORD dwConnection)
948 {
950 
951  TRACE("(%p, %d)\n", iface, dwConnection);
952 
953  /*
954  * If we don't have an advise holder yet, it means we don't have
955  * a connection.
956  */
957  if (!This->oleAdviseHolder)
958  return OLE_E_NOCONNECTION;
959 
960  return IOleAdviseHolder_Unadvise(This->oleAdviseHolder,
961  dwConnection);
962 }
963 
964 /************************************************************************
965  * DefaultHandler_EnumAdvise (IOleObject)
966  *
967  * The default handler's implementation of this method simply
968  * delegates to the OleAdviseHolder.
969  *
970  * See Windows documentation for more details on IOleObject methods.
971  */
973  IOleObject* iface,
974  IEnumSTATDATA** ppenumAdvise)
975 {
977 
978  TRACE("(%p, %p)\n", iface, ppenumAdvise);
979 
980  if (!ppenumAdvise)
981  return E_POINTER;
982 
983  *ppenumAdvise = NULL;
984 
985  if (!This->oleAdviseHolder)
986  return S_OK;
987 
988  return IOleAdviseHolder_EnumAdvise(This->oleAdviseHolder, ppenumAdvise);
989 }
990 
991 /************************************************************************
992  * DefaultHandler_GetMiscStatus (IOleObject)
993  *
994  * The default handler's implementation of this method simply delegates
995  * to OleRegGetMiscStatus.
996  *
997  * See Windows documentation for more details on IOleObject methods.
998  */
1000  IOleObject* iface,
1001  DWORD dwAspect,
1002  DWORD* pdwStatus)
1003 {
1004  HRESULT hres;
1006 
1007  TRACE("(%p, %x, %p)\n", iface, dwAspect, pdwStatus);
1008 
1009  if (object_is_running(This))
1010  {
1012  hres = IOleObject_GetMiscStatus(This->pOleDelegate, dwAspect, pdwStatus);
1013  end_object_call( This );
1014  return hres;
1015  }
1016 
1017  hres = OleRegGetMiscStatus(&This->clsid, dwAspect, pdwStatus);
1018 
1019  if (FAILED(hres))
1020  *pdwStatus = 0;
1021 
1022  return hres;
1023 }
1024 
1025 /************************************************************************
1026  * DefaultHandler_SetColorScheme (IOleObject)
1027  *
1028  * This method is meaningless if the server is not running
1029  *
1030  * See Windows documentation for more details on IOleObject methods.
1031  */
1033  IOleObject* iface,
1034  struct tagLOGPALETTE* pLogpal)
1035 {
1038 
1039  TRACE("(%p, %p))\n", iface, pLogpal);
1040 
1041  if (object_is_running(This))
1042  {
1044  hr = IOleObject_SetColorScheme(This->pOleDelegate, pLogpal);
1045  end_object_call( This );
1046  }
1047 
1048  return hr;
1049 }
1050 
1051 /*********************************************************
1052  * Methods implementation for the IDataObject part of
1053  * the DefaultHandler class.
1054  */
1055 
1056 /************************************************************************
1057  * DefaultHandler_IDataObject_QueryInterface (IUnknown)
1058  *
1059  * See Windows documentation for more details on IUnknown methods.
1060  */
1062  IDataObject* iface,
1063  REFIID riid,
1064  void** ppvObject)
1065 {
1067 
1068  return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
1069 }
1070 
1071 /************************************************************************
1072  * DefaultHandler_IDataObject_AddRef (IUnknown)
1073  *
1074  * See Windows documentation for more details on IUnknown methods.
1075  */
1077  IDataObject* iface)
1078 {
1080 
1081  return IUnknown_AddRef(This->outerUnknown);
1082 }
1083 
1084 /************************************************************************
1085  * DefaultHandler_IDataObject_Release (IUnknown)
1086  *
1087  * See Windows documentation for more details on IUnknown methods.
1088  */
1090  IDataObject* iface)
1091 {
1093 
1094  return IUnknown_Release(This->outerUnknown);
1095 }
1096 
1097 /************************************************************************
1098  * DefaultHandler_GetData
1099  *
1100  * Get Data from a source dataobject using format pformatetcIn->cfFormat
1101  * See Windows documentation for more details on GetData.
1102  * Default handler's implementation of this method delegates to the cache.
1103  */
1105  IDataObject* iface,
1106  LPFORMATETC pformatetcIn,
1107  STGMEDIUM* pmedium)
1108 {
1109  IDataObject* cacheDataObject = NULL;
1110  HRESULT hres;
1111 
1113 
1114  TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
1115 
1116  hres = IUnknown_QueryInterface(This->dataCache,
1117  &IID_IDataObject,
1118  (void**)&cacheDataObject);
1119 
1120  if (FAILED(hres))
1121  return E_UNEXPECTED;
1122 
1123  hres = IDataObject_GetData(cacheDataObject,
1124  pformatetcIn,
1125  pmedium);
1126 
1127  IDataObject_Release(cacheDataObject);
1128 
1129  if (hres == S_OK) return hres;
1130 
1131  if (object_is_running( This ))
1132  {
1134  hres = IDataObject_GetData(This->pDataDelegate, pformatetcIn, pmedium);
1136  if (hres == S_OK) return hres;
1137  }
1138 
1139  /* Query running state again, as the object may have closed during _GetData call */
1140  if (!object_is_running( This ))
1142 
1143  return hres;
1144 }
1145 
1147  IDataObject* iface,
1148  LPFORMATETC pformatetc,
1149  STGMEDIUM* pmedium)
1150 {
1151  FIXME(": Stub\n");
1152  return E_NOTIMPL;
1153 }
1154 
1155 /************************************************************************
1156  * DefaultHandler_QueryGetData (IDataObject)
1157  *
1158  * The default handler's implementation of this method delegates to
1159  * the cache.
1160  *
1161  * See Windows documentation for more details on IDataObject methods.
1162  */
1164  IDataObject* iface,
1165  LPFORMATETC pformatetc)
1166 {
1167  IDataObject* cacheDataObject = NULL;
1168  HRESULT hres;
1169 
1171 
1172  TRACE("(%p, %p)\n", iface, pformatetc);
1173 
1174  hres = IUnknown_QueryInterface(This->dataCache,
1175  &IID_IDataObject,
1176  (void**)&cacheDataObject);
1177 
1178  if (FAILED(hres))
1179  return E_UNEXPECTED;
1180 
1181  hres = IDataObject_QueryGetData(cacheDataObject,
1182  pformatetc);
1183 
1184  IDataObject_Release(cacheDataObject);
1185 
1186  if (hres == S_OK) return hres;
1187 
1188  if (object_is_running( This ))
1189  {
1191  hres = IDataObject_QueryGetData(This->pDataDelegate, pformatetc);
1192  end_object_call( This );
1193  if (hres == S_OK) return hres;
1194  }
1195 
1196  /* Query running state again, as the object may have closed during _QueryGetData call */
1197  if (!object_is_running( This ))
1199 
1200  return hres;
1201 }
1202 
1203 /************************************************************************
1204  * DefaultHandler_GetCanonicalFormatEtc (IDataObject)
1205  *
1206  * This method is meaningless if the server is not running
1207  *
1208  * See Windows documentation for more details on IDataObject methods.
1209  */
1211  IDataObject* iface,
1212  LPFORMATETC pformatetcIn,
1213  LPFORMATETC pformatetcOut)
1214 {
1216  HRESULT hr;
1217 
1218  TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pformatetcOut);
1219 
1220  if (!object_is_running( This ))
1221  return OLE_E_NOTRUNNING;
1222 
1224  hr = IDataObject_GetCanonicalFormatEtc(This->pDataDelegate, pformatetcIn, pformatetcOut);
1225  end_object_call( This );
1226 
1227  return hr;
1228 }
1229 
1230 /************************************************************************
1231  * DefaultHandler_SetData (IDataObject)
1232  *
1233  * The default handler's implementation of this method delegates to
1234  * the cache.
1235  *
1236  * See Windows documentation for more details on IDataObject methods.
1237  */
1239  IDataObject* iface,
1240  LPFORMATETC pformatetc,
1241  STGMEDIUM* pmedium,
1242  BOOL fRelease)
1243 {
1245  IDataObject* cacheDataObject = NULL;
1246  HRESULT hres;
1247 
1248  TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1249 
1250  hres = IUnknown_QueryInterface(This->dataCache,
1251  &IID_IDataObject,
1252  (void**)&cacheDataObject);
1253 
1254  if (FAILED(hres))
1255  return E_UNEXPECTED;
1256 
1257  hres = IDataObject_SetData(cacheDataObject,
1258  pformatetc,
1259  pmedium,
1260  fRelease);
1261 
1262  IDataObject_Release(cacheDataObject);
1263 
1264  return hres;
1265 }
1266 
1267 /************************************************************************
1268  * DefaultHandler_EnumFormatEtc (IDataObject)
1269  *
1270  * The default handler's implementation of This method simply delegates
1271  * to OleRegEnumFormatEtc.
1272  *
1273  * See Windows documentation for more details on IDataObject methods.
1274  */
1276  IDataObject* iface,
1277  DWORD dwDirection,
1278  IEnumFORMATETC** ppenumFormatEtc)
1279 {
1281 
1282  TRACE("(%p, %x, %p)\n", iface, dwDirection, ppenumFormatEtc);
1283 
1284  return OleRegEnumFormatEtc(&This->clsid, dwDirection, ppenumFormatEtc);
1285 }
1286 
1287 /************************************************************************
1288  * DefaultHandler_DAdvise (IDataObject)
1289  *
1290  * The default handler's implementation of this method simply
1291  * delegates to the DataAdviseHolder.
1292  *
1293  * See Windows documentation for more details on IDataObject methods.
1294  */
1296  IDataObject* iface,
1297  FORMATETC* pformatetc,
1298  DWORD advf,
1299  IAdviseSink* pAdvSink,
1300  DWORD* pdwConnection)
1301 {
1302  HRESULT hres = S_OK;
1304 
1305  TRACE("(%p, %p, %d, %p, %p)\n",
1306  iface, pformatetc, advf, pAdvSink, pdwConnection);
1307 
1308  /* Make sure we have a data advise holder before we start. */
1309  if (!This->dataAdviseHolder)
1310  {
1311  hres = CreateDataAdviseHolder(&This->dataAdviseHolder);
1312  if (SUCCEEDED(hres) && object_is_running( This ))
1313  {
1315  DataAdviseHolder_OnConnect(This->dataAdviseHolder, This->pDataDelegate);
1316  end_object_call( This );
1317  }
1318  }
1319 
1320  if (SUCCEEDED(hres))
1321  hres = IDataAdviseHolder_Advise(This->dataAdviseHolder,
1322  iface,
1323  pformatetc,
1324  advf,
1325  pAdvSink,
1326  pdwConnection);
1327 
1328  return hres;
1329 }
1330 
1331 /************************************************************************
1332  * DefaultHandler_DUnadvise (IDataObject)
1333  *
1334  * The default handler's implementation of this method simply
1335  * delegates to the DataAdviseHolder.
1336  *
1337  * See Windows documentation for more details on IDataObject methods.
1338  */
1340  IDataObject* iface,
1341  DWORD dwConnection)
1342 {
1344 
1345  TRACE("(%p, %d)\n", iface, dwConnection);
1346 
1347  /*
1348  * If we don't have a data advise holder yet, it means that
1349  * we don't have any connections..
1350  */
1351  if (!This->dataAdviseHolder)
1352  return OLE_E_NOCONNECTION;
1353 
1354  return IDataAdviseHolder_Unadvise(This->dataAdviseHolder,
1355  dwConnection);
1356 }
1357 
1358 /************************************************************************
1359  * DefaultHandler_EnumDAdvise (IDataObject)
1360  *
1361  * The default handler's implementation of this method simply
1362  * delegates to the DataAdviseHolder.
1363  *
1364  * See Windows documentation for more details on IDataObject methods.
1365  */
1367  IDataObject* iface,
1368  IEnumSTATDATA** ppenumAdvise)
1369 {
1371 
1372  TRACE("(%p, %p)\n", iface, ppenumAdvise);
1373 
1374  if (!ppenumAdvise)
1375  return E_POINTER;
1376 
1377  *ppenumAdvise = NULL;
1378 
1379  /* If we have a data advise holder object, delegate. */
1380  if (This->dataAdviseHolder)
1381  return IDataAdviseHolder_EnumAdvise(This->dataAdviseHolder,
1382  ppenumAdvise);
1383 
1384  return S_OK;
1385 }
1386 
1387 /*********************************************************
1388  * Methods implementation for the IRunnableObject part
1389  * of the DefaultHandler class.
1390  */
1391 
1392 /************************************************************************
1393  * DefaultHandler_IRunnableObject_QueryInterface (IUnknown)
1394  *
1395  * See Windows documentation for more details on IUnknown methods.
1396  */
1398  IRunnableObject* iface,
1399  REFIID riid,
1400  void** ppvObject)
1401 {
1403 
1404  return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
1405 }
1406 
1407 /************************************************************************
1408  * DefaultHandler_IRunnableObject_AddRef (IUnknown)
1409  *
1410  * See Windows documentation for more details on IUnknown methods.
1411  */
1413  IRunnableObject* iface)
1414 {
1416 
1417  return IUnknown_AddRef(This->outerUnknown);
1418 }
1419 
1420 /************************************************************************
1421  * DefaultHandler_IRunnableObject_Release (IUnknown)
1422  *
1423  * See Windows documentation for more details on IUnknown methods.
1424  */
1426  IRunnableObject* iface)
1427 {
1429 
1430  return IUnknown_Release(This->outerUnknown);
1431 }
1432 
1433 /************************************************************************
1434  * DefaultHandler_GetRunningClass (IRunnableObject)
1435  *
1436  * See Windows documentation for more details on IRunnableObject methods.
1437  */
1439  IRunnableObject* iface,
1440  LPCLSID lpClsid)
1441 {
1442  FIXME("()\n");
1443  return S_OK;
1444 }
1445 
1447  IRunnableObject* iface,
1448  IBindCtx* pbc)
1449 {
1451  HRESULT hr;
1452  IOleCacheControl *cache_ctrl;
1453 
1454  FIXME("(%p): semi-stub\n", pbc);
1455 
1456  /* already running? if so nothing to do */
1457  if (object_is_running(This))
1458  return S_OK;
1459 
1461 
1462  hr = CoCreateInstance(&This->clsid, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER,
1463  &IID_IOleObject, (void **)&This->pOleDelegate);
1464  if (FAILED(hr))
1465  return hr;
1466 
1467  hr = IOleObject_Advise(This->pOleDelegate, &This->IAdviseSink_iface, &This->dwAdvConn);
1468  if (FAILED(hr)) goto fail;
1469 
1470  if (This->clientSite)
1471  {
1472  hr = IOleObject_SetClientSite(This->pOleDelegate, This->clientSite);
1473  if (FAILED(hr)) goto fail;
1474  }
1475 
1476  hr = IOleObject_QueryInterface(This->pOleDelegate, &IID_IPersistStorage,
1477  (void **)&This->pPSDelegate);
1478  if (FAILED(hr)) goto fail;
1479 
1480  if (This->storage_state == storage_state_initialised)
1481  hr = IPersistStorage_InitNew(This->pPSDelegate, This->storage);
1482  else if (This->storage_state == storage_state_loaded)
1483  hr = IPersistStorage_Load(This->pPSDelegate, This->storage);
1484  if (FAILED(hr)) goto fail;
1485 
1486  if (This->containerApp)
1487  {
1488  hr = IOleObject_SetHostNames(This->pOleDelegate, This->containerApp,
1489  This->containerObj);
1490  if (FAILED(hr)) goto fail;
1491  }
1492 
1493  /* FIXME: do more stuff here:
1494  * - IOleObject_GetMiscStatus
1495  * - IOleObject_GetMoniker
1496  */
1497 
1498  hr = IOleObject_QueryInterface(This->pOleDelegate, &IID_IDataObject,
1499  (void **)&This->pDataDelegate);
1500  if (FAILED(hr)) goto fail;
1501 
1502  This->object_state = object_state_running;
1503 
1504  if (This->dataAdviseHolder)
1505  {
1506  hr = DataAdviseHolder_OnConnect(This->dataAdviseHolder, This->pDataDelegate);
1507  if (FAILED(hr)) goto fail;
1508  }
1509 
1510  hr = IUnknown_QueryInterface( This->dataCache, &IID_IOleCacheControl, (void **)&cache_ctrl );
1511  if (FAILED(hr)) goto fail;
1512  hr = IOleCacheControl_OnRun( cache_ctrl, This->pDataDelegate );
1513  IOleCacheControl_Release( cache_ctrl );
1514  if (FAILED(hr)) goto fail;
1515 
1516  return hr;
1517 
1518 fail:
1520  return hr;
1521 }
1522 
1523 /************************************************************************
1524  * DefaultHandler_IsRunning (IRunnableObject)
1525  *
1526  * See Windows documentation for more details on IRunnableObject methods.
1527  */
1529  IRunnableObject* iface)
1530 {
1532 
1533  TRACE("()\n");
1534 
1535  if (This->object_state == object_state_running)
1536  return TRUE;
1537  else
1538  return FALSE;
1539 }
1540 
1541 /************************************************************************
1542  * DefaultHandler_LockRunning (IRunnableObject)
1543  *
1544  * See Windows documentation for more details on IRunnableObject methods.
1545  */
1547  IRunnableObject* iface,
1548  BOOL fLock,
1549  BOOL fLastUnlockCloses)
1550 {
1551  FIXME("()\n");
1552  return S_OK;
1553 }
1554 
1555 /************************************************************************
1556  * DefaultHandler_SetContainedObject (IRunnableObject)
1557  *
1558  * See Windows documentation for more details on IRunnableObject methods.
1559  */
1561  IRunnableObject* iface,
1562  BOOL fContained)
1563 {
1564  FIXME("()\n");
1565  return S_OK;
1566 }
1567 
1569  IAdviseSink *iface,
1570  REFIID riid,
1571  void **ppvObject)
1572 {
1573  if (IsEqualIID(riid, &IID_IUnknown) ||
1575  {
1576  *ppvObject = iface;
1577  IAdviseSink_AddRef(iface);
1578  return S_OK;
1579  }
1580 
1581  return E_NOINTERFACE;
1582 }
1583 
1585  IAdviseSink *iface)
1586 {
1588 
1589  return IUnknown_AddRef(&This->IUnknown_iface);
1590 }
1591 
1593  IAdviseSink *iface)
1594 {
1596 
1597  return IUnknown_Release(&This->IUnknown_iface);
1598 }
1599 
1601  IAdviseSink *iface,
1602  FORMATETC *pFormatetc,
1603  STGMEDIUM *pStgmed)
1604 {
1605  FIXME(": stub\n");
1606 }
1607 
1609  IAdviseSink *iface,
1610  DWORD dwAspect,
1611  LONG lindex)
1612 {
1613  FIXME(": stub\n");
1614 }
1615 
1617  IAdviseSink *iface,
1618  IMoniker *pmk)
1619 {
1621 
1622  TRACE("(%p)\n", pmk);
1623 
1624  if (This->oleAdviseHolder)
1625  IOleAdviseHolder_SendOnRename(This->oleAdviseHolder, pmk);
1626 }
1627 
1629  IAdviseSink *iface)
1630 {
1632 
1633  TRACE("()\n");
1634 
1635  if (This->oleAdviseHolder)
1636  IOleAdviseHolder_SendOnSave(This->oleAdviseHolder);
1637 }
1638 
1640  IAdviseSink *iface)
1641 {
1643 
1644  TRACE("()\n");
1645 
1646  if (This->oleAdviseHolder)
1647  IOleAdviseHolder_SendOnClose(This->oleAdviseHolder);
1648 
1649  if(!This->in_call)
1651  else
1652  {
1653  TRACE("OnClose during call. Deferring shutdown\n");
1654  This->object_state = object_state_deferred_close;
1655  }
1656 }
1657 
1658 /************************************************************************
1659  * DefaultHandler_IPersistStorage_QueryInterface
1660  *
1661  */
1663  IPersistStorage* iface,
1664  REFIID riid,
1665  void** ppvObject)
1666 {
1668 
1669  return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
1670 }
1671 
1672 /************************************************************************
1673  * DefaultHandler_IPersistStorage_AddRef
1674  *
1675  */
1677  IPersistStorage* iface)
1678 {
1680 
1681  return IUnknown_AddRef(This->outerUnknown);
1682 }
1683 
1684 /************************************************************************
1685  * DefaultHandler_IPersistStorage_Release
1686  *
1687  */
1689  IPersistStorage* iface)
1690 {
1692 
1693  return IUnknown_Release(This->outerUnknown);
1694 }
1695 
1696 /************************************************************************
1697  * DefaultHandler_IPersistStorage_GetClassID
1698  *
1699  */
1701  IPersistStorage* iface,
1702  CLSID* clsid)
1703 {
1705  HRESULT hr;
1706 
1707  TRACE("(%p)->(%p)\n", iface, clsid);
1708 
1709  if(object_is_running(This))
1710  {
1712  hr = IPersistStorage_GetClassID(This->pPSDelegate, clsid);
1713  end_object_call( This );
1714  }
1715  else
1716  hr = IPersistStorage_GetClassID(This->dataCache_PersistStg, clsid);
1717 
1718  return hr;
1719 }
1720 
1721 /************************************************************************
1722  * DefaultHandler_IPersistStorage_IsDirty
1723  *
1724  */
1726  IPersistStorage* iface)
1727 {
1729  HRESULT hr;
1730 
1731  TRACE("(%p)\n", iface);
1732 
1733  hr = IPersistStorage_IsDirty(This->dataCache_PersistStg);
1734  if(hr != S_FALSE) return hr;
1735 
1736  if(object_is_running(This))
1737  {
1739  hr = IPersistStorage_IsDirty(This->pPSDelegate);
1740  end_object_call( This );
1741  }
1742 
1743  return hr;
1744 }
1745 
1746 /***********************************************************************
1747  *
1748  * The format of '\1Ole' stream is as follows:
1749  *
1750  * DWORD Version == 0x02000001
1751  * DWORD Flags - low bit set indicates the object is a link otherwise it's embedded.
1752  * DWORD LinkupdateOption - [MS-OLEDS describes this as an implementation specific hint
1753  * supplied by the app that creates the data structure. May be
1754  * ignored on processing].
1755  *
1756  * DWORD Reserved == 0
1757  * DWORD MonikerStreamSize - size of the rest of the data (ie CLSID + moniker stream data).
1758  * CLSID clsid - class id of object capable of processing the moniker
1759  * BYTE data[] - moniker data for a link
1760  */
1761 
1762 static const WCHAR OleStream[] = {1,'O','l','e',0};
1763 typedef struct
1764 {
1771 static const DWORD ole_stream_version = 0x02000001;
1772 
1774 {
1775  IStream *stream;
1776  HRESULT hr;
1777 
1778  hr = IStorage_OpenStream(storage, OleStream, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
1779 
1780  if(SUCCEEDED(hr))
1781  {
1782  DWORD read;
1784 
1785  hr = IStream_Read(stream, &header, sizeof(header), &read);
1786  if(hr == S_OK && read == sizeof(header) && header.version == ole_stream_version)
1787  {
1788  if(header.flags & 1)
1789  {
1790  /* FIXME: Read the moniker and deal with the link */
1791  FIXME("Linked objects are not supported yet\n");
1792  }
1793  }
1794  else
1795  {
1796  WARN("Incorrect OleStream header\n");
1797  hr = DV_E_CLIPFORMAT;
1798  }
1799  IStream_Release(stream);
1800  }
1801  else
1803 
1804  return hr;
1805 }
1806 
1807 /************************************************************************
1808  * DefaultHandler_IPersistStorage_InitNew
1809  *
1810  */
1812  IPersistStorage* iface,
1813  IStorage* pStg)
1814 {
1816  HRESULT hr;
1817 
1818  TRACE("(%p)->(%p)\n", iface, pStg);
1819  hr = STORAGE_CreateOleStream(pStg, 0);
1820  if (hr != S_OK) return hr;
1821 
1822  hr = IPersistStorage_InitNew(This->dataCache_PersistStg, pStg);
1823 
1825  {
1827  hr = IPersistStorage_InitNew(This->pPSDelegate, pStg);
1828  end_object_call( This );
1829  }
1830 
1831  if(SUCCEEDED(hr))
1832  {
1833  IStorage_AddRef(pStg);
1834  This->storage = pStg;
1835  This->storage_state = storage_state_initialised;
1836  }
1837 
1838  return hr;
1839 }
1840 
1841 
1842 /************************************************************************
1843  * DefaultHandler_IPersistStorage_Load
1844  *
1845  */
1847  IPersistStorage* iface,
1848  IStorage* pStg)
1849 {
1851  HRESULT hr;
1852 
1853  TRACE("(%p)->(%p)\n", iface, pStg);
1854 
1855  hr = load_ole_stream(This, pStg);
1856 
1857  if(SUCCEEDED(hr))
1858  hr = IPersistStorage_Load(This->dataCache_PersistStg, pStg);
1859 
1861  {
1863  hr = IPersistStorage_Load(This->pPSDelegate, pStg);
1864  end_object_call( This );
1865  }
1866 
1867  if(SUCCEEDED(hr))
1868  {
1869  IStorage_AddRef(pStg);
1870  This->storage = pStg;
1871  This->storage_state = storage_state_loaded;
1872  }
1873  return hr;
1874 }
1875 
1876 
1877 /************************************************************************
1878  * DefaultHandler_IPersistStorage_Save
1879  *
1880  */
1882  IPersistStorage* iface,
1883  IStorage* pStgSave,
1884  BOOL fSameAsLoad)
1885 {
1887  HRESULT hr;
1888 
1889  TRACE("(%p)->(%p, %d)\n", iface, pStgSave, fSameAsLoad);
1890 
1891  hr = IPersistStorage_Save(This->dataCache_PersistStg, pStgSave, fSameAsLoad);
1893  {
1895  hr = IPersistStorage_Save(This->pPSDelegate, pStgSave, fSameAsLoad);
1896  end_object_call( This );
1897  }
1898 
1899  return hr;
1900 }
1901 
1902 
1903 /************************************************************************
1904  * DefaultHandler_IPersistStorage_SaveCompleted
1905  *
1906  */
1908  IPersistStorage* iface,
1909  IStorage* pStgNew)
1910 {
1912  HRESULT hr;
1913 
1914  TRACE("(%p)->(%p)\n", iface, pStgNew);
1915 
1916  hr = IPersistStorage_SaveCompleted(This->dataCache_PersistStg, pStgNew);
1917 
1919  {
1921  hr = IPersistStorage_SaveCompleted(This->pPSDelegate, pStgNew);
1922  end_object_call( This );
1923  }
1924 
1925  if(pStgNew)
1926  {
1927  IStorage_AddRef(pStgNew);
1928  if(This->storage) IStorage_Release(This->storage);
1929  This->storage = pStgNew;
1930  This->storage_state = storage_state_loaded;
1931  }
1932 
1933  return hr;
1934 }
1935 
1936 
1937 /************************************************************************
1938  * DefaultHandler_IPersistStorage_HandsOffStorage
1939  *
1940  */
1942  IPersistStorage* iface)
1943 {
1945  HRESULT hr;
1946 
1947  TRACE("(%p)\n", iface);
1948 
1949  hr = IPersistStorage_HandsOffStorage(This->dataCache_PersistStg);
1950 
1952  {
1954  hr = IPersistStorage_HandsOffStorage(This->pPSDelegate);
1955  end_object_call( This );
1956  }
1957 
1958  if(This->storage) IStorage_Release(This->storage);
1959  This->storage = NULL;
1960  This->storage_state = storage_state_uninitialised;
1961 
1962  return hr;
1963 }
1964 
1965 
1966 /*
1967  * Virtual function tables for the DefaultHandler class.
1968  */
1969 static const IOleObjectVtbl DefaultHandler_IOleObject_VTable =
1970 {
1995 };
1996 
1997 static const IUnknownVtbl DefaultHandler_NDIUnknown_VTable =
1998 {
2002 };
2003 
2004 static const IDataObjectVtbl DefaultHandler_IDataObject_VTable =
2005 {
2018 };
2019 
2020 static const IRunnableObjectVtbl DefaultHandler_IRunnableObject_VTable =
2021 {
2030 };
2031 
2032 static const IAdviseSinkVtbl DefaultHandler_IAdviseSink_VTable =
2033 {
2042 };
2043 
2044 static const IPersistStorageVtbl DefaultHandler_IPersistStorage_VTable =
2045 {
2056 };
2057 
2058 /*********************************************************
2059  * Methods implementation for the DefaultHandler class.
2060  */
2062  REFCLSID clsid,
2063  LPUNKNOWN pUnkOuter,
2064  DWORD flags,
2065  IClassFactory *pCF)
2066 {
2068  HRESULT hr;
2069 
2070  This = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
2071 
2072  if (!This)
2073  return This;
2074 
2075  This->IOleObject_iface.lpVtbl = &DefaultHandler_IOleObject_VTable;
2076  This->IUnknown_iface.lpVtbl = &DefaultHandler_NDIUnknown_VTable;
2077  This->IDataObject_iface.lpVtbl = &DefaultHandler_IDataObject_VTable;
2078  This->IRunnableObject_iface.lpVtbl = &DefaultHandler_IRunnableObject_VTable;
2079  This->IAdviseSink_iface.lpVtbl = &DefaultHandler_IAdviseSink_VTable;
2080  This->IPersistStorage_iface.lpVtbl = &DefaultHandler_IPersistStorage_VTable;
2081 
2082  This->inproc_server = (flags & EMBDHLP_INPROC_SERVER) != 0;
2083 
2084  /*
2085  * Start with one reference count. The caller of this function
2086  * must release the interface pointer when it is done.
2087  */
2088  This->ref = 1;
2089 
2090  /*
2091  * Initialize the outer unknown
2092  * We don't keep a reference on the outer unknown since, the way
2093  * aggregation works, our lifetime is at least as large as its
2094  * lifetime.
2095  */
2096  if (!pUnkOuter)
2097  pUnkOuter = &This->IUnknown_iface;
2098 
2099  This->outerUnknown = pUnkOuter;
2100 
2101  /*
2102  * Create a datacache object.
2103  * We aggregate with the datacache. Make sure we pass our outer
2104  * unknown as the datacache's outer unknown.
2105  */
2106  hr = CreateDataCache(This->outerUnknown,
2107  clsid,
2108  &IID_IUnknown,
2109  (void**)&This->dataCache);
2110  if(SUCCEEDED(hr))
2111  {
2112  hr = IUnknown_QueryInterface(This->dataCache, &IID_IPersistStorage, (void**)&This->dataCache_PersistStg);
2113  /* keeping a reference to This->dataCache_PersistStg causes us to keep a
2114  * reference on the outer object */
2115  if (SUCCEEDED(hr))
2116  IUnknown_Release(This->outerUnknown);
2117  else
2118  IUnknown_Release(This->dataCache);
2119  }
2120  if(FAILED(hr))
2121  {
2122  ERR("Unexpected error creating data cache\n");
2123  HeapFree(GetProcessHeap(), 0, This);
2124  return NULL;
2125  }
2126 
2127  This->clsid = *clsid;
2128  This->clientSite = NULL;
2129  This->oleAdviseHolder = NULL;
2130  This->dataAdviseHolder = NULL;
2131  This->containerApp = NULL;
2132  This->containerObj = NULL;
2133  This->pOleDelegate = NULL;
2134  This->pPSDelegate = NULL;
2135  This->pDataDelegate = NULL;
2136  This->object_state = object_state_not_running;
2137  This->in_call = 0;
2138 
2139  This->dwAdvConn = 0;
2140  This->storage = NULL;
2141  This->storage_state = storage_state_uninitialised;
2142 
2143  if (This->inproc_server && !(flags & EMBDHLP_DELAYCREATE))
2144  {
2145  HRESULT hr;
2146  This->pCFObject = NULL;
2147  if (pCF)
2148  hr = IClassFactory_CreateInstance(pCF, NULL, &IID_IOleObject, (void **)&This->pOleDelegate);
2149  else
2150  hr = CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
2151  &IID_IOleObject, (void **)&This->pOleDelegate);
2152  if (SUCCEEDED(hr))
2153  hr = IOleObject_QueryInterface(This->pOleDelegate, &IID_IPersistStorage, (void **)&This->pPSDelegate);
2154  if (SUCCEEDED(hr))
2155  hr = IOleObject_QueryInterface(This->pOleDelegate, &IID_IDataObject, (void **)&This->pDataDelegate);
2156  if (SUCCEEDED(hr))
2157  This->object_state = object_state_running;
2158  if (FAILED(hr))
2159  WARN("object creation failed with error %08x\n", hr);
2160  }
2161  else
2162  {
2163  This->pCFObject = pCF;
2164  if (pCF) IClassFactory_AddRef(pCF);
2165  }
2166 
2167  return This;
2168 }
2169 
2172 {
2173  TRACE("(%p)\n", This);
2174 
2175  /* AddRef/Release may be called on this object during destruction.
2176  * Prevent the object being destroyed recursively by artificially raising
2177  * the reference count. */
2178  This->ref = 10000;
2179 
2180  /* release delegates */
2182 
2183  HeapFree( GetProcessHeap(), 0, This->containerApp );
2184  This->containerApp = NULL;
2185  HeapFree( GetProcessHeap(), 0, This->containerObj );
2186  This->containerObj = NULL;
2187 
2188  if (This->dataCache)
2189  {
2190  /* to balance out the release of dataCache_PersistStg which will result
2191  * in a reference being released from the outer unknown */
2192  IUnknown_AddRef(This->outerUnknown);
2193  IPersistStorage_Release(This->dataCache_PersistStg);
2194  IUnknown_Release(This->dataCache);
2195  This->dataCache_PersistStg = NULL;
2196  This->dataCache = NULL;
2197  }
2198 
2199  if (This->clientSite)
2200  {
2201  IOleClientSite_Release(This->clientSite);
2202  This->clientSite = NULL;
2203  }
2204 
2205  if (This->oleAdviseHolder)
2206  {
2207  IOleAdviseHolder_Release(This->oleAdviseHolder);
2208  This->oleAdviseHolder = NULL;
2209  }
2210 
2211  if (This->dataAdviseHolder)
2212  {
2213  IDataAdviseHolder_Release(This->dataAdviseHolder);
2214  This->dataAdviseHolder = NULL;
2215  }
2216 
2217  if (This->storage)
2218  {
2219  IStorage_Release(This->storage);
2220  This->storage = NULL;
2221  }
2222 
2223  if (This->pCFObject)
2224  {
2225  IClassFactory_Release(This->pCFObject);
2226  This->pCFObject = NULL;
2227  }
2228 
2229  HeapFree(GetProcessHeap(), 0, This);
2230 }
2231 
2232 /******************************************************************************
2233  * OleCreateEmbeddingHelper [OLE32.@]
2234  */
2236  REFCLSID clsid,
2237  LPUNKNOWN pUnkOuter,
2238  DWORD flags,
2239  IClassFactory *pCF,
2240  REFIID riid,
2241  LPVOID* ppvObj)
2242 {
2243  DefaultHandler* newHandler = NULL;
2244  HRESULT hr = S_OK;
2245 
2246  TRACE("(%s, %p, %08x, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter, flags, pCF, debugstr_guid(riid), ppvObj);
2247 
2248  if (!ppvObj)
2249  return E_POINTER;
2250 
2251  *ppvObj = NULL;
2252 
2253  /*
2254  * If This handler is constructed for aggregation, make sure
2255  * the caller is requesting the IUnknown interface.
2256  * This is necessary because it's the only time the non-delegating
2257  * IUnknown pointer can be returned to the outside.
2258  */
2259  if (pUnkOuter && !IsEqualIID(&IID_IUnknown, riid))
2260  return CLASS_E_NOAGGREGATION;
2261 
2262  /*
2263  * Try to construct a new instance of the class.
2264  */
2265  newHandler = DefaultHandler_Construct(clsid, pUnkOuter, flags, pCF);
2266 
2267  if (!newHandler)
2268  return E_OUTOFMEMORY;
2269 
2270  /*
2271  * Make sure it supports the interface required by the caller.
2272  */
2273  hr = IUnknown_QueryInterface(&newHandler->IUnknown_iface, riid, ppvObj);
2274 
2275  /*
2276  * Release the reference obtained in the constructor. If
2277  * the QueryInterface was unsuccessful, it will free the class.
2278  */
2279  IUnknown_Release(&newHandler->IUnknown_iface);
2280 
2281  return hr;
2282 }
2283 
2284 
2285 /******************************************************************************
2286  * OleCreateDefaultHandler [OLE32.@]
2287  */
2289  REFIID riid, LPVOID* ppvObj)
2290 {
2291  TRACE("(%s, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter,debugstr_guid(riid), ppvObj);
2293  NULL, riid, ppvObj);
2294 }
2295 
2296 typedef struct HandlerCF
2297 {
2301 } HandlerCF;
2302 
2304 {
2305  return CONTAINING_RECORD(iface, HandlerCF, IClassFactory_iface);
2306 }
2307 
2308 static HRESULT WINAPI
2310 {
2311  *ppv = NULL;
2312  if (IsEqualIID(riid,&IID_IUnknown) ||
2314  {
2315  *ppv = iface;
2316  IClassFactory_AddRef(iface);
2317  return S_OK;
2318  }
2319  return E_NOINTERFACE;
2320 }
2321 
2322 static ULONG WINAPI HandlerCF_AddRef(LPCLASSFACTORY iface)
2323 {
2325  return InterlockedIncrement(&This->refs);
2326 }
2327 
2328 static ULONG WINAPI HandlerCF_Release(LPCLASSFACTORY iface)
2329 {
2331  ULONG refs = InterlockedDecrement(&This->refs);
2332  if (!refs)
2333  HeapFree(GetProcessHeap(), 0, This);
2334  return refs;
2335 }
2336 
2337 static HRESULT WINAPI
2339  REFIID riid, LPVOID *ppv)
2340 {
2342  return OleCreateDefaultHandler(&This->clsid, pUnk, riid, ppv);
2343 }
2344 
2345 static HRESULT WINAPI HandlerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
2346 {
2347  FIXME("(%d), stub!\n",fLock);
2348  return S_OK;
2349 }
2350 
2351 static const IClassFactoryVtbl HandlerClassFactoryVtbl = {
2357 };
2358 
2360 {
2361  HRESULT hr;
2362  HandlerCF *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
2363  if (!This) return E_OUTOFMEMORY;
2364  This->IClassFactory_iface.lpVtbl = &HandlerClassFactoryVtbl;
2365  This->refs = 0;
2366  This->clsid = *rclsid;
2367 
2368  hr = IClassFactory_QueryInterface(&This->IClassFactory_iface, riid, ppv);
2369  if (FAILED(hr))
2370  HeapFree(GetProcessHeap(), 0, This);
2371 
2372  return hr;
2373 }
enum storage_state storage_state
HRESULT WINAPI OleCreateEmbeddingHelper(REFCLSID clsid, LPUNKNOWN pUnkOuter, DWORD flags, IClassFactory *pCF, REFIID riid, LPVOID *ppvObj)
static HRESULT WINAPI DefaultHandler_Unadvise(IOleObject *iface, DWORD dwConnection)
static ULONG WINAPI HandlerCF_AddRef(LPCLASSFACTORY iface)
static HRESULT WINAPI DefaultHandler_IPersistStorage_GetClassID(IPersistStorage *iface, CLSID *clsid)
HRESULT WINAPI CreateOleAdviseHolder(IOleAdviseHolder **ppOAHolder)
Definition: oleobj.c:878
static ULONG WINAPI DefaultHandler_IRunnableObject_Release(IRunnableObject *iface)
#define REFIID
Definition: guiddef.h:113
#define TRUE
Definition: types.h:120
IAdviseSink IAdviseSink_iface
const GUID IID_IViewObject
static HRESULT WINAPI DefaultHandler_SetContainedObject(IRunnableObject *iface, BOOL fContained)
#define E_NOINTERFACE
Definition: winerror.h:2364
static DefaultHandler * impl_from_IUnknown(IUnknown *iface)
HRESULT hr
Definition: shlfolder.c:183
static const WCHAR OleStream[]
static void end_object_call(DefaultHandler *This)
static HRESULT WINAPI DefaultHandler_Run(IRunnableObject *iface, IBindCtx *pbc)
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
static void WINAPI DefaultHandler_IAdviseSink_OnRename(IAdviseSink *iface, IMoniker *pmk)
IDataObject * pDataDelegate
static HRESULT WINAPI HandlerCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppv)
static ULONG WINAPI DefaultHandler_IAdviseSink_AddRef(IAdviseSink *iface)
static const IRunnableObjectVtbl DefaultHandler_IRunnableObject_VTable
REFIID riid
Definition: precomp.h:44
static HRESULT WINAPI DefaultHandler_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
static DefaultHandler * impl_from_IAdviseSink(IAdviseSink *iface)
#define REFCLSID
Definition: guiddef.h:112
static const IOleObjectVtbl DefaultHandler_IOleObject_VTable
const GUID IID_IPersist
Definition: proxy.cpp:14
HRESULT WINAPI DECLSPEC_HOTPATCH OleRegEnumFormatEtc(REFCLSID clsid, DWORD dwDirection, LPENUMFORMATETC *ppenumFormatetc)
Definition: ole2stubs.c:77
static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
const GUID IID_IOleCacheControl
static HRESULT WINAPI DefaultHandler_EnumDAdvise(IDataObject *iface, IEnumSTATDATA **ppenumAdvise)
#define WARN(fmt,...)
Definition: debug.h:111
static void WINAPI DefaultHandler_IAdviseSink_OnClose(IAdviseSink *iface)
static void DefaultHandler_Destroy(DefaultHandler *This)
REFIID LPVOID * ppv
Definition: atlbase.h:39
static HRESULT WINAPI DefaultHandler_IPersistStorage_Load(IPersistStorage *iface, IStorage *pStg)
static HRESULT WINAPI DefaultHandler_QueryGetData(IDataObject *iface, LPFORMATETC pformatetc)
#define EMBDHLP_DELAYCREATE
Definition: ole2.h:50
IRunnableObject IRunnableObject_iface
static ULONG WINAPI DefaultHandler_IPersistStorage_AddRef(IPersistStorage *iface)
const GUID IID_IDataObject
#define DV_E_CLIPFORMAT
Definition: winerror.h:2639
const GUID IID_IPersistStorage
static HRESULT WINAPI DefaultHandler_IAdviseSink_QueryInterface(IAdviseSink *iface, REFIID riid, void **ppvObject)
static LPOLESTR
Definition: stg_prop.c:27
IPersistStorage * dataCache_PersistStg
static HRESULT WINAPI DefaultHandler_SetColorScheme(IOleObject *iface, struct tagLOGPALETTE *pLogpal)
#define lstrlenW
Definition: compat.h:407
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT WINAPI DefaultHandler_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved)
static HRESULT load_ole_stream(DefaultHandler *This, IStorage *storage)
#define EMBDHLP_CREATENOW
Definition: ole2.h:49
Definition: send.c:47
static HRESULT WINAPI DefaultHandler_IPersistStorage_IsDirty(IPersistStorage *iface)
IPersistStorage * pPSDelegate
HRESULT HandlerCF_Create(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
static HRESULT WINAPI DefaultHandler_LockRunning(IRunnableObject *iface, BOOL fLock, BOOL fLastUnlockCloses)
const GUID IID_IAdviseSink
void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface) DECLSPEC_HIDDEN
Definition: oleobj.c:831
#define OLE_E_NOCONNECTION
Definition: winerror.h:2618
static HRESULT WINAPI DefaultHandler_GetRunningClass(IRunnableObject *iface, LPCLSID lpClsid)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
unsigned int BOOL
Definition: ntddk_ex.h:94
static HRESULT WINAPI DefaultHandler_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
long LONG
Definition: pedump.c:60
static LPUNKNOWN
Definition: ndr_ole.c:49
#define debugstr_w
Definition: kernel32.h:32
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
HRESULT STORAGE_CreateOleStream(IStorage *storage, DWORD flags)
Definition: storage32.c:9208
HRESULT WINAPI CreateDataAdviseHolder(IDataAdviseHolder **ppDAHolder)
Definition: oleobj.c:896
static void WINAPI DefaultHandler_IAdviseSink_OnSave(IAdviseSink *iface)
#define S_FALSE
Definition: winerror.h:2357
static HRESULT WINAPI DefaultHandler_SetData(IDataObject *iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
LONG cx
Definition: windef.h:319
static void DefaultHandler_Stop(DefaultHandler *This)
static HRESULT WINAPI DefaultHandler_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
static HRESULT WINAPI DefaultHandler_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
static HRESULT WINAPI DefaultHandler_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
IUnknown * outerUnknown
static const IClassFactoryVtbl HandlerClassFactoryVtbl
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(IUnknown *iface)
const GUID IID_IOleObject
static void release_delegates(DefaultHandler *This)
#define STGM_READ
Definition: objbase.h:916
static HRESULT WINAPI DefaultHandler_GetUserClassID(IOleObject *iface, CLSID *pClsid)
static HRESULT WINAPI DefaultHandler_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
static ULONG WINAPI DefaultHandler_IDataObject_Release(IDataObject *iface)
IClassFactory IClassFactory_iface
static BOOL object_is_running(DefaultHandler *This)
static HRESULT WINAPI DefaultHandler_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define EMBDHLP_INPROC_SERVER
Definition: ole2.h:48
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static HRESULT WINAPI DefaultHandler_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
__wchar_t WCHAR
Definition: xmlstorage.h:180
IDataObject IDataObject_iface
static ULONG WINAPI DefaultHandler_AddRef(IOleObject *iface)
LONG HRESULT
Definition: typedefs.h:77
static HRESULT WINAPI DefaultHandler_EnumFormatEtc(IDataObject *iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
const GUID IID_IUnknown
object_state
#define WINAPI
Definition: msvc.h:8
const char * wine_dbgstr_rect(const RECT *rect)
#define EMBDHLP_INPROC_HANDLER
Definition: ole2.h:47
static HRESULT WINAPI DefaultHandler_QueryInterface(IOleObject *iface, REFIID riid, void **ppvObject)
unsigned long DWORD
Definition: ntddk_ex.h:95
static HRESULT WINAPI HandlerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
static const IPersistStorageVtbl DefaultHandler_IPersistStorage_VTable
IClassFactory * pCFObject
static DefaultHandler * impl_from_IRunnableObject(IRunnableObject *iface)
static HRESULT WINAPI DefaultHandler_IPersistStorage_HandsOffStorage(IPersistStorage *iface)
IOleObject * pOleDelegate
GLbitfield flags
Definition: glext.h:7161
static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(IDataObject *iface, REFIID riid, void **ppvObject)
#define OLE_S_USEREG
Definition: winerror.h:2608
static HRESULT WINAPI DefaultHandler_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
static HRESULT WINAPI DefaultHandler_Update(IOleObject *iface)
REFCLSID clsid
Definition: msctf.c:84
#define InterlockedDecrement
Definition: armddk.h:52
Definition: parse.h:22
static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(IDataObject *iface, LPFORMATETC pformatetcIn, LPFORMATETC pformatetcOut)
GLuint GLuint stream
Definition: glext.h:7522
static HRESULT WINAPI DefaultHandler_Close(IOleObject *iface, DWORD dwSaveOption)
WINE_DEFAULT_DEBUG_CHANNEL(ole)
HRESULT WINAPI OleRegGetMiscStatus(REFCLSID clsid, DWORD dwAspect, DWORD *pdwStatus)
Definition: ole2.c:867
static HRESULT WINAPI DefaultHandler_IPersistStorage_InitNew(IPersistStorage *iface, IStorage *pStg)
IUnknown * dataCache
struct HandlerCF HandlerCF
REFIID LPVOID * ppvObject
Definition: precomp.h:44
static DefaultHandler * impl_from_IDataObject(IDataObject *iface)
IPersistStorage IPersistStorage_iface
IOleObject IOleObject_iface
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
const GUID IID_IRunnableObject
IUnknown IUnknown_iface
IOleClientSite * clientSite
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
static BOOL WINAPI DefaultHandler_IsRunning(IRunnableObject *iface)
HRESULT WINAPI CreateDataCache(LPUNKNOWN pUnkOuter, REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
Definition: datacache.c:3036
#define ERR(fmt,...)
Definition: debug.h:109
storage_state
static HRESULT WINAPI DefaultHandler_IPersistStorage_QueryInterface(IPersistStorage *iface, REFIID riid, void **ppvObject)
static ULONG WINAPI DefaultHandler_NDIUnknown_Release(IUnknown *iface)
const GUID IID_IOleCache2
static ULONG WINAPI DefaultHandler_IAdviseSink_Release(IAdviseSink *iface)
#define S_OK
Definition: intsafe.h:59
enum object_state object_state
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static void start_object_call(DefaultHandler *This)
static const IUnknownVtbl DefaultHandler_NDIUnknown_VTable
static DefaultHandler * impl_from_IPersistStorage(IPersistStorage *iface)
#define InterlockedIncrement
Definition: armddk.h:53
static ULONG WINAPI DefaultHandler_Release(IOleObject *iface)
const GUID IID_IViewObject2
HRESULT WINAPI OleCreateDefaultHandler(REFCLSID clsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(IRunnableObject *iface, REFIID riid, void **ppvObject)
static void WINAPI DefaultHandler_IAdviseSink_OnDataChange(IAdviseSink *iface, FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
static HRESULT WINAPI HandlerCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(IRunnableObject *iface)
IStorage * storage
#define E_NOTIMPL
Definition: ddrawi.h:99
static ULONG WINAPI DefaultHandler_IPersistStorage_Release(IPersistStorage *iface)
static ULONG WINAPI HandlerCF_Release(LPCLASSFACTORY iface)
static const IAdviseSinkVtbl DefaultHandler_IAdviseSink_VTable
static HRESULT WINAPI DefaultHandler_IPersistStorage_SaveCompleted(IPersistStorage *iface, IStorage *pStgNew)
static const DWORD ole_stream_version
#define E_UNEXPECTED
Definition: winerror.h:2456
static HRESULT WINAPI DefaultHandler_DAdvise(IDataObject *iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
static HRESULT WINAPI DefaultHandler_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
IDataAdviseHolder * dataAdviseHolder
unsigned int ULONG
Definition: retypes.h:1
static HRESULT WINAPI DefaultHandler_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
static ULONG WINAPI DefaultHandler_IDataObject_AddRef(IDataObject *iface)
HRESULT WINAPI OleRegGetUserType(REFCLSID clsid, DWORD form, LPOLESTR *usertype)
Definition: ole2.c:681
static HRESULT WINAPI DefaultHandler_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
static HRESULT WINAPI DefaultHandler_GetData(IDataObject *iface, LPFORMATETC pformatetcIn, STGMEDIUM *pmedium)
static HRESULT WINAPI DefaultHandler_GetDataHere(IDataObject *iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium)
static DefaultHandler * DefaultHandler_Construct(REFCLSID clsid, LPUNKNOWN pUnkOuter, DWORD flags, IClassFactory *pCF)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static HRESULT WINAPI DefaultHandler_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
IOleAdviseHolder * oleAdviseHolder
#define E_POINTER
Definition: winerror.h:2365
static void WINAPI DefaultHandler_IAdviseSink_OnViewChange(IAdviseSink *iface, DWORD dwAspect, LONG lindex)
const GUID IID_IClassFactory
static DefaultHandler * impl_from_IOleObject(IOleObject *iface)
HRESULT WINAPI OleRegEnumVerbs(REFCLSID clsid, LPENUMOLEVERB *ppenum)
Definition: ole2.c:1128
#define OLE_E_NOTRUNNING
Definition: winerror.h:2619
LONG cy
Definition: windef.h:320
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
#define HeapFree(x, y, z)
Definition: compat.h:394
static HRESULT WINAPI DefaultHandler_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG *lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate) DECLSPEC_HIDDEN
Definition: oleobj.c:809
struct CFHEADER header
Definition: fdi.c:109
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
static HandlerCF * impl_from_IClassFactory(IClassFactory *iface)
static HRESULT WINAPI DefaultHandler_IsUpToDate(IOleObject *iface)
static HRESULT WINAPI DefaultHandler_IPersistStorage_Save(IPersistStorage *iface, IStorage *pStgSave, BOOL fSameAsLoad)
const GUID IID_IOleCache
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT WINAPI DefaultHandler_DUnadvise(IDataObject *iface, DWORD dwConnection)
static const IDataObjectVtbl DefaultHandler_IDataObject_VTable