diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-08-09 10:08:14 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-08-09 15:45:35 +0200 |
commit | 63a004f51f063cad68c007d79d5cd4f56adde96b (patch) | |
tree | 1f750bd25c5101ec1a8068d8bb1b7cd07c45d5a4 | |
parent | d2c1a4fa508572cc2908787deeebc5baa9d6e0c3 (diff) |
wina11y: Use return value instead of out param
... to return the `IAccessible*` in
`AccObjectWinManager::GetIAccessibleFromXAccessible` and
`CMAccessible::get_IAccessibleFromXAccessible` and adapt
the call sites accordingly.
This is more straight-forward and the extra bool return
value didn't add anything, since it was also just
saying whether the pointer was a nullptr, so rather
check that directly.
Also drop `AccObjectWinManager::GetIMAccByXAcc` that
does the same thing and switch the only call site
to use `AccObjectWinManager::GetIAccessibleFromXAccessible`
instead.
Change-Id: I72933df62aa9ac1ff3f2a84c5045dfae354c18e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155505
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | winaccessibility/inc/AccObjectWinManager.hxx | 3 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccRelation.cxx | 8 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccTable.cxx | 22 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccTableCell.cxx | 23 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/EnumVariant.cxx | 11 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/MAccessible.cxx | 39 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/MAccessible.h | 3 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObjectWinManager.cxx | 19 |
8 files changed, 45 insertions, 83 deletions
diff --git a/winaccessibility/inc/AccObjectWinManager.hxx b/winaccessibility/inc/AccObjectWinManager.hxx index 11b65d0325b4..024a58fc8655 100644 --- a/winaccessibility/inc/AccObjectWinManager.hxx +++ b/winaccessibility/inc/AccObjectWinManager.hxx @@ -121,8 +121,7 @@ public: static bool IsContainer( css::accessibility::XAccessible* pAccessible ); - virtual IMAccessible* GetIMAccByXAcc(css::accessibility::XAccessible* pXAcc); - virtual bool GetIAccessibleFromXAccessible(css::accessibility::XAccessible* pXAcc, IAccessible** ppIA); + virtual IMAccessible* GetIAccessibleFromXAccessible(css::accessibility::XAccessible* pXAcc); virtual IMAccessible* GetIAccessibleFromResID(long resID); void NotifyDestroy( css::accessibility::XAccessible* pXAcc ); diff --git a/winaccessibility/source/UAccCOM/AccRelation.cxx b/winaccessibility/source/UAccCOM/AccRelation.cxx index ef3265000bab..2c815c674f24 100644 --- a/winaccessibility/source/UAccCOM/AccRelation.cxx +++ b/winaccessibility/source/UAccCOM/AccRelation.cxx @@ -108,12 +108,10 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccRelation::get_target(long targetIndex, IUn return E_FAIL; Reference<XAccessible> xRAcc(xTargets[targetIndex], UNO_QUERY); - IAccessible* pRet = nullptr; - - bool isGet = CMAccessible::get_IAccessibleFromXAccessible(xRAcc.get(), &pRet); - if(isGet) + IAccessible* pRet = CMAccessible::get_IAccessibleFromXAccessible(xRAcc.get()); + if (pRet) { - *target = /*(IAccessible2 *)*/pRet; + *target = pRet; pRet->AddRef(); return S_OK; } diff --git a/winaccessibility/source/UAccCOM/AccTable.cxx b/winaccessibility/source/UAccCOM/AccTable.cxx index 6cb0dd1d26b2..9fd32c532bc5 100644 --- a/winaccessibility/source/UAccCOM/AccTable.cxx +++ b/winaccessibility/source/UAccCOM/AccTable.cxx @@ -64,10 +64,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_accessibleAt(long row, long col return E_FAIL; } - IAccessible* pRet = nullptr; - - bool isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet); - if(isTRUE) + IAccessible* pRet = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get()); + if (pRet) { *accessible = pRet; pRet->AddRef(); @@ -78,9 +76,9 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_accessibleAt(long row, long col Reference<XAccessible> pxTable(pRXTable, UNO_QUERY); CMAccessible::g_pAccObjectManager->InsertAccObj(pRAcc.get(),pxTable.get()); - isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet); + pRet = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get()); - if(isTRUE) + if (pRet) { *accessible = pRet; pRet->AddRef(); @@ -549,8 +547,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_summary(IUnknown * * accessible Reference<XAccessible> pRAcc = pRXTable->getAccessibleSummary(); - IAccessible* pRet = nullptr; - CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet); + IAccessible* pRet = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get()); if(pRet) { @@ -1099,17 +1096,16 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedCells(IUnknown * * * ce Reference<XAccessible> xAcc = xSelection->getSelectedAccessibleChild(i); assert(xAcc.is()); - IAccessible* pIAccessible; - bool bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pIAccessible); + IAccessible* pIAccessible = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get()); - if (!bOK) + if (!pIAccessible) { Reference<XAccessible> xTable(pRXTable, UNO_QUERY); CMAccessible::g_pAccObjectManager->InsertAccObj(xAcc.get(), xTable.get()); - bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pIAccessible); + pIAccessible = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get()); } - assert(bOK && "Couldn't retrieve IAccessible object"); + assert(pIAccessible && "Couldn't retrieve IAccessible object"); pIAccessible->AddRef(); (*cells)[i] = pIAccessible; diff --git a/winaccessibility/source/UAccCOM/AccTableCell.cxx b/winaccessibility/source/UAccCOM/AccTableCell.cxx index 9b8bf21529d5..95725c2a4042 100644 --- a/winaccessibility/source/UAccCOM/AccTableCell.cxx +++ b/winaccessibility/source/UAccCOM/AccTableCell.cxx @@ -116,15 +116,14 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_columnHeaderCells(IUnknown* Reference<XAccessible> xCell = xHeaders->getAccessibleCellAt(nRow, nCol); assert(xCell.is()); - IAccessible* pIAccessible; - bool bOK = CMAccessible::get_IAccessibleFromXAccessible(xCell.get(), &pIAccessible); - if (!bOK) + IAccessible* pIAccessible = CMAccessible::get_IAccessibleFromXAccessible(xCell.get()); + if (!pIAccessible) { Reference<XAccessible> xTableAcc(m_xTable, UNO_QUERY); CMAccessible::g_pAccObjectManager->InsertAccObj(xCell.get(), xTableAcc.get()); - bOK = CMAccessible::get_IAccessibleFromXAccessible(xCell.get(), &pIAccessible); + pIAccessible = CMAccessible::get_IAccessibleFromXAccessible(xCell.get()); } - assert(bOK && "Couldn't retrieve IAccessible object for cell."); + assert(pIAccessible && "Couldn't retrieve IAccessible object for cell."); pIAccessible->AddRef(); (*cellAccessibles)[nRow] = pIAccessible; @@ -204,15 +203,14 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_rowHeaderCells(IUnknown*** Reference<XAccessible> xCell = xHeaders->getAccessibleCellAt(nRow, nCol); assert(xCell.is()); - IAccessible* pIAccessible; - bool bOK = CMAccessible::get_IAccessibleFromXAccessible(xCell.get(), &pIAccessible); - if (!bOK) + IAccessible* pIAccessible = CMAccessible::get_IAccessibleFromXAccessible(xCell.get()); + if (!pIAccessible) { Reference<XAccessible> xTableAcc(m_xTable, UNO_QUERY); CMAccessible::g_pAccObjectManager->InsertAccObj(xCell.get(), xTableAcc.get()); - bOK = CMAccessible::get_IAccessibleFromXAccessible(xCell.get(), &pIAccessible); + pIAccessible = CMAccessible::get_IAccessibleFromXAccessible(xCell.get()); } - assert(bOK && "Couldn't retrieve IAccessible object for cell."); + assert(pIAccessible && "Couldn't retrieve IAccessible object for cell."); pIAccessible->AddRef(); (*cellAccessibles)[nCol] = pIAccessible; @@ -301,9 +299,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_table(IUnknown** ppTable) if (!xAcc.is()) return E_FAIL; - IAccessible* pRet = nullptr; - bool bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pRet); - if (!bOK) + IAccessible* pRet = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get()); + if (!pRet) return E_FAIL; *ppTable = pRet; diff --git a/winaccessibility/source/UAccCOM/EnumVariant.cxx b/winaccessibility/source/UAccCOM/EnumVariant.cxx index 5f26159cef7f..cdac95f6b34b 100644 --- a/winaccessibility/source/UAccCOM/EnumVariant.cxx +++ b/winaccessibility/source/UAccCOM/EnumVariant.cxx @@ -64,10 +64,8 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Next(ULONG cElements,VARIANT __RPC_FAR * for (l1 = m_nCurrent, l2 = 0; l1 < nChildCount && l2 < cElements; l1++, l2++) { Reference< XAccessible > pRXAcc = m_pXAccessibleSelection->getSelectedAccessibleChild(l1); - IAccessible* pChild = nullptr; - bool isGet = CMAccessible::get_IAccessibleFromXAccessible(pRXAcc.get(), - &pChild); - if(isGet) + IAccessible* pChild = CMAccessible::get_IAccessibleFromXAccessible(pRXAcc.get()); + if(pChild) { pvar[l2].vt = VT_DISPATCH; pvar[l2].pdispVal = pChild; @@ -77,9 +75,8 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Next(ULONG cElements,VARIANT __RPC_FAR * { if (CMAccessible::g_pAccObjectManager) CMAccessible::g_pAccObjectManager->InsertAccObj(pRXAcc.get(),pUNOInterface); - isGet = CMAccessible::get_IAccessibleFromXAccessible( - pRXAcc.get(), &pChild); - if(isGet) + pChild = CMAccessible::get_IAccessibleFromXAccessible(pRXAcc.get()); + if(pChild) { pvar[l2].vt = VT_DISPATCH; pvar[l2].pdispVal = pChild; diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 1a5ec8c4efc1..2b7771507ece 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -991,14 +991,13 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::accHitTest(long xLeft, long yTop if (!xAccAtPoint.is()) return S_FALSE; - IAccessible* pRet = nullptr; - bool bHaveIAccessible = get_IAccessibleFromXAccessible(xAccAtPoint.get(), &pRet); - if (!bHaveIAccessible) + IAccessible* pRet = get_IAccessibleFromXAccessible(xAccAtPoint.get()); + if (!pRet) { g_pAccObjectManager->InsertAccObj(xAccAtPoint.get(), m_xAccessible.get(), m_hwnd); - bHaveIAccessible = get_IAccessibleFromXAccessible(xAccAtPoint.get(), &pRet); + pRet = get_IAccessibleFromXAccessible(xAccAtPoint.get()); } - if (!bHaveIAccessible) + if (!pRet) return S_FALSE; pvarChild->vt = VT_DISPATCH; @@ -1312,17 +1311,16 @@ IMAccessible* CMAccessible::GetChildInterface(long dChildID)//for test if(dChildID<1 || dChildID>pRContext->getAccessibleChildCount()) return nullptr; - IAccessible* pChild = nullptr; Reference< XAccessible > pXChild = pRContext->getAccessibleChild(dChildID-1); - bool isGet = get_IAccessibleFromXAccessible(pXChild.get(), &pChild); + IAccessible* pChild = get_IAccessibleFromXAccessible(pXChild.get()); - if(!isGet) + if(!pChild) { g_pAccObjectManager->InsertAccObj(pXChild.get(), m_xAccessible.get(), m_hwnd); - isGet = get_IAccessibleFromXAccessible(pXChild.get(), &pChild); + pChild = get_IAccessibleFromXAccessible(pXChild.get()); } - if(isGet) + if (pChild) { IMAccessible* pIMAcc = static_cast<IMAccessible*>(pChild); return pIMAcc; @@ -1406,7 +1404,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) } pChildXAcc = pRChildXAcc.get(); g_pAccObjectManager->InsertAccObj(pChildXAcc, m_xAccessible.get()); - return g_pAccObjectManager->GetIMAccByXAcc(pChildXAcc); + return g_pAccObjectManager->GetIAccessibleFromXAccessible(pChildXAcc); } /** @@ -2432,25 +2430,17 @@ HRESULT WINAPI CMAccessible::SmartQI(void* /*pv*/, REFIID iid, void** ppvObject) } catch(...) { return E_FAIL; } } -bool CMAccessible::get_IAccessibleFromXAccessible(XAccessible* pXAcc, IAccessible** ppIA) +IAccessible* CMAccessible::get_IAccessibleFromXAccessible(XAccessible* pXAcc) { try { - // #CHECK# - if(ppIA == nullptr) - { - return false; - } - bool isGet = false; if (g_pAccObjectManager) - isGet = g_pAccObjectManager->GetIAccessibleFromXAccessible(pXAcc, ppIA); - - return isGet; + return g_pAccObjectManager->GetIAccessibleFromXAccessible(pXAcc); } catch(...) { - return false; } + return nullptr; } OUString CMAccessible::get_StringFromAny(Any const & pAny) @@ -2733,13 +2723,12 @@ void CMAccessible::ConvertAnyToVariant(const css::uno::Any &rAnyVal, VARIANT *pv { if(pXAcc.is()) { - IAccessible* pIAcc = nullptr; - get_IAccessibleFromXAccessible(pXAcc.get(), &pIAcc); + IAccessible* pIAcc = get_IAccessibleFromXAccessible(pXAcc.get()); if(pIAcc == nullptr) { Reference< XAccessibleContext > pXAccContext = pXAcc->getAccessibleContext(); g_pAccObjectManager->InsertAccObj(pXAcc.get(),pXAccContext->getAccessibleParent().get()); - get_IAccessibleFromXAccessible(pXAcc.get(), &pIAcc); + pIAcc = get_IAccessibleFromXAccessible(pXAcc.get()); } if(pIAcc) { diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h index 5b42358f505e..d807258e4060 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.h +++ b/winaccessibility/source/UAccCOM/MAccessible.h @@ -206,8 +206,7 @@ public: // implement some specific MSAA methods,such as accSelection,accNavigate static AccObjectWinManager* g_pAccObjectManager; - static bool get_IAccessibleFromXAccessible( - css::accessibility::XAccessible * pXAcc, IAccessible** ppIA); + static IAccessible* get_IAccessibleFromXAccessible(css::accessibility::XAccessible* pXAcc); XGUIDToComObjHash m_containedObjects; static HRESULT WINAPI SmartQI_(void* pv, diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index 963573628372..04f81875cd88 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -998,26 +998,13 @@ bool AccObjectWinManager::IsStateManageDescendant(XAccessible* pAccessible) * @param pXAcc XAccessible interface. * @return Com accobject interface. */ -IMAccessible* AccObjectWinManager::GetIMAccByXAcc(XAccessible* pXAcc) +IMAccessible* AccObjectWinManager::GetIAccessibleFromXAccessible(XAccessible* pXAcc) { AccObject* pAccObj = GetAccObjByXAcc(pXAcc); - if(pAccObj) - { + if (pAccObj) return pAccObj->GetIMAccessible(); - } - else - { - return nullptr; - } -} -bool AccObjectWinManager::GetIAccessibleFromXAccessible(css::accessibility::XAccessible* pXAcc, - IAccessible** ppIA) -{ - *ppIA = GetIMAccByXAcc(pXAcc); - if (*ppIA) - return true; - return false; + return nullptr; } /** |