winaccessibility/source/service/AccObject.cxx | 82 +++------------- winaccessibility/source/service/AccObjectWinManager.cxx | 24 +--- 2 files changed, 27 insertions(+), 79 deletions(-)
New commits: commit e6965d03288b70b4565730120c73d51b4033bffe Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 11 16:23:18 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Sep 12 07:07:42 2024 +0200 wina11y: Drop superfluous AccObject::m_pIMAcc null checks The `AccObject` ctor already asserts it's non-null, so there's no need to check again in various places. Change-Id: Ibba363d326198a89e391a4da54cff25c95eef776 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173223 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index 8a62a546632e..aa8bdc8ba873 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -323,8 +323,7 @@ void AccObject::DeleteChild( AccObject* pChild ) if(iter!=m_childrenList.end()) { m_childrenList.erase(iter); - if(m_pIMAcc) - pChild->SetParentObj(nullptr); + pChild->SetParentObj(nullptr); } } @@ -334,11 +333,7 @@ void AccObject::DeleteChild( AccObject* pChild ) * @param. * @return */ -void AccObject::UpdateValidWindow() -{ - if(m_pIMAcc) - m_pIMAcc->Put_XAccWindowHandle(m_pParantID); -} +void AccObject::UpdateValidWindow() { m_pIMAcc->Put_XAccWindowHandle(m_pParantID); } /** * Update value property to com object. @@ -347,7 +342,7 @@ void AccObject::UpdateValidWindow() */ void AccObject::UpdateValue() { - if( nullptr == m_pIMAcc || !m_xAccContextRef.is() ) + if (!m_xAccContextRef.is()) { assert(false); return ; @@ -370,7 +365,7 @@ void AccObject::UpdateValue() */ void AccObject::SetValue( Any pAny ) { - if( nullptr == m_pIMAcc || !m_xAccContextRef.is() ) + if (!m_xAccContextRef.is()) { assert(false); return ; @@ -576,10 +571,7 @@ DWORD AccObject::GetMSAAStateFromUNO(sal_Int64 nState) //case SENSITIVE: // IState = STATE_SYSTEM_PROTECTED; case EDITABLE: - if( m_pIMAcc ) - { - m_pIMAcc->DecreaseState( STATE_SYSTEM_READONLY ); - } + m_pIMAcc->DecreaseState(STATE_SYSTEM_READONLY); break; case OFFSCREEN: IState = STATE_SYSTEM_OFFSCREEN; @@ -607,11 +599,6 @@ DWORD AccObject::GetMSAAStateFromUNO(sal_Int64 nState) */ void AccObject::DecreaseState( sal_Int64 xState ) { - if( nullptr == m_pIMAcc ) - { - return; - } - if( xState == FOCUSABLE) { if (m_accRole == MENU_ITEM || m_accRole == RADIO_MENU_ITEM || m_accRole == CHECK_MENU_ITEM) @@ -647,13 +634,6 @@ void AccObject::DecreaseState( sal_Int64 xState ) */ void AccObject::IncreaseState( sal_Int64 xState ) { - if( nullptr == m_pIMAcc ) - { - assert(false); - return; - } - - if( xState == AccessibleStateType::VISIBLE ) { m_pIMAcc->DecreaseState( STATE_SYSTEM_INVISIBLE ); @@ -689,11 +669,6 @@ AccObject* AccObject::NextChild() */ void AccObject::UpdateRole() { - if (!m_pIMAcc) - { - return; - } - const sal_Int16 nUnoRole = m_xAccContextRef->getAccessibleRole(); short nIA2Role = lcl_mapToIAccessible2Role(nUnoRole); m_pIMAcc->Put_XAccRole(nIA2Role); @@ -706,11 +681,6 @@ void AccObject::UpdateRole() */ void AccObject::UpdateState() { - if (!m_pIMAcc) - { - return; - } - XAccessibleContext* pContext = m_xAccContextRef.get(); sal_Int64 nRState = pContext->getAccessibleStateSet(); @@ -880,7 +850,7 @@ void AccObject::UpdateState() */ bool AccObject::UpdateAccessibleInfoFromUnoToMSAA() { - if( nullptr == m_pIMAcc || !m_xAccContextRef.is() ) + if (!m_xAccContextRef.is()) { assert(false); return false; @@ -903,13 +873,10 @@ bool AccObject::UpdateAccessibleInfoFromUnoToMSAA() */ void AccObject::setFocus() { - if(m_pIMAcc) - { - IncreaseState(FOCUSED); - m_pIMAcc->Put_XAccFocus(CHILDID_SELF); + IncreaseState(FOCUSED); + m_pIMAcc->Put_XAccFocus(CHILDID_SELF); - UpdateRole(); - } + UpdateRole(); } /** @@ -919,11 +886,8 @@ void AccObject::setFocus() */ void AccObject::unsetFocus() { - if(m_pIMAcc) - { - DecreaseState( FOCUSED ); - m_pIMAcc->Put_XAccFocus(UACC_NO_FOCUS); - } + DecreaseState(FOCUSED); + m_pIMAcc->Put_XAccFocus(UACC_NO_FOCUS); } void AccObject::GetExpandedState( sal_Bool* isExpandable, sal_Bool* isExpanded) @@ -943,34 +907,22 @@ void AccObject::GetExpandedState( sal_Bool* isExpandable, sal_Bool* isExpanded) *isExpandable = true; } -void AccObject::NotifyDestroy() -{ - if(m_pIMAcc) - m_pIMAcc->NotifyDestroy(); -} +void AccObject::NotifyDestroy() { m_pIMAcc->NotifyDestroy(); } void AccObject::SetParentObj(AccObject* pParentAccObj) { m_pParentObj = pParentAccObj; - if(m_pIMAcc) - { - if(m_pParentObj) - { - m_pIMAcc->Put_XAccParent(m_pParentObj->GetIMAccessible()); - } - else - { - m_pIMAcc->Put_XAccParent(nullptr); - } - } + if (m_pParentObj) + m_pIMAcc->Put_XAccParent(m_pParentObj->GetIMAccessible()); + else + m_pIMAcc->Put_XAccParent(nullptr); } //ResID means ChildID in MSAA void AccObject::SetResID(long id) { m_resID = id; - if(m_pIMAcc) - m_pIMAcc->Put_XAccChildID(m_resID); + m_pIMAcc->Put_XAccChildID(m_resID); } //return COM interface in acc object IMAccessible* AccObject::GetIMAccessible() commit 07a7551f60010614825ad52f18c03f7a1bf1b8d0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 11 16:02:47 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Sep 12 07:07:36 2024 +0200 wina11y: Move var decl to first assignment ... and rename to use the "x" prefix for this uno::Reference. Change-Id: Ibf422aa48d6fbada49975fa8c5f43ad6c4c3ddee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173222 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index 04f67f669279..62bd5f2a27eb 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -576,17 +576,15 @@ void AccObjectWinManager::InsertAccChildNode( AccObject* pCurObj, AccObject* pPa */ bool AccObjectWinManager::InsertAccObj( XAccessible* pXAcc,XAccessible* pParentXAcc,HWND pWnd ) { - Reference< XAccessibleContext > pRContext; - if( pXAcc == nullptr) return false; - pRContext = pXAcc->getAccessibleContext(); - if( !pRContext.is() ) + Reference<XAccessibleContext> xContext = pXAcc->getAccessibleContext(); + if (!xContext.is()) return false; { - short nCurRole = pRContext->getAccessibleRole(); + short nCurRole = xContext->getAccessibleRole(); std::scoped_lock l(m_Mutex); @@ -647,7 +645,7 @@ bool AccObjectWinManager::InsertAccObj( XAccessible* pXAcc,XAccessible* pParentX CreateAccEventListener(pXAcc); if (!pListener.is()) return false; - Reference<XAccessibleComponent> xComponent(pRContext,UNO_QUERY); + Reference<XAccessibleComponent> xComponent(xContext, UNO_QUERY); Reference<XAccessibleEventBroadcaster> broadcaster(xComponent,UNO_QUERY); if (broadcaster.is()) { commit 0792cf256f437279f7ae2595dc49eceb608620c8 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 11 15:48:38 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Sep 12 07:07:29 2024 +0200 wina11y: Move var declaration to where it's assigned ... and rename the variable to use the "x" prefix in line with naming conventions. Change-Id: Ife49161162654efdf1d543909218e31e464d2fc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173221 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index 85804c9a59d6..04f67f669279 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -510,15 +510,14 @@ bool AccObjectWinManager::InsertChildrenAccObj( css::accessibility::XAccessible* if(!IsContainer(pXAcc)) return false; - Reference< XAccessibleContext > pRContext; - if( pXAcc == nullptr) return false; - pRContext = pXAcc->getAccessibleContext(); - if( !pRContext.is() ) + + Reference<XAccessibleContext> xContext = pXAcc->getAccessibleContext(); + if (!xContext.is()) return false; - short role = pRContext->getAccessibleRole(); + short role = xContext->getAccessibleRole(); if(css::accessibility::AccessibleRole::DOCUMENT == role || css::accessibility::AccessibleRole::DOCUMENT_PRESENTATION == role || @@ -531,11 +530,10 @@ bool AccObjectWinManager::InsertChildrenAccObj( css::accessibility::XAccessible* } } - const sal_Int64 nCount = pRContext->getAccessibleChildCount(); + const sal_Int64 nCount = xContext->getAccessibleChildCount(); for (sal_Int64 i = 0; i < nCount; i++) { - Reference<XAccessible> mxAccessible - = pRContext->getAccessibleChild(i); + Reference<XAccessible> mxAccessible = xContext->getAccessibleChild(i); XAccessible* mpAccessible = mxAccessible.get(); if(mpAccessible != nullptr) {