X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0a0e6a5bafe2efb3466b1527eb7eb670aaa5e634..efa4bab2d1fc98b69d50a20759b5a6a26cef1f8d:/src/msw/ole/access.cpp diff --git a/src/msw/ole/access.cpp b/src/msw/ole/access.cpp index 47cbf00934..32dab02e82 100644 --- a/src/msw/ole/access.cpp +++ b/src/msw/ole/access.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: msw/ole/access.cpp +// Name: src/msw/ole/access.cpp // Purpose: implementation of wxIAccessible and wxAccessible // Author: Julian Smart // Modified by: @@ -17,28 +17,22 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "access.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #if defined(__BORLANDC__) #pragma hdrstop #endif -#ifndef WX_PRECOMP -#include "wx/window.h" -#endif - -#include "wx/setup.h" #if wxUSE_OLE && wxUSE_ACCESSIBILITY -#include "wx/log.h" #include "wx/access.h" -#include "wx/msw/wrapwin.h" +#ifndef WX_PRECOMP + #include "wx/msw/wrapwin.h" + #include "wx/window.h" + #include "wx/log.h" +#endif // for some compilers, the entire ole2.h must be included, not only oleauto.h #if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__) @@ -47,7 +41,6 @@ #include #include -#include #include "wx/msw/ole/oleutils.h" @@ -71,6 +64,7 @@ int wxConvertToWindowsSelFlag(wxAccSelectionFlags sel); // Convert from Windows selection flag wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel); +#if wxUSE_VARIANT // ---------------------------------------------------------------------------- // wxIEnumVARIANT interface implementation // ---------------------------------------------------------------------------- @@ -93,7 +87,7 @@ private: wxVariant m_variant; // List of further variants int m_nCurrent; // Current enum position - DECLARE_NO_COPY_CLASS(wxIEnumVARIANT) + wxDECLARE_NO_COPY_CLASS(wxIEnumVARIANT); }; // ---------------------------------------------------------------------------- @@ -182,6 +176,7 @@ STDMETHODIMP wxIEnumVARIANT::Clone(IEnumVARIANT **ppenum) return S_OK; } +#endif // wxUSE_VARIANT // ---------------------------------------------------------------------------- // wxIAccessible implementation of IAccessible interface @@ -192,6 +187,9 @@ class wxIAccessible : public IAccessible public: wxIAccessible(wxAccessible *pAccessible); + // Called to indicate object should prepare to be deleted. + void Quiesce(); + DECLARE_IUNKNOWN_METHODS; // IAccessible @@ -302,8 +300,8 @@ public: // Obsolete - STDMETHODIMP put_accName(VARIANT varChild, BSTR szName) { return E_FAIL; } - STDMETHODIMP put_accValue(VARIANT varChild, BSTR szName) { return E_FAIL; } + STDMETHODIMP put_accName(VARIANT WXUNUSED(varChild), BSTR WXUNUSED(szName)) { return E_FAIL; } + STDMETHODIMP put_accValue(VARIANT WXUNUSED(varChild), BSTR WXUNUSED(szName)) { return E_FAIL; } // IDispatch @@ -339,8 +337,9 @@ public: private: wxAccessible *m_pAccessible; // pointer to C++ class we belong to + bool m_bQuiescing; // Object is to be deleted - DECLARE_NO_COPY_CLASS(wxIAccessible) + wxDECLARE_NO_COPY_CLASS(wxIAccessible); }; // ============================================================================ @@ -363,6 +362,15 @@ wxIAccessible::wxIAccessible(wxAccessible *pAccessible) wxASSERT( pAccessible != NULL ); m_pAccessible = pAccessible; + m_bQuiescing = false; +} + +// Called to indicate object should prepare to be deleted. + +void wxIAccessible::Quiesce() +{ + m_bQuiescing = true; + m_pAccessible = NULL; } // Retrieves the child element or child object at a given point on the screen. @@ -371,7 +379,7 @@ wxIAccessible::wxIAccessible(wxAccessible *pAccessible) STDMETHODIMP wxIAccessible::accHitTest(long xLeft, long yLeft, VARIANT* pVarID) { wxLogTrace(wxT("access"), wxT("accHitTest")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -440,7 +448,7 @@ STDMETHODIMP wxIAccessible::accHitTest(long xLeft, long yLeft, VARIANT* pVarID) STDMETHODIMP wxIAccessible::accLocation ( long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varID) { wxLogTrace(wxT("access"), wxT("accLocation")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -486,7 +494,7 @@ STDMETHODIMP wxIAccessible::accLocation ( long* pxLeft, long* pyTop, long* pcxWi STDMETHODIMP wxIAccessible::accNavigate ( long navDir, VARIANT varStart, VARIANT* pVarEnd) { - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; wxLogTrace(wxT("access"), wxString(wxT("accNavigate for ")) + m_pAccessible->GetWindow()->GetClassInfo()->GetClassName()); @@ -643,7 +651,7 @@ STDMETHODIMP wxIAccessible::accNavigate ( long navDir, VARIANT varStart, VARIANT STDMETHODIMP wxIAccessible::get_accChild ( VARIANT varChildID, IDispatch** ppDispChild) { wxLogTrace(wxT("access"), wxT("get_accChild")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -717,7 +725,7 @@ STDMETHODIMP wxIAccessible::get_accChild ( VARIANT varChildID, IDispatch** ppDis STDMETHODIMP wxIAccessible::get_accChildCount ( long* pCountChildren) { wxLogTrace(wxT("access"), wxT("get_accChildCount")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -761,7 +769,7 @@ STDMETHODIMP wxIAccessible::get_accChildCount ( long* pCountChildren) STDMETHODIMP wxIAccessible::get_accParent ( IDispatch** ppDispParent) { wxLogTrace(wxT("access"), wxT("get_accParent")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -825,7 +833,7 @@ STDMETHODIMP wxIAccessible::get_accParent ( IDispatch** ppDispParent) STDMETHODIMP wxIAccessible::accDoDefaultAction(VARIANT varID) { wxLogTrace(wxT("access"), wxT("accDoDefaultAction")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -870,7 +878,7 @@ STDMETHODIMP wxIAccessible::accDoDefaultAction(VARIANT varID) STDMETHODIMP wxIAccessible::get_accDefaultAction ( VARIANT varID, BSTR* pszDefaultAction) { wxLogTrace(wxT("access"), wxT("get_accDefaultAction")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -930,7 +938,7 @@ STDMETHODIMP wxIAccessible::get_accDefaultAction ( VARIANT varID, BSTR* pszDefau STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescription) { wxLogTrace(wxT("access"), wxT("get_accDescription")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -966,7 +974,7 @@ STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescrip } else { - if (description.IsEmpty()) + if (description.empty()) { * pszDescription = NULL; return S_FALSE; @@ -987,7 +995,7 @@ STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescrip STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp) { wxLogTrace(wxT("access"), wxT("get_accHelp")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1023,7 +1031,7 @@ STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp) } else { - if (helpString.IsEmpty()) + if (helpString.empty()) { * pszHelp = NULL; return S_FALSE; @@ -1047,7 +1055,7 @@ STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp) STDMETHODIMP wxIAccessible::get_accHelpTopic ( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic) { wxLogTrace(wxT("access"), wxT("get_accHelpTopic")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1092,7 +1100,7 @@ STDMETHODIMP wxIAccessible::get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKe wxLogTrace(wxT("access"), wxT("get_accKeyboardShortcut")); *pszKeyboardShortcut = NULL; - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1128,7 +1136,7 @@ STDMETHODIMP wxIAccessible::get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKe } else { - if (keyboardShortcut.IsEmpty()) + if (keyboardShortcut.empty()) { * pszKeyboardShortcut = NULL; return S_FALSE; @@ -1151,7 +1159,7 @@ STDMETHODIMP wxIAccessible::get_accName ( VARIANT varID, BSTR* pszName) wxLogTrace(wxT("access"), wxT("get_accName")); *pszName = NULL; - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1202,7 +1210,7 @@ STDMETHODIMP wxIAccessible::get_accName ( VARIANT varID, BSTR* pszName) STDMETHODIMP wxIAccessible::get_accRole ( VARIANT varID, VARIANT* pVarRole) { wxLogTrace(wxT("access"), wxT("get_accRole")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1262,7 +1270,7 @@ STDMETHODIMP wxIAccessible::get_accRole ( VARIANT varID, VARIANT* pVarRole) STDMETHODIMP wxIAccessible::get_accState ( VARIANT varID, VARIANT* pVarState) { wxLogTrace(wxT("access"), wxT("get_accState")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1313,7 +1321,7 @@ STDMETHODIMP wxIAccessible::get_accState ( VARIANT varID, VARIANT* pVarState) STDMETHODIMP wxIAccessible::get_accValue ( VARIANT varID, BSTR* pszValue) { wxLogTrace(wxT("access"), wxT("get_accValue")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1365,7 +1373,7 @@ STDMETHODIMP wxIAccessible::get_accValue ( VARIANT varID, BSTR* pszValue) STDMETHODIMP wxIAccessible::accSelect ( long flagsSelect, VARIANT varID ) { wxLogTrace(wxT("access"), wxT("get_accSelect")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1412,7 +1420,7 @@ STDMETHODIMP wxIAccessible::accSelect ( long flagsSelect, VARIANT varID ) STDMETHODIMP wxIAccessible::get_accFocus ( VARIANT* pVarID) { wxLogTrace(wxT("access"), wxT("get_accFocus")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1477,8 +1485,9 @@ STDMETHODIMP wxIAccessible::get_accFocus ( VARIANT* pVarID) STDMETHODIMP wxIAccessible::get_accSelection ( VARIANT * pVarChildren) { +#if wxUSE_VARIANT wxLogTrace(wxT("access"), wxT("get_accSelection")); - wxASSERT (m_pAccessible != NULL); + wxASSERT( ( m_pAccessible != NULL ) || ( m_bQuiescing == true ) ); if (!m_pAccessible) return E_FAIL; @@ -1534,6 +1543,9 @@ STDMETHODIMP wxIAccessible::get_accSelection ( VARIANT * pVarChildren) return S_OK; } } +#else + wxUnusedVar(pVarChildren); +#endif // wxUSE_VARIANT return E_NOTIMPL; } @@ -1707,6 +1719,7 @@ wxAccessible::wxAccessible(wxWindow* win) wxAccessible::~wxAccessible() { + m_pIAccessible->Quiesce(); m_pIAccessible->Release(); if (m_pIAccessibleStd) ((IAccessible*)m_pIAccessibleStd)->Release(); @@ -1748,6 +1761,8 @@ int wxConvertToWindowsRole(wxAccRole wxrole) { switch (wxrole) { + case wxROLE_NONE: + return 0; case wxROLE_SYSTEM_ALERT: return ROLE_SYSTEM_ALERT; case wxROLE_SYSTEM_ANIMATION: @@ -1996,4 +2011,4 @@ wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel) } -#endif //USE_ACCESSIBILITY +#endif // wxUSE_OLE && wxUSE_ACCESSIBILITY