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.

2115 lines
50 KiB

  1. // DHTMLEdit.cpp : Implementation of CDHTMLEdit and CDHTMLSafe
  2. // Copyright (c)1997-1999 Microsoft Corporation, All Rights Reserved
  3. #include "stdafx.h"
  4. #include "DHTMLEd.h"
  5. #include "DHTMLEdit.h"
  6. #include "proxyframe.h"
  7. #include "site.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CDHTMLSafe
  10. CDHTMLSafe::CDHTMLSafe()
  11. {
  12. m_bWindowOnly = TRUE; // A window is needed when we activate Trident.
  13. m_pFrame = NULL;
  14. m_piControlSite = NULL;
  15. m_fJustCreated = TRUE;
  16. m_piOuterEditCtl = (IDHTMLEdit*)-1; // Crash if we use this without properly initializing it.
  17. m_bfOuterEditUnknownTested = NULL;
  18. }
  19. CDHTMLSafe::~CDHTMLSafe()
  20. {
  21. }
  22. HRESULT CDHTMLSafe::FinalConstruct()
  23. {
  24. HRESULT hr E_FAIL;
  25. m_pFrame = new CProxyFrame(this);
  26. _ASSERTE(m_pFrame);
  27. if (NULL == m_pFrame)
  28. return E_OUTOFMEMORY;
  29. // not aggregating TriEdit -- don't get
  30. // reference to its pUnk;
  31. hr = m_pFrame->Init(NULL, NULL);
  32. _ASSERTE(SUCCEEDED(hr));
  33. if (FAILED(hr))
  34. {
  35. m_pFrame->Release ();
  36. m_pFrame = NULL;
  37. }
  38. return hr;
  39. }
  40. void CDHTMLSafe::FinalRelease()
  41. {
  42. if ( NULL != m_piControlSite )
  43. {
  44. m_piControlSite->Release ();
  45. m_piControlSite = NULL;
  46. }
  47. if (NULL != m_pFrame)
  48. {
  49. if (m_pFrame->IsCreated())
  50. {
  51. _ASSERTE(FALSE == m_pFrame->IsActivated());
  52. m_pFrame->Close();
  53. }
  54. m_pFrame->Release ();
  55. m_pFrame = NULL;
  56. }
  57. }
  58. HRESULT CDHTMLSafe::OnDraw(ATL_DRAWINFO& di)
  59. {
  60. HRESULT hr = S_OK;
  61. _ASSERTE(m_pFrame);
  62. if (NULL == m_pFrame)
  63. return E_UNEXPECTED;
  64. if (IsUserMode() == FALSE)
  65. {
  66. HBRUSH hgreyBrush = NULL;
  67. hgreyBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
  68. RECT& rc = *(RECT*)di.prcBounds;
  69. Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
  70. FillRect(di.hdcDraw, &rc, hgreyBrush);
  71. return S_OK;
  72. }
  73. else if (IsUserMode() && m_pFrame->IsCreated() == TRUE && m_pFrame->IsActivated() == FALSE)
  74. {
  75. _ASSERTE(m_bInPlaceActive == TRUE);
  76. hr = m_pFrame->LoadInitialDoc();
  77. }
  78. return hr;
  79. }
  80. LRESULT
  81. CDHTMLSafe::OnSize(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& lResult)
  82. {
  83. m_pFrame->UpdateObjectRects();
  84. lResult = TRUE;
  85. return 0;
  86. }
  87. STDMETHODIMP CDHTMLSafe::TranslateAccelerator(LPMSG lpmsg)
  88. {
  89. HRESULT hr = S_OK;
  90. hr = m_pFrame->HrTranslateAccelerator(lpmsg);
  91. return hr;
  92. }
  93. STDMETHODIMP CDHTMLSafe::OnMnemonic(LPMSG /*pMsg*/)
  94. {
  95. return S_FALSE;
  96. }
  97. STDMETHODIMP CDHTMLSafe::SetClientSite(IOleClientSite *pClientSite)
  98. {
  99. HRESULT hr = S_OK;
  100. if ( NULL == pClientSite )
  101. {
  102. _ASSERTE ( m_pFrame );
  103. if ( NULL != m_pFrame )
  104. {
  105. _ASSERTE(m_pFrame->IsCreated());
  106. hr = m_pFrame->Close();
  107. _ASSERTE(SUCCEEDED(hr));
  108. }
  109. }
  110. return IOleObject_SetClientSite ( pClientSite );
  111. }
  112. LRESULT
  113. CDHTMLSafe::OnDestroy(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*lResult*/)
  114. {
  115. HRESULT hr = S_OK;
  116. // This would, in turn, destroy the hosted Trident's window.
  117. if ( NULL != m_pFrame )
  118. {
  119. _ASSERTE(m_pFrame->IsCreated());
  120. _ASSERTE ( m_hWndCD );
  121. m_pFrame->SetParent ( NULL );
  122. }
  123. return hr;
  124. }
  125. LRESULT
  126. CDHTMLSafe::OnCreate(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*lResult*/)
  127. {
  128. if ( NULL != m_pFrame )
  129. {
  130. _ASSERTE(m_pFrame->IsCreated());
  131. _ASSERTE ( m_hWndCD );
  132. m_pFrame->SetParent ( m_hWndCD );
  133. }
  134. return 0;
  135. }
  136. LRESULT
  137. CDHTMLSafe::OnShow(UINT /*nMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*lResult*/)
  138. {
  139. if ( NULL != m_pFrame )
  140. {
  141. _ASSERTE(m_pFrame->IsCreated());
  142. m_pFrame->Show ( wParam );
  143. }
  144. return 0;
  145. }
  146. // Do our best to set the focus on the ControlSite.
  147. // m_piControlSite is obtained on demand, and released in FinalRelease.
  148. //
  149. void
  150. CDHTMLSafe::FocusSite ( BOOL bfGetFocus )
  151. {
  152. if ( NULL == m_piControlSite )
  153. {
  154. _ASSERTE ( m_spClientSite );
  155. if ( m_spClientSite )
  156. {
  157. m_spClientSite->QueryInterface ( IID_IOleControlSite, (void**)&m_piControlSite );
  158. }
  159. }
  160. if ( m_piControlSite )
  161. {
  162. m_piControlSite->OnFocus ( bfGetFocus );
  163. }
  164. }
  165. LRESULT
  166. CDHTMLSafe::OnSetFocus(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& lResult)
  167. {
  168. lResult = FALSE; // Pass it on to the default event handler if not handled by Frame.
  169. _ASSERTE ( m_pFrame );
  170. if ( NULL != m_pFrame )
  171. {
  172. // If its the Trident instance loosing the focus, let's not set it right back again!
  173. // Also, if it has not yet been UIActivated, don't risk inplace deactivationg with this:
  174. if ( m_pFrame->GetDocWindow() != (HWND)wParam )
  175. {
  176. FocusSite ( TRUE );
  177. return m_pFrame->OnSetFocus ( nMsg, wParam, lParam, lResult );
  178. }
  179. }
  180. return 0;
  181. }
  182. // This message is posted in OnReadyStateChanged.
  183. // This postpones firing DocumentComplete until MSHTML is actually complete.
  184. //
  185. LRESULT
  186. CDHTMLSafe::OnDocumentComplete(UINT /*nMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& lResult)
  187. {
  188. _ASSERTE ( DOCUMENT_COMPETE_SIGNATURE == wParam );
  189. if ( DOCUMENT_COMPETE_SIGNATURE == wParam )
  190. {
  191. lResult = TRUE;
  192. m_pFrame->ClearLoadingFlag ();
  193. Fire_DocumentComplete();
  194. }
  195. return 0;
  196. }
  197. STDMETHODIMP CDHTMLSafe::OnAmbientPropertyChange(DISPID /*dispID*/)
  198. {
  199. HRESULT hr = S_OK;
  200. // There may be some VB ambients we may want to handle here
  201. // in the future for VB debugging.
  202. return hr;
  203. }
  204. // IE5 security settings for Paste, and possibly for Copy and Cut, require that we call
  205. // ITHMLDocument2->execCommand for testing.
  206. //
  207. HRESULT CDHTMLSafe::SpecialEdit ( DHTMLEDITCMDID cmdID, OLECMDEXECOPT cmdexecopt )
  208. {
  209. HRESULT hr = S_OK;
  210. CComPtr<IHTMLDocument2> spDOM = NULL;
  211. VARIANT_BOOL vbResult = VARIANT_FALSE;
  212. CComBSTR bstrCommand;
  213. CComVariant varValue;
  214. // Regression: The point of SpecialEdit was to call execCommand rather than Exec for the
  215. // editing commands and allow Trident to do the corss-zone security checks, but this has
  216. // broken. (Bug 547802.) In response, we now check the cross-zone security of the current
  217. // selection ourselves. We stick with execCommand to minimize impact on behavior.
  218. hr = m_pFrame->CheckCrossZoneSecurityOfSelection ();
  219. if ( SUCCEEDED ( hr ) )
  220. {
  221. hr = get_DOM ( &spDOM );
  222. if ( SUCCEEDED ( hr ) )
  223. {
  224. switch ( cmdID )
  225. {
  226. case DECMD_CUT:
  227. bstrCommand = L"Cut";
  228. break;
  229. case DECMD_COPY:
  230. bstrCommand = L"Copy";
  231. break;
  232. case DECMD_PASTE:
  233. bstrCommand = L"Paste";
  234. break;
  235. default:
  236. return E_UNEXPECTED;
  237. }
  238. hr = spDOM->execCommand ( bstrCommand, cmdexecopt == OLECMDEXECOPT_PROMPTUSER, varValue, &vbResult );
  239. }
  240. }
  241. return hr;
  242. }
  243. // To be Safe for Scripting, restrict the range of cmdIDs to a known set.
  244. // Handle edit commands specially to utilize IE5's security settings.
  245. //
  246. STDMETHODIMP CDHTMLSafe::ExecCommand(DHTMLEDITCMDID cmdID, OLECMDEXECOPT cmdexecopt, LPVARIANT pInVar, LPVARIANT pOutVar)
  247. {
  248. HRESULT hr = S_OK;
  249. LPVARIANT _pVarIn = NULL;
  250. LPVARIANT _pVarOut = NULL;
  251. // It is valid for pVar to be VT_EMPTY (on a DECMD_GETXXX op) but not VT_ERROR
  252. if (pInVar && (V_VT(pInVar) != VT_ERROR))
  253. _pVarIn = pInVar;
  254. if (pOutVar && (V_VT(pOutVar) != VT_ERROR))
  255. _pVarOut = pOutVar;
  256. if ( ( cmdexecopt < OLECMDEXECOPT_DODEFAULT ) ||
  257. ( cmdexecopt > OLECMDEXECOPT_DONTPROMPTUSER ) )
  258. {
  259. return E_INVALIDARG;
  260. }
  261. // Special case for editing commands in Safe for Scripting version:
  262. if ( ( DECMD_CUT == cmdID ) || ( DECMD_COPY == cmdID ) || ( DECMD_PASTE == cmdID ) )
  263. {
  264. return SpecialEdit ( cmdID, cmdexecopt );
  265. }
  266. hr = m_pFrame->HrMapExecCommand(cmdID, cmdexecopt, _pVarIn, _pVarOut);
  267. return hr;
  268. }
  269. STDMETHODIMP CDHTMLSafe::QueryStatus(DHTMLEDITCMDID cmdID, DHTMLEDITCMDF* retval)
  270. {
  271. HRESULT hr = S_OK;
  272. hr = m_pFrame->HrMapQueryStatus(cmdID, retval);
  273. return hr;
  274. }
  275. // Get Document Object Model
  276. //
  277. STDMETHODIMP CDHTMLSafe::get_DOM(IHTMLDocument2 ** pVal)
  278. {
  279. HRESULT hr = S_OK;
  280. _ASSERTE(pVal);
  281. if (NULL == pVal)
  282. return E_INVALIDARG;
  283. *pVal = NULL;
  284. hr = m_pFrame->HrGetDoc(pVal);
  285. return hr;
  286. }
  287. STDMETHODIMP CDHTMLSafe::get_DocumentHTML(BSTR * pVal)
  288. {
  289. HRESULT hr = S_OK;
  290. _ASSERTE(pVal);
  291. _ASSERTE(m_pFrame);
  292. if (!pVal)
  293. return E_INVALIDARG;
  294. hr = m_pFrame->HrGetDocumentHTML(pVal);
  295. return hr;
  296. }
  297. STDMETHODIMP CDHTMLSafe::put_DocumentHTML(BSTR newVal)
  298. {
  299. HRESULT hr = S_OK;
  300. _ASSERTE(m_pFrame);
  301. hr = m_pFrame->HrSetDocumentHTML(newVal);
  302. if ( SUCCEEDED ( hr ) )
  303. {
  304. SetDirty ( TRUE );
  305. FireOnChanged ( DISPID_DOCUMENTHTML );
  306. }
  307. return hr;
  308. }
  309. STDMETHODIMP CDHTMLSafe::get_ActivateApplets(VARIANT_BOOL * pVal)
  310. {
  311. HRESULT hr = S_OK;
  312. BOOL bVal = FALSE;
  313. _ASSERTE(pVal);
  314. _ASSERTE(m_pFrame);
  315. if (!pVal)
  316. return E_INVALIDARG;
  317. hr = m_pFrame->HrGetPropActivateApplets(bVal);
  318. #pragma warning(disable: 4310) // cast truncates constant value
  319. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  320. #pragma warning(default: 4310) // cast truncates constant value
  321. return hr;
  322. }
  323. STDMETHODIMP CDHTMLSafe::put_ActivateApplets(VARIANT_BOOL newVal)
  324. {
  325. HRESULT hr = S_OK;
  326. _ASSERTE(m_pFrame);
  327. hr = m_pFrame->HrSetPropActivateApplets(newVal);
  328. if ( SUCCEEDED ( hr ) )
  329. {
  330. SetDirty ( TRUE );
  331. FireOnChanged ( DISPID_ACTIVATEAPPLETS );
  332. }
  333. return hr;
  334. }
  335. STDMETHODIMP CDHTMLSafe::get_ActivateActiveXControls(VARIANT_BOOL * pVal)
  336. {
  337. HRESULT hr = S_OK;
  338. BOOL bVal = FALSE;
  339. _ASSERTE(pVal);
  340. _ASSERTE(m_pFrame);
  341. if (!pVal)
  342. return E_INVALIDARG;
  343. hr = m_pFrame->HrGetPropActivateControls(bVal);
  344. #pragma warning(disable: 4310) // cast truncates constant value
  345. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  346. #pragma warning(default: 4310) // cast truncates constant value
  347. return hr;
  348. }
  349. STDMETHODIMP CDHTMLSafe::put_ActivateActiveXControls(VARIANT_BOOL newVal)
  350. {
  351. HRESULT hr = S_OK;
  352. _ASSERTE(m_pFrame);
  353. hr = m_pFrame->HrSetPropActivateControls(newVal);
  354. if ( SUCCEEDED ( hr ) )
  355. {
  356. SetDirty ( TRUE );
  357. FireOnChanged ( DISPID_ACTIVATEACTIVEXCONTROLS );
  358. }
  359. return hr;
  360. }
  361. STDMETHODIMP CDHTMLSafe::get_ActivateDTCs(VARIANT_BOOL * pVal)
  362. {
  363. HRESULT hr = S_OK;
  364. BOOL bVal = FALSE;
  365. _ASSERTE(pVal);
  366. _ASSERTE(m_pFrame);
  367. if (!pVal)
  368. return E_INVALIDARG;
  369. hr = m_pFrame->HrGetPropActivateDTCs(bVal);
  370. #pragma warning(disable: 4310) // cast truncates constant value
  371. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  372. #pragma warning(default: 4310) // cast truncates constant value
  373. return hr;
  374. }
  375. STDMETHODIMP CDHTMLSafe::put_ActivateDTCs(VARIANT_BOOL newVal)
  376. {
  377. HRESULT hr = S_OK;
  378. _ASSERTE(m_pFrame);
  379. hr = m_pFrame->HrSetPropActivateDTCs(newVal);
  380. if ( SUCCEEDED ( hr ) )
  381. {
  382. SetDirty ( TRUE );
  383. FireOnChanged ( DISPID_ACTIVATEDTCS );
  384. }
  385. return hr;
  386. }
  387. STDMETHODIMP CDHTMLSafe::get_ShowDetails(VARIANT_BOOL * pVal)
  388. {
  389. HRESULT hr = S_OK;
  390. BOOL bVal = FALSE;
  391. _ASSERTE(pVal);
  392. _ASSERTE(m_pFrame);
  393. if (!pVal)
  394. return E_INVALIDARG;
  395. hr = m_pFrame->HrGetPropShowAllTags(bVal);
  396. #pragma warning(disable: 4310) // cast truncates constant value
  397. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  398. #pragma warning(default: 4310) // cast truncates constant value
  399. return hr;
  400. }
  401. STDMETHODIMP CDHTMLSafe::put_ShowDetails(VARIANT_BOOL newVal)
  402. {
  403. _ASSERTE(m_pFrame);
  404. SetDirty ( TRUE );
  405. FireOnChanged ( DISPID_SHOWDETAILS );
  406. return m_pFrame->HrSetPropShowAllTags(newVal);
  407. }
  408. STDMETHODIMP CDHTMLSafe::get_ShowBorders(VARIANT_BOOL * pVal)
  409. {
  410. HRESULT hr = S_OK;
  411. BOOL bVal = FALSE;
  412. _ASSERTE(pVal);
  413. _ASSERTE(m_pFrame);
  414. if (!pVal)
  415. return E_INVALIDARG;
  416. hr = m_pFrame->HrGetPropShowBorders(bVal);
  417. #pragma warning(disable: 4310) // cast truncates constant value
  418. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  419. #pragma warning(default: 4310) // cast truncates constant value
  420. return hr;
  421. }
  422. STDMETHODIMP CDHTMLSafe::put_ShowBorders(VARIANT_BOOL newVal)
  423. {
  424. HRESULT hr = S_OK;
  425. _ASSERTE(m_pFrame);
  426. hr = m_pFrame->HrSetPropShowBorders(newVal);
  427. if ( SUCCEEDED ( hr ) )
  428. {
  429. SetDirty ( TRUE );
  430. FireOnChanged ( DISPID_SHOWBORDERS );
  431. }
  432. return hr;
  433. }
  434. STDMETHODIMP CDHTMLSafe::get_Appearance(DHTMLEDITAPPEARANCE * pVal)
  435. {
  436. HRESULT hr = S_OK;
  437. BOOL bVal = FALSE;
  438. _ASSERTE(pVal);
  439. _ASSERTE(m_pFrame);
  440. if (!pVal)
  441. return E_INVALIDARG;
  442. hr = m_pFrame->HrGetDisplay3D(bVal);
  443. *pVal = (bVal) ? DEAPPEARANCE_3D : DEAPPEARANCE_FLAT;
  444. return hr;
  445. }
  446. STDMETHODIMP CDHTMLSafe::put_Appearance(DHTMLEDITAPPEARANCE newVal)
  447. {
  448. HRESULT hr = S_OK;
  449. BOOL bVal = (newVal == DEAPPEARANCE_3D) ? TRUE : FALSE;
  450. _ASSERTE(m_pFrame);
  451. hr = m_pFrame->HrSetDisplay3D(bVal);
  452. if ( SUCCEEDED ( hr ) )
  453. {
  454. SetDirty ( TRUE );
  455. FireOnChanged ( DISPID_DHTMLEDITAPPEARANCE );
  456. }
  457. return hr;
  458. }
  459. STDMETHODIMP CDHTMLSafe::get_Scrollbars(VARIANT_BOOL * pVal)
  460. {
  461. HRESULT hr = S_OK;
  462. BOOL bVal = FALSE;
  463. _ASSERTE(pVal);
  464. _ASSERTE(m_pFrame);
  465. if (!pVal)
  466. return E_INVALIDARG;
  467. hr = m_pFrame->HrGetScrollbars(bVal);
  468. #pragma warning(disable: 4310) // cast truncates constant value
  469. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  470. #pragma warning(default: 4310) // cast truncates constant value
  471. return hr;
  472. }
  473. STDMETHODIMP CDHTMLSafe::put_Scrollbars(VARIANT_BOOL newVal)
  474. {
  475. HRESULT hr = S_OK;
  476. _ASSERTE(m_pFrame);
  477. hr = m_pFrame->HrSetScrollbars(newVal);
  478. if ( SUCCEEDED ( hr ) )
  479. {
  480. SetDirty ( TRUE );
  481. FireOnChanged ( DISPID_DHTMLEDITSCROLLBARS );
  482. }
  483. return hr;
  484. }
  485. STDMETHODIMP CDHTMLSafe::get_ScrollbarAppearance(DHTMLEDITAPPEARANCE * pVal)
  486. {
  487. HRESULT hr = S_OK;
  488. BOOL bVal = FALSE;
  489. _ASSERTE(pVal);
  490. _ASSERTE(m_pFrame);
  491. if (!pVal)
  492. return E_INVALIDARG;
  493. hr = m_pFrame->HrGetDisplayFlatScrollbars(bVal);
  494. *pVal = (bVal) ? DEAPPEARANCE_FLAT : DEAPPEARANCE_3D;
  495. return hr;
  496. }
  497. STDMETHODIMP CDHTMLSafe::put_ScrollbarAppearance(DHTMLEDITAPPEARANCE newVal)
  498. {
  499. HRESULT hr = S_OK;
  500. BOOL bVal = (newVal == DEAPPEARANCE_3D) ? FALSE : TRUE;
  501. _ASSERTE(m_pFrame);
  502. hr = m_pFrame->HrSetDisplayFlatScrollbars(bVal);
  503. if ( SUCCEEDED ( hr ) )
  504. {
  505. SetDirty ( TRUE );
  506. FireOnChanged ( DISPID_SCROLLBARAPPEARANCE );
  507. }
  508. return hr;
  509. }
  510. STDMETHODIMP CDHTMLSafe::get_SourceCodePreservation(VARIANT_BOOL * pVal)
  511. {
  512. HRESULT hr = S_OK;
  513. BOOL bVal = FALSE;
  514. _ASSERTE(pVal);
  515. _ASSERTE(m_pFrame);
  516. if (!pVal)
  517. return E_INVALIDARG;
  518. hr = m_pFrame->HrGetPreserveSource(bVal);
  519. #pragma warning(disable: 4310) // cast truncates constant value
  520. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  521. #pragma warning(default: 4310) // cast truncates constant value
  522. return hr;
  523. }
  524. STDMETHODIMP CDHTMLSafe::put_SourceCodePreservation(VARIANT_BOOL newVal)
  525. {
  526. HRESULT hr = S_OK;
  527. _ASSERTE(m_pFrame);
  528. hr = m_pFrame->HrSetPreserveSource(newVal);
  529. if ( SUCCEEDED ( hr ) )
  530. {
  531. SetDirty ( TRUE );
  532. FireOnChanged ( DISPID_SOURCECODEPRESERVATION );
  533. }
  534. return hr;
  535. }
  536. ///////////////////////////////////////
  537. STDMETHODIMP CDHTMLSafe::get_AbsoluteDropMode(VARIANT_BOOL* pVal)
  538. {
  539. HRESULT hr = S_OK;
  540. BOOL bVal = FALSE;
  541. _ASSERTE(pVal);
  542. _ASSERTE(m_pFrame);
  543. if (!pVal)
  544. return E_INVALIDARG;
  545. hr = m_pFrame->HrGetAbsoluteDropMode(bVal);
  546. #pragma warning(disable: 4310) // cast truncates constant value
  547. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  548. #pragma warning(default: 4310) // cast truncates constant value
  549. return hr;
  550. }
  551. STDMETHODIMP CDHTMLSafe::put_AbsoluteDropMode(VARIANT_BOOL newVal)
  552. {
  553. HRESULT hr = S_OK;
  554. _ASSERTE(m_pFrame);
  555. hr = m_pFrame->HrSetAbsoluteDropMode(newVal);
  556. if ( SUCCEEDED ( hr ) )
  557. {
  558. SetDirty ( TRUE );
  559. FireOnChanged ( DISPID_ABSOLUTEDROPMODE );
  560. }
  561. return hr;
  562. }
  563. STDMETHODIMP CDHTMLSafe::get_SnapToGrid(VARIANT_BOOL* pVal)
  564. {
  565. HRESULT hr = S_OK;
  566. BOOL bVal = FALSE;
  567. _ASSERTE(pVal);
  568. _ASSERTE(m_pFrame);
  569. if (!pVal)
  570. return E_INVALIDARG;
  571. hr = m_pFrame->HrGetSnapToGrid(bVal);
  572. #pragma warning(disable: 4310) // cast truncates constant value
  573. *pVal = (bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  574. #pragma warning(default: 4310) // cast truncates constant value
  575. return hr;
  576. }
  577. STDMETHODIMP CDHTMLSafe::put_SnapToGrid(VARIANT_BOOL newVal)
  578. {
  579. HRESULT hr = S_OK;
  580. _ASSERTE(m_pFrame);
  581. hr = m_pFrame->HrSetSnapToGrid(newVal);
  582. if ( SUCCEEDED ( hr ) )
  583. {
  584. SetDirty ( TRUE );
  585. FireOnChanged ( DISPID_SNAPTOGRID );
  586. }
  587. return hr;
  588. }
  589. STDMETHODIMP CDHTMLSafe::get_SnapToGridX(LONG* pVal)
  590. {
  591. HRESULT hr = S_OK;
  592. _ASSERTE(pVal);
  593. _ASSERTE(m_pFrame);
  594. if (!pVal)
  595. return E_INVALIDARG;
  596. hr = m_pFrame->HrGetSnapToGridX(*pVal);
  597. return hr;
  598. }
  599. STDMETHODIMP CDHTMLSafe::put_SnapToGridX(LONG newVal)
  600. {
  601. HRESULT hr = S_OK;
  602. _ASSERTE(m_pFrame);
  603. hr = m_pFrame->HrSetSnapToGridX(newVal);
  604. if ( SUCCEEDED ( hr ) )
  605. {
  606. SetDirty ( TRUE );
  607. FireOnChanged ( DISPID_SNAPTOGRIDX );
  608. }
  609. return hr;
  610. }
  611. STDMETHODIMP CDHTMLSafe::get_SnapToGridY(LONG* pVal)
  612. {
  613. HRESULT hr = S_OK;
  614. _ASSERTE(pVal);
  615. _ASSERTE(m_pFrame);
  616. if (!pVal)
  617. return E_INVALIDARG;
  618. hr = m_pFrame->HrGetSnapToGridY(*pVal);
  619. return hr;
  620. }
  621. STDMETHODIMP CDHTMLSafe::put_SnapToGridY(LONG newVal)
  622. {
  623. HRESULT hr = S_OK;
  624. _ASSERTE(m_pFrame);
  625. hr = m_pFrame->HrSetSnapToGridY(newVal);
  626. if ( SUCCEEDED ( hr ) )
  627. {
  628. SetDirty ( TRUE );
  629. FireOnChanged ( DISPID_SNAPTOGRIDY );
  630. }
  631. return hr;
  632. }
  633. STDMETHODIMP CDHTMLSafe::get_CurrentDocumentPath(BSTR * pVal)
  634. {
  635. HRESULT hr = S_OK;
  636. _ASSERTE(pVal);
  637. _ASSERTE(m_pFrame);
  638. if (!pVal)
  639. return E_INVALIDARG;
  640. hr = m_pFrame->HrGetCurrentDocumentPath(pVal);
  641. return hr;
  642. }
  643. STDMETHODIMP CDHTMLSafe::get_IsDirty(VARIANT_BOOL * pVal)
  644. {
  645. HRESULT hr = S_OK;
  646. BOOL bVal = FALSE;
  647. _ASSERTE(pVal);
  648. _ASSERTE(m_pFrame);
  649. if (NULL == pVal)
  650. return E_INVALIDARG;
  651. hr = m_pFrame->HrGetIsDirty(bVal);
  652. #pragma warning(disable: 4310) // cast truncates constant value
  653. *pVal = (TRUE == bVal) ? VARIANT_TRUE : VARIANT_FALSE;
  654. #pragma warning(default: 4310) // cast truncates constant value
  655. return hr;
  656. }
  657. STDMETHODIMP CDHTMLSafe::get_BaseURL(/* [retval][out] */ BSTR *baseURL)
  658. {
  659. HRESULT hr = S_OK;
  660. _ASSERTE(m_pFrame);
  661. _ASSERTE ( baseURL );
  662. if ( NULL == baseURL )
  663. {
  664. return E_INVALIDARG;
  665. }
  666. CComBSTR bstr;
  667. hr = m_pFrame->GetBaseURL ( bstr );
  668. if ( SUCCEEDED ( hr ) )
  669. {
  670. SysReAllocString ( baseURL, bstr );
  671. }
  672. return hr;
  673. }
  674. STDMETHODIMP CDHTMLSafe::put_BaseURL(/* [in] */ BSTR baseURL)
  675. {
  676. HRESULT hr = S_OK;
  677. _ASSERTE(m_pFrame);
  678. _ASSERTE ( baseURL );
  679. if ( NULL == baseURL )
  680. {
  681. return E_INVALIDARG;
  682. }
  683. CComBSTR bstr = baseURL;
  684. hr = m_pFrame->SetBaseURL ( bstr );
  685. if ( SUCCEEDED ( hr ) )
  686. {
  687. SetDirty ( TRUE );
  688. FireOnChanged ( DISPID_BASEURL );
  689. }
  690. return hr;
  691. }
  692. STDMETHODIMP CDHTMLSafe::get_DocumentTitle(/* [retval][out] */ BSTR *docTitle)
  693. {
  694. HRESULT hr = S_OK;
  695. _ASSERTE ( docTitle );
  696. _ASSERTE ( m_pFrame );
  697. if ( NULL == docTitle )
  698. {
  699. return E_INVALIDARG;
  700. }
  701. CComBSTR bstr;
  702. hr = m_pFrame->GetDocumentTitle ( bstr );
  703. if ( SUCCEEDED ( hr ) )
  704. {
  705. SysReAllocString ( docTitle, bstr );
  706. }
  707. return hr;
  708. }
  709. STDMETHODIMP CDHTMLSafe::get_UseDivOnCarriageReturn ( VARIANT_BOOL *pVal )
  710. {
  711. _ASSERTE ( pVal );
  712. if ( NULL == pVal )
  713. {
  714. return E_INVALIDARG;
  715. }
  716. return m_pFrame->GetDivOnCr ( pVal );
  717. }
  718. STDMETHODIMP CDHTMLSafe::get_Busy ( VARIANT_BOOL *pVal )
  719. {
  720. _ASSERTE ( pVal );
  721. if ( NULL == pVal )
  722. {
  723. return E_INVALIDARG;
  724. }
  725. return m_pFrame->GetBusy ( pVal );
  726. }
  727. STDMETHODIMP CDHTMLSafe::put_UseDivOnCarriageReturn ( VARIANT_BOOL newVal )
  728. {
  729. HRESULT hr = S_OK;
  730. hr = m_pFrame->SetDivOnCr( newVal );
  731. if ( SUCCEEDED ( hr ) )
  732. {
  733. SetDirty ( TRUE );
  734. FireOnChanged ( DISPID_USEDIVONCR );
  735. }
  736. return hr;
  737. }
  738. STDMETHODIMP CDHTMLSafe::SetContextMenu(/*[in]*/LPVARIANT menuStrings, /*[in]*/ LPVARIANT menuStates)
  739. {
  740. HRESULT hr = S_OK;
  741. hr = m_pFrame->SetContextMenu(menuStrings, menuStates);
  742. return hr;
  743. }
  744. STDMETHODIMP CDHTMLSafe::NewDocument ()
  745. {
  746. HRESULT hr = E_FAIL;
  747. _ASSERTE ( m_pFrame );
  748. if ( NULL == m_pFrame )
  749. {
  750. return E_UNEXPECTED;
  751. }
  752. hr = m_pFrame->LoadDocument( NULL );
  753. return hr;
  754. }
  755. STDMETHODIMP CDHTMLSafe::Refresh ()
  756. {
  757. HRESULT hr = E_FAIL;
  758. _ASSERTE ( m_pFrame );
  759. if ( NULL == m_pFrame )
  760. {
  761. return E_UNEXPECTED;
  762. }
  763. hr = m_pFrame->RefreshDoc ();
  764. return hr;
  765. }
  766. // In the safe for scripting version, only the http: protocol is permitted.
  767. //
  768. STDMETHODIMP CDHTMLSafe::LoadURL ( BSTR url )
  769. {
  770. HRESULT hr = S_OK;
  771. CComBSTR rbstrSafeProtocols[] = { L"http://", L"https://", L"ftp://" };
  772. _ASSERTE(url);
  773. _ASSERTE ( m_pFrame );
  774. if ( NULL == m_pFrame )
  775. {
  776. return E_UNEXPECTED;
  777. }
  778. if ( ( NULL == url ) || ( 0 == SysStringLen ( url ) ) )
  779. return E_INVALIDARG;
  780. // Check for the protocol:
  781. CComBSTR bstrURL = url;
  782. _wcslwr ( bstrURL.m_str );
  783. BOOL bfSafe = FALSE;
  784. for ( int iProtocol = 0;
  785. iProtocol < ( sizeof ( rbstrSafeProtocols ) / sizeof ( CComBSTR ) );
  786. iProtocol++ )
  787. {
  788. if ( 0 == wcsncmp ( bstrURL.m_str, rbstrSafeProtocols[iProtocol],
  789. rbstrSafeProtocols[iProtocol].Length () ) )
  790. {
  791. bfSafe = TRUE;
  792. break;
  793. }
  794. }
  795. hr = m_pFrame->CheckCrossZoneSecurity ( url );
  796. if ( SUCCEEDED ( hr ) )
  797. {
  798. hr = DE_E_UNKNOWN_PROTOCOL;
  799. if ( bfSafe )
  800. {
  801. hr = m_pFrame->LoadDocument( url, TRUE );
  802. }
  803. }
  804. return hr;
  805. }
  806. STDMETHODIMP CDHTMLSafe::FilterSourceCode(BSTR sourceCodeIn, BSTR* sourceCodeOut)
  807. {
  808. HRESULT hr;
  809. _ASSERTE ( sourceCodeIn );
  810. _ASSERTE ( sourceCodeOut );
  811. if ( ( NULL == sourceCodeIn ) || ( NULL == sourceCodeOut ) )
  812. {
  813. return E_INVALIDARG;
  814. }
  815. *sourceCodeOut = NULL;
  816. hr = m_pFrame->FilterSourceCode ( sourceCodeIn, sourceCodeOut );
  817. return hr;
  818. }
  819. // Override handler for IOleInPlaceObject->UIDeactivate to fire the blur event.
  820. //
  821. HRESULT CDHTMLSafe::IOleInPlaceObject_UIDeactivate ( void )
  822. {
  823. Fire_onblur();
  824. m_pFrame->UIDeactivate();
  825. return CComControlBase::IOleInPlaceObject_UIDeactivate ();
  826. }
  827. // Override IOleObjectImpl methods
  828. // We must set the object as dirty when resized
  829. //
  830. HRESULT CDHTMLSafe::IOleObject_SetExtent(DWORD dwDrawAspect, SIZEL *psizel)
  831. {
  832. if ((m_sizeExtent.cx != psizel->cx || m_sizeExtent.cy != psizel->cy) && !m_fJustCreated)
  833. SetDirty(TRUE);
  834. m_fJustCreated = FALSE;
  835. return CComControlBase::IOleObject_SetExtent(dwDrawAspect, psizel);
  836. }
  837. HRESULT CDHTMLSafe::IPersistStreamInit_Save(LPSTREAM pStm, BOOL fClearDirty, ATL_PROPMAP_ENTRY*)
  838. {
  839. return CComControlBase::IPersistStreamInit_Save ( pStm, fClearDirty, ProperPropMap() );
  840. }
  841. HRESULT CDHTMLSafe::IPersistStreamInit_Load(LPSTREAM pStm, ATL_PROPMAP_ENTRY*)
  842. {
  843. return CComControlBase::IPersistStreamInit_Load ( pStm, ProperPropMap() );
  844. }
  845. HRESULT CDHTMLSafe::IPersistPropertyBag_Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties, ATL_PROPMAP_ENTRY* )
  846. {
  847. return CComControlBase::IPersistPropertyBag_Save(pPropBag, fClearDirty, fSaveAllProperties, ProperPropMap());
  848. }
  849. HRESULT CDHTMLSafe::IPersistPropertyBag_Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog, ATL_PROPMAP_ENTRY*)
  850. {
  851. return CComControlBase::IPersistPropertyBag_Load(pPropBag, pErrorLog, ProperPropMap());
  852. }
  853. // We cannot QI for the OuterEditControl in the FinalConstruct, or we crash whenever
  854. // we're aggregated. So, we QI on demand.
  855. // Call this routine to get the outer control's unknown, never use m_piOuterEditCtl
  856. // directly.
  857. // NOTE:
  858. // This routine DOES NOT addref the interface returned! Do not release it!
  859. //
  860. IDHTMLEdit * CDHTMLSafe::GetOuterEditControl ()
  861. {
  862. if ( ! m_bfOuterEditUnknownTested )
  863. {
  864. m_bfOuterEditUnknownTested = TRUE;
  865. // Keep an un-addreffed pointer to the aggregating DHTMLEdit control, if it exists.
  866. if ( SUCCEEDED ( GetControllingUnknown()->QueryInterface ( IID_IDHTMLEdit, (void**)&m_piOuterEditCtl ) ) )
  867. {
  868. _ASSERTE ( m_piOuterEditCtl );
  869. m_piOuterEditCtl->Release ();
  870. }
  871. }
  872. _ASSERTE ( (IDHTMLEdit*)-1 != m_piOuterEditCtl );
  873. return m_piOuterEditCtl;
  874. }
  875. // There are two property maps to choose from.
  876. // Return the one for the DHTMLEdit control if it's aggregating us,
  877. // else return our own.
  878. //
  879. ATL_PROPMAP_ENTRY* CDHTMLSafe::ProperPropMap ()
  880. {
  881. IDHTMLEdit *piOuterEditControl = GetOuterEditControl ();
  882. if ( NULL == piOuterEditControl )
  883. {
  884. return CDHTMLSafe::GetPropertyMap();
  885. }
  886. else
  887. {
  888. return CDHTMLEdit::GetPropertyMap();
  889. }
  890. }
  891. // Return the appropriate CLSID, depending on whether we're the safe or unsafe control.
  892. //
  893. HRESULT CDHTMLSafe::GetClassID( CLSID *pClassID )
  894. {
  895. IDHTMLEdit *piOuterEditControl = GetOuterEditControl ();
  896. if ( NULL == piOuterEditControl )
  897. {
  898. *pClassID = CLSID_DHTMLSafe;
  899. }
  900. else
  901. {
  902. *pClassID = CLSID_DHTMLEdit;
  903. }
  904. return S_OK;
  905. }
  906. // The above redirecting of the PropertyMap doesn't work unless we override this method,
  907. // We keep an un-addref'd pointer to the aggregating DHTMLEdit control if available.
  908. // Addreffing it would cause a circular reference.
  909. //
  910. HRESULT CDHTMLSafe::ControlQueryInterface(const IID& iid, void** ppv)
  911. {
  912. HRESULT hr = S_OK;
  913. IDHTMLEdit *piOuterEditControl = GetOuterEditControl ();
  914. if ( NULL == piOuterEditControl )
  915. {
  916. hr = GetUnknown()->QueryInterface ( iid, ppv );
  917. }
  918. else
  919. {
  920. hr = piOuterEditControl->QueryInterface ( iid, ppv );
  921. }
  922. return hr;
  923. }
  924. ////////////////////////////////////////////////////
  925. //
  926. // Event sink
  927. //
  928. class ATL_NO_VTABLE CEventXferSink :
  929. public CComObjectRootEx<CComSingleThreadModel>,
  930. public _DHTMLSafeEvents
  931. {
  932. public:
  933. BEGIN_COM_MAP(CEventXferSink)
  934. COM_INTERFACE_ENTRY_IID(DIID__DHTMLSafeEvents, _DHTMLSafeEvents)
  935. END_COM_MAP()
  936. CEventXferSink ()
  937. {
  938. m_pCtl = NULL;
  939. }
  940. void SetOwner ( CDHTMLEdit* pCtl )
  941. {
  942. _ASSERTE ( pCtl );
  943. _ASSERTE ( NULL == m_pCtl );
  944. if ( NULL == m_pCtl )
  945. {
  946. m_pCtl = pCtl;
  947. }
  948. }
  949. STDMETHOD(GetTypeInfoCount) ( UINT * )
  950. {
  951. _ASSERTE ( FALSE );
  952. return E_NOTIMPL;
  953. }
  954. STDMETHOD(GetTypeInfo) ( UINT, LCID, ITypeInfo ** )
  955. {
  956. _ASSERTE ( FALSE );
  957. return E_NOTIMPL;
  958. }
  959. STDMETHOD(GetIDsOfNames) ( REFIID, OLECHAR **, UINT, LCID, DISPID * )
  960. {
  961. _ASSERTE ( FALSE );
  962. return E_NOTIMPL;
  963. }
  964. STDMETHOD(Invoke) ( DISPID dispid, REFIID, LCID, USHORT, DISPPARAMS *pDispParams, VARIANT* /*pVarResult*/, EXCEPINFO *, UINT * )
  965. {
  966. HRESULT hr = E_UNEXPECTED;
  967. _ASSERTE ( m_pCtl );
  968. if ( NULL != m_pCtl )
  969. {
  970. switch ( dispid )
  971. {
  972. case DISPID_DOCUMENTCOMPLETE:
  973. m_pCtl->Fire_DocumentComplete();
  974. break;
  975. case DISPID_DISPLAYCHANGED:
  976. m_pCtl->Fire_DisplayChanged ();
  977. break;
  978. case DISPID_SHOWCONTEXTMENU:
  979. {
  980. CComVariant varParam;
  981. long xPos = 0;
  982. long yPos = 0;
  983. unsigned int uiErr;
  984. // There should be exactly two parameters.
  985. _ASSERTE ( 2 == pDispParams->cArgs );
  986. if (2 == pDispParams->cArgs )
  987. {
  988. hr = DispGetParam( pDispParams, 1, VT_I4, &varParam, &uiErr );
  989. _ASSERTE ( SUCCEEDED ( hr ) );
  990. if ( SUCCEEDED ( hr ) )
  991. {
  992. yPos = varParam.lVal;
  993. hr = DispGetParam( pDispParams, 0, VT_I4, &varParam, &uiErr );
  994. _ASSERTE ( SUCCEEDED ( hr ) );
  995. if ( SUCCEEDED ( hr ) )
  996. {
  997. xPos = varParam.lVal;
  998. m_pCtl->Fire_ShowContextMenu ( xPos, yPos );
  999. }
  1000. }
  1001. }
  1002. break;
  1003. }
  1004. case DISPID_CONTEXTMENUACTION:
  1005. {
  1006. CComVariant varMenuIndex;
  1007. unsigned int uiErr;
  1008. // There should be exactly one parameter.
  1009. _ASSERTE ( 1 == pDispParams->cArgs );
  1010. if (1 == pDispParams->cArgs )
  1011. {
  1012. hr = DispGetParam( pDispParams, 0, VT_I4, &varMenuIndex, &uiErr );
  1013. _ASSERTE ( SUCCEEDED ( hr ) );
  1014. if ( SUCCEEDED ( hr ) )
  1015. {
  1016. long lMenuIndex = varMenuIndex.lVal;
  1017. m_pCtl->Fire_ContextMenuAction ( lMenuIndex );
  1018. }
  1019. }
  1020. break;
  1021. }
  1022. case DISPID_ONMOUSEDOWN:
  1023. m_pCtl->Fire_onmousedown ();
  1024. break;
  1025. case DISPID_ONMOUSEMOVE:
  1026. m_pCtl->Fire_onmousemove ();
  1027. break;
  1028. case DISPID_ONMOUSEUP:
  1029. m_pCtl->Fire_onmouseup ();
  1030. break;
  1031. case DISPID_ONMOUSEOUT:
  1032. m_pCtl->Fire_onmouseout ();
  1033. break;
  1034. case DISPID_ONMOUSEOVER:
  1035. m_pCtl->Fire_onmouseover ();
  1036. break;
  1037. case DISPID_ONCLICK:
  1038. m_pCtl->Fire_onclick ();
  1039. break;
  1040. case DISPID_ONDBLCLICK:
  1041. m_pCtl->Fire_ondblclick ();
  1042. break;
  1043. case DISPID_ONKEYDOWN:
  1044. m_pCtl->Fire_onkeydown ();
  1045. break;
  1046. case DISPID_ONKEYPRESS:
  1047. {
  1048. m_pCtl->Fire_onkeypress ();
  1049. #if 0
  1050. VARIANT_BOOL vbCancel;
  1051. vbCancel = m_pCtl->Fire_onkeypress ();
  1052. if ( NULL != pVarResult )
  1053. {
  1054. VariantClear ( pVarResult );
  1055. pVarResult->vt = VT_BOOL;
  1056. pVarResult->boolVal = vbCancel;
  1057. }
  1058. #endif
  1059. }
  1060. break;
  1061. case DISPID_ONKEYUP:
  1062. m_pCtl->Fire_onkeyup ();
  1063. break;
  1064. case DISPID_ONBLUR:
  1065. m_pCtl->Fire_onblur ();
  1066. break;
  1067. case DISPID_ONREADYSTATECHANGE:
  1068. m_pCtl->Fire_onreadystatechange ();
  1069. break;
  1070. default:
  1071. break;
  1072. }
  1073. }
  1074. return S_OK;
  1075. }
  1076. private:
  1077. CDHTMLEdit* m_pCtl;
  1078. };
  1079. ////////////////////////////////////////////////////
  1080. //
  1081. // CDHTMLEdit implementation
  1082. //
  1083. CDHTMLEdit::CDHTMLEdit()
  1084. {
  1085. m_punkInnerCtl = NULL; // Aggregated control's IUnknown
  1086. m_pInnerCtl = NULL; // Aggregated control's custome interface
  1087. m_pInnerIOleObj = NULL; // Aggregated control's IOleObject
  1088. m_pXferSink = NULL; // Event sink for aggregated control
  1089. m_piInnerCtlConPt = NULL; // Connection point to aggregated control
  1090. m_pInterconnect = NULL; // Interface on inner control for communication
  1091. m_dwXferCookie = 0; // Cookie for aggregated control's connection point.
  1092. }
  1093. CDHTMLEdit::~CDHTMLEdit()
  1094. {
  1095. }
  1096. HRESULT CDHTMLEdit::FinalConstruct()
  1097. {
  1098. // Aggregate DHTMLSafe control:
  1099. HRESULT hr = E_FAIL;
  1100. IUnknown* punkContUnk = NULL;
  1101. punkContUnk = GetControllingUnknown ();
  1102. _ASSERTE ( punkContUnk );
  1103. hr = CoCreateInstance ( CLSID_DHTMLSafe, punkContUnk, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&m_punkInnerCtl );
  1104. if ( SUCCEEDED ( hr ) )
  1105. {
  1106. _ASSERTE ( m_punkInnerCtl );
  1107. hr = m_punkInnerCtl->QueryInterface ( IID_IOleObject, (void**)&m_pInnerIOleObj);
  1108. _ASSERTE ( SUCCEEDED ( hr ) );
  1109. _ASSERTE ( m_pInnerIOleObj );
  1110. punkContUnk->Release ();
  1111. hr = m_punkInnerCtl->QueryInterface ( IID_IDHTMLSafe, (void**)&m_pInnerCtl ); // This addrefs my unknown
  1112. _ASSERTE ( SUCCEEDED ( hr ) );
  1113. _ASSERTE ( m_pInnerCtl );
  1114. punkContUnk->Release ();
  1115. hr = m_punkInnerCtl->QueryInterface ( IID_IInterconnector, (void**)&m_pInterconnect ); // This addrefs my unknown
  1116. _ASSERTE ( SUCCEEDED ( hr ) );
  1117. _ASSERTE ( m_pInterconnect );
  1118. punkContUnk->Release ();
  1119. // Sink events from the aggregated control:
  1120. m_pXferSink = new CComObject<CEventXferSink>;
  1121. // Check if the new worked
  1122. if(!m_pXferSink)
  1123. return E_OUTOFMEMORY;
  1124. m_pXferSink->AddRef ();
  1125. m_pXferSink->SetOwner ( this );
  1126. // Hook the sink up to the aggregated control:
  1127. CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer>picpc ( m_punkInnerCtl );
  1128. if ( picpc )
  1129. {
  1130. punkContUnk->Release ();
  1131. hr = picpc->FindConnectionPoint ( DIID__DHTMLSafeEvents, &m_piInnerCtlConPt );
  1132. if ( SUCCEEDED ( hr ) )
  1133. {
  1134. hr = m_piInnerCtlConPt->Advise ( static_cast<IDispatch *>(m_pXferSink), &m_dwXferCookie);
  1135. _ASSERTE ( SUCCEEDED ( hr ) );
  1136. }
  1137. }
  1138. }
  1139. _ASSERTE ( SUCCEEDED ( hr ) );
  1140. return hr;
  1141. }
  1142. void CDHTMLEdit::FinalRelease()
  1143. {
  1144. IUnknown* punkContUnk = NULL;
  1145. punkContUnk = GetControllingUnknown ();
  1146. _ASSERTE ( punkContUnk );
  1147. // Unadvise the event sink:
  1148. _ASSERTE ( m_pXferSink );
  1149. _ASSERTE ( m_piInnerCtlConPt );
  1150. if ( NULL != m_piInnerCtlConPt )
  1151. {
  1152. punkContUnk->AddRef ();
  1153. m_piInnerCtlConPt->Unadvise ( m_dwXferCookie );
  1154. m_piInnerCtlConPt->Release ();
  1155. m_piInnerCtlConPt = NULL;
  1156. }
  1157. if ( NULL != m_pXferSink )
  1158. {
  1159. m_pXferSink->Release ();
  1160. m_pXferSink = NULL;
  1161. }
  1162. if ( m_pInnerCtl )
  1163. {
  1164. // Releasing the cached interface will release my unknown, which has already been ballanced.
  1165. punkContUnk->AddRef ();
  1166. m_pInnerCtl->Release ();
  1167. }
  1168. if ( m_pInnerIOleObj )
  1169. {
  1170. punkContUnk->AddRef ();
  1171. m_pInnerIOleObj->Release ();
  1172. }
  1173. if ( m_pInterconnect )
  1174. {
  1175. punkContUnk->AddRef ();
  1176. m_pInterconnect->Release ();
  1177. }
  1178. if ( m_punkInnerCtl )
  1179. {
  1180. punkContUnk->AddRef ();
  1181. m_punkInnerCtl->Release ();
  1182. }
  1183. }
  1184. HRESULT
  1185. CDHTMLEdit::PromptOpenFile(LPTSTR pPath, ULONG ulPathLen)
  1186. {
  1187. HRESULT hr = S_OK;
  1188. OPENFILENAME ofn = {0};
  1189. BOOL bResult = FALSE;
  1190. HWND hWndCD = NULL;
  1191. _ASSERTE(pPath);
  1192. if (NULL == pPath)
  1193. return E_INVALIDARG;
  1194. hr = m_pInterconnect->GetCtlWnd ( (SIZE_T*)&hWndCD );
  1195. _ASSERTE ( SUCCEEDED ( hr ) );
  1196. if ( FAILED ( hr ) )
  1197. {
  1198. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1199. }
  1200. memset(&ofn, 0, sizeof(ofn));
  1201. ofn.lStructSize = sizeof(ofn);
  1202. ofn.hwndOwner = NULL;
  1203. ofn.hwndOwner = hWndCD;
  1204. ofn.lpstrTitle = NULL;
  1205. ofn.lpstrFilter = TEXT("HTML Documents (*.htm, *.html)\0*.htm;*.html\0");
  1206. ofn.lpstrFile = pPath;
  1207. ofn.lpstrInitialDir = NULL;
  1208. ofn.lpstrDefExt = TEXT("htm");
  1209. ofn.nMaxFile = ulPathLen;
  1210. ofn.Flags = OFN_EXPLORER |
  1211. OFN_FILEMUSTEXIST |
  1212. OFN_PATHMUSTEXIST |
  1213. OFN_OVERWRITEPROMPT |
  1214. OFN_HIDEREADONLY;
  1215. bResult = GetOpenFileName(&ofn);
  1216. if (!bResult)
  1217. return S_FALSE;
  1218. return S_OK;
  1219. }
  1220. HRESULT
  1221. CDHTMLEdit::PromptSaveAsFile(LPTSTR pPath, ULONG ulPathLen)
  1222. {
  1223. HRESULT hr = S_OK;
  1224. OPENFILENAME ofn = {0};
  1225. BOOL bResult = FALSE;
  1226. HWND hWndCD = NULL;
  1227. _ASSERTE(pPath);
  1228. if (NULL == pPath)
  1229. return E_INVALIDARG;
  1230. hr = m_pInterconnect->GetCtlWnd ( (SIZE_T*)&hWndCD );
  1231. _ASSERTE ( SUCCEEDED ( hr ) );
  1232. _ASSERTE ( hWndCD );
  1233. if ( FAILED ( hr ) || ( NULL == hWndCD ) )
  1234. {
  1235. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1236. }
  1237. memset(&ofn, 0, sizeof(ofn));
  1238. ofn.lStructSize = sizeof(ofn);
  1239. ofn.hwndOwner = NULL;
  1240. ofn.hwndOwner = hWndCD;
  1241. ofn.lpstrTitle = NULL;
  1242. ofn.lpstrFilter = TEXT("HTML Documents (*.htm, *.html)\0*.htm;*.html\0");
  1243. ofn.lpstrFile = pPath;
  1244. ofn.lpstrInitialDir = NULL;
  1245. ofn.lpstrDefExt = TEXT("htm");
  1246. ofn.nMaxFile = ulPathLen;
  1247. ofn.Flags = OFN_OVERWRITEPROMPT |
  1248. OFN_CREATEPROMPT |
  1249. OFN_HIDEREADONLY |
  1250. OFN_EXPLORER;
  1251. bResult = GetSaveFileName(&ofn);
  1252. if (!bResult)
  1253. return S_FALSE;
  1254. return S_OK;
  1255. }
  1256. STDMETHODIMP CDHTMLEdit::LoadDocument(LPVARIANT path, LPVARIANT promptUser)
  1257. {
  1258. USES_CONVERSION;
  1259. HRESULT hr = S_OK;
  1260. BOOL bPromptUser = NULL;
  1261. TCHAR promptPath[MAX_PATH] = {0};
  1262. CComBSTR bstrPath;
  1263. BSTR _path = NULL;
  1264. _ASSERTE(path);
  1265. CProxyFrame* pFrame = NULL;
  1266. hr = m_pInterconnect->GetInterconnector ( (SIZE_T*)&pFrame );
  1267. _ASSERTE ( SUCCEEDED ( hr ) );
  1268. _ASSERTE ( pFrame );
  1269. if ( FAILED ( hr ) || ( NULL == pFrame ) )
  1270. {
  1271. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1272. }
  1273. if (NULL == path || !(V_VT(path) == VT_BSTR || V_VT(path) == (VT_BSTR|VT_BYREF)))
  1274. return E_INVALIDARG;
  1275. // Note that it is valid for path to be NULL,
  1276. // In automation an empty string (BSTR) is a NULL pointer
  1277. // Passing in an emtpy string here allows for initializing TriEdit with
  1278. // an empty document (IPersistStreamInit->InitNew)
  1279. if (promptUser && (V_VT(promptUser) != VT_EMPTY && V_VT(promptUser) != VT_ERROR))
  1280. {
  1281. // note that if promptUser is not type VT_BOOL or VT_BOOL|VT_BYREF
  1282. // then user is not prompted
  1283. #pragma warning(disable: 4310) // cast truncates constant value
  1284. if (VT_BOOL == V_VT(promptUser))
  1285. bPromptUser = (VARIANT_TRUE == V_BOOL(promptUser)) ? TRUE : FALSE;
  1286. else if ((VT_BOOL|VT_BYREF) == V_VT(promptUser))
  1287. {
  1288. _ASSERTE(V_BOOLREF(promptUser));
  1289. if (V_BOOLREF(promptUser))
  1290. bPromptUser = (BOOL) (*(V_BOOLREF(promptUser)) == VARIANT_TRUE) ? TRUE : FALSE;
  1291. }
  1292. #pragma warning(default: 4310) // cast truncates constant value
  1293. }
  1294. // prompt user overrides any doc name that is specified
  1295. // Change VK:
  1296. // ...but the provided doc name is used as the default.
  1297. if (bPromptUser)
  1298. {
  1299. if ( NULL != path->bstrVal )
  1300. {
  1301. _tcsncpy ( promptPath, OLE2T(path->bstrVal), MAX_PATH );
  1302. }
  1303. hr = PromptOpenFile(promptPath, MAX_PATH);
  1304. if (S_FALSE == hr)
  1305. return S_OK;
  1306. bstrPath = promptPath;
  1307. _path = bstrPath;
  1308. }
  1309. else
  1310. {
  1311. if ((VT_BSTR|VT_BYREF) == V_VT(path) && V_BSTRREF(path))
  1312. _path = *(V_BSTRREF(path));
  1313. else if (VT_BSTR == V_VT(path) && V_BSTR(path))
  1314. _path = V_BSTR(path);
  1315. }
  1316. if ( 0 == SysStringLen ( _path ) )
  1317. {
  1318. return DE_E_INVALIDARG;
  1319. }
  1320. hr = pFrame->LoadDocument(_path);
  1321. return hr;
  1322. }
  1323. STDMETHODIMP CDHTMLEdit::SaveDocument(LPVARIANT path, LPVARIANT promptUser)
  1324. {
  1325. USES_CONVERSION;
  1326. HRESULT hr= S_OK;
  1327. TCHAR promptPath[MAX_PATH] = {0};
  1328. CComBSTR bstrPath;
  1329. BOOL bPromptUser = FALSE;
  1330. BSTR _path = NULL;
  1331. _ASSERTE(path);
  1332. CProxyFrame* pFrame = NULL;
  1333. hr = m_pInterconnect->GetInterconnector ( (SIZE_T*)&pFrame );
  1334. _ASSERTE ( SUCCEEDED ( hr ) );
  1335. _ASSERTE ( pFrame );
  1336. if ( FAILED ( hr ) || ( NULL == pFrame ) )
  1337. {
  1338. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1339. }
  1340. if (NULL == path || !(V_VT(path) == VT_BSTR || V_VT(path) == (VT_BSTR|VT_BYREF)))
  1341. return E_INVALIDARG;
  1342. // prompt user overrides any doc name that is specified
  1343. if (promptUser && (V_VT(promptUser) != VT_EMPTY && V_VT(promptUser) != VT_ERROR))
  1344. {
  1345. // note that if promptUser is not type VT_BOOL or VT_BOOL|VT_BYREF
  1346. // then user is not prompted
  1347. #pragma warning(disable: 4310) // cast truncates constant value
  1348. if (VT_BOOL == V_VT(promptUser))
  1349. bPromptUser = (VARIANT_TRUE == V_BOOL(promptUser)) ? TRUE : FALSE;
  1350. else if ((VT_BOOL|VT_BYREF) == V_VT(promptUser))
  1351. {
  1352. _ASSERTE(V_BOOLREF(promptUser));
  1353. if (V_BOOLREF(promptUser))
  1354. bPromptUser = (BOOL) (*(V_BOOLREF(promptUser)) == VARIANT_TRUE) ? TRUE : FALSE;
  1355. }
  1356. #pragma warning(default: 4310) // cast truncates constant value
  1357. }
  1358. // prompt user overrides any doc name that is specified
  1359. // Change VK:
  1360. // ...but the provided doc name is used as the default. If doc name is empty,
  1361. // and the doc was opened from a file, the original file name is provided as a default.
  1362. if (bPromptUser)
  1363. {
  1364. if ( NULL != path->bstrVal )
  1365. {
  1366. _tcsncpy ( promptPath, OLE2T(path->bstrVal), MAX_PATH );
  1367. if ( 0 == _tcslen ( promptPath ) )
  1368. {
  1369. CComBSTR bstrFileName;
  1370. if ( SUCCEEDED ( pFrame->GetCurDocNameWOPath ( bstrFileName ) ) )
  1371. {
  1372. _tcsncpy ( promptPath, OLE2T(bstrFileName), MAX_PATH );
  1373. }
  1374. }
  1375. }
  1376. hr = PromptSaveAsFile(promptPath, MAX_PATH);
  1377. if (S_FALSE == hr)
  1378. return S_OK;
  1379. bstrPath = promptPath;
  1380. _path = bstrPath;
  1381. }
  1382. else
  1383. {
  1384. if ((VT_BSTR|VT_BYREF) == V_VT(path) && V_BSTRREF(path))
  1385. _path = *(V_BSTRREF(path));
  1386. else if (VT_BSTR == V_VT(path) && V_BSTR(path))
  1387. _path = V_BSTR(path);
  1388. }
  1389. hr = pFrame->SaveDocument(_path);
  1390. return hr;
  1391. }
  1392. STDMETHODIMP CDHTMLEdit::LoadURL ( BSTR url )
  1393. {
  1394. HRESULT hr = E_FAIL;
  1395. CProxyFrame* pFrame = NULL;
  1396. hr = m_pInterconnect->GetInterconnector ( (SIZE_T*)&pFrame );
  1397. _ASSERTE ( SUCCEEDED ( hr ) );
  1398. _ASSERTE ( pFrame );
  1399. if ( FAILED ( hr ) || ( NULL == pFrame ) )
  1400. {
  1401. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1402. }
  1403. if ( ( NULL == url ) || ( 0 == SysStringLen ( url ) ) )
  1404. return E_INVALIDARG;
  1405. hr = pFrame->LoadDocument( url, TRUE );
  1406. return hr;
  1407. }
  1408. STDMETHODIMP CDHTMLEdit::PrintDocument ( VARIANT* pvarWithUI )
  1409. {
  1410. BOOL bfWithUI = FALSE;
  1411. HRESULT hr = E_FAIL;
  1412. CProxyFrame* pFrame = NULL;
  1413. hr = m_pInterconnect->GetInterconnector ( (SIZE_T*)&pFrame );
  1414. _ASSERTE ( SUCCEEDED ( hr ) );
  1415. _ASSERTE ( pFrame );
  1416. if ( FAILED ( hr ) || ( NULL == pFrame ) )
  1417. {
  1418. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1419. }
  1420. if ( NULL != pvarWithUI )
  1421. {
  1422. CComVariant varLocal = *pvarWithUI;
  1423. hr = varLocal.ChangeType ( VT_BOOL );
  1424. if ( SUCCEEDED ( hr ) )
  1425. {
  1426. bfWithUI = varLocal.boolVal; // VariantBool to Bool is safe, not the reverse.
  1427. }
  1428. }
  1429. hr = pFrame->Print ( bfWithUI );
  1430. return S_OK; // We can't return anything meaningful, because w/UI, Cancel returns E_FAIL.
  1431. }
  1432. STDMETHODIMP CDHTMLEdit::get_BrowseMode(/* [retval][out] */ VARIANT_BOOL *pVal)
  1433. {
  1434. HRESULT hr = S_OK;
  1435. CProxyFrame* pFrame = NULL;
  1436. hr = m_pInterconnect->GetInterconnector ( (SIZE_T*)&pFrame );
  1437. _ASSERTE ( SUCCEEDED ( hr ) );
  1438. _ASSERTE ( pFrame );
  1439. if ( FAILED ( hr ) || ( NULL == pFrame ) )
  1440. {
  1441. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1442. }
  1443. _ASSERTE ( pVal );
  1444. if ( NULL == pVal )
  1445. {
  1446. return E_INVALIDARG;
  1447. }
  1448. return pFrame->GetBrowseMode ( pVal );
  1449. }
  1450. STDMETHODIMP CDHTMLEdit::put_BrowseMode(/* [in] */ VARIANT_BOOL newVal)
  1451. {
  1452. HRESULT hr = S_OK;
  1453. CProxyFrame* pFrame = NULL;
  1454. hr = m_pInterconnect->GetInterconnector ( (SIZE_T*)&pFrame );
  1455. _ASSERTE ( SUCCEEDED ( hr ) );
  1456. _ASSERTE ( pFrame );
  1457. if ( FAILED ( hr ) || ( NULL == pFrame ) )
  1458. {
  1459. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1460. }
  1461. hr = pFrame->SetBrowseMode ( newVal );
  1462. if ( SUCCEEDED ( hr ) )
  1463. {
  1464. m_pInterconnect->MakeDirty ( DISPID_BROWSEMODE );
  1465. }
  1466. return hr;
  1467. }
  1468. // To be safe, restrict the range of cmdIDs to a known set.
  1469. //
  1470. STDMETHODIMP CDHTMLEdit::ExecCommand(DHTMLEDITCMDID cmdID, OLECMDEXECOPT cmdexecopt, LPVARIANT pInVar, LPVARIANT pOutVar)
  1471. {
  1472. HRESULT hr = S_OK;
  1473. LPVARIANT _pVarIn = NULL;
  1474. LPVARIANT _pVarOut = NULL;
  1475. CProxyFrame* pFrame = NULL;
  1476. hr = m_pInterconnect->GetInterconnector ( (SIZE_T*)&pFrame );
  1477. _ASSERTE ( SUCCEEDED ( hr ) );
  1478. _ASSERTE ( pFrame );
  1479. if ( FAILED ( hr ) || ( NULL == pFrame ) )
  1480. {
  1481. return ( SUCCEEDED ( hr ) ) ? E_UNEXPECTED : hr;
  1482. }
  1483. // It is valid for pVar to be VT_EMPTY (on a DECMD_GETXXX op) but not VT_ERROR
  1484. if (pInVar && (V_VT(pInVar) != VT_ERROR))
  1485. _pVarIn = pInVar;
  1486. if (pOutVar && (V_VT(pOutVar) != VT_ERROR))
  1487. _pVarOut = pOutVar;
  1488. if ( ( cmdexecopt < OLECMDEXECOPT_DODEFAULT ) ||
  1489. ( cmdexecopt > OLECMDEXECOPT_DONTPROMPTUSER ) )
  1490. {
  1491. return E_INVALIDARG;
  1492. }
  1493. hr = pFrame->HrMapExecCommand(cmdID, cmdexecopt, _pVarIn, _pVarOut);
  1494. return hr;
  1495. }
  1496. /*
  1497. * IServiceProvider implementation
  1498. */
  1499. STDMETHODIMP CDHTMLEdit::QueryService( REFGUID guidService, REFIID riid, void** ppvService )
  1500. {
  1501. *ppvService = NULL;
  1502. if ( SID_SInternetSecurityManager == guidService )
  1503. {
  1504. return GetUnknown()->QueryInterface ( riid, ppvService );
  1505. }
  1506. return E_NOINTERFACE;
  1507. }
  1508. /*
  1509. * IInternetSecurityManager implementation
  1510. *
  1511. * The purpose of this implementation is to OVERRIDE security and reduce it to the minimum.
  1512. * This should only be provided in Edit mode, not in browse mode. (Browse mode edits scripts.)
  1513. * This prevents warnings about unsafe for scripting DTCs, etc.
  1514. *
  1515. * From HTMED/TriSite, by Carlos Gomes.
  1516. *
  1517. */
  1518. STDMETHODIMP CDHTMLEdit::GetSecurityId ( LPCWSTR /*pwszUrl*/, BYTE* /*pbSecurityId*/,
  1519. DWORD* /*pcbSecurityId*/, DWORD_PTR /*dwReserved*/ )
  1520. {
  1521. return INET_E_DEFAULT_ACTION;
  1522. }
  1523. STDMETHODIMP CDHTMLEdit::GetSecuritySite ( IInternetSecurityMgrSite** /*ppSite*/ )
  1524. {
  1525. return INET_E_DEFAULT_ACTION;
  1526. }
  1527. STDMETHODIMP CDHTMLEdit::GetZoneMappings ( DWORD /*dwZone*/, IEnumString** /*ppenumString*/, DWORD /*dwFlags*/ )
  1528. {
  1529. return INET_E_DEFAULT_ACTION;
  1530. }
  1531. STDMETHODIMP CDHTMLEdit::MapUrlToZone ( LPCWSTR /*pwszUrl*/, DWORD *pdwZone, DWORD /*dwFlags*/ )
  1532. {
  1533. if ( pdwZone != NULL )
  1534. {
  1535. *pdwZone = URLZONE_LOCAL_MACHINE;
  1536. return NOERROR;
  1537. }
  1538. return INET_E_DEFAULT_ACTION;
  1539. }
  1540. STDMETHODIMP CDHTMLEdit::ProcessUrlAction ( LPCWSTR /*pwszUrl*/, DWORD dwAction, BYTE* pPolicy, DWORD cbPolicy,
  1541. BYTE* /*pContext*/, DWORD /*cbContext*/, DWORD /*dwFlags*/, DWORD /*dwReserved*/ )
  1542. {
  1543. _ASSERTE ( pPolicy );
  1544. if ( NULL == pPolicy )
  1545. {
  1546. return E_INVALIDARG;
  1547. }
  1548. // Handle
  1549. // URLACTION_DOWNLOAD_SIGNED_ACTIVEX
  1550. // URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
  1551. // URLACTION_ACTIVEX_OVERRIDE_DATA_SAFETY
  1552. // URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
  1553. // URLACTION_SCRIPT_OVERRIDE_SAFETY
  1554. // URLACTION_ACTIVEX_RUN
  1555. // URLACTION_ACTIVEX_CONFIRM_NOOBJECTSAFETY
  1556. // URLACTION_SCRIPT_SAFE_ACTIVEX
  1557. //
  1558. if(dwAction >= URLACTION_ACTIVEX_MIN && dwAction <= URLACTION_ACTIVEX_MAX)
  1559. {
  1560. if (cbPolicy >= sizeof(DWORD))
  1561. {
  1562. *(DWORD *)pPolicy = URLPOLICY_ALLOW;
  1563. return S_OK;
  1564. }
  1565. return S_FALSE;
  1566. }
  1567. //
  1568. // Handle
  1569. // URLACTION_DOWNLOAD_SIGNED_ACTIVEX
  1570. // URLACTION_DOWNLOAD_UNSIGNED_ACTIVEX
  1571. //
  1572. // BUG 597859: Disable download overrides; use default action instead.
  1573. //else if(dwAction >= URLACTION_DOWNLOAD_MIN && dwAction <= URLACTION_DOWNLOAD_MAX)
  1574. //{
  1575. // if (cbPolicy >= sizeof(DWORD))
  1576. // {
  1577. // *(DWORD *)pPolicy = URLPOLICY_ALLOW;
  1578. // return S_OK;
  1579. // }
  1580. // return S_FALSE;
  1581. //}
  1582. //
  1583. // Handle
  1584. // URLACTION_SCRIPT_RUN
  1585. // URLACTION_SCRIPT_JAVA_USE
  1586. // URLACTION_SCRIPT_SAFE_ACTIVEX
  1587. //
  1588. else if(dwAction >= URLACTION_SCRIPT_MIN && dwAction <= URLACTION_SCRIPT_MAX)
  1589. {
  1590. if (cbPolicy >= sizeof(DWORD))
  1591. {
  1592. *(DWORD *)pPolicy = URLPOLICY_ALLOW;
  1593. return S_OK;
  1594. }
  1595. return S_FALSE;
  1596. }
  1597. //
  1598. // Allow applets to do anything they want.
  1599. // Provide the java permissions.
  1600. //
  1601. else if(dwAction == URLACTION_JAVA_PERMISSIONS)
  1602. {
  1603. if (cbPolicy >= sizeof(DWORD))
  1604. {
  1605. //
  1606. // URLPOLICY_JAVA_LOW
  1607. // Set low Java security. Java applets will be allowed to
  1608. // do high-capability operations, such as file I/O.
  1609. //
  1610. *(DWORD *)pPolicy = URLPOLICY_JAVA_LOW;
  1611. return S_OK;
  1612. }
  1613. return S_FALSE;
  1614. }
  1615. return INET_E_DEFAULT_ACTION;
  1616. }
  1617. STDMETHODIMP CDHTMLEdit::QueryCustomPolicy ( LPCWSTR /*pwszUrl*/, REFGUID /*guidKey*/,
  1618. BYTE** /*ppPolicy*/, DWORD* /*pcbPolicy*/, BYTE* /*pContext*/, DWORD /*cbContext*/, DWORD /*dwReserved*/ )
  1619. {
  1620. return INET_E_DEFAULT_ACTION;
  1621. }
  1622. STDMETHODIMP CDHTMLEdit::SetSecuritySite ( IInternetSecurityMgrSite* /*pSite*/ )
  1623. {
  1624. return INET_E_DEFAULT_ACTION;
  1625. }
  1626. STDMETHODIMP CDHTMLEdit::SetZoneMapping ( DWORD /*dwZone*/, LPCWSTR /*lpszPattern*/, DWORD /*dwFlags*/ )
  1627. {
  1628. return INET_E_DEFAULT_ACTION;
  1629. }
  1630. // Map to aggregated control's methods:
  1631. //
  1632. STDMETHODIMP CDHTMLEdit::get_IsDirty(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_IsDirty ( pVal );}
  1633. STDMETHODIMP CDHTMLEdit::get_SourceCodePreservation(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_SourceCodePreservation ( pVal );}
  1634. STDMETHODIMP CDHTMLEdit::put_SourceCodePreservation(VARIANT_BOOL newVal) {return m_pInnerCtl->put_SourceCodePreservation ( newVal );}
  1635. STDMETHODIMP CDHTMLEdit::get_ScrollbarAppearance(DHTMLEDITAPPEARANCE *pVal) {return m_pInnerCtl->get_ScrollbarAppearance ( pVal );}
  1636. STDMETHODIMP CDHTMLEdit::put_ScrollbarAppearance(DHTMLEDITAPPEARANCE newVal) {return m_pInnerCtl->put_ScrollbarAppearance ( newVal );}
  1637. STDMETHODIMP CDHTMLEdit::get_Scrollbars(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_Scrollbars ( pVal );}
  1638. STDMETHODIMP CDHTMLEdit::put_Scrollbars(VARIANT_BOOL newVal) {return m_pInnerCtl->put_Scrollbars ( newVal );}
  1639. STDMETHODIMP CDHTMLEdit::get_Appearance(DHTMLEDITAPPEARANCE *pVal) {return m_pInnerCtl->get_Appearance ( pVal );}
  1640. STDMETHODIMP CDHTMLEdit::put_Appearance(DHTMLEDITAPPEARANCE newVal) {return m_pInnerCtl->put_Appearance ( newVal );}
  1641. STDMETHODIMP CDHTMLEdit::get_ShowBorders(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_ShowBorders ( pVal );}
  1642. STDMETHODIMP CDHTMLEdit::put_ShowBorders(VARIANT_BOOL newVal) {return m_pInnerCtl->put_ShowBorders ( newVal );}
  1643. STDMETHODIMP CDHTMLEdit::get_ShowDetails(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_ShowDetails ( pVal );}
  1644. STDMETHODIMP CDHTMLEdit::put_ShowDetails(VARIANT_BOOL newVal) {return m_pInnerCtl->put_ShowDetails ( newVal );}
  1645. STDMETHODIMP CDHTMLEdit::get_ActivateDTCs(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_ActivateDTCs ( pVal );}
  1646. STDMETHODIMP CDHTMLEdit::put_ActivateDTCs(VARIANT_BOOL newVal) {return m_pInnerCtl->put_ActivateDTCs ( newVal );}
  1647. STDMETHODIMP CDHTMLEdit::get_ActivateActiveXControls(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_ActivateActiveXControls ( pVal );}
  1648. STDMETHODIMP CDHTMLEdit::put_ActivateActiveXControls(VARIANT_BOOL newVal) {return m_pInnerCtl->put_ActivateActiveXControls ( newVal );}
  1649. STDMETHODIMP CDHTMLEdit::get_ActivateApplets(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_ActivateApplets ( pVal );}
  1650. STDMETHODIMP CDHTMLEdit::put_ActivateApplets(VARIANT_BOOL newVal) {return m_pInnerCtl->put_ActivateApplets ( newVal );}
  1651. STDMETHODIMP CDHTMLEdit::get_DOM(IHTMLDocument2 **pVal) {return m_pInnerCtl->get_DOM ( pVal );}
  1652. STDMETHODIMP CDHTMLEdit::get_DocumentHTML(BSTR *pVal) {return m_pInnerCtl->get_DocumentHTML ( pVal );}
  1653. STDMETHODIMP CDHTMLEdit::put_DocumentHTML(BSTR newVal) {return m_pInnerCtl->put_DocumentHTML ( newVal );}
  1654. STDMETHODIMP CDHTMLEdit::get_AbsoluteDropMode(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_AbsoluteDropMode ( pVal );}
  1655. STDMETHODIMP CDHTMLEdit::put_AbsoluteDropMode(VARIANT_BOOL newVal) {return m_pInnerCtl->put_AbsoluteDropMode ( newVal );}
  1656. STDMETHODIMP CDHTMLEdit::get_SnapToGridX(LONG *pVal) {return m_pInnerCtl->get_SnapToGridX ( pVal );}
  1657. STDMETHODIMP CDHTMLEdit::put_SnapToGridX(LONG newVal) {return m_pInnerCtl->put_SnapToGridX ( newVal );}
  1658. STDMETHODIMP CDHTMLEdit::get_SnapToGridY(LONG *pVal) {return m_pInnerCtl->get_SnapToGridY ( pVal );}
  1659. STDMETHODIMP CDHTMLEdit::put_SnapToGridY(LONG newVal) {return m_pInnerCtl->put_SnapToGridY ( newVal );}
  1660. STDMETHODIMP CDHTMLEdit::get_SnapToGrid(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_SnapToGrid ( pVal );}
  1661. STDMETHODIMP CDHTMLEdit::put_SnapToGrid(VARIANT_BOOL newVal) {return m_pInnerCtl->put_SnapToGrid ( newVal );}
  1662. STDMETHODIMP CDHTMLEdit::get_CurrentDocumentPath(BSTR *pVal) {return m_pInnerCtl->get_CurrentDocumentPath ( pVal );}
  1663. STDMETHODIMP CDHTMLEdit::QueryStatus(DHTMLEDITCMDID cmdID, DHTMLEDITCMDF* retval) {return m_pInnerCtl->QueryStatus ( cmdID, retval );}
  1664. STDMETHODIMP CDHTMLEdit::SetContextMenu(LPVARIANT menuStrings,LPVARIANT menuStates) {return m_pInnerCtl->SetContextMenu ( menuStrings, menuStates );}
  1665. STDMETHODIMP CDHTMLEdit::get_BaseURL(BSTR *baseURL) {return m_pInnerCtl->get_BaseURL(baseURL);}
  1666. STDMETHODIMP CDHTMLEdit::put_BaseURL(BSTR baseURL) {return m_pInnerCtl->put_BaseURL(baseURL);}
  1667. STDMETHODIMP CDHTMLEdit::get_DocumentTitle(BSTR *docTitle) {return m_pInnerCtl->get_DocumentTitle(docTitle);}
  1668. STDMETHODIMP CDHTMLEdit::NewDocument() {return m_pInnerCtl->NewDocument();}
  1669. STDMETHODIMP CDHTMLEdit::get_UseDivOnCarriageReturn(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_UseDivOnCarriageReturn(pVal);}
  1670. STDMETHODIMP CDHTMLEdit::put_UseDivOnCarriageReturn(VARIANT_BOOL newVal) {return m_pInnerCtl->put_UseDivOnCarriageReturn(newVal);}
  1671. STDMETHODIMP CDHTMLEdit::FilterSourceCode(BSTR sourceCodeIn, BSTR* sourceCodeOut) {return m_pInnerCtl->FilterSourceCode(sourceCodeIn, sourceCodeOut);}
  1672. STDMETHODIMP CDHTMLEdit::Refresh() {return m_pInnerCtl->Refresh();}
  1673. STDMETHODIMP CDHTMLEdit::get_Busy(VARIANT_BOOL *pVal) {return m_pInnerCtl->get_Busy(pVal);}
  1674. // End of DHTMLEdit.cpp