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.

492 lines
14 KiB

  1. /*
  2. * SITE.H
  3. * View Site for Document Objects.
  4. *
  5. * Copyright (c)1995-1999 Microsoft Corporation, All Rights Reserved
  6. */
  7. #ifndef _SITE_H_
  8. #define _SITE_H_
  9. #include "stdafx.h"
  10. #include "mlang.h"
  11. class CProxyFrame;
  12. class CTriEditEventSink;
  13. class CImpIOleClientSite : public IOleClientSite
  14. {
  15. protected:
  16. ULONG m_cRef;
  17. class CSite *m_pSite;
  18. LPUNKNOWN m_pUnkOuter;
  19. public:
  20. CImpIOleClientSite(class CSite *, IUnknown *);
  21. ~CImpIOleClientSite(void);
  22. STDMETHODIMP QueryInterface(REFIID, void **);
  23. STDMETHODIMP_(ULONG) AddRef(void);
  24. STDMETHODIMP_(ULONG) Release(void);
  25. STDMETHODIMP SaveObject(void);
  26. STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);
  27. STDMETHODIMP GetContainer(LPOLECONTAINER *);
  28. STDMETHODIMP ShowObject(void);
  29. STDMETHODIMP OnShowWindow(BOOL);
  30. STDMETHODIMP RequestNewObjectLayout(void);
  31. };
  32. typedef CImpIOleClientSite *PCImpIOleClientSite;
  33. class CImpIAdviseSink : public IAdviseSink
  34. {
  35. protected:
  36. ULONG m_cRef;
  37. class CSite *m_pSite;
  38. LPUNKNOWN m_pUnkOuter;
  39. public:
  40. CImpIAdviseSink(class CSite *, IUnknown *);
  41. ~CImpIAdviseSink(void);
  42. STDMETHODIMP QueryInterface(REFIID, void **);
  43. STDMETHODIMP_(ULONG) AddRef(void);
  44. STDMETHODIMP_(ULONG) Release(void);
  45. STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM);
  46. STDMETHODIMP_(void) OnViewChange(DWORD, LONG);
  47. STDMETHODIMP_(void) OnRename(LPMONIKER);
  48. STDMETHODIMP_(void) OnSave(void);
  49. STDMETHODIMP_(void) OnClose(void);
  50. };
  51. typedef CImpIAdviseSink *PCImpIAdviseSink;
  52. class CImplPropertyNotifySink : public IPropertyNotifySink
  53. {
  54. protected:
  55. ULONG m_cRef;
  56. class CSite *m_pSite;
  57. LPUNKNOWN m_pUnkOuter;
  58. public:
  59. CImplPropertyNotifySink(class CSite *, IUnknown *);
  60. ~CImplPropertyNotifySink(void);
  61. STDMETHODIMP QueryInterface(REFIID, void **);
  62. STDMETHODIMP_(ULONG) AddRef(void);
  63. STDMETHODIMP_(ULONG) Release(void);
  64. STDMETHODIMP OnChanged(DISPID dispid);
  65. STDMETHODIMP OnRequestEdit (DISPID dispid);
  66. };
  67. typedef CImplPropertyNotifySink *PCImplPropertyNotifySink;
  68. class CImpIOleInPlaceSite : public IOleInPlaceSite
  69. {
  70. protected:
  71. ULONG m_cRef;
  72. class CSite *m_pSite;
  73. LPUNKNOWN m_pUnkOuter;
  74. public:
  75. CImpIOleInPlaceSite(class CSite *, IUnknown *);
  76. ~CImpIOleInPlaceSite(void);
  77. STDMETHODIMP QueryInterface(REFIID, void **);
  78. STDMETHODIMP_(ULONG) AddRef(void);
  79. STDMETHODIMP_(ULONG) Release(void);
  80. STDMETHODIMP GetWindow(HWND *);
  81. STDMETHODIMP ContextSensitiveHelp(BOOL);
  82. STDMETHODIMP CanInPlaceActivate(void);
  83. STDMETHODIMP OnInPlaceActivate(void);
  84. STDMETHODIMP OnUIActivate(void);
  85. STDMETHODIMP GetWindowContext(LPOLEINPLACEFRAME *
  86. , LPOLEINPLACEUIWINDOW *, LPRECT, LPRECT
  87. , LPOLEINPLACEFRAMEINFO);
  88. STDMETHODIMP Scroll(SIZE);
  89. STDMETHODIMP OnUIDeactivate(BOOL);
  90. STDMETHODIMP OnInPlaceDeactivate(void);
  91. STDMETHODIMP DiscardUndoState(void);
  92. STDMETHODIMP DeactivateAndUndo(void);
  93. STDMETHODIMP OnPosRectChange(LPCRECT);
  94. };
  95. typedef CImpIOleInPlaceSite *PCImpIOleInPlaceSite;
  96. class CImpIOleDocumentSite : public IOleDocumentSite
  97. {
  98. protected:
  99. ULONG m_cRef;
  100. class CSite *m_pSite;
  101. LPUNKNOWN m_pUnkOuter;
  102. public:
  103. CImpIOleDocumentSite(class CSite *, IUnknown *);
  104. ~CImpIOleDocumentSite(void);
  105. STDMETHODIMP QueryInterface(REFIID, void **);
  106. STDMETHODIMP_(ULONG) AddRef(void);
  107. STDMETHODIMP_(ULONG) Release(void);
  108. STDMETHODIMP ActivateMe(IOleDocumentView *);
  109. };
  110. typedef CImpIOleDocumentSite *PCImpIOleDocumentSite;
  111. ///////////////////////////////////////////////////
  112. // MSHTML.DLL host integration interfaces
  113. ///////////////////////////////////////////////////
  114. class CImpIDocHostUIHandler : public IDocHostUIHandler
  115. {
  116. protected:
  117. ULONG m_cRef;
  118. class CSite *m_pSite;
  119. LPUNKNOWN m_pUnkOuter;
  120. public:
  121. CImpIDocHostUIHandler(class CSite *, IUnknown *);
  122. ~CImpIDocHostUIHandler(void);
  123. STDMETHODIMP QueryInterface(REFIID, void **);
  124. STDMETHODIMP_(ULONG) AddRef(void);
  125. STDMETHODIMP_(ULONG) Release(void);
  126. STDMETHODIMP GetHostInfo(DOCHOSTUIINFO * pInfo);
  127. STDMETHODIMP ShowUI(
  128. DWORD dwID,
  129. IOleInPlaceActiveObject * pActiveObject,
  130. IOleCommandTarget * pCommandTarget,
  131. IOleInPlaceFrame * pFrame,
  132. IOleInPlaceUIWindow * pDoc);
  133. STDMETHODIMP HideUI(void);
  134. STDMETHODIMP UpdateUI(void);
  135. STDMETHODIMP EnableModeless(BOOL fEnable);
  136. STDMETHODIMP OnDocWindowActivate(BOOL fActivate);
  137. STDMETHODIMP OnFrameWindowActivate(BOOL fActivate);
  138. STDMETHODIMP ResizeBorder(
  139. LPCRECT prcBorder,
  140. IOleInPlaceUIWindow * pUIWindow,
  141. BOOL fRameWindow);
  142. STDMETHODIMP ShowContextMenu(
  143. DWORD dwID,
  144. POINT * pptPosition,
  145. IUnknown* pCommandTarget,
  146. IDispatch * pDispatchObjectHit);
  147. STDMETHODIMP TranslateAccelerator(
  148. /* [in] */ LPMSG lpMsg,
  149. /* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
  150. /* [in] */ DWORD nCmdID);
  151. STDMETHODIMP GetOptionKeyPath(BSTR* pbstrKey, DWORD dw);
  152. STDMETHODIMP GetDropTarget(
  153. /* [in] */ IDropTarget __RPC_FAR *pDropTarget,
  154. /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
  155. STDMETHODIMP GetExternal(
  156. /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
  157. STDMETHODIMP TranslateUrl(
  158. /* [in] */ DWORD dwTranslate,
  159. /* [in] */ OLECHAR __RPC_FAR *pchURLIn,
  160. /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
  161. STDMETHODIMP FilterDataObject(
  162. /* [in] */ IDataObject __RPC_FAR *pDO,
  163. /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet);
  164. };
  165. typedef CImpIDocHostUIHandler* PCImpIDocHostUIHandler;
  166. class CImpIDocHostShowUI : public IDocHostShowUI
  167. {
  168. protected:
  169. ULONG m_cRef;
  170. class CSite *m_pSite;
  171. LPUNKNOWN m_pUnkOuter;
  172. public:
  173. CImpIDocHostShowUI(class CSite *, IUnknown *);
  174. ~CImpIDocHostShowUI(void);
  175. STDMETHODIMP QueryInterface(REFIID, void **);
  176. STDMETHODIMP_(ULONG) AddRef(void);
  177. STDMETHODIMP_(ULONG) Release(void);
  178. STDMETHODIMP ShowMessage(
  179. HWND hwnd,
  180. LPOLESTR lpstrText,
  181. LPOLESTR lpstrCaption,
  182. DWORD dwType,
  183. LPOLESTR lpstrHelpFile,
  184. DWORD dwHelpContext,
  185. LRESULT * plResult);
  186. STDMETHODIMP ShowHelp(
  187. HWND hwnd,
  188. LPOLESTR pszHelpFile,
  189. UINT uCommand,
  190. DWORD dwData,
  191. POINT ptMouse,
  192. IDispatch * pDispatchObjectHit);
  193. };
  194. typedef CImpIDocHostShowUI* PCImpIDocHostShowUI;
  195. /*
  196. * IDispatch - implements Ambient properties
  197. */
  198. class CImpAmbientIDispatch : public IDispatch
  199. {
  200. protected:
  201. ULONG m_cRef;
  202. class CSite *m_pSite;
  203. LPUNKNOWN m_pUnkOuter;
  204. public:
  205. CImpAmbientIDispatch(class CSite *, IUnknown *);
  206. ~CImpAmbientIDispatch(void);
  207. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  208. STDMETHODIMP_(ULONG) AddRef(void);
  209. STDMETHODIMP_(ULONG) Release(void);
  210. STDMETHODIMP GetTypeInfoCount(UINT *);
  211. STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
  212. STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT
  213. , LCID, DISPID *);
  214. STDMETHODIMP Invoke(DISPID, REFIID, LCID, USHORT
  215. , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
  216. };
  217. typedef class CImpAmbientIDispatch *PCImpAmbientIDispatch;
  218. class CImpIOleControlSite : public IOleControlSite
  219. {
  220. protected:
  221. ULONG m_cRef;
  222. class CSite *m_pSite;
  223. LPUNKNOWN m_pUnkOuter;
  224. public:
  225. CImpIOleControlSite(class CSite *, IUnknown *);
  226. ~CImpIOleControlSite(void);
  227. STDMETHODIMP QueryInterface(REFIID, void **);
  228. STDMETHODIMP_(ULONG) AddRef(void);
  229. STDMETHODIMP_(ULONG) Release(void);
  230. STDMETHODIMP OnControlInfoChanged(void) { return S_OK;}
  231. STDMETHODIMP LockInPlaceActive(BOOL) {return E_NOTIMPL;}
  232. STDMETHODIMP GetExtendedControl(IDispatch**) {return E_NOTIMPL;}
  233. STDMETHODIMP TransformCoords(POINTL*, POINTF*, DWORD) {return E_NOTIMPL;}
  234. STDMETHODIMP TranslateAccelerator(LPMSG, DWORD) {return E_NOTIMPL;}
  235. STDMETHODIMP OnFocus(BOOL) { return S_OK;}
  236. STDMETHODIMP ShowPropertyFrame(void) { return E_NOTIMPL; }
  237. };
  238. typedef class CImpIOleControlSite *PCImpIOleControlSite;
  239. /*
  240. * The CSite class, a COM object with the interfaces IOleClientSite,
  241. * IAdviseSink, IOleInPlaceSite, and IOleDocumentSite.
  242. */
  243. class CSite : public IUnknown
  244. {
  245. private:
  246. ULONG m_cRef;
  247. HWND m_hWnd; //Client area window of parent
  248. DWORD m_dwPropNotifyCookie;
  249. DWORD m_dwOleObjectCookie;
  250. class CProxyFrame* m_pFR;
  251. BOOL m_bFiltered;
  252. //Object interfaces
  253. LPUNKNOWN m_pObj;
  254. LPOLEOBJECT m_pIOleObject;
  255. LPOLEINPLACEOBJECT m_pIOleIPObject;
  256. LPOLEDOCUMENTVIEW m_pIOleDocView;
  257. LPOLECOMMANDTARGET m_pIOleCommandTarget;
  258. //Our interfaces
  259. PCImpIOleClientSite m_pImpIOleClientSite;
  260. PCImpIAdviseSink m_pImpIAdviseSink;
  261. PCImpIOleInPlaceSite m_pImpIOleIPSite;
  262. PCImpIOleDocumentSite m_pImpIOleDocumentSite;
  263. PCImpIDocHostUIHandler m_pImpIDocHostUIHandler;
  264. PCImpIDocHostShowUI m_pImpIDocHostShowUI;
  265. PCImpAmbientIDispatch m_pImpAmbientIDispatch;
  266. PCImplPropertyNotifySink m_pImpIPropertyNotifySink;
  267. PCImpIOleControlSite m_pImpIOleControlSite;
  268. CTriEditEventSink* m_pTriEdDocEvtSink;
  269. CTriEditEventSink* m_pTriEdWndEvtSink;
  270. BOOL m_bfSaveAsUnicode;
  271. UINT m_cpCodePage;
  272. IMultiLanguage2* m_piMLang;
  273. protected:
  274. public:
  275. CSite(CProxyFrame*);
  276. ~CSite(void);
  277. //BOOL ObjectInitialize( TCHAR* pchPath );
  278. //Gotta have an IUnknown for delegation
  279. STDMETHODIMP QueryInterface(REFIID, void** );
  280. STDMETHODIMP_(ULONG) AddRef(void);
  281. STDMETHODIMP_(ULONG) Release(void);
  282. // Other functions
  283. HRESULT HrCreate(IUnknown* pUnk, IUnknown** ppUnkTriEdit);
  284. HRESULT HrObjectInitialize();
  285. HRESULT HrRegisterPropNotifySink(BOOL fRegister);
  286. void Close(BOOL);
  287. void InitialActivate(LONG, HWND hWnd);
  288. void Activate(LONG);
  289. void UpdateObjectRects(void);
  290. HRESULT HrIsDirtyIPersistStreamInit(BOOL& bVal);
  291. HRESULT HrSaveToFile(BSTR bstrPath, DWORD dwFilterFlags);
  292. HRESULT HrSaveToBstr(BSTR* bstr, DWORD dwFilterFlags);
  293. HRESULT HrSaveToStream(LPSTREAM pStream);
  294. HRESULT HrSaveToStreamAndFilter(LPSTREAM* ppStream, DWORD dwFilterFlags);
  295. HRESULT HrTestFileOpen(BSTR path);
  296. // Filtering methods
  297. HRESULT HrFileToStream(LPCTSTR fileName, LPSTREAM* ppiStream);
  298. HRESULT HrURLToStream(LPCTSTR szURL, LPSTREAM* ppiStream);
  299. HRESULT HrSecureURLToStream(LPCTSTR szURL, LPSTREAM* ppiStream);
  300. HRESULT HrNonSecureURLToStream(LPCTSTR szURL, LPSTREAM* ppiStream);
  301. HRESULT HrStreamToFile(LPSTREAM pStream, LPCTSTR fileName);
  302. HRESULT HrBstrToStream(BSTR bstrSrc, LPSTREAM* ppStream);
  303. HRESULT HrStreamToBstr(LPSTREAM pStream, BSTR* pBstr, BOOL bfRetainByteOrderMark = FALSE);
  304. HRESULT HrFilter(BOOL bDirection, LPSTREAM pSrcStream, LPSTREAM* ppFilteredStream, DWORD dwFilterFlags);
  305. HRESULT HrConvertStreamToUnicode ( IStream* piStream );
  306. BOOL BfFlipBytesIfBigEndianUnicode ( CHAR* pchData, int cbSize );
  307. BOOL IsUnicode ( void* pData, int cbSize );
  308. // ReadyState property methods
  309. void OnReadyStateChanged();
  310. // helper functions
  311. HRESULT GetContainer ( LPOLECONTAINER* ppContainer );
  312. inline CProxyFrame* GetFrame(void) {
  313. return m_pFR;
  314. }
  315. inline LPUNKNOWN GetObjectUnknown(void ) {
  316. return m_pObj;
  317. }
  318. inline PCImpIOleInPlaceSite GetIPSite(void) {
  319. return m_pImpIOleIPSite;
  320. }
  321. inline HWND GetWindow(void) {
  322. return m_hWnd;
  323. }
  324. inline void SetWindow(HWND hwnd) {
  325. m_hWnd = hwnd;
  326. }
  327. inline LPOLECOMMANDTARGET GetCommandTarget(void) {
  328. return m_pIOleCommandTarget;
  329. }
  330. inline void SetCommandTarget(LPOLECOMMANDTARGET pTarget) {
  331. m_pIOleCommandTarget = pTarget;
  332. }
  333. inline void SetDocView(LPOLEDOCUMENTVIEW pDocView) {
  334. // VSQFE:406/WinSERAID:23872, hongyuwu, 4/18/2002
  335. // need to release the old pointer first
  336. // (AddRef'ed in CImpIOleDocumentSite::ActivateMe)
  337. if(m_pIOleDocView) m_pIOleDocView->Release();
  338. m_pIOleDocView = pDocView;
  339. }
  340. inline void SetIPObject(LPOLEINPLACEOBJECT pIPObject) {
  341. m_pIOleIPObject = pIPObject;
  342. }
  343. inline LPOLEINPLACEOBJECT GetIPObject(void) {
  344. return m_pIOleIPObject;
  345. }
  346. inline BOOL GetSaveAsUnicode ( void ) {
  347. return m_bfSaveAsUnicode;
  348. }
  349. inline BOOL SetSaveAsUnicode ( BOOL bfUnicode ) {
  350. BOOL bf = m_bfSaveAsUnicode;
  351. m_bfSaveAsUnicode = bfUnicode;
  352. return bf;
  353. }
  354. inline UINT GetCurrentCodePage ( void ) {
  355. return m_cpCodePage;
  356. }
  357. };
  358. typedef CSite* PCSite;
  359. //DeleteInterfaceImp calls 'delete' and NULLs the pointer
  360. #define DeleteInterfaceImp(p)\
  361. {\
  362. if (NULL!=p)\
  363. {\
  364. delete p;\
  365. p=NULL;\
  366. }\
  367. }
  368. //ReleaseInterface calls 'Release' and NULLs the pointer
  369. #define ReleaseInterface(p)\
  370. {\
  371. IUnknown *pt=(IUnknown *)p;\
  372. p=NULL;\
  373. if (NULL!=pt)\
  374. pt->Release();\
  375. }
  376. #endif //_SITE_H_