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.

470 lines
12 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1999 **
  4. //*********************************************************************
  5. //
  6. // IOSITE.CPP - Implementation of IOleSite
  7. //
  8. // HISTORY:
  9. //
  10. // 1/27/99 a-jaswed Created.
  11. //
  12. // Class which will provide the an IOleSite to the WebOC
  13. #include <windows.h>
  14. #include <assert.h>
  15. #include <tchar.h>
  16. #include <exdispid.h>
  17. #include <mshtmhst.h>
  18. #include <oleacc.h>
  19. #include <mshtmdid.h>
  20. #include "iosite.h"
  21. #include "appdefs.h"
  22. #include "util.h"
  23. /////////////////////////////////////////////////////////////
  24. // COleSite::COleSite
  25. COleSite::COleSite (void)
  26. {
  27. // Init member vars
  28. m_cRef = 0;
  29. m_hWnd = NULL;
  30. m_hwndIPObj = NULL;
  31. m_lpInPlaceObject = NULL;
  32. m_fScrolling = FALSE;
  33. m_bIsOEMDebug = IsOEMDebugMode();
  34. m_pOleInPlaceFrame = new COleInPlaceFrame (this);
  35. m_pOleInPlaceSite = new COleInPlaceSite (this);
  36. m_pOleClientSite = new COleClientSite (this);
  37. // Create a storage file for creating/embedding an OLE oject into this site
  38. StgCreateDocfile (NULL,
  39. STGM_READWRITE |
  40. STGM_TRANSACTED |
  41. STGM_SHARE_EXCLUSIVE |
  42. STGM_DELETEONRELEASE,
  43. 0,
  44. &m_lpStorage);
  45. RECT rectWorkArea;
  46. SystemParametersInfo(SPI_GETWORKAREA, 0, (void*)&rectWorkArea, 0);
  47. //If the window is too short it should have a scrollbar
  48. if(rectWorkArea.bottom < MSN_HEIGHT)
  49. m_fScrolling = TRUE;
  50. AddRef();
  51. }
  52. /////////////////////////////////////////////////////////////
  53. // COleSite::~COleSite
  54. COleSite::~COleSite ()
  55. {
  56. if(m_pOleInPlaceFrame)
  57. {
  58. m_pOleInPlaceFrame->Release();
  59. m_pOleInPlaceFrame = NULL;
  60. }
  61. if(m_pOleInPlaceSite)
  62. {
  63. m_pOleInPlaceSite->Release();
  64. m_pOleInPlaceSite = NULL;
  65. }
  66. if(m_pOleClientSite)
  67. {
  68. m_pOleClientSite->Release();
  69. m_pOleClientSite = NULL;
  70. }
  71. if (m_lpStorage)
  72. {
  73. m_lpStorage->Release();
  74. m_lpStorage = NULL;
  75. }
  76. assert(m_cRef == 0);
  77. }
  78. /////////////////////////////////////////////////////////////
  79. // COleSite::QueryInterface
  80. STDMETHODIMP COleSite::QueryInterface(REFIID riid, LPVOID* ppvObj)
  81. {
  82. // must set out pointer parameters to NULL
  83. *ppvObj = NULL;
  84. if(riid == IID_IDocHostUIHandler)
  85. {
  86. AddRef();
  87. *ppvObj = (IDocHostUIHandler*)this;
  88. return ResultFromScode(S_OK);
  89. }
  90. if(riid == IID_IUnknown)
  91. {
  92. AddRef();
  93. *ppvObj = this;
  94. return ResultFromScode(S_OK);
  95. }
  96. if(riid == IID_IOleClientSite)
  97. {
  98. m_pOleClientSite->AddRef();
  99. *ppvObj = m_pOleClientSite;
  100. return ResultFromScode(S_OK);
  101. }
  102. if(riid == IID_IOleInPlaceSite)
  103. {
  104. m_pOleInPlaceSite->AddRef();
  105. *ppvObj = m_pOleInPlaceSite;
  106. return ResultFromScode(S_OK);
  107. }
  108. if(riid == IID_IAccessible)
  109. {
  110. AddRef();
  111. *ppvObj = (IAccessible*)this;
  112. return ResultFromScode(S_OK);
  113. }
  114. if((riid == DIID_DWebBrowserEvents2) ||
  115. (riid == IID_IDispatch))
  116. {
  117. AddRef();
  118. *ppvObj = (LPVOID)(IUnknown*)(DWebBrowserEvents2*)this;
  119. return ResultFromScode(S_OK);
  120. }
  121. if(riid == IID_IServiceProvider)
  122. {
  123. AddRef();
  124. *ppvObj = (IServiceProvider*)this;
  125. return ResultFromScode(S_OK);
  126. }
  127. // Not a supported interface
  128. return ResultFromScode(E_NOINTERFACE);
  129. }
  130. /////////////////////////////////////////////////////////////
  131. // COleSite::AddRef
  132. STDMETHODIMP_(ULONG) COleSite::AddRef()
  133. {
  134. return ++m_cRef;
  135. }
  136. /////////////////////////////////////////////////////////////
  137. // COleSite::Release
  138. STDMETHODIMP_(ULONG) COleSite::Release()
  139. {
  140. --m_cRef;
  141. if (m_cRef == 0)
  142. {
  143. delete this;
  144. return 0;
  145. }
  146. return m_cRef;
  147. }
  148. /////////////////////////////////////////////////////////////
  149. // COleSite::QueryService
  150. STDMETHODIMP COleSite::QueryService (REFGUID guidService, REFIID riid, void** ppvService)
  151. {
  152. // must set out pointer parameters to NULL
  153. *ppvService = NULL;
  154. //Is MSHTML looking for a custom security manager?
  155. if((guidService == SID_SInternetSecurityManager) &&
  156. (riid == IID_IInternetSecurityManager))
  157. {
  158. AddRef();
  159. *ppvService = (IInternetSecurityManager*)this;
  160. return ResultFromScode(S_OK);
  161. }
  162. // Not a supported service
  163. return ResultFromScode(E_NOTIMPL);
  164. }
  165. /////////////////////////////////////////////////////////////
  166. // COleSite::GetHostInfo
  167. HRESULT COleSite::GetHostInfo( DOCHOSTUIINFO* pInfo )
  168. {
  169. pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
  170. pInfo->dwFlags = DOCHOSTUIFLAG_DIALOG |
  171. DOCHOSTUIFLAG_NO3DBORDER |
  172. DOCHOSTUIFLAG_DISABLE_HELP_MENU;
  173. if(!m_fScrolling)
  174. pInfo->dwFlags |= DOCHOSTUIFLAG_SCROLL_NO;
  175. return S_OK;
  176. }
  177. /////////////////////////////////////////////////////////////
  178. // COleSite::ShowUI
  179. HRESULT COleSite::ShowUI
  180. (
  181. DWORD dwID,
  182. IOleInPlaceActiveObject* pActiveObject,
  183. IOleCommandTarget* pCommandTarget,
  184. IOleInPlaceFrame* pFrame,
  185. IOleInPlaceUIWindow* pDoc
  186. )
  187. {
  188. return S_OK;
  189. }
  190. /////////////////////////////////////////////////////////////
  191. // COleSite::HideUI
  192. HRESULT COleSite::HideUI(void)
  193. {
  194. return S_OK;
  195. }
  196. /////////////////////////////////////////////////////////////
  197. // COleSite::UpdateUI
  198. HRESULT COleSite::UpdateUI(void)
  199. {
  200. return S_OK;
  201. }
  202. /////////////////////////////////////////////////////////////
  203. // COleSite::EnableModeless
  204. HRESULT COleSite::EnableModeless(BOOL fEnable)
  205. {
  206. if( fEnable )
  207. UpdateWindow ( m_hWnd );
  208. return S_OK;
  209. }
  210. /////////////////////////////////////////////////////////////
  211. // COleSite::OnDocWindowActivate
  212. HRESULT COleSite::OnDocWindowActivate(BOOL fActivate)
  213. {
  214. return E_NOTIMPL;
  215. }
  216. /////////////////////////////////////////////////////////////
  217. // COleSite::OnFrameWindowActivate
  218. HRESULT COleSite::OnFrameWindowActivate(BOOL fActivate)
  219. {
  220. return E_NOTIMPL;
  221. }
  222. /////////////////////////////////////////////////////////////
  223. // COleSite::ResizeBorder
  224. HRESULT COleSite::ResizeBorder(
  225. LPCRECT prcBorder,
  226. IOleInPlaceUIWindow* pUIWindow,
  227. BOOL fRameWindow)
  228. {
  229. return E_NOTIMPL;
  230. }
  231. /////////////////////////////////////////////////////////////
  232. // COleSite::ShowContextMenu
  233. HRESULT COleSite::ShowContextMenu(
  234. DWORD /*dwID*/,
  235. POINT* /*pptPosition*/,
  236. IUnknown* /*pCommandTarget*/,
  237. IDispatch* /*pDispatchObjectHit*/)
  238. {
  239. #ifdef DEBUG
  240. return E_NOTIMPL;
  241. #else
  242. return S_OK; // We've shown our own context menu. MSHTML.DLL will no longer try to show its own.
  243. #endif
  244. }
  245. /////////////////////////////////////////////////////////////
  246. // COleSite::TranslateAccelerator
  247. HRESULT COleSite::TranslateAccelerator(LPMSG lpMsg,
  248. /* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
  249. /* [in] */ DWORD nCmdID)
  250. {
  251. return ResultFromScode(S_FALSE);
  252. }
  253. /////////////////////////////////////////////////////////////
  254. // COleSite::GetOptionKeyPath
  255. HRESULT COleSite::GetOptionKeyPath(BSTR* pbstrKey, DWORD)
  256. {
  257. return E_NOTIMPL;
  258. }
  259. /////////////////////////////////////////////////////////////
  260. // COleSite::GetDropTarget
  261. STDMETHODIMP COleSite::GetDropTarget(
  262. /* [in] */ IDropTarget __RPC_FAR *pDropTarget,
  263. /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget)
  264. {
  265. return E_NOTIMPL;
  266. }
  267. /////////////////////////////////////////////////////////////
  268. // COleSite::GetExternal
  269. STDMETHODIMP COleSite::GetExternal(
  270. /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch)
  271. {
  272. // return the IDispatch we have for extending the object Model
  273. // "window.external" from script
  274. m_pExternalInterface->AddRef();
  275. *ppDispatch = m_pExternalInterface;
  276. return S_OK;
  277. }
  278. /////////////////////////////////////////////////////////////
  279. // COleSite::GetIDsOfNames
  280. STDMETHODIMP COleSite::GetIDsOfNames(
  281. /* [in] */ REFIID riid,
  282. /* [size_is][in] */ OLECHAR** rgszNames,
  283. /* [in] */ UINT cNames,
  284. /* [in] */ LCID lcid,
  285. /* [size_is][out] */ DISPID* rgDispId)
  286. {
  287. rgDispId[0] = DISPID_UNKNOWN;
  288. // Set the disid's for the parameters
  289. if (cNames > 1)
  290. {
  291. // Set a DISPID for function parameters
  292. for (UINT i = 1; i < cNames ; i++)
  293. rgDispId[i] = DISPID_UNKNOWN;
  294. }
  295. return DISP_E_UNKNOWNNAME;
  296. }
  297. /////////////////////////////////////////////////////////////
  298. // COleSite::TranslateUrl
  299. STDMETHODIMP COleSite::TranslateUrl(
  300. /* [in] */ DWORD dwTranslate,
  301. /* [in] */ OLECHAR __RPC_FAR *pchURLIn,
  302. /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut)
  303. {
  304. return E_NOTIMPL;
  305. }
  306. /////////////////////////////////////////////////////////////
  307. // COleSite::FilterDataObject
  308. STDMETHODIMP COleSite::FilterDataObject(
  309. /* [in] */ IDataObject __RPC_FAR *pDO,
  310. /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet)
  311. {
  312. return E_NOTIMPL;
  313. }
  314. STDMETHODIMP COleSite::SetExternalInterface (IDispatch* pUnk)
  315. {
  316. m_pExternalInterface = pUnk;
  317. return S_OK;
  318. }
  319. HRESULT COleSite::GetTypeInfoCount(UINT* pcInfo)
  320. {
  321. return E_NOTIMPL;
  322. }
  323. HRESULT COleSite::GetTypeInfo(UINT, LCID, ITypeInfo**)
  324. {
  325. return E_NOTIMPL;
  326. }
  327. /////////////////////////////////////////////////////////////
  328. // COleSite::Invoke
  329. HRESULT COleSite::Invoke
  330. (
  331. DISPID dispidMember,
  332. REFIID riid,
  333. LCID lcid,
  334. WORD wFlags,
  335. DISPPARAMS FAR* pdispparams,
  336. VARIANT FAR* pvarResult,
  337. EXCEPINFO FAR* pexcepinfo,
  338. UINT FAR* puArgErr
  339. )
  340. {
  341. HRESULT hr = DISP_E_MEMBERNOTFOUND;
  342. if (!m_bIsOEMDebug)
  343. {
  344. switch(dispidMember)
  345. {
  346. case DISPID_AMBIENT_DLCONTROL:
  347. {
  348. if (pvarResult != NULL)
  349. {
  350. VariantInit(pvarResult);
  351. V_VT(pvarResult) = VT_I4;
  352. pvarResult->lVal = DLCTL_DLIMAGES| DLCTL_VIDEOS| DLCTL_BGSOUNDS |DLCTL_SILENT;
  353. }
  354. hr = S_OK;
  355. }
  356. }
  357. }
  358. return hr;
  359. }
  360. HRESULT COleSite::GetSecurityId(LPCWSTR pwszUrl, BYTE __RPC_FAR *pbSecurityId, DWORD __RPC_FAR *pcbSecurityId, DWORD_PTR dwReserved)
  361. {
  362. return INET_E_DEFAULT_ACTION;
  363. }
  364. HRESULT COleSite::GetSecuritySite(IInternetSecurityMgrSite __RPC_FAR *__RPC_FAR *ppSite)
  365. {
  366. return INET_E_DEFAULT_ACTION;
  367. }
  368. HRESULT COleSite::SetSecuritySite(IInternetSecurityMgrSite __RPC_FAR *pSite)
  369. {
  370. return S_OK;
  371. }
  372. HRESULT COleSite::MapUrlToZone(LPCWSTR pwszUrl, DWORD __RPC_FAR *pdwZone, DWORD dwFlags)
  373. {
  374. return INET_E_DEFAULT_ACTION;
  375. }
  376. HRESULT COleSite::ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE __RPC_FAR *pPolicy, DWORD cbPolicy, BYTE __RPC_FAR *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved)
  377. {
  378. // *DO NOT CHANGE THIS RETURN VALUE*
  379. // This is what allows us to override IE.
  380. switch (dwAction)
  381. {
  382. case URLACTION_CROSS_DOMAIN_DATA:
  383. case URLACTION_HTML_SUBMIT_FORMS:
  384. case URLACTION_HTML_SUBMIT_FORMS_FROM:
  385. case URLACTION_HTML_SUBMIT_FORMS_TO:
  386. case URLACTION_SCRIPT_OVERRIDE_SAFETY:
  387. case URLACTION_HTML_JAVA_RUN:
  388. case URLACTION_ACTIVEX_RUN:
  389. {
  390. return S_OK;
  391. }
  392. default:
  393. return INET_E_DEFAULT_ACTION;
  394. }
  395. }
  396. HRESULT COleSite::QueryCustomPolicy(LPCWSTR pwszUrl, REFGUID guidKey, BYTE __RPC_FAR *__RPC_FAR *ppPolicy, DWORD __RPC_FAR *pcbPolicy, BYTE __RPC_FAR *pContext, DWORD cbContext, DWORD dwReserved)
  397. {
  398. return INET_E_DEFAULT_ACTION;
  399. }
  400. HRESULT COleSite::GetZoneMappings(DWORD dwZone, IEnumString __RPC_FAR *__RPC_FAR *ppenumString, DWORD dwFlags)
  401. {
  402. return INET_E_DEFAULT_ACTION;
  403. }
  404. HRESULT COleSite::SetZoneMapping(DWORD dwZone, LPCWSTR lpszPattern, DWORD dwFlags)
  405. {
  406. return INET_E_DEFAULT_ACTION;
  407. }