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.

260 lines
7.3 KiB

  1. //------------------------------------------------------------------------------
  2. // idhuihnd.cpp
  3. // Copyright (c)1997-1999 Microsoft Corporation, All Rights Reserved
  4. //
  5. // Author
  6. // bash
  7. //
  8. // History
  9. // 6-27-97 created (bash)
  10. //
  11. // Implementation of IDocHostUIHandler.
  12. //
  13. //------------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "triedit.h"
  16. #include "document.h"
  17. STDMETHODIMP CTriEditUIHandler::QueryInterface( REFIID riid, void **ppv )
  18. {
  19. *ppv = NULL;
  20. if ( IID_IDocHostUIHandler == riid || IID_IUnknown == riid )
  21. {
  22. *ppv = this;
  23. }
  24. if ( NULL != *ppv )
  25. {
  26. ((LPUNKNOWN)*ppv)->AddRef();
  27. return S_OK;
  28. }
  29. return E_NOINTERFACE;
  30. }
  31. STDMETHODIMP_(ULONG) CTriEditUIHandler::AddRef(void)
  32. {
  33. return ++m_cRef;
  34. }
  35. STDMETHODIMP_(ULONG) CTriEditUIHandler::Release(void)
  36. {
  37. if (0 != --m_cRef)
  38. {
  39. return m_cRef;
  40. }
  41. return 0;
  42. }
  43. STDMETHODIMP CTriEditUIHandler::GetHostInfo(DOCHOSTUIINFO* pInfo)
  44. {
  45. ATLTRACE(_T("IDocHostUIImpl::GetHostInfo\n"));
  46. if (m_pDoc->m_pUIHandlerHost)
  47. return m_pDoc->m_pUIHandlerHost->GetHostInfo(pInfo);
  48. // REVIEW(MikhailA): remove this as soon as we start using IE5 headers VS-wide
  49. #define DOCHOSTUIFLAG_TABSTOPONBODY 0x0800 // MikhailA: From IE5 headers
  50. pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_TABSTOPONBODY;
  51. pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
  52. return S_OK;
  53. }
  54. STDMETHODIMP CTriEditUIHandler::ShowUI(DWORD dwID, IOleInPlaceActiveObject* pActiveObject,
  55. IOleCommandTarget* /*pCommandTarget*/, IOleInPlaceFrame* pFrame,
  56. IOleInPlaceUIWindow* pDoc)
  57. {
  58. // ATLTRACE(_T("IDocHostUIImpl::ShowUI\n")); Turn this off for now
  59. if (m_pDoc->m_pUIHandlerHost)
  60. return m_pDoc->m_pUIHandlerHost->ShowUI(dwID, pActiveObject, static_cast<IOleCommandTarget*>(m_pDoc), pFrame, pDoc);
  61. return S_FALSE;
  62. }
  63. STDMETHODIMP CTriEditUIHandler::HideUI()
  64. {
  65. // ATLTRACE(_T("IDocHostUIImpl::HideUI\n")); Turn this off for now
  66. if (m_pDoc->m_pUIHandlerHost)
  67. return m_pDoc->m_pUIHandlerHost->HideUI();
  68. return S_OK;
  69. }
  70. STDMETHODIMP CTriEditUIHandler::UpdateUI()
  71. {
  72. // ATLTRACE(_T("IDocHostUIImpl::UpdateUI\n")); Turn this off for now
  73. if (m_pDoc->m_pUIHandlerHost)
  74. return m_pDoc->m_pUIHandlerHost->UpdateUI();
  75. return S_OK;
  76. }
  77. STDMETHODIMP CTriEditUIHandler::EnableModeless(BOOL fEnable)
  78. {
  79. ATLTRACE(_T("IDocHostUIImpl::EnableModeless\n"));
  80. if (m_pDoc->m_pUIHandlerHost)
  81. return m_pDoc->m_pUIHandlerHost->EnableModeless(fEnable);
  82. return E_NOTIMPL;
  83. }
  84. STDMETHODIMP CTriEditUIHandler::OnDocWindowActivate(BOOL fActivate)
  85. {
  86. ATLTRACE(_T("IDocHostUIImpl::OnDocWindowActivate\n"));
  87. if (m_pDoc->m_pUIHandlerHost)
  88. return m_pDoc->m_pUIHandlerHost->OnDocWindowActivate(fActivate);
  89. return E_NOTIMPL;
  90. }
  91. STDMETHODIMP CTriEditUIHandler::OnFrameWindowActivate(BOOL fActivate)
  92. {
  93. ATLTRACE(_T("IDocHostUIImpl::OnFrameWindowActivate\n"));
  94. if (m_pDoc->m_pUIHandlerHost)
  95. return m_pDoc->m_pUIHandlerHost->OnFrameWindowActivate(fActivate);
  96. return E_NOTIMPL;
  97. }
  98. STDMETHODIMP CTriEditUIHandler::ResizeBorder(LPCRECT prcBorder, IOleInPlaceUIWindow* pUIWindow, BOOL fFrameWindow)
  99. {
  100. ATLTRACE(_T("IDocHostUIImpl::ResizeBorder\n"));
  101. if (m_pDoc->m_pUIHandlerHost)
  102. return m_pDoc->m_pUIHandlerHost->ResizeBorder(prcBorder, pUIWindow, fFrameWindow);
  103. return E_NOTIMPL;
  104. }
  105. STDMETHODIMP CTriEditUIHandler::ShowContextMenu(DWORD dwID, POINT* pptPosition, IUnknown* pCommandTarget,
  106. IDispatch* pDispatchObjectHit)
  107. {
  108. ATLTRACE(_T("IDocHostUIImpl::ShowContextMenu\n"));
  109. if (m_pDoc->m_pUIHandlerHost)
  110. {
  111. HRESULT hr = S_OK;
  112. // Work around a Trident bug where they call ShowContextMenu recursively under some circumstances
  113. if (!m_pDoc->m_fInContextMenu)
  114. {
  115. m_pDoc->m_fInContextMenu = TRUE;
  116. hr = m_pDoc->m_pUIHandlerHost->ShowContextMenu(dwID, pptPosition, pCommandTarget, pDispatchObjectHit);
  117. m_pDoc->m_fInContextMenu = FALSE;
  118. }
  119. ATLTRACE(_T("Returning From IDocHostUIImpl::ShowContextMenu\n"));
  120. return hr;
  121. }
  122. return E_NOTIMPL;
  123. }
  124. STDMETHODIMP CTriEditUIHandler::TranslateAccelerator(LPMSG lpMsg, const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID)
  125. {
  126. // ATLTRACE(_T("IDocHostUIImpl::TranslateAccelerator\n")); Turn this off for now.
  127. // This is where we would add code if we wanted to handle any accelerators in TriEdit
  128. HRESULT hr = S_FALSE; // Defualt return value: not handled
  129. if (m_pDoc->m_pUIHandlerHost)
  130. {
  131. hr = m_pDoc->m_pUIHandlerHost->TranslateAccelerator(lpMsg, pguidCmdGroup, nCmdID);
  132. }
  133. // Kill ctrl-g and ctrl-h before they reach Trident: erronious handling attempts to bring up
  134. // non-existant html dialogs for Go and Replace.
  135. if ( ( S_FALSE == hr ) && ( lpMsg->message == WM_KEYDOWN ) )
  136. {
  137. BOOL fControl = (0x8000 & GetKeyState(VK_CONTROL));
  138. BOOL fShift = (0x8000 & GetKeyState(VK_SHIFT));
  139. if ( fControl && !fShift )
  140. {
  141. switch ( lpMsg->wParam )
  142. {
  143. case 'G':
  144. case 'H':
  145. hr = S_OK; // Consider them handled.
  146. default:
  147. break;
  148. }
  149. }
  150. }
  151. return hr;
  152. }
  153. STDMETHODIMP CTriEditUIHandler::GetOptionKeyPath(LPOLESTR* pbstrKey, DWORD dw)
  154. {
  155. ATLTRACE(_T("IDocHostUIImpl::GetOptionKeyPath\n"));
  156. if (m_pDoc->m_pUIHandlerHost)
  157. return m_pDoc->m_pUIHandlerHost->GetOptionKeyPath(pbstrKey, dw);
  158. *pbstrKey = NULL;
  159. return S_FALSE;
  160. }
  161. STDMETHODIMP CTriEditUIHandler::GetDropTarget(IDropTarget __RPC_FAR *pDropTarget,
  162. IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget)
  163. {
  164. ATLTRACE(_T("IDocHostUIImpl::GetDropTarget\n"));
  165. SAFERELEASE(m_pDoc->m_pDropTgtTrident);
  166. m_pDoc->m_pDropTgtTrident = pDropTarget;
  167. m_pDoc->m_pDropTgtTrident->AddRef();
  168. if (NULL == m_pDoc->m_pUIHandlerHost ||
  169. S_OK != m_pDoc->m_pUIHandlerHost->GetDropTarget(static_cast<IDropTarget*>(m_pDoc), ppDropTarget))
  170. {
  171. *ppDropTarget = static_cast<IDropTarget*>(m_pDoc);
  172. (*ppDropTarget)->AddRef();
  173. }
  174. return S_OK;
  175. }
  176. STDMETHODIMP CTriEditUIHandler::GetExternal(IDispatch **ppDispatch)
  177. {
  178. ATLTRACE(_T("IDocHostUIImpl::GetExternal\n"));
  179. if (m_pDoc->m_pUIHandlerHost)
  180. return m_pDoc->m_pUIHandlerHost->GetExternal(ppDispatch);
  181. return E_NOTIMPL;
  182. }
  183. STDMETHODIMP CTriEditUIHandler::TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
  184. {
  185. ATLTRACE(_T("IDocHostUIImpl::TranslateUrl\n"));
  186. if (m_pDoc->m_pUIHandlerHost)
  187. return m_pDoc->m_pUIHandlerHost->TranslateUrl(dwTranslate, pchURLIn, ppchURLOut);
  188. return E_NOTIMPL;
  189. }
  190. STDMETHODIMP CTriEditUIHandler::FilterDataObject(IDataObject *pDO, IDataObject **ppDORet)
  191. {
  192. ATLTRACE(_T("IDocHostUIImpl::FilterDataObject\n"));
  193. if (m_pDoc->m_pUIHandlerHost)
  194. return m_pDoc->m_pUIHandlerHost->FilterDataObject(pDO, ppDORet);
  195. return E_NOTIMPL;
  196. }