Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
9.8 KiB

  1. #ifndef __SHEMBED_H__
  2. #define __SHEMBED_H__
  3. #include "caggunk.h"
  4. #include "cwndproc.h"
  5. //=========================================================================
  6. // CShellEmbedding class definition
  7. //
  8. // NOTE: I'm killing the embeddingness of this class since we
  9. // never shipped a control marked for embedding. If we need it
  10. // back we can easily inherit from CImpIPersistStorage instead
  11. // of IPersist. If you do this, make sure dvoc.cpp explicitly
  12. // returns failure for QI for IPersistStorage or Trident won't
  13. // host it.
  14. //
  15. //=========================================================================
  16. class CShellEmbedding
  17. : public IPersist
  18. , public IOleObject // Embedding MUST
  19. , public IViewObject2 // Embedding MUST
  20. , public IDataObject // for Word/Excel
  21. , public IOleInPlaceObject // In-Place MUST
  22. , public IOleInPlaceActiveObject // In-Place MUST
  23. , public IInternetSecurityMgrSite
  24. , public CAggregatedUnknown
  25. , protected CImpWndProc
  26. {
  27. public:
  28. // *** IUnknown ***
  29. virtual HRESULT __stdcall QueryInterface(REFIID riid, LPVOID * ppvObj)
  30. { return CAggregatedUnknown::QueryInterface(riid, ppvObj); }
  31. virtual ULONG __stdcall AddRef(void)
  32. { return CAggregatedUnknown::AddRef(); }
  33. virtual ULONG __stdcall Release(void)
  34. { return CAggregatedUnknown::Release(); }
  35. // *** IPersist ***
  36. virtual STDMETHODIMP GetClassID(CLSID *pClassID);
  37. // *** IViewObject ***
  38. virtual STDMETHODIMP Draw(DWORD, LONG, void *, DVTARGETDEVICE *, HDC, HDC,
  39. const RECTL *, const RECTL *, BOOL (*)(ULONG_PTR), ULONG_PTR);
  40. virtual STDMETHODIMP GetColorSet(DWORD, LONG, void *, DVTARGETDEVICE *,
  41. HDC, LOGPALETTE **);
  42. virtual STDMETHODIMP Freeze(DWORD, LONG, void *, DWORD *);
  43. virtual STDMETHODIMP Unfreeze(DWORD);
  44. virtual STDMETHODIMP SetAdvise(DWORD, DWORD, IAdviseSink *);
  45. virtual STDMETHODIMP GetAdvise(DWORD *, DWORD *, IAdviseSink **);
  46. // *** IViewObject2 ***
  47. virtual STDMETHODIMP GetExtent(DWORD, LONG, DVTARGETDEVICE *, LPSIZEL);
  48. // *** IOleObject ***
  49. virtual HRESULT __stdcall SetClientSite(IOleClientSite *pClientSite);
  50. virtual HRESULT __stdcall GetClientSite(IOleClientSite **ppClientSite);
  51. virtual HRESULT __stdcall SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj);
  52. virtual HRESULT __stdcall Close(DWORD dwSaveOption);
  53. virtual HRESULT __stdcall SetMoniker(DWORD dwWhichMoniker, IMoniker *pmk);
  54. virtual HRESULT __stdcall GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk);
  55. virtual HRESULT __stdcall InitFromData(IDataObject *pDataObject,BOOL fCreation,DWORD dwReserved);
  56. virtual HRESULT __stdcall GetClipboardData(DWORD dwReserved,IDataObject **ppDataObject);
  57. virtual HRESULT __stdcall DoVerb(LONG iVerb,LPMSG lpmsg,IOleClientSite *pActiveSite,LONG lindex,HWND hwndParent,LPCRECT lprcPosRect);
  58. virtual HRESULT __stdcall EnumVerbs(IEnumOLEVERB **ppEnumOleVerb);
  59. virtual HRESULT __stdcall Update(void);
  60. virtual HRESULT __stdcall IsUpToDate(void);
  61. virtual HRESULT __stdcall GetUserClassID(CLSID *pClsid);
  62. virtual HRESULT __stdcall GetUserType(DWORD dwFormOfType, LPOLESTR *pszUserType);
  63. virtual HRESULT __stdcall SetExtent(DWORD dwDrawAspect, SIZEL *psizel);
  64. virtual HRESULT __stdcall GetExtent(DWORD dwDrawAspect, SIZEL *psizel);
  65. virtual HRESULT __stdcall Advise(IAdviseSink *pAdvSink, DWORD *pdwConnection);
  66. virtual HRESULT __stdcall Unadvise(DWORD dwConnection);
  67. virtual HRESULT __stdcall EnumAdvise(IEnumSTATDATA **ppenumAdvise);
  68. virtual HRESULT __stdcall GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus);
  69. virtual HRESULT __stdcall SetColorScheme(LOGPALETTE *pLogpal);
  70. // *** IDataObject ***
  71. virtual HRESULT __stdcall GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium);
  72. virtual HRESULT __stdcall GetDataHere(FORMATETC *pformatetc, STGMEDIUM *pmedium);
  73. virtual HRESULT __stdcall QueryGetData(FORMATETC *pformatetc);
  74. virtual HRESULT __stdcall GetCanonicalFormatEtc(FORMATETC *pformatectIn, FORMATETC *pformatetcOut);
  75. virtual HRESULT __stdcall SetData(FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease);
  76. virtual HRESULT __stdcall EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc);
  77. virtual HRESULT __stdcall DAdvise(FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection);
  78. virtual HRESULT __stdcall DUnadvise(DWORD dwConnection);
  79. virtual HRESULT __stdcall EnumDAdvise(IEnumSTATDATA **ppenumAdvise);
  80. // *** IOleWindow ***
  81. virtual HRESULT __stdcall GetWindow(HWND * lphwnd);
  82. virtual HRESULT __stdcall ContextSensitiveHelp(BOOL fEnterMode);
  83. // *** IOleInPlaceObject ***
  84. virtual HRESULT __stdcall InPlaceDeactivate(void);
  85. virtual HRESULT __stdcall UIDeactivate(void);
  86. virtual HRESULT __stdcall SetObjectRects(LPCRECT lprcPosRect,
  87. LPCRECT lprcClipRect);
  88. virtual HRESULT __stdcall ReactivateAndUndo(void);
  89. // *** IOleInPlaceActiveObject ***
  90. virtual HRESULT __stdcall TranslateAccelerator(LPMSG lpmsg);
  91. virtual HRESULT __stdcall OnFrameWindowActivate(BOOL fActivate);
  92. virtual HRESULT __stdcall OnDocWindowActivate(BOOL fActivate);
  93. virtual HRESULT __stdcall ResizeBorder(LPCRECT prcBorder,
  94. IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow);
  95. virtual HRESULT __stdcall EnableModeless(BOOL fEnable);
  96. protected:
  97. CShellEmbedding(IUnknown* punkOuter, LPCOBJECTINFO poi, const OLEVERB* pverbs=NULL);
  98. virtual ~CShellEmbedding();
  99. virtual HRESULT v_InternalQueryInterface(REFIID riid, LPVOID * ppvObj);
  100. virtual void _OnSetClientSite(void); // called when we actually get a client site
  101. // Activation related -- this is the normal order these funcs get called
  102. HRESULT _DoActivateChange(IOleClientSite* pActiveSite, UINT uState, BOOL fForce); // figures out what to do
  103. virtual HRESULT _OnActivateChange(IOleClientSite* pActiveSite, UINT uState);// calls below
  104. virtual void _OnInPlaceActivate(void); // called when we actually go in-place-active
  105. virtual void _OnUIActivate(void); // called when we actually go ui-active
  106. virtual void _OnUIDeactivate(void); // called when we actually go ui-deactive
  107. virtual void _OnInPlaceDeactivate(void); // called when we actually deactivate
  108. // Window related
  109. virtual LRESULT v_WndProc(HWND, UINT, WPARAM, LPARAM);
  110. void _RegisterWindowClass(void);
  111. // Helper functions for subclasses
  112. HRESULT _CreateWindowOrSetParent(IOleWindow* pwin);
  113. HDC _OleStdCreateDC(DVTARGETDEVICE *ptd);
  114. void _ViewChange(DWORD dwAspect, LONG lindex);
  115. void _SendAdvise(UINT uCode);
  116. BOOL _ShouldDraw(LONG lindex);
  117. IOleClientSite* _pcli;
  118. IOleClientSite* _pcliHold; // Save a pointer to our client site if we're DoVerbed after Close
  119. IAdviseSink* _padv;
  120. DWORD _advf; // ADVF_ flags (p.166 OLE spec)
  121. DWORD _asp; // DVASPECT
  122. IStorage* _pstg;
  123. SIZE _size;
  124. SIZEL _sizeHIM; // HIMETRIC SetExtent size -- we pretty much ignore this.
  125. LPCOBJECTINFO _pObjectInfo; // pointer into global object array
  126. // WARNING: Load's OLE
  127. IOleAdviseHolder* _poah;
  128. IDataAdviseHolder* _pdah;
  129. // In-Place object specific
  130. RECT _rcPos;
  131. RECT _rcClip;
  132. IOleInPlaceSite* _pipsite;
  133. IOleInPlaceFrame* _pipframe;
  134. IOleInPlaceUIWindow* _pipui;
  135. OLEINPLACEFRAMEINFO _finfo;
  136. HWND _hwndChild;
  137. const OLEVERB* _pverbs;
  138. BOOL _fDirty:1;
  139. BOOL _fOpen:1;
  140. BOOL _fUsingWindowRgn:1;
  141. UINT _nActivate;
  142. };
  143. // Activation defines
  144. #define OC_DEACTIVE 0
  145. #define OC_INPLACEACTIVE 1
  146. #define OC_UIACTIVE 2
  147. //
  148. //Copied from polyline.h in Inside OLE 2nd edition
  149. //
  150. //Code for CShellEmbedding::_SendAdvise
  151. //......Code.....................Method called in CShellEmbedding::_SendAdvise
  152. #define OBJECTCODE_SAVED 0 //IOleAdviseHolder::SendOnSave
  153. #define OBJECTCODE_CLOSED 1 //IOleAdviseHolder::SendOnClose
  154. #define OBJECTCODE_RENAMED 2 //IOleAdviseHolder::SendOnRename
  155. #define OBJECTCODE_SAVEOBJECT 3 //IOleClientSite::SaveObject
  156. #define OBJECTCODE_DATACHANGED 4 //IDataAdviseHolder::SendOnDataChange
  157. #define OBJECTCODE_SHOWWINDOW 5 //IOleClientSite::OnShowWindow(TRUE)
  158. #define OBJECTCODE_HIDEWINDOW 6 //IOleClientSite::OnShowWindow(FALSE)
  159. #define OBJECTCODE_SHOWOBJECT 7 //IOleClientSite::ShowObject
  160. #define OBJECTCODE_VIEWCHANGED 8 //IAdviseSink::OnViewChange
  161. // A helper function in shembed.c
  162. void PixelsToMetric(SIZEL* psize);
  163. void MetricToPixels(SIZEL* psize);
  164. //=========================================================================
  165. // CSVVerb class definition
  166. //=========================================================================
  167. class CSVVerb : public IEnumOLEVERB
  168. {
  169. public:
  170. // *** IUnknown ***
  171. virtual HRESULT __stdcall QueryInterface(REFIID riid, LPVOID * ppvObj);
  172. virtual ULONG __stdcall AddRef(void) ;
  173. virtual ULONG __stdcall Release(void);
  174. // *** IEnumOLEVERB ***
  175. virtual /* [local] */ HRESULT __stdcall Next(
  176. /* [in] */ ULONG celt,
  177. /* [out] */ LPOLEVERB rgelt,
  178. /* [out] */ ULONG *pceltFetched);
  179. virtual HRESULT __stdcall Skip(
  180. /* [in] */ ULONG celt);
  181. virtual HRESULT __stdcall Reset( void);
  182. virtual HRESULT __stdcall Clone(
  183. /* [out] */ IEnumOLEVERB **ppenum);
  184. CSVVerb(const OLEVERB* pverbs) : _cRef(1), _iCur(0), _pverbs(pverbs) {}
  185. protected:
  186. UINT _cRef;
  187. UINT _iCur;
  188. const OLEVERB* _pverbs;
  189. };
  190. #endif // __SHEMBED_H__