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.

307 lines
10 KiB

  1. // wvcoord.h : Declaration of the CWebViewCoord
  2. #ifndef __WEBVIEWCOORD_H_
  3. #define __WEBVIEWCOORD_H_
  4. #include "dxmplay.h"
  5. #include "resource.h" // main symbols
  6. #include "evtsink.h"
  7. #include "mshtml.h"
  8. #include "mshtmdid.h"
  9. EXTERN_C const CLSID CLSID_WebViewOld; // retired from service
  10. extern HRESULT FindObjectStyle(IUnknown *punkObject, CComPtr<IHTMLStyle>& spStyle);
  11. extern BOOL IsRTLDocument(CComPtr<IHTMLDocument2>& spHTMLElement);
  12. class CThumbNailWrapper;
  13. class CFileListWrapper;
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CWebViewCoord
  16. class ATL_NO_VTABLE CWebViewCoord :
  17. public CComObjectRootEx<CComSingleThreadModel>,
  18. public CComCoClass<CWebViewCoord, &CLSID_WebView>,
  19. public IDispatchImpl<IWebView, &IID_IWebView, &LIBID_WEBVWLib>,
  20. public IObjectSafetyImpl<CWebViewCoord, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
  21. public IObjectWithSiteImpl<CWebViewCoord>
  22. {
  23. public:
  24. CWebViewCoord();
  25. ~CWebViewCoord();
  26. DECLARE_REGISTRY_RESOURCEID(IDR_WEBVIEWCOORD)
  27. BEGIN_COM_MAP(CWebViewCoord)
  28. COM_INTERFACE_ENTRY(IDispatch)
  29. COM_INTERFACE_ENTRY(IWebView)
  30. COM_INTERFACE_ENTRY(IObjectSafety)
  31. COM_INTERFACE_ENTRY_IMPL(IObjectWithSite)
  32. END_COM_MAP()
  33. // IObjectWithSite overrides
  34. STDMETHOD(SetSite)(IUnknown *pClientSite);
  35. private:
  36. //
  37. // Initialization helpers (including event sinks)
  38. //
  39. HRESULT InitFolderObjects(VOID);
  40. //
  41. // CDispatchEventSink overrides
  42. //
  43. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
  44. LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  45. EXCEPINFO* pexcepinfo, UINT* puArgErr);
  46. // IWebView methods
  47. STDMETHOD(OnCSCClick)();
  48. STDMETHOD(CSCSynchronize)();
  49. STDMETHOD(OnCSCMouseOver)();
  50. STDMETHOD(OnCSCMouseOut)();
  51. //
  52. // Event handlers
  53. //
  54. STDMETHOD(OnWindowLoad)(VOID);
  55. STDMETHOD(OnWindowUnLoad)(VOID);
  56. STDMETHOD(OnFixSize)(VOID);
  57. private:
  58. HRESULT ReleaseFolderObjects(VOID);
  59. // security
  60. HRESULT _IsSafe()
  61. {
  62. return (0==m_dwCurrentSafety) ? S_OK : IsSafePage(m_spClientSite);
  63. };
  64. //
  65. // Objects in web view
  66. //
  67. CFileListWrapper *m_pFileListWrapper;
  68. CThumbNailWrapper *m_pThumbNailWrapper;
  69. //
  70. // Host HTML window Dispatch
  71. //
  72. IDispatch * m_pdispWindow;
  73. //
  74. // Some frequently used interfaces
  75. //
  76. CComPtr<IHTMLDocument2> m_spDocument;
  77. CComPtr<IHTMLElementCollection> m_spDocAll;
  78. CComPtr<IHTMLControlElement> m_spDocBody;
  79. CComPtr<IHTMLStyle> m_spFileListStyle;
  80. CComPtr<IHTMLStyle> m_spPanelStyle;
  81. CComPtr<IHTMLStyle> m_spRuleStyle;
  82. CComPtr<IHTMLStyle> m_spHeadingStyle;
  83. CComPtr<IHTMLElement> m_spHeading;
  84. CComPtr<IOleClientSite> m_spClientSite;
  85. //
  86. // Event sink advise cookies
  87. //
  88. DWORD m_dwFileListAdviseCookie;
  89. DWORD m_dwThumbNailAdviseCookie;
  90. DWORD m_dwHtmlWindowAdviseCookie;
  91. DWORD m_dwCSCHotTrackCookie;
  92. BOOL m_bRTLDocument;
  93. };
  94. /////////////////////////////////////////////////////////////////////////////
  95. // CThumbNailWrapper
  96. class CThumbNailWrapper : public CDispatchEventSink {
  97. public:
  98. CThumbNailWrapper();
  99. ~CThumbNailWrapper();
  100. //
  101. // Initialization
  102. //
  103. HRESULT Init(CComPtr<IThumbCtl> spThumbNailCtl,
  104. CComPtr<IHTMLElement> spThumbnailLabel);
  105. //
  106. // CDispatchEventSink overrides
  107. //
  108. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
  109. LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  110. EXCEPINFO* pexcepinfo, UINT* puArgErr);
  111. //
  112. // Event Handlers
  113. //
  114. HRESULT OnThumbNailReady(VOID);
  115. //
  116. // Cover for properties
  117. //
  118. HRESULT UsedSpace(CComBSTR &bstrUsed);
  119. HRESULT TotalSpace(CComBSTR &bstrTotal);
  120. HRESULT FreeSpace(CComBSTR &bstrFree);
  121. CComPtr<IThumbCtl> Control(VOID) {return m_spThumbNailCtl;};
  122. //
  123. // Methods
  124. //
  125. BOOL UpdateThumbNail(CComPtr<FolderItem> spFolderItems);
  126. HRESULT SetDisplay(CComBSTR &bstrDisplay);
  127. HRESULT SetHeight(int iHeight);
  128. HRESULT ClearThumbNail();
  129. private:
  130. HRESULT _SetThumbnailLabel(CComBSTR& bstrLabel);
  131. // Pointer to the control + style
  132. CComPtr<IThumbCtl> m_spThumbNailCtl;
  133. CComPtr<IHTMLElement> m_spThumbnailLabel;
  134. CComPtr<IHTMLStyle> m_spThumbNailStyle;
  135. };
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CFileListWrapper
  138. class CFileListWrapper : public CDispatchEventSink {
  139. public:
  140. CFileListWrapper();
  141. ~CFileListWrapper();
  142. // Initialization
  143. HRESULT Init(CComPtr<IShellFolderViewDual> spFileList,
  144. CComPtr<IHTMLElement> spInfo,
  145. CComPtr<IHTMLElement> spLinks,
  146. CComPtr<IHTMLStyle> spPanelStyle,
  147. CComPtr<IHTMLElement> spMediaPlayerSpan,
  148. CComPtr<IHTMLElement> spCSCPlusMin,
  149. CComPtr<IHTMLElement> spCSCText,
  150. CComPtr<IHTMLElement> spCSCDetail,
  151. CComPtr<IHTMLElement> spCSCButton,
  152. CComPtr<IHTMLStyle> spCSCStyle,
  153. CComPtr<IHTMLStyle> spCSCDetailStyle,
  154. CComPtr<IHTMLStyle> spCSCButtonStyle,
  155. CComPtr<IHTMLDocument2> spDocument,
  156. CComPtr<IHTMLWindow2> spWindow,
  157. CThumbNailWrapper *pThumbNailWrapper);
  158. // CDispatchEventSink overrides
  159. STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid,
  160. WORD wFlags, DISPPARAMS *pDispParams,
  161. VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
  162. UINT *puArgErr);
  163. // Event Handlers
  164. HRESULT OnSelectionChanged(VOID);
  165. // Cover function for properties
  166. CComPtr<IShellFolderViewDual> Control(VOID) {return m_spFileList;};
  167. HRESULT SetDefaultPanelDisplay();
  168. HRESULT OnCSCClick();
  169. HRESULT CSCSynchronize();
  170. HRESULT OnCSCMouseOnOff(BOOL fOn);
  171. // Needs to be called by WVCoord, so public
  172. HRESULT AdviseWebviewLinks( BOOL fAdvise );
  173. private:
  174. //
  175. // Object pointers
  176. //
  177. CComPtr<IShellFolderViewDual> m_spFileList;
  178. CComPtr<IHTMLElement> m_spInfo;
  179. CComPtr<IHTMLElement> m_spLinks;
  180. CComPtr<IHTMLStyle> m_spPanelStyle;
  181. CComPtr<IMediaPlayer> m_spIMediaPlayer;
  182. CComPtr<IHTMLElement> m_spMediaPlayerSpan;
  183. CComPtr<IHTMLStyle> m_spMediaPlayerStyle;
  184. CComPtr<IHTMLElement> m_spCSCPlusMin;
  185. CComPtr<IHTMLElement> m_spCSCText;
  186. CComPtr<IHTMLElement> m_spCSCDetail;
  187. CComPtr<IHTMLElement> m_spCSCButton;
  188. CComPtr<IHTMLStyle> m_spCSCStyle;
  189. CComPtr<IHTMLStyle> m_spCSCDetailStyle;
  190. CComPtr<IHTMLStyle> m_spCSCButtonStyle;
  191. CComPtr<IHTMLDocument2> m_spDocument;
  192. CComPtr<IHTMLWindow2> m_spWindow;
  193. CThumbNailWrapper *m_pThumbNailWrapper;
  194. CComPtr<Folder2> m_spFolder2;
  195. CComPtr<FolderItem> m_spFolderItem;
  196. CComPtr<FolderItem2> m_spFolderItem2;
  197. CComPtr<FolderItems> m_spFolderItems;
  198. CComBSTR m_bstrInfoHTML;
  199. CComBSTR m_bstrCrossLinksHTML;
  200. BOOL m_bFoundAuthor;
  201. BOOL m_bFoundComment;
  202. BOOL m_bCSCDisplayed;
  203. BOOL m_bNeverGotPanelInfo;
  204. BOOL m_bExpanded;
  205. BOOL m_bHotTracked;
  206. DWORD m_dwDateFlags;
  207. BOOL m_bRTLDocument;
  208. BOOL m_bPathIsSlow;
  209. //
  210. // Helper functions
  211. //
  212. HRESULT ClearThumbNail();
  213. HRESULT StopMediaPlayer();
  214. HRESULT ClearMediaPlayer();
  215. HRESULT NoneSelected();
  216. HRESULT MultipleSelected(long cSelection);
  217. HRESULT OneSelected();
  218. HRESULT GetItemNameForDisplay();
  219. HRESULT GetItemType();
  220. HRESULT GetItemDateTime();
  221. HRESULT GetItemSize();
  222. HRESULT GetItemAttributes();
  223. HRESULT GetItemAuthor();
  224. HRESULT GetItemComment();
  225. HRESULT GetItemHTMLInfoTip();
  226. HRESULT GetOtherItemDetails();
  227. HRESULT GetItemInfoTip();
  228. HRESULT DealWithDriveInfo();
  229. HRESULT GetCrossLink(int nFolder, UINT uIDToolTip);
  230. HRESULT GetCrossLinks();
  231. HRESULT FormatCrossLink(LPCWSTR pwszDisplayName, LPCWSTR pwszUrlPath, UINT uIDToolTip);
  232. HRESULT DisplayInfoHTML();
  233. HRESULT DisplayCrossLinksHTML();
  234. HRESULT GetItemInfo(long lResId, LPWSTR wszInfoDescCanonical, CComBSTR& bstrInfoDesc, CComBSTR& bstrInfo);
  235. HRESULT IsItThisFolder(int nFolder, BOOL& bResult, LPWSTR pwszDisplayName, DWORD cchDisplayName, LPWSTR pwszPath, DWORD cchPath);
  236. HRESULT GetIMediaPlayer(CComPtr<IMediaPlayer>& spIMediaPlayer);
  237. // CSC functions
  238. HRESULT CSCGetStatusText(LONG lStatus, CComBSTR& bstrCSCText);
  239. HRESULT CSCGetStatusDetail(LONG lStatus, CComBSTR& bstrCSCDetail);
  240. HRESULT CSCGetStatusButton(LONG lStatus, CComBSTR& bstrCSCButton);
  241. HRESULT GetCSCFolderStatus(LONG* plStatus);
  242. HRESULT CSCShowStatusInfo();
  243. HRESULT CSCShowStatus_FoldExpand_Toggle();
  244. // Event handlers for setting status bar text
  245. HRESULT OnWebviewLinkEvent( BOOL fEnter );
  246. HRESULT GetEventAnchorElement(IHTMLEventObj *pEvent, IHTMLElement **ppElt);
  247. HRESULT GetWVLinksCollection( IHTMLElementCollection **ppCollection, long *pcLinks );
  248. };
  249. #endif //__WEBVIEWCOORD_H_