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.

266 lines
7.1 KiB

  1. #include "precomp.hxx"
  2. #pragma hdrstop
  3. #include "access.h"
  4. CAccessibleWrapper::CAccessibleWrapper(IAccessible *pAcc)
  5. : _cRef(1), _pAcc(pAcc), _pEnumVar(NULL), _pOleWin(NULL)
  6. {
  7. _pAcc->AddRef();
  8. }
  9. CAccessibleWrapper::~CAccessibleWrapper()
  10. {
  11. if (_pEnumVar)
  12. _pEnumVar->Release();
  13. if (_pOleWin)
  14. _pOleWin->Release();
  15. _pAcc->Release();
  16. }
  17. // IUnknown
  18. // Implement refcounting ourselves
  19. // Also implement QI ourselves, so that we return a ptr back to the wrapper.
  20. STDMETHODIMP CAccessibleWrapper::QueryInterface(REFIID riid, void** ppv)
  21. {
  22. HRESULT hr;
  23. *ppv = NULL;
  24. if ((riid == IID_IUnknown) ||
  25. (riid == IID_IDispatch) ||
  26. (riid == IID_IAccessible))
  27. {
  28. *ppv = SAFECAST(this, IAccessible*);
  29. }
  30. else if (riid == IID_IEnumVARIANT)
  31. {
  32. // Get the IEnumVariant from the object we are sub-classing so we can delegate
  33. // calls.
  34. if (!_pEnumVar)
  35. {
  36. hr = _pAcc->QueryInterface(IID_PPV_ARG(IEnumVARIANT, &_pEnumVar));
  37. if (FAILED(hr))
  38. {
  39. _pEnumVar = NULL;
  40. return hr;
  41. }
  42. // Paranoia (in case QI returns S_OK with NULL...)
  43. if (!_pEnumVar)
  44. return E_NOINTERFACE;
  45. }
  46. *ppv = SAFECAST(this, IEnumVARIANT*);
  47. }
  48. else if (riid == IID_IOleWindow)
  49. {
  50. // Get the IOleWindow from the object we are sub-classing so we can delegate
  51. // calls.
  52. if (!_pOleWin)
  53. {
  54. hr = _pAcc->QueryInterface(IID_PPV_ARG(IOleWindow, &_pOleWin));
  55. if(FAILED(hr))
  56. {
  57. _pOleWin = NULL;
  58. return hr;
  59. }
  60. // Paranoia (in case QI returns S_OK with NULL...)
  61. if (!_pOleWin)
  62. return E_NOINTERFACE;
  63. }
  64. *ppv = SAFECAST(this, IOleWindow*);
  65. }
  66. else
  67. return E_NOINTERFACE;
  68. AddRef();
  69. return S_OK;
  70. }
  71. STDMETHODIMP_(ULONG) CAccessibleWrapper::AddRef()
  72. {
  73. return InterlockedIncrement(&_cRef);
  74. }
  75. STDMETHODIMP_(ULONG) CAccessibleWrapper::Release()
  76. {
  77. ASSERT( 0 != _cRef );
  78. ULONG cRef = InterlockedDecrement(&_cRef);
  79. if ( 0 == cRef )
  80. {
  81. delete this;
  82. }
  83. return cRef;
  84. }
  85. // IDispatch
  86. // - pass all through _pAcc
  87. STDMETHODIMP CAccessibleWrapper::GetTypeInfoCount(UINT* pctinfo)
  88. {
  89. return _pAcc->GetTypeInfoCount(pctinfo);
  90. }
  91. STDMETHODIMP CAccessibleWrapper::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  92. {
  93. return _pAcc->GetTypeInfo(itinfo, lcid, pptinfo);
  94. }
  95. STDMETHODIMP CAccessibleWrapper::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames,
  96. LCID lcid, DISPID* rgdispid)
  97. {
  98. return _pAcc->GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid);
  99. }
  100. STDMETHODIMP CAccessibleWrapper::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags,
  101. DISPPARAMS* pdp, VARIANT* pvarResult,
  102. EXCEPINFO* pxi, UINT* puArgErr)
  103. {
  104. return _pAcc->Invoke(dispid, riid, lcid, wFlags, pdp, pvarResult, pxi, puArgErr);
  105. }
  106. // IAccessible
  107. // - pass all through _pAcc
  108. STDMETHODIMP CAccessibleWrapper::get_accParent(IDispatch ** ppdispParent)
  109. {
  110. return _pAcc->get_accParent(ppdispParent);
  111. }
  112. STDMETHODIMP CAccessibleWrapper::get_accChildCount(long* pChildCount)
  113. {
  114. return _pAcc->get_accChildCount(pChildCount);
  115. }
  116. STDMETHODIMP CAccessibleWrapper::get_accChild(VARIANT varChild, IDispatch ** ppdispChild)
  117. {
  118. return _pAcc->get_accChild(varChild, ppdispChild);
  119. }
  120. STDMETHODIMP CAccessibleWrapper::get_accName(VARIANT varChild, BSTR* pszName)
  121. {
  122. return _pAcc->get_accName(varChild, pszName);
  123. }
  124. STDMETHODIMP CAccessibleWrapper::get_accValue(VARIANT varChild, BSTR* pszValue)
  125. {
  126. return _pAcc->get_accValue(varChild, pszValue);
  127. }
  128. STDMETHODIMP CAccessibleWrapper::get_accDescription(VARIANT varChild, BSTR* pszDescription)
  129. {
  130. return _pAcc->get_accDescription(varChild, pszDescription);
  131. }
  132. STDMETHODIMP CAccessibleWrapper::get_accRole(VARIANT varChild, VARIANT *pvarRole)
  133. {
  134. return _pAcc->get_accRole(varChild, pvarRole);
  135. }
  136. STDMETHODIMP CAccessibleWrapper::get_accState(VARIANT varChild, VARIANT *pvarState)
  137. {
  138. return _pAcc->get_accState(varChild, pvarState);
  139. }
  140. STDMETHODIMP CAccessibleWrapper::get_accHelp(VARIANT varChild, BSTR* pszHelp)
  141. {
  142. return _pAcc->get_accHelp(varChild, pszHelp);
  143. }
  144. STDMETHODIMP CAccessibleWrapper::get_accHelpTopic(BSTR* pszHelpFile, VARIANT varChild, long* pidTopic)
  145. {
  146. return _pAcc->get_accHelpTopic(pszHelpFile, varChild, pidTopic);
  147. }
  148. STDMETHODIMP CAccessibleWrapper::get_accKeyboardShortcut(VARIANT varChild, BSTR* pszKeyboardShortcut)
  149. {
  150. return _pAcc->get_accKeyboardShortcut(varChild, pszKeyboardShortcut);
  151. }
  152. STDMETHODIMP CAccessibleWrapper::get_accFocus(VARIANT * pvarFocusChild)
  153. {
  154. return _pAcc->get_accFocus(pvarFocusChild);
  155. }
  156. STDMETHODIMP CAccessibleWrapper::get_accSelection(VARIANT * pvarSelectedChildren)
  157. {
  158. return _pAcc->get_accSelection(pvarSelectedChildren);
  159. }
  160. STDMETHODIMP CAccessibleWrapper::get_accDefaultAction(VARIANT varChild, BSTR* pszDefaultAction)
  161. {
  162. return _pAcc->get_accDefaultAction(varChild, pszDefaultAction);
  163. }
  164. STDMETHODIMP CAccessibleWrapper::accSelect(long flagsSel, VARIANT varChild)
  165. {
  166. return _pAcc->accSelect(flagsSel, varChild);
  167. }
  168. STDMETHODIMP CAccessibleWrapper::accLocation(long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varChild)
  169. {
  170. return _pAcc->accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varChild);
  171. }
  172. STDMETHODIMP CAccessibleWrapper::accNavigate(long navDir, VARIANT varStart, VARIANT * pvarEndUpAt)
  173. {
  174. return _pAcc->accNavigate(navDir, varStart, pvarEndUpAt);
  175. }
  176. STDMETHODIMP CAccessibleWrapper::accHitTest(long xLeft, long yTop, VARIANT * pvarChildAtPoint)
  177. {
  178. return _pAcc->accHitTest(xLeft, yTop, pvarChildAtPoint);
  179. }
  180. STDMETHODIMP CAccessibleWrapper::accDoDefaultAction(VARIANT varChild)
  181. {
  182. return _pAcc->accDoDefaultAction(varChild);
  183. }
  184. STDMETHODIMP CAccessibleWrapper::put_accName(VARIANT varChild, BSTR szName)
  185. {
  186. return _pAcc->put_accName(varChild, szName);
  187. }
  188. STDMETHODIMP CAccessibleWrapper::put_accValue(VARIANT varChild, BSTR pszValue)
  189. {
  190. return _pAcc->put_accValue(varChild, pszValue);
  191. }
  192. // IEnumVARIANT
  193. // - pass all through _pEnumVar
  194. STDMETHODIMP CAccessibleWrapper::Next(ULONG celt, VARIANT* rgvar, ULONG * pceltFetched)
  195. {
  196. return _pEnumVar->Next(celt, rgvar, pceltFetched);
  197. }
  198. STDMETHODIMP CAccessibleWrapper::Skip(ULONG celt)
  199. {
  200. return _pEnumVar->Skip(celt);
  201. }
  202. STDMETHODIMP CAccessibleWrapper::Reset()
  203. {
  204. return _pEnumVar->Reset();
  205. }
  206. STDMETHODIMP CAccessibleWrapper::Clone(IEnumVARIANT ** ppenum)
  207. {
  208. return _pEnumVar->Clone(ppenum);
  209. }
  210. // IOleWindow
  211. // - pass all through _pOleWin
  212. STDMETHODIMP CAccessibleWrapper::GetWindow(HWND* phwnd)
  213. {
  214. return _pOleWin->GetWindow(phwnd);
  215. }
  216. STDMETHODIMP CAccessibleWrapper::ContextSensitiveHelp(BOOL fEnterMode)
  217. {
  218. return _pOleWin->ContextSensitiveHelp(fEnterMode);
  219. }