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.

360 lines
13 KiB

  1. // Copyright (c)1997-1999 Microsoft Corporation, All Rights Reserved
  2. #ifndef _proxyframe_h_
  3. #define _proxyframe_h_
  4. #include <docobj.h>
  5. #include <ocidl.h>
  6. #include <WinINet.h>
  7. #include "plgprot.h"
  8. #include "dhtmledit.h"
  9. // This was given in email from Josh Kaplan to Steve Isaac in response
  10. // to what command is necessary so that Trident won't clear the undo
  11. // stack on setAttribute calls. The command takes a BOOL -- True == good behavior
  12. #define IDM_GOOD_UNDO_BEHAVIOR 6049
  13. typedef struct _CommandMap
  14. {
  15. DHTMLEDITCMDID typeLibCmdID;
  16. ULONG cmdID;
  17. BOOL bOutParam;
  18. } CommandMap;
  19. #ifdef LATE_BIND_URLMON_WININET
  20. typedef HRESULT (WINAPI *PFNCoInternetCombineUrl)(LPCWSTR,LPCWSTR,DWORD,LPWSTR,DWORD,DWORD*,DWORD);
  21. typedef HRESULT (WINAPI *PFNCoInternetParseUrl)(LPCWSTR,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD);
  22. typedef HRESULT (WINAPI *PFNCreateURLMoniker)(LPMONIKER,LPCWSTR,LPMONIKER FAR*);
  23. typedef HRESULT (WINAPI *PFNCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
  24. typedef HRESULT (WINAPI *PFNURLOpenBlockingStream)(LPUNKNOWN,LPCSTR,LPSTREAM*,DWORD,LPBINDSTATUSCALLBACK);
  25. typedef BOOL (WINAPI *PFNDeleteUrlCacheEntry)(LPCSTR);
  26. typedef BOOL (WINAPI *PFNInternetCreateUrl)(LPURL_COMPONENTSA,DWORD,LPSTR,LPDWORD);
  27. typedef BOOL (WINAPI *PFNInternetCrackURL)(LPCSTR,DWORD,DWORD,LPURL_COMPONENTSA);
  28. #endif // LATE_BIND_URLMON_WININET
  29. class CDHTMLEdProtocolInfo;
  30. typedef CComObject<CDHTMLEdProtocolInfo> *PProtocolInfo;
  31. class CDHTMLSafe;
  32. typedef enum DENudgeDirection {
  33. deNudgeUp = 8000,
  34. deNudgeDown,
  35. deNudgeLeft,
  36. deNudgeRight,
  37. };
  38. class CProxyFrame : public IOleInPlaceFrame, public IOleCommandTarget,
  39. public IBindStatusCallback, public IAuthenticate
  40. {
  41. public:
  42. CProxyFrame(CDHTMLSafe* pCtl);
  43. ~CProxyFrame();
  44. HRESULT Init(IUnknown* pUnk, IUnknown** ppUnkTriEdit);
  45. HRESULT PreActivate();
  46. HRESULT Activate();
  47. void UIDeactivate();
  48. HRESULT Close();
  49. HRESULT LoadInitialDoc();
  50. HRESULT LoadDocument(BSTR path, BOOL bfIsURL = FALSE);
  51. HRESULT FilterSourceCode ( BSTR bsSourceIn, BSTR* pbsSourceOut );
  52. HRESULT Print( BOOL bfWithUI );
  53. HRESULT SaveDocument(BSTR path);
  54. HRESULT SetContextMenu(LPVARIANT pVarMenuStrings, LPVARIANT pVarMenuStates);
  55. HRESULT SetContextMenuSA(LPVARIANT pVarMenuStrings, LPVARIANT pVarMenuStates);
  56. HRESULT SetContextMenuDispEx(LPVARIANT pVarMenuStrings, LPVARIANT pVarMenuStates);
  57. HRESULT GetBrowseMode ( VARIANT_BOOL *pVal );
  58. HRESULT SetBrowseMode ( VARIANT_BOOL newVal );
  59. HRESULT GetDocumentTitle ( CComBSTR& bstrTitle );
  60. HRESULT GetDivOnCr ( VARIANT_BOOL *pVal );
  61. HRESULT SetDivOnCr ( VARIANT_BOOL newVal );
  62. HRESULT GetBusy ( VARIANT_BOOL *pVal );
  63. HRESULT RefreshDoc ( void );
  64. HRESULT HrTridentSetPropBool(ULONG cmd, BOOL bVal);
  65. HRESULT HrTridentGetPropBool(ULONG cmd, BOOL& bVal);
  66. HRESULT HrMapCommand(DHTMLEDITCMDID typeLibCmdID, ULONG* cmdID, const GUID** ppguidCmdGroup, BOOL* bpInParam);
  67. HRESULT HrExecCommand(const GUID* pguidCmdGroup, ULONG ucmdID, OLECMDEXECOPT cmdexecopt, VARIANT* pVarIn, VARIANT* pVarOut);
  68. HRESULT HrMapExecCommand(DHTMLEDITCMDID deCommand, OLECMDEXECOPT cmdexecopt, VARIANT* pVarIn, VARIANT* pVarOut);
  69. HRESULT HrExecGenericCommands(const GUID* pguidCmdGroup, ULONG cmdID, OLECMDEXECOPT cmdexecopt, LPVARIANT pVarInput, BOOL bOutParam);
  70. HRESULT HrExecGetBlockFmtNames(LPVARIANT pVarInput);
  71. HRESULT HrExecInsertTable(LPVARIANT pVarInput);
  72. HRESULT HrExecGetColor(DHTMLEDITCMDID deCommand, ULONG ulMappedCommand, LPVARIANT pVarOutput);
  73. HRESULT HrExecSetFontSize(LPVARIANT pVarInput);
  74. HRESULT HrQueryStatus(const GUID* pguidCmdGroup, ULONG ucmdID, OLECMDF* cmdf);
  75. HRESULT HrMapQueryStatus( DHTMLEDITCMDID ucmdID, DHTMLEDITCMDF* cmdf);
  76. HRESULT HrGetDoc(IHTMLDocument2 **ppDoc);
  77. HRESULT HrGetTableSafeArray(IDEInsertTableParam* pTable, LPVARIANT pVarIn);
  78. HRESULT HrTranslateAccelerator(LPMSG lpmsg);
  79. HRESULT HrHandleAccelerator(LPMSG lpmsg);
  80. HRESULT HrNudge(DENudgeDirection dir);
  81. HRESULT HrToggleAbsolutePositioned();
  82. HRESULT HrHyperLink();
  83. HRESULT HrIncreaseIndent();
  84. HRESULT HrDecreaseIndent();
  85. void UpdateObjectRects(void);
  86. void SetParent ( HWND hwndControl );
  87. void Show ( WPARAM nCmdShow );
  88. LRESULT OnSetFocus(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  89. void OnReadyStateChanged(READYSTATE readyState);
  90. inline CDHTMLSafe* GetControl() {
  91. return m_pCtl;
  92. };
  93. inline BOOL IsCreated() {
  94. return m_fCreated;
  95. };
  96. inline BOOL IsActivated() {
  97. return m_fActivated;
  98. };
  99. inline SAFEARRAY* GetMenuStrings() {
  100. return m_pMenuStrings;
  101. };
  102. inline SAFEARRAY* GetMenuStates() {
  103. return m_pMenuStates;
  104. };
  105. HRESULT GetContainer ( LPOLECONTAINER* ppContainer );
  106. HRESULT GetCurDocNameWOPath ( CComBSTR& bstrDocName );
  107. HRESULT GetBaseURL ( CComBSTR& bstrBaseURL );
  108. HRESULT SetBaseURL ( CComBSTR& bstrBaseURL );
  109. HRESULT GetFilteredStream ( IStream** ppStream );
  110. HRESULT GetSecurityURL (CComBSTR& bstrSecurityURL );
  111. protected:
  112. HRESULT HrSetRuntimeProperties();
  113. HRESULT HrSetDocLoadedProperties();
  114. HRESULT SetBaseURLFromBaseHref ( void );
  115. HRESULT SetBaseURLFromCurDocPath ( BOOL bfIsURL );
  116. HRESULT SetBaseURLFromURL ( const CComBSTR& bstrURL );
  117. HRESULT SetBaseURLFromFileName ( const CComBSTR& bstrFName );
  118. HRESULT SetBaseUrlFromFileUrlComponents ( URL_COMPONENTS & urlc );
  119. HRESULT SetBaseUrlFromUrlComponents ( URL_COMPONENTS & urlc );
  120. typedef enum TriEditState {
  121. ESTATE_NOTCREATED = 0,
  122. ESTATE_CREATED,
  123. ESTATE_PREACTIVATING,
  124. ESTATE_ACTIVATING,
  125. ESTATE_ACTIVATED,
  126. } TriEditState;
  127. void ChangeState(TriEditState state) { m_state = state; }
  128. inline TriEditState GetState() { return m_state; }
  129. HRESULT GetSelectionPos ( LPPOINT lpWhere );
  130. public: // properties
  131. HRESULT HrSetPropActivateControls(BOOL activateControls);
  132. HRESULT HrGetPropActivateControls(BOOL& activateControls);
  133. HRESULT HrSetPropActivateApplets(BOOL activateApplets);
  134. HRESULT HrGetPropActivateApplets(BOOL& activateApplets);
  135. HRESULT HrSetPropActivateDTCs(BOOL activateDTCs);
  136. HRESULT HrGetPropActivateDTCs(BOOL& activateDTCs);
  137. HRESULT HrSetPropShowAllTags(BOOL showAllTags);
  138. HRESULT HrGetPropShowAllTags(BOOL& showAllTags);
  139. HRESULT HrSetPropShowBorders(BOOL showBorders);
  140. HRESULT HrGetPropShowBorders(BOOL& showBorders);
  141. HRESULT HrSetDisplay3D(BOOL bVal);
  142. HRESULT HrGetDisplay3D(BOOL& bVal);
  143. HRESULT HrSetScrollbars(BOOL bVal);
  144. HRESULT HrGetScrollbars(BOOL& bVal);
  145. HRESULT HrSetDisplayFlatScrollbars(BOOL bVal);
  146. HRESULT HrGetDisplayFlatScrollbars(BOOL& bVal);
  147. HRESULT HrSetDocumentHTML(BSTR bVal);
  148. HRESULT HrGetDocumentHTML(BSTR* bVal);
  149. HRESULT HrSetPreserveSource(BOOL bVal);
  150. HRESULT HrGetPreserveSource(BOOL& bVal);
  151. HRESULT HrSetAbsoluteDropMode(BOOL dropMode);
  152. HRESULT HrGetAbsoluteDropMode(BOOL& dropMode);
  153. HRESULT HrSetSnapToGrid(BOOL snapToGrid);
  154. HRESULT HrGetSnapToGrid(BOOL& snapToGrid);
  155. HRESULT HrSetSnapToGridX(LONG snapToGridX);
  156. HRESULT HrGetSnapToGridX(LONG& snapToGridX);
  157. HRESULT HrSetSnapToGridY(LONG snapToGridY);
  158. HRESULT HrGetSnapToGridY(LONG& snapToGridY);
  159. HRESULT HrGetIsDirty(BOOL& bVal);
  160. HRESULT HrGetCurrentDocumentPath(BSTR* bVal);
  161. // IBindStatusCallback trivial implementation, for synchronous transfer ONLY:
  162. STDMETHOD(GetBindInfo)(DWORD*,BINDINFO*) { return E_NOTIMPL; }
  163. STDMETHOD(OnStartBinding)(DWORD, IBinding*) { return S_OK; }
  164. STDMETHOD(GetPriority)(LONG *pnPriority) { *pnPriority = THREAD_PRIORITY_NORMAL; return S_OK; }
  165. STDMETHOD(OnProgress)(ULONG, ULONG, ULONG, LPCWSTR);
  166. STDMETHOD(OnDataAvailable)(DWORD, DWORD, FORMATETC*, STGMEDIUM*) { return E_NOTIMPL; }
  167. STDMETHOD(OnObjectAvailable)(REFIID, IUnknown*) { return E_NOTIMPL; }
  168. STDMETHOD(OnLowResource)(DWORD) { return E_NOTIMPL; }
  169. STDMETHOD(OnStopBinding)(HRESULT, LPCWSTR) { return S_OK; }
  170. // IAuthenticate
  171. STDMETHOD(Authenticate)(HWND *phwnd, LPWSTR *pszUserName, LPWSTR *pszPassword)
  172. { *phwnd = m_hWndObj; *pszUserName = NULL; *pszPassword = NULL; return S_OK; }
  173. public:
  174. //Shared IUnknown implementation
  175. STDMETHODIMP QueryInterface(REFIID, void **);
  176. STDMETHODIMP_(ULONG) AddRef(void);
  177. STDMETHODIMP_(ULONG) Release(void);
  178. //IOleInPlaceFrame implementation
  179. STDMETHODIMP GetWindow(HWND *);
  180. STDMETHODIMP ContextSensitiveHelp(BOOL);
  181. STDMETHODIMP GetBorder(LPRECT);
  182. STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS);
  183. STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS);
  184. STDMETHODIMP SetActiveObject(LPOLEINPLACEACTIVEOBJECT
  185. , LPCOLESTR);
  186. STDMETHODIMP InsertMenus(HMENU, LPOLEMENUGROUPWIDTHS);
  187. STDMETHODIMP SetMenu(HMENU, HOLEMENU, HWND);
  188. STDMETHODIMP RemoveMenus(HMENU);
  189. STDMETHODIMP SetStatusText(LPCOLESTR);
  190. STDMETHODIMP EnableModeless(BOOL);
  191. STDMETHODIMP TranslateAccelerator(LPMSG, WORD);
  192. //IOleCommandTarget
  193. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds
  194. , OLECMD prgCmds[], OLECMDTEXT *pCmdText);
  195. STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID
  196. , DWORD nCmdexecopt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  197. HRESULT OnTriEditEvent ( const GUID& iidEventInterface, DISPID dispid );
  198. HWND GetDocWindow () { return m_hWndObj; }
  199. HRESULT GetScrollPos ( LPPOINT lpPos );
  200. HRESULT CheckCrossZoneSecurity ( BSTR url );
  201. HRESULT CheckCrossZoneSecurityOfSelection ( void );
  202. void ClearSFSRedirect ( void ) { m_bfSFSRedirect = FALSE; }
  203. BOOL GetSFSRedirect ( void ) { return m_bfSFSRedirect; }
  204. void ClearLoadingFlag ( void ) { m_bfIsLoading = FALSE; }
  205. private:
  206. HRESULT RegisterPluggableProtocol ( void );
  207. HRESULT UnRegisterPluggableProtocol ( void );
  208. HRESULT LoadBSTRDeferred ( BSTR bVal );
  209. void AssureActivated ( void );
  210. WCHAR* GetInitialHTML ( void );
  211. void InitializeDocString ( void ) { m_bstrInitialDoc = GetInitialHTML (); }
  212. BOOL IsMissingBackSlash ( BSTR path, BOOL bfIsURL );
  213. HRESULT SetDirtyFlag ( BOOL bfMakeDirty );
  214. #ifdef LATE_BIND_URLMON_WININET
  215. BOOL DynLoadLibraries ( void );
  216. void DynUnloadLibraries ( void );
  217. #endif // LATE_BIND_URLMON_WININET
  218. private:
  219. ULONG m_cRef;
  220. TriEditState m_state;
  221. class CDHTMLSafe*m_pCtl; // back pointer to control
  222. class CSite* m_pSite; // Site holding object
  223. BOOL m_fCreated;
  224. BOOL m_fActivated;
  225. LPUNKNOWN m_pUnkTriEdit;
  226. IOleInPlaceActiveObject *m_pIOleIPActiveObject;
  227. HWND m_hWndObj; // Trident's window
  228. READYSTATE m_readyState;
  229. DWORD m_dwFilterFlags; // Flags to use for the next filter in
  230. DWORD m_dwFilterOutFlags; // Flags used on the last filter out
  231. SAFEARRAY* m_pMenuStrings;
  232. SAFEARRAY* m_pMenuStates;
  233. BOOL m_fActivateApplets; // takes affect at init only
  234. BOOL m_fActivateControls; // takes affect at init only
  235. BOOL m_fActivateDTCs; // takes affect at init only
  236. BOOL m_fShowAllTags; // can be set anytime
  237. BOOL m_fShowBorders; // can be set anytime
  238. BOOL m_fDialogEditing; // takes affect at init only
  239. BOOL m_fDisplay3D; // takes affect at init only
  240. BOOL m_fScrollbars; // takes affect at init only
  241. BOOL m_fDisplayFlatScrollbars; // takes affect at init only
  242. BOOL m_fContextMenu; // takes affect at init only
  243. BOOL m_fPreserveSource; // takes affect at init only
  244. BOOL m_fAbsoluteDropMode;
  245. BOOL m_fSnapToGrid;
  246. LONG m_ulSnapToGridX;
  247. LONG m_ulSnapToGridY;
  248. CComBSTR m_bstrInitialDoc;
  249. CComBSTR m_bstrCurDocPath;
  250. CComBSTR m_bstrBaseURL;
  251. VARIANT_BOOL m_vbBrowseMode;
  252. PProtocolInfo m_pProtInfo;
  253. WCHAR m_wszProtocol[16];
  254. WCHAR m_wszProtocolPrefix[16];
  255. BOOL m_bfIsURL;
  256. CComBSTR m_bstrLoadText;
  257. HWND m_hwndRestoreFocus;
  258. VARIANT_BOOL m_vbUseDivOnCr;
  259. BOOL m_bfIsLoading;
  260. BOOL m_bfBaseURLFromBASETag;
  261. BOOL m_bfPreserveDirtyFlagAcrossBrowseMode;
  262. HRESULT m_hrDeferredLoadError;
  263. BOOL m_bfModeSwitched;
  264. BOOL m_bfReloadAttempted;
  265. BOOL m_bfSFSRedirect;
  266. #ifdef LATE_BIND_URLMON_WININET
  267. HMODULE m_hUlrMon;
  268. HMODULE m_hWinINet;
  269. public:
  270. PFNCoInternetCombineUrl m_pfnCoInternetCombineUrl;
  271. PFNCoInternetParseUrl m_pfnCoInternetParseUrl;
  272. PFNCreateURLMoniker m_pfnCreateURLMoniker;
  273. PFNCoInternetGetSession m_pfnCoInternetGetSession;
  274. PFNURLOpenBlockingStream m_pfnURLOpenBlockingStream;
  275. PFNDeleteUrlCacheEntry m_pfnDeleteUrlCacheEntry;
  276. PFNInternetCreateUrl m_pfnInternetCreateUrl;
  277. PFNInternetCrackURL m_pfnInternetCrackUrl;
  278. #endif // LATE_BIND_URLMON_WININET
  279. };
  280. #endif