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.

371 lines
15 KiB

  1. #ifndef _BODY_H
  2. #define _BODY_H
  3. /*
  4. * includes
  5. */
  6. #include "dochost.h"
  7. /*
  8. * forward references
  9. */
  10. interface IHTMLTxtRange;
  11. interface IHTMLElement;
  12. interface IHTMLDocument2;
  13. interface IMoniker;
  14. interface IHTMLBodyElement;
  15. interface IDocHostUIHandler;
  16. interface ITargetFrame2;
  17. interface ITargetFramePriv;
  18. class CBody;
  19. class CFmtBar;
  20. class CAttMenu;
  21. class CSecManager;
  22. class CMsgSource;
  23. class CSpell;
  24. /*
  25. * constants
  26. */
  27. enum
  28. {
  29. BI_MESSAGE,
  30. BI_MONIKER
  31. };
  32. /*
  33. * typedefs
  34. */
  35. typedef struct BODYINITDATA_tag
  36. {
  37. DWORD dwType;
  38. union
  39. {
  40. IMimeMessage *pMsg;
  41. IMoniker *pmk;
  42. };
  43. } BODYINITDATA, * LPBODYINITDATA;
  44. typedef CBody *LPBODYOBJ;
  45. typedef struct BODYHOSTINFO_tag
  46. {
  47. IOleInPlaceSite *pInPlaceSite;
  48. IOleInPlaceFrame *pInPlaceFrame;
  49. IOleInPlaceActiveObject *pDoc;
  50. } BODYHOSTINFO, *PBODYHOSTINFO;
  51. /*
  52. * objects
  53. */
  54. class CBody :
  55. public CDocHost,
  56. public IPropertyNotifySink,
  57. public IDocHostUIHandler,
  58. public IPersistMime,
  59. public ITargetFramePriv,
  60. public IPersistMoniker,
  61. public IFontCacheNotify
  62. #if 0
  63. public IDispatch
  64. #endif
  65. {
  66. public:
  67. CBody();
  68. virtual ~CBody();
  69. // override QI to add IBodyObj
  70. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID FAR *);
  71. virtual ULONG STDMETHODCALLTYPE AddRef();
  72. virtual ULONG STDMETHODCALLTYPE Release();
  73. // IPersist
  74. virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pCLSID);
  75. // IPersistMime
  76. virtual HRESULT STDMETHODCALLTYPE Load(IMimeMessage *pMsg);
  77. virtual HRESULT STDMETHODCALLTYPE Save(IMimeMessage *pMsg, DWORD dwFlags);
  78. // IPersistMoniker Members
  79. virtual HRESULT STDMETHODCALLTYPE Load(BOOL fFullyAvailable, IMoniker *pMoniker, IBindCtx *pBindCtx, DWORD grfMode);
  80. virtual HRESULT STDMETHODCALLTYPE GetCurMoniker(IMoniker **ppMoniker) {return E_NOTIMPL;}
  81. virtual HRESULT STDMETHODCALLTYPE Save(IMoniker *pMoniker, IBindCtx *pBindCtx, BOOL fRemember) {return E_NOTIMPL;}
  82. virtual HRESULT STDMETHODCALLTYPE SaveCompleted(IMoniker *pMoniker, IBindCtx *pBindCtx) {return E_NOTIMPL;}
  83. virtual HRESULT STDMETHODCALLTYPE IsDirty();
  84. // IPropertyNotifySink
  85. virtual HRESULT STDMETHODCALLTYPE OnChanged(DISPID dispid);
  86. virtual HRESULT STDMETHODCALLTYPE OnRequestEdit (DISPID dispid);
  87. // DocHostUIHandler
  88. virtual HRESULT STDMETHODCALLTYPE GetHostInfo(DOCHOSTUIINFO * pInfo);
  89. virtual HRESULT STDMETHODCALLTYPE ShowUI(DWORD dwID, IOleInPlaceActiveObject * pActiveObject, IOleCommandTarget * pCommandTarget, IOleInPlaceFrame * pFrame, IOleInPlaceUIWindow * pDoc);
  90. virtual HRESULT STDMETHODCALLTYPE HideUI(void);
  91. virtual HRESULT STDMETHODCALLTYPE UpdateUI(void);
  92. virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable);
  93. virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate(BOOL fActivate);
  94. virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate(BOOL fActivate);
  95. virtual HRESULT STDMETHODCALLTYPE ResizeBorder(LPCRECT prcBorder, IOleInPlaceUIWindow * pUIWindow,BOOL fRameWindow);
  96. virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath(BSTR * pbstrKey, DWORD dw);
  97. virtual HRESULT STDMETHODCALLTYPE ShowContextMenu(DWORD dwID, POINT* ppt, IUnknown* pcmdtReserved, IDispatch* pdispReserved);
  98. virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG lpMsg, const GUID * pguidCmdGroup, DWORD nCmdID);
  99. virtual HRESULT STDMETHODCALLTYPE GetDropTarget(IDropTarget * pDropTarget, IDropTarget ** ppDropTarget);
  100. virtual HRESULT STDMETHODCALLTYPE GetExternal(IDispatch **ppDispatch);
  101. virtual HRESULT STDMETHODCALLTYPE TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut);
  102. virtual HRESULT STDMETHODCALLTYPE FilterDataObject(IDataObject *pDO, IDataObject **ppDORet);
  103. // ITargetFramePriv
  104. virtual HRESULT STDMETHODCALLTYPE FindFrameDownwards(LPCWSTR pszTargetName, DWORD dwFlags, IUnknown **ppunkTargetFrame);
  105. virtual HRESULT STDMETHODCALLTYPE FindFrameInContext(LPCWSTR pszTargetName, IUnknown *punkContextFrame, DWORD dwFlags, IUnknown **ppunkTargetFrame) ;
  106. virtual HRESULT STDMETHODCALLTYPE OnChildFrameActivate(IUnknown *pUnkChildFrame);
  107. virtual HRESULT STDMETHODCALLTYPE OnChildFrameDeactivate(IUnknown *pUnkChildFrame);
  108. virtual HRESULT STDMETHODCALLTYPE NavigateHack(DWORD grfHLNF,LPBC pbc, IBindStatusCallback *pibsc, LPCWSTR pszTargetName, LPCWSTR pszUrl, LPCWSTR pszLocation);
  109. virtual HRESULT STDMETHODCALLTYPE FindBrowserByIndex(DWORD dwID,IUnknown **ppunkBrowser);
  110. // *** IFontCacheNotify ***
  111. virtual HRESULT STDMETHODCALLTYPE OnPreFontChange();
  112. virtual HRESULT STDMETHODCALLTYPE OnPostFontChange();
  113. #if 0
  114. // *** IDispatch ***
  115. virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
  116. virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo);
  117. virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid);
  118. virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr);
  119. #endif
  120. // override CDocHost members
  121. virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
  122. virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  123. virtual HRESULT STDMETHODCALLTYPE OnUIActivate();
  124. virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate(BOOL);
  125. virtual HRESULT STDMETHODCALLTYPE SetStatusText(LPCOLESTR);
  126. virtual HRESULT GetDocObjSize(LPRECT prc);
  127. virtual HRESULT STDMETHODCALLTYPE OnFocus(BOOL fGotFocus);
  128. virtual LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  129. HRESULT Init(HWND hwnd, DWORD dwFlags, LPRECT prc, PBODYHOSTINFO pHostInfo);
  130. HRESULT Close();
  131. HRESULT UnloadAll();
  132. HRESULT SetRect(LPRECT prc);
  133. HRESULT GetRect(LPRECT prc);
  134. HRESULT UIActivate(BOOL fUIActivate);
  135. HRESULT LoadStream(LPSTREAM pstm);
  136. HRESULT OnFrameActivate(BOOL fActivate);
  137. HRESULT PrivateQueryService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
  138. HRESULT PrivateQueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText);
  139. HRESULT PrivateExec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  140. HRESULT PrivateTranslateAccelerator(LPMSG lpmsg);
  141. HRESULT PrivateEnableModeless(BOOL fEnable);
  142. HRESULT SetParentSites(IOleInPlaceSite *pInPlaceSite, IOleInPlaceFrame *pInPlaceFrame, IOleInPlaceActiveObject *pDoc);
  143. IHTMLDocument2 *GetDoc(){return m_pDoc;};
  144. HRESULT SetCharset(HCHARSET hCharset);
  145. HRESULT GetSelection(IHTMLTxtRange **ppRange);
  146. private:
  147. DWORD m_dwStyle,
  148. m_dwNotify,
  149. m_dwReadyState,
  150. m_cchTotal,
  151. m_dwAutoTicks,
  152. m_dwFontCacheNotify;
  153. HCHARSET m_hCharset;
  154. BOOL m_fEmpty : 1,
  155. m_fDirty : 1,
  156. m_fDesignMode : 1,
  157. m_fAutoDetect : 1,
  158. m_fPlainMode : 1,
  159. m_fMessageParsed : 1,
  160. m_fOnImage : 1,
  161. m_fLoading : 1,
  162. m_fTabLinks : 1,
  163. m_fSrcTabs : 1,
  164. m_fBkgrndSpelling : 1,
  165. m_fReloadingSrc : 1, // reloading source-view
  166. m_fWasDirty : 1, // used by source-tabs to remember state of edit-mode
  167. m_fForceCharsetLoad : 1, // used when replying and don't keep message body
  168. m_fIgnoreAccel : 1;
  169. IMimeMessage *m_pMsg;
  170. IMimeMessageW *m_pMsgW;
  171. IHTMLDocument2 *m_pDoc;
  172. LPWSTR m_pszUrlW;
  173. LPTEMPFILEINFO m_pTempFileUrl;
  174. ULONG m_cchStart,
  175. m_uHdrStyle,
  176. m_cyPreview,
  177. m_cVisibleBtns;
  178. IDocHostUIHandler *m_pParentDocHostUI;
  179. IOleCommandTarget *m_pParentCmdTarget;
  180. LPOLEINPLACESITE m_pParentInPlaceSite;
  181. LPOLEINPLACEFRAME m_pParentInPlaceFrame;
  182. CMsgSource *m_pSrcView;
  183. HWND m_hwndBtnBar,
  184. m_hwndTab,
  185. m_hwndSrc;
  186. LPSTR m_pszLayout;
  187. LPWSTR m_pszFrom,
  188. m_pszTo,
  189. m_pszCc,
  190. m_pszSubject;
  191. CFmtBar *m_pFmtBar;
  192. CSpell *m_pSpell;
  193. IHTMLTxtRange *m_pRangeIgnoreSpell;
  194. IFontCache *m_pFontCache;
  195. IOleInPlaceActiveObject *m_pDocActiveObj;
  196. CAttMenu *m_pAttMenu;
  197. HIMAGELIST m_hIml,
  198. m_hImlHot;
  199. CSecManager *m_pSecMgr;
  200. ULONG m_uSrcView;
  201. IDispatch *m_pDispContext;
  202. DWORD m_dwContextItem;
  203. LPSTREAM m_pstmHtmlSrc;
  204. IHashTable *m_pHashExternal;
  205. IMarkupPointer *m_pAutoStartPtr;
  206. #ifdef PLUSPACK
  207. // Background speller
  208. IHTMLSpell *m_pBkgSpeller;
  209. #endif //PLUSPACK
  210. // notifications
  211. void OnReadyStateChanged();
  212. void OnDocumentReady();
  213. HRESULT OnWMCommand(HWND hwnd, int id, WORD wCmd);
  214. HRESULT OnPaint();
  215. HRESULT OnEraseBkgnd(HDC hdc);
  216. void WMSize(int x, int y);
  217. LRESULT WMNotify(WPARAM wParam, NMHDR* pnmhdr);
  218. HRESULT OnWMCreate();
  219. // load functions
  220. HRESULT RegisterLoadNotify(BOOL fRegister);
  221. HRESULT EnsureLoaded();
  222. HRESULT LoadFromData(LPBODYINITDATA pbiData);
  223. HRESULT LoadFromMoniker(IMoniker *pmk, HCHARSET hCharset);
  224. // Auto-Detect
  225. HRESULT AutoDetectTimer();
  226. HRESULT StopAutoDetect();
  227. HRESULT StartAutoDetect();
  228. HRESULT UrlHighlight(IHTMLTxtRange *pRange);
  229. // Trident OM helper functions
  230. HRESULT DeleteElement(IHTMLElement *pElem);
  231. HRESULT ReplaceElement(LPCTSTR pszName, BSTR bstrPaste, BOOL fHtml);
  232. HRESULT SelectElement(IHTMLElement *pElem, BOOL fScrollIntoView);
  233. HRESULT CreateRangeFromElement(IHTMLElement *pElem, IHTMLTxtRange **ppRange);
  234. HRESULT CreateRange(IHTMLTxtRange **ppRange);
  235. HRESULT GetElement(LPCTSTR pszName, IHTMLElement **ppElem);
  236. HRESULT GetBodyElement(IHTMLBodyElement **ppBody);
  237. HRESULT GetSelectedAnchor(BSTR* pbstr);
  238. HRESULT InsertTextAtCaret(BSTR bstr, BOOL fHtml, BOOL fMoveCaretToEnd);
  239. HRESULT InsertStreamAtCaret(LPSTREAM pstm, BOOL fHtml);
  240. HRESULT InsertBodyText(BSTR bstrPaste, DWORD dwFlags);
  241. HRESULT _CreateRangePointer(IMarkupPointer **pPtr);
  242. HRESULT _UrlHighlightBetweenPtrs(IMarkupPointer *pStartPtr, IMarkupPointer *pEndPtr);
  243. HRESULT _MovePtrByCch(IMarkupPointer *pPtr, LONG *pcp);
  244. // Printing
  245. HRESULT Print(BOOL fPrompt, VARIANTARG *pvaIn);
  246. // menu helpers
  247. HRESULT UpdateContextMenu(HMENU hmenuEdit, BOOL fEnableProperties, IDispatch *pDisp);
  248. HRESULT AppendAnchorItems(HMENU hMenu, IDispatch *pDisp);
  249. // verb supports
  250. HRESULT AddToWab();
  251. HRESULT AddToFavorites();
  252. HRESULT ViewSource(BOOL fMessage);
  253. HRESULT DoRot13();
  254. HRESULT SetStyle(ULONG uStyle);
  255. DWORD DwChooseProperties();
  256. HRESULT UpdateCommands();
  257. HRESULT ShowFormatBar(BOOL fOn);
  258. HRESULT SetDesignMode(BOOL fOn);
  259. HRESULT SetPlainTextMode(BOOL fOn);
  260. HRESULT InsertFile(BSTR bstrFileName);
  261. HRESULT FormatFont();
  262. HRESULT FormatPara();
  263. HRESULT DowngradeToPlainText(BOOL fForceFixedFont);
  264. HRESULT SetDocumentText(BSTR bstr);
  265. HRESULT ApplyDocumentVerb(VARIANTARG *pvaIn);
  266. HRESULT ApplyDocument(IHTMLDocument2 *pDoc);
  267. HRESULT SaveAttachments();
  268. HRESULT _OnSaveImage();
  269. BOOL IsEmpty();
  270. HRESULT SafeToEncodeText(ULONG ulCodePage);
  271. // edit mode support
  272. HRESULT SetComposeFont(BSTR bstr);
  273. HRESULT SetHostComposeFont();
  274. HRESULT PasteReplyHeader();
  275. HRESULT FormatBlockQuote(COLORREF crTextColor);
  276. HRESULT GetAutoText(BSTR *pbstr, BOOL *pfTop);
  277. HRESULT PasteAutoText();
  278. HRESULT GetHostFlags(LPDWORD pdwFlags);
  279. HRESULT SetWindowBgColor(BOOL fForce);
  280. HRESULT InsertBackgroundSound();
  281. // other
  282. HRESULT GetWebPageOptions(WEBPAGEOPTIONS *pOptions, BOOL *pfIncludeMsg);
  283. HRESULT CreateFontCache(LPCSTR pszTridentKey);
  284. HRESULT HrFormatParagraph();
  285. // preview pane mode helpers
  286. HRESULT RecalcPreivewHeight(HDC hdc);
  287. HRESULT UpdatePreviewLabels();
  288. LONG lGetClientHeight();
  289. HRESULT Resize();
  290. void OutputHeaderText(HDC hdc, LPWSTR psz, int *pcxPos, int cyPos, int cxMax, ULONG uFlags);
  291. LONG lGetLineHeight(HDC hdc);
  292. // MHTML saving helpers
  293. HRESULT ClearDirtyFlag();
  294. HRESULT ClearUndoStack();
  295. HRESULT DoHostProperties();
  296. HRESULT SaveAsStationery(VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  297. HRESULT TagUnreferencedImages();
  298. HRESULT GetBackgroundColor(DWORD *pdwColor);
  299. HRESULT SetBackgroundColor(DWORD dwColor);
  300. HRESULT SearchForCIDUrls();
  301. HRESULT UpdateBtnBar();
  302. HRESULT InitToolbar();
  303. HRESULT UpdateButtons();
  304. HRESULT ShowAttachMenu(BOOL fRightClick);
  305. HRESULT ShowPreview(BOOL fOn);
  306. HRESULT PointFromButton(int idm, POINT *ppt);
  307. HRESULT EnsureAttMenu();
  308. HRESULT EnableSounds(BOOL fOn);
  309. // source editing mode helpers
  310. HRESULT ShowSourceView(ULONG uSrcView);
  311. HRESULT ShowSourceTabs(BOOL fOn);
  312. HRESULT SetSourceTabs(ULONG ulTab);
  313. HRESULT IsColorSourceEditing();
  314. // spellchecker
  315. HRESULT HrCreateSpeller(BOOL fBkgrnd);
  316. HRESULT _ReloadWithHtmlSrc(IStream *pstm);
  317. HRESULT _EnsureSrcView();
  318. };
  319. HRESULT CreateBodyObject(HWND hwnd, DWORD dwFlags, LPRECT prc, PBODYHOSTINFO pHostInfo, LPBODYOBJ *ppBodyObj);
  320. #endif //_BODY_H