winaccessibility/inc/AccObject.hxx | 2 winaccessibility/inc/AccObjectWinManager.hxx | 1 winaccessibility/source/UAccCOM/MAccessible.cxx | 82 ++-------- winaccessibility/source/UAccCOM/MAccessible.h | 5 winaccessibility/source/UAccCOMIDL/UAccCOM.idl | 2 winaccessibility/source/service/AccComponentEventListener.cxx | 3 winaccessibility/source/service/AccObject.cxx | 22 -- winaccessibility/source/service/AccObjectWinManager.cxx | 7 8 files changed, 23 insertions(+), 101 deletions(-)
New commits: commit b08e52a2f4c179aa0cf990f414bdc797da2cf651 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Aug 21 15:12:33 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Aug 21 18:50:08 2024 +0200 wina11y: Drop COM indirection to get other CMAccessible's XAccessible Instead of having a COM method `CMAccessible::GetUNOInterface` to get the `CMAccessible::m_xAccessible` for another `CMAccessible` via COM, simply cast the `IMAccessible` to `CMAccessible` and access the member directly. Change-Id: Ic91c6cde3eb1ebb2bfaabdeb0a5e38017233949c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172214 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 50ebb113d626..81ca05856ab1 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -1349,15 +1349,12 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) { return nullptr; } - union { - XAccessible* pChildXAcc; - hyper nHyper = 0; - }; - pCurChild->GetUNOInterface(&nHyper); - if(pChildXAcc==nullptr) - { + + CMAccessible* pChildCMAcc = static_cast<CMAccessible*>(pCurChild); + XAccessible* pChildXAcc = pChildCMAcc->m_xAccessible.get(); + if (!pChildXAcc) return nullptr; - } + XAccessibleContext* pChildContext = GetContextByXAcc(pChildXAcc); if(pChildContext == nullptr) { @@ -2088,16 +2085,12 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARI if( flagsSelect&SELFLAG_TAKEFOCUS ) { - union { - XAccessible* pTempUNO; - hyper nHyper = 0; - }; - pSelectAcc->GetUNOInterface(&nHyper); - - if( pTempUNO == nullptr ) + CMAccessible* pSelectCMAcc = static_cast<CMAccessible*>(pSelectAcc); + Reference<XAccessible> xSelectAcc = pSelectCMAcc->m_xAccessible; + if (!xSelectAcc.is()) return 0; - Reference<XAccessibleContext> pRContext = pTempUNO->getAccessibleContext(); + Reference<XAccessibleContext> pRContext = xSelectAcc->getAccessibleContext(); Reference< XAccessibleComponent > pRComponent(pRContext,UNO_QUERY); Reference< XAccessible > pRParentXAcc = pRContext->getAccessibleParent(); Reference< XAccessibleContext > pRParentContext = pRParentXAcc->getAccessibleContext(); @@ -2142,22 +2135,6 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARI } catch(...) { return E_FAIL; } } -/** -* Return XAccessible interface pointer when needed -* @param pXAcc, [in, out] the Uno interface of the current object. -* @return S_OK if successful. -*/ -COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::GetUNOInterface(hyper * pXAcc) -{ - // internal IMAccessible - no mutex meeded - - if(pXAcc == nullptr) - return E_INVALIDARG; - - *pXAcc = reinterpret_cast<hyper>(m_xAccessible.get()); - return S_OK; -} - /** * This method is called when AT open some UI elements initially * the UI element takes the default action defined here diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h index cf793184265d..a0733fa0c9a9 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.h +++ b/winaccessibility/source/UAccCOM/MAccessible.h @@ -146,7 +146,6 @@ public: STDMETHOD(Put_XAccChildID)(long dChildID) override; STDMETHOD(Put_XAccObjectManager)(hyper pManager) override; STDMETHOD(NotifyDestroy)() override; - STDMETHOD(GetUNOInterface)(hyper*) override; STDMETHOD(SetXAccessible)(hyper) override; private: diff --git a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl index 5f936f85f958..8c63a5a3bfdf 100644 --- a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl +++ b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl @@ -42,7 +42,6 @@ import "defines.idl"; [id(13), helpstring("method Put_XAccWindowHandle")] HRESULT Put_XAccWindowHandle(HWND hwnd); [id(14), helpstring("method Put_XAccChildID")] HRESULT Put_XAccChildID(long dChildID); [id(19), helpstring("method SetXAccessible")] HRESULT SetXAccessible(hyper XAccessible); - [id(20), helpstring("method GetUNOInterface")] HRESULT GetUNOInterface(hyper* UNOInterface); [id(25), helpstring("method Put_XAccObjectManager")] HRESULT Put_XAccObjectManager(hyper pManager); [id(26), helpstring("method NotifyDestroy")] HRESULT NotifyDestroy(); }; commit e5adf2b514f04e4ec9800ab6cdc5592efea86007 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Aug 21 14:59:09 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Aug 21 18:50:01 2024 +0200 wina11y: Clarify + reduce variable scope In `CMAccessible::GetNavigateChildForDM`: * reduce scope of local variables and the union used only in one of the cases * don't reuse the `pChildXAcc` union member at the end of the method for something that's completely unrelated Change-Id: I2169bbf5a7af3c806181ab284294514ff68a1506 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172213 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 762e8673d995..50ebb113d626 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -1332,14 +1332,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) return nullptr; } - IMAccessible* pCurChild = nullptr; - union { - XAccessible* pChildXAcc; - hyper nHyper = 0; - }; Reference<XAccessible> pRChildXAcc; - XAccessibleContext* pChildContext = nullptr; - sal_Int64 index = 0, delta = 0; switch(flags) { case DM_FIRSTCHILD: @@ -1350,31 +1343,37 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) break; case DM_NEXTCHILD: case DM_PREVCHILD: - pCurChild = GetChildInterface(varCur.lVal); + { + IMAccessible* pCurChild = GetChildInterface(varCur.lVal); if(pCurChild==nullptr) { return nullptr; } + union { + XAccessible* pChildXAcc; + hyper nHyper = 0; + }; pCurChild->GetUNOInterface(&nHyper); if(pChildXAcc==nullptr) { return nullptr; } - pChildContext = GetContextByXAcc(pChildXAcc); + XAccessibleContext* pChildContext = GetContextByXAcc(pChildXAcc); if(pChildContext == nullptr) { return nullptr; } - delta = (flags==DM_NEXTCHILD)?1:-1; + const sal_Int64 delta = (flags == DM_NEXTCHILD) ? 1 : -1; //currently, getAccessibleIndexInParent is error in UNO for //some kind of List,such as ValueSet, the index will be less 1 than //what should be, need to fix UNO code - index = pChildContext->getAccessibleIndexInParent()+delta; + const sal_Int64 index = pChildContext->getAccessibleIndexInParent() + delta; if((index>=0)&&(index<=count-1)) { pRChildXAcc = pXContext->getAccessibleChild(index); } break; + } default: break; } @@ -1383,9 +1382,8 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) { return nullptr; } - pChildXAcc = pRChildXAcc.get(); - g_pAccObjectManager->InsertAccObj(pChildXAcc, m_xAccessible.get()); - return g_pAccObjectManager->GetIAccessibleFromXAccessible(pChildXAcc); + g_pAccObjectManager->InsertAccObj(pRChildXAcc.get(), m_xAccessible.get()); + return g_pAccObjectManager->GetIAccessibleFromXAccessible(pRChildXAcc.get()); } /** commit 2acf6f42533146888920e2e70ed80fd01b8048dc Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Aug 21 11:10:47 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Aug 21 18:49:54 2024 +0200 wina11y: Query XAccessibleAction iface on demand Despite the // initially m_xAction and m_xContext are the same object // but they may be different once AccObject::UpdateAction() is called? comment in winaccessibility/source/UAccCOM/MAccessible.h, `MAccessible::m_xAction` is supposed to point to the same underlying object as `MAccessible::m_xContext`, see `AccObject::UpdateAction` (which queries for the `XAccessibleAction` interface and sets that). Simplify this by just querying `MAccessible::m_xContext` for the `XAccessibleAction` iface on demand in those places where it's needed. Change-Id: Id3d89213937c2c72a936947da69ca7fddc8f1b09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172205 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/winaccessibility/inc/AccObject.hxx b/winaccessibility/inc/AccObject.hxx index 9810e7a42d72..cb9f0ceaf711 100644 --- a/winaccessibility/inc/AccObject.hxx +++ b/winaccessibility/inc/AccObject.hxx @@ -56,7 +56,6 @@ private: ::rtl::Reference<AccEventListener> m_pListener; css::uno::Reference < css::accessibility::XAccessible > m_xAccRef; - css::uno::Reference < css::accessibility::XAccessibleAction > m_xAccActionRef; css::uno::Reference < css::accessibility::XAccessibleContext > m_xAccContextRef; void UpdateRole(); @@ -105,7 +104,6 @@ public: void UpdateState(); void UpdateValue(); - void UpdateAction(); void UpdateValidWindow(); void setFocus(); diff --git a/winaccessibility/inc/AccObjectWinManager.hxx b/winaccessibility/inc/AccObjectWinManager.hxx index 9a6b9f0fe243..e03fa8a1c7bf 100644 --- a/winaccessibility/inc/AccObjectWinManager.hxx +++ b/winaccessibility/inc/AccObjectWinManager.hxx @@ -114,7 +114,6 @@ public: void UpdateValue( css::accessibility::XAccessible* pXAcc ); void UpdateAccFocus( css::accessibility::XAccessible* newFocus ); - void UpdateAction( css::accessibility::XAccessible* pXAcc ); static bool IsContainer( css::accessibility::XAccessible* pAccessible ); diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index fbf035902aae..762e8673d995 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -2160,19 +2160,6 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::GetUNOInterface(hyper * pXAcc) return S_OK; } -/** -* Helper method for Implementation of get_accDefaultAction -* @param pAction, the default action point of the current object. -* @return S_OK if successful. -*/ -COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::SetDefaultAction(hyper pAction) -{ - // internal IMAccessible - no mutex meeded - - m_xAction = reinterpret_cast<XAccessibleAction*>(pAction); - return S_OK; -} - /** * This method is called when AT open some UI elements initially * the UI element takes the default action defined here @@ -2195,10 +2182,11 @@ COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CMAccessible::get_accDefaultActio { if(varChild.lVal==CHILDID_SELF) { - if (!m_xAction.is() || m_xAction->getAccessibleActionCount() < 1) + Reference<XAccessibleAction> xAction(m_xContext, UNO_QUERY); + if (!xAction.is() || xAction->getAccessibleActionCount() < 1) return S_FALSE; - const OUString sActionDescription = m_xAction->getAccessibleActionDescription(0); + const OUString sActionDescription = xAction->getAccessibleActionDescription(0); SysFreeString(*pszDefaultAction); *pszDefaultAction = SysAllocString(o3tl::toW(sActionDescription.getStr())); return S_OK; @@ -2232,10 +2220,11 @@ COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CMAccessible::accDoDefaultAction( if (varChild.lVal == CHILDID_SELF) { - if (!m_xAction.is() || m_xAction->getAccessibleActionCount() < 1) + Reference<XAccessibleAction> xAction(m_xContext, UNO_QUERY); + if (!xAction.is() || xAction->getAccessibleActionCount() < 1) return S_FALSE; - m_xAction->doAccessibleAction(0); + xAction->doAccessibleAction(0); return S_OK; } diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h index 0bcbda08fa02..cf793184265d 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.h +++ b/winaccessibility/source/UAccCOM/MAccessible.h @@ -146,7 +146,6 @@ public: STDMETHOD(Put_XAccChildID)(long dChildID) override; STDMETHOD(Put_XAccObjectManager)(hyper pManager) override; STDMETHOD(NotifyDestroy)() override; - STDMETHOD(SetDefaultAction)(hyper pAction) override; STDMETHOD(GetUNOInterface)(hyper*) override; STDMETHOD(SetXAccessible)(hyper) override; @@ -174,9 +173,6 @@ private: bool m_isDestroy; css::uno::Reference<css::accessibility::XAccessible> m_xAccessible; - // initially m_xAction and m_xContext are the same object - // but they may be different once AccObject::UpdateAction() is called? - css::uno::Reference<css::accessibility::XAccessibleAction> m_xAction; css::uno::Reference<css::accessibility::XAccessibleContext> m_xContext; private: diff --git a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl index 20281fcfe910..5f936f85f958 100644 --- a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl +++ b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl @@ -43,7 +43,6 @@ import "defines.idl"; [id(14), helpstring("method Put_XAccChildID")] HRESULT Put_XAccChildID(long dChildID); [id(19), helpstring("method SetXAccessible")] HRESULT SetXAccessible(hyper XAccessible); [id(20), helpstring("method GetUNOInterface")] HRESULT GetUNOInterface(hyper* UNOInterface); - [id(23), helpstring("method SetDefaultAction")] HRESULT SetDefaultAction(hyper pAction); [id(25), helpstring("method Put_XAccObjectManager")] HRESULT Put_XAccObjectManager(hyper pManager); [id(26), helpstring("method NotifyDestroy")] HRESULT NotifyDestroy(); }; diff --git a/winaccessibility/source/service/AccComponentEventListener.cxx b/winaccessibility/source/service/AccComponentEventListener.cxx index a55b585544d2..a5e73bc208a1 100644 --- a/winaccessibility/source/service/AccComponentEventListener.cxx +++ b/winaccessibility/source/service/AccComponentEventListener.cxx @@ -101,7 +101,6 @@ void AccComponentEventListener::HandleValueChangedEvent(Any, Any) */ void AccComponentEventListener::HandleActionChangedEvent() { - m_rObjManager.UpdateAction(m_xAccessible.get()); m_rObjManager.NotifyAccEvent(m_xAccessible.get(), UnoMSAAEvent::OBJECT_DEFACTIONCHANGE); } @@ -228,7 +227,6 @@ void AccComponentEventListener::FireStatePropertyChange(sal_Int64 state, bool se case AccessibleStateType::CHECKED: case AccessibleStateType::INDETERMINATE: m_rObjManager.IncreaseState(m_xAccessible.get(), state); - m_rObjManager.UpdateAction(m_xAccessible.get()); if (bPressedInsteadOfChecked) m_rObjManager.NotifyAccEvent(m_xAccessible.get(), UnoMSAAEvent::STATE_PRESSED); else @@ -267,7 +265,6 @@ void AccComponentEventListener::FireStatePropertyChange(sal_Int64 state, bool se case AccessibleStateType::CHECKED: case AccessibleStateType::INDETERMINATE: m_rObjManager.DecreaseState(m_xAccessible.get(), state); - m_rObjManager.UpdateAction(m_xAccessible.get()); if (bPressedInsteadOfChecked) m_rObjManager.NotifyAccEvent(m_xAccessible.get(), UnoMSAAEvent::STATE_PRESSED); else diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index 3b4a0fc7a3e2..6b24b034cf3c 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -268,12 +268,10 @@ AccObject::AccObject(XAccessible* pAcc, AccObjectWinManager* pManager, assert(m_pIMAcc); m_xAccContextRef = m_xAccRef->getAccessibleContext(); - m_xAccActionRef.set(m_xAccContextRef,UNO_QUERY); m_accRole = m_xAccContextRef -> getAccessibleRole(); m_pIMAcc->SetXAccessible(reinterpret_cast<hyper>(m_xAccRef.get())); m_pIMAcc->Put_XAccObjectManager(reinterpret_cast<hyper>(pManager)); - m_pIMAcc->SetDefaultAction(reinterpret_cast<hyper>(m_xAccActionRef.get())); } /** * Destructor. @@ -283,7 +281,6 @@ AccObject::AccObject(XAccessible* pAcc, AccObjectWinManager* pManager, AccObject::~AccObject() { m_xAccRef = nullptr; - m_xAccActionRef = nullptr; m_xAccContextRef = nullptr; } @@ -344,25 +341,6 @@ void AccObject::UpdateValidWindow() m_pIMAcc->Put_XAccWindowHandle(m_pParantID); } -/** - * Update default action property to com object. - * @param - * @return - */ -void AccObject::UpdateAction() -{ - m_xAccActionRef.set(m_xAccContextRef,UNO_QUERY); - - if( m_xAccActionRef.is() && m_pIMAcc ) - { - if( m_xAccActionRef->getAccessibleActionCount() > 0 ) - { - m_pIMAcc->SetDefaultAction( - reinterpret_cast<hyper>(m_xAccActionRef.get())); - } - } -} - /** * Update value property to com object. * @param diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index 8e08d4cafedf..244983cdac75 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -844,13 +844,6 @@ void AccObjectWinManager::UpdateState( css::accessibility::XAccessible* pXAcc ) pAccObj->UpdateState( ); } -void AccObjectWinManager::UpdateAction( XAccessible* pXAcc ) -{ - AccObject* pAccObj = GetAccObjByXAcc( pXAcc ); - if( pAccObj ) - pAccObj->UpdateAction(); -} - /** * Set corresponding com object's value via XAccessible interface and new value. * @param pXAcc XAccessible interface.