diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-09-02 13:06:08 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-09-02 15:47:37 +0200 |
commit | 206543c7bef58fc559852553a3b2faba0b604259 (patch) | |
tree | 4fc3e0e57e6f9b50e276998fc04241035a2dffb6 /winaccessibility | |
parent | 38671e21d7dbcd5019912b9468305018de0c922e (diff) |
[API CHANGE] tdf#150683 a11y: Switch a11y child index to 64 bit
With 16k column support in Calc enabled by default in
commit 4c5f8ccf0a2320432b8fe91add1dcadf54d9fd58
Date: Tue Mar 8 12:44:49 2022 +0100
change default Calc number of columns to 16384 (tdf#50916)
, the number of Calc cells in a spreadsheet is larger than
SAL_MAX_INT32, meaning that a 32-bit a11y child index is no more
enough and using it resulted in integer overflows in
methods handling corresponding Calc cells in the a11y layer.
This e.g. had the effect of the Orca and NVDA screen readers
not announcing focused or selected cells properly when their
a11y child index was out of the 32-bit integer range.
Switch the internal a11y child indices to 64 bit to
be able to handle this properly internally.
Since the platform APIs (at least AT-SPI on Linux and
IAccessible2 on Windows; from what I can see LO's macOS
a11y bridge doesn't directly expose the child index)
are still restricted to 32 bit, larger child indices
still cannot be exposed via the platform APIs.
As a consequence, use of the the IAccessible2 and
AT-SPI methods that use the child index remains
problematic in those cases where the child index
is larger. However, as an alternative to using the
AT-SPI Table interface and the IAccessibleTable/
IAccessibleTable2 interfaces with the child index
to retrieve information about a specific cell,
both AT-SPI and IAccessible2 also provide interfaces
to retrieve that information directly
from the cell object (TableCell interface for AT-SPI,
IAccessibleTableCell for IAccessible2).
Those interfaces are already implemented/exposed
for winaccessibility (s. `CAccTable`) and the
qt5/qt6/kf5 VCL plugins (s. the `QAccessibleTableCellInterface`
methods implemented in `QtAccessibleInterface`).
With the switch to 64-bit internal a11y child indices,
these now behave correctly for cells with a child
index that doesn't fit into 32 bit as well.
NVDA on Windows already uses the IAccessibleTableCell
interface and thus announcing focused cells works fine
with this change in place.
Orca on Linux currently doesn't make use of the AT-SPI
TableCell interface yet, but with a suggested change to
do so [1], announcement of selected cells works
with the qt6 VCL plugin with a current qtbase dev branch
as well - when combined with the suggested changes
to implement support for the AT-SPI TableCell interface
in Qt [2] [3] and the LO change based on that [4] and
a fix for a nullptr dereference [5].
The gtk3 VCL plugin doesn't expose the AT-SPI
TableCell interface yet, but once it does so
(via `AtkTableCell`), it also works with the
suggested Orca change [1] in place.
(Adding that is planned for an upcoming change,
works with a local WIP patch.)
For handling return values that are larger than what
platform APIs support, the following approach has
been chosen for now:
1) When the return value is for the count of
(selected) children, the maximum value N
supported by the platform API is returned.
(This is what `ScAccessibleTableBase::getAccessibleChildCount`
did previously.)
The first N elements can be accessed by their
actual (selection) indices.
2) When the return value is the child/cell index,
-2 is returned for objects whose index is greater
than the maximum value supported by the platform
API.
Using a non-negative value would mean that the
index would refer to *another* actually existing
child. A child index of -1 on the other hand
tends to be interpreted as "child is invalid" or
"object isn't actually a child of its (previous)
parent any more)". For the Orca case, this would
result in objects with a child index of -1
not being announced, as they are considered
"zombies" [6].
What's still somewhat problematic is the case where
more than 2^31 children are *selected*, since access
to those children still happens by the index into
the selection in the platform APIs, and not all
selected items are accessible this way.
(Screen readers usually just retrieve
the first and last element from the selection and
announce those.)
Orca already seems to apply different handling for the
case for fully selected rows and columns, so
"All cells selected" or "Columns ... to ... selected"
is announced just fine even if more than 2^31
cells are selected.
(Side note: While Microsoft User Interface
Automation - UIA - also uses 32-bit indices, it also
has specific methods in the ISelectionProvider2
interface that allow to explicitly retrieve the
first and last selected item,
`ISelectionProvider2::get_FirstSelectedItem` and
`ISelectionProvider2::get_LastSelectedItem`, but
we currently don't support UIA on Windows.)
Bound checks at the beginning of the methods from the
`XAccessibleContext`, `XAccessibleSelection` and
`XAccessibleTable` interfaces that take a child index
(or in helper methods called by those) should generally
already prevent too large indices from being passed to
the methods in the lower layer code that take smaller
integer types. Such bound checking has been
been added in various places where it wasn't present yet.
If there any remaining issues of this
kind that show after this commit, they can probably be
solved in a similar way (s.e.g. the change to
`AccessibleBrowseBox::getAccessibleChild` in this
commit).
A few asserts were also added at
places where my understanding is that values shouldn't
be larger than what is supported by a called method
anyway.
A test case will be added in a following change.
[1] https://gitlab.gnome.org/GNOME/orca/-/merge_requests/131
[2] https://codereview.qt-project.org/c/qt/qtbase/+/428566
[3] https://codereview.qt-project.org/c/qt/qtbase/+/428567
[4] https://gerrit.libreoffice.org/c/core/+/138750
[5] https://codereview.qt-project.org/c/qt/qtbase/+/430157
[6] https://gitlab.gnome.org/GNOME/orca/-/blob/82c8542002e36e0d3d918088d583162d25136143/src/orca/script_utilities.py#L5155
Change-Id: I3af590c988b0e6754fc72545918412f39e8fea07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139258
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'winaccessibility')
9 files changed, 139 insertions, 60 deletions
diff --git a/winaccessibility/source/UAccCOM/AccTable.cxx b/winaccessibility/source/UAccCOM/AccTable.cxx index 63f9edf7ec14..16eea5bb533d 100644 --- a/winaccessibility/source/UAccCOM/AccTable.cxx +++ b/winaccessibility/source/UAccCOM/AccTable.cxx @@ -32,6 +32,7 @@ #pragma clang diagnostic pop #endif +#include <sal/log.hxx> #include <vcl/svapp.hxx> #include <o3tl/char16_t2wchar_t.hxx> @@ -684,8 +685,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::selectRow(long row) lColumnCount = pRXTable->getAccessibleColumnCount(); for(lCol = 0; lCol < lColumnCount; lCol ++) { - long lChildIndex = pRXTable->getAccessibleIndex(row, lCol); - pRSelection->selectAccessibleChild(lChildIndex); + sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(row, lCol); + pRSelection->selectAccessibleChild(nChildIndex); } return S_OK; @@ -728,8 +729,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::selectColumn(long column) lRowCount = pRXTable->getAccessibleRowCount(); for(lRow = 0; lRow < lRowCount; lRow ++) { - long lChildIndex = pRXTable->getAccessibleIndex(lRow, column); - pRSelection->selectAccessibleChild(lChildIndex); + sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(lRow, column); + pRSelection->selectAccessibleChild(nChildIndex); } return S_OK; @@ -775,8 +776,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::unselectRow(long row) lColumnCount = pRXTable->getAccessibleColumnCount(); for(lColumn = 0; lColumn < lColumnCount; lColumn ++) { - long lChildIndex = pRXTable->getAccessibleIndex(row, lColumn); - pRSelection->deselectAccessibleChild(lChildIndex); + sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(row, lColumn); + pRSelection->deselectAccessibleChild(nChildIndex); } return S_OK; @@ -823,8 +824,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::unselectColumn(long column) for(lRow = 0; lRow < lRowCount; lRow ++) { - long lChildIndex = pRXTable->getAccessibleIndex(lRow, column); - pRSelection->deselectAccessibleChild(lChildIndex); + sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(lRow, column); + pRSelection->deselectAccessibleChild(nChildIndex); } return S_OK; } @@ -931,7 +932,17 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_childIndex(long RowIndex , long if(!pRXTable.is()) return E_FAIL; - *childIndex = pRXTable->getAccessibleIndex(RowIndex, columnIndex); + sal_Int64 nIndex = pRXTable->getAccessibleIndex(RowIndex, columnIndex); + if (nIndex > std::numeric_limits<long>::max()) + { + // use -2 when the child index is too large to fit into 32 bit to neither use the + // valid index of another child nor -1, which is more commonly used to indicate that + // a child is no more inside of a parent or invalid otherwise + SAL_WARN("vcl.qt", "CAccTable::get_childIndex: Child index exceeds maximum long value, " + "returning -2."); + nIndex = -2; + } + *childIndex = nIndex; return S_OK; } catch(...) { return E_FAIL; } @@ -973,7 +984,14 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedChildren(long *childCo if(!pRSelection.is()) return E_FAIL; - *childCount = pRSelection->getSelectedAccessibleChildCount(); + sal_Int64 nSelected = pRSelection->getSelectedAccessibleChildCount(); + if (nSelected > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CAccTable::get_nSelectedChildren: Selected item count exceeds maximum long value, " + "using max long."); + nSelected = std::numeric_limits<long>::max(); + } + *childCount = nSelected; return S_OK; } catch(...) { return E_FAIL; } @@ -1011,13 +1029,18 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedChildren(long, long **c if(!pRSelection.is()) return E_FAIL; - long childCount = pRSelection->getSelectedAccessibleChildCount() ; - - *nChildren = childCount; + sal_Int64 nChildCount = pRSelection->getSelectedAccessibleChildCount(); + if (nChildCount > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CAccTable::get_selectedChildren: Selected child count exceeds maximum long value, " + "using max long."); + nChildCount = std::numeric_limits<long>::max(); + } - *children = static_cast<long*>(CoTaskMemAlloc(childCount * sizeof(long))); + *nChildren = nChildCount; + *children = static_cast<long*>(CoTaskMemAlloc(nChildCount * sizeof(long))); - for( long i = 0; i< childCount; i++) + for( long i = 0; i< nChildCount; i++) { Reference<XAccessible> pRAcc = pRSelection->getSelectedAccessibleChild(i); if(pRAcc.is()) @@ -1026,8 +1049,15 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedChildren(long, long **c if( !pRContext.is() ) return E_FAIL; - long childIndex = pRContext->getAccessibleIndexInParent(); - (*children)[i] = childIndex; + + sal_Int64 nChildIndex = pRContext->getAccessibleIndexInParent(); + if (nChildIndex > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CAccTable::get_selectedChildren: Child index exceeds maximum long value, " + "using max long."); + nChildIndex = std::numeric_limits<long>::max(); + } + (*children)[i] = nChildIndex; } } @@ -1061,7 +1091,13 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedCells(IUnknown * * * ce if (!xSelection.is()) return E_FAIL; - const long nSelected = xSelection->getSelectedAccessibleChildCount(); + sal_Int64 nSelected = xSelection->getSelectedAccessibleChildCount(); + if (nSelected > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CAccTable::get_selectedCells: Selected cell count exceeds maximum long value, " + "using max long."); + nSelected = std::numeric_limits<long>::max(); + } *nSelectedCells = nSelected; *cells = static_cast<IUnknown**>(CoTaskMemAlloc(nSelected * sizeof(IUnknown*))); diff --git a/winaccessibility/source/UAccCOM/AccTableCell.h b/winaccessibility/source/UAccCOM/AccTableCell.h index ee1649ea7115..95250d53ada3 100644 --- a/winaccessibility/source/UAccCOM/AccTableCell.h +++ b/winaccessibility/source/UAccCOM/AccTableCell.h @@ -81,7 +81,7 @@ public: private: css::uno::Reference<css::accessibility::XAccessibleTable> m_xTable; - sal_Int32 m_nIndexInParent; + sal_Int64 m_nIndexInParent; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/UAccCOM/EnumVariant.cxx b/winaccessibility/source/UAccCOM/EnumVariant.cxx index 92d4540796be..885a1ebc3cb8 100644 --- a/winaccessibility/source/UAccCOM/EnumVariant.cxx +++ b/winaccessibility/source/UAccCOM/EnumVariant.cxx @@ -30,6 +30,7 @@ #pragma clang diagnostic pop #endif +#include <sal/log.hxx> #include <vcl/svapp.hxx> using namespace com::sun::star::uno; @@ -50,7 +51,6 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Next(ULONG cElements,VARIANT __RPC_FAR * { SolarMutexGuard g; - long l1; ULONG l2; if (pvar == nullptr) @@ -59,9 +59,17 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Next(ULONG cElements,VARIANT __RPC_FAR * if (pcElementFetched != nullptr) *pcElementFetched = 0; + sal_Int64 nChildCount = m_pXAccessibleSelection->getSelectedAccessibleChildCount(); + if (nChildCount > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CEnumVariant::Next: Child count exceeds maximum long value, " + "using max long."); + nChildCount = std::numeric_limits<long>::max(); + } + // Retrieve the next cElements. - for (l1=m_lCurrent, l2=0; l1<m_pXAccessibleSelection->getSelectedAccessibleChildCount() && - l2<cElements; l1++, l2++) + sal_Int64 l1; + for (l1 = m_nCurrent, l2 = 0; l1 < nChildCount && l2 < cElements; l1++, l2++) { Reference< XAccessible > pRXAcc = m_pXAccessibleSelection->getSelectedAccessibleChild(l1); IAccessible* pChild = nullptr; @@ -90,7 +98,7 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Next(ULONG cElements,VARIANT __RPC_FAR * // Set count of elements retrieved. if (pcElementFetched != nullptr) *pcElementFetched = l2; - m_lCurrent = l1; + m_nCurrent = l1; return (l2 < cElements) ? S_FALSE : NOERROR; } @@ -104,10 +112,17 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Skip(ULONG cElements) { SolarMutexGuard g; - m_lCurrent += cElements; - if (m_lCurrent > m_pXAccessibleSelection->getSelectedAccessibleChildCount()) + m_nCurrent += cElements; + sal_Int64 nChildCount = m_pXAccessibleSelection->getSelectedAccessibleChildCount(); + if (nChildCount > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CEnumVariant::Skip: Child count exceeds maximum long value, " + "using max long."); + nChildCount = std::numeric_limits<long>::max(); + } + if (m_nCurrent > nChildCount) { - m_lCurrent = m_pXAccessibleSelection->getSelectedAccessibleChildCount(); + m_nCurrent = nChildCount; return E_FAIL; } else @@ -124,7 +139,7 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Reset() { SolarMutexGuard g; - m_lCurrent = 0; + m_nCurrent = 0; return NOERROR; } @@ -188,12 +203,21 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Create(CEnumVariant __RPC_FAR *__RPC_FAR long CEnumVariant::GetCountOfElements() { if(m_pXAccessibleSelection.is()) - return m_pXAccessibleSelection->getSelectedAccessibleChildCount(); + { + sal_Int64 nCount = m_pXAccessibleSelection->getSelectedAccessibleChildCount(); + if (nCount > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CEnumVariant::GetCountOfElements: Count exceeds maximum long value, " + "using max long."); + nCount = std::numeric_limits<long>::max(); + } + return nCount; + } return 0; } /** - * Set member m_pXAccessibleSelection to NULL and m_lCurrent to 0. + * Set member m_pXAccessibleSelection to NULL and m_nCurrent to 0. * @param. * @return Result */ @@ -203,7 +227,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CEnumVariant::ClearEnumeration() pUNOInterface = nullptr; m_pXAccessibleSelection = nullptr; - m_lCurrent = 0; + m_nCurrent = 0; return S_OK; } diff --git a/winaccessibility/source/UAccCOM/EnumVariant.h b/winaccessibility/source/UAccCOM/EnumVariant.h index 6d5bd286dbaf..bf7a45feb155 100644 --- a/winaccessibility/source/UAccCOM/EnumVariant.h +++ b/winaccessibility/source/UAccCOM/EnumVariant.h @@ -43,7 +43,7 @@ class ATL_NO_VTABLE CEnumVariant : { public: CEnumVariant() - :m_lCurrent(0), + :m_nCurrent(0), pUNOInterface(nullptr) { } @@ -98,7 +98,7 @@ public: private: - long m_lCurrent; + sal_Int64 m_nCurrent; css::accessibility::XAccessible* pUNOInterface; css::uno::Reference<css::accessibility::XAccessibleSelection> m_pXAccessibleSelection; diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index a7b313ae0abf..2b11d2ed7d12 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -44,6 +44,7 @@ #include "AccHyperLink.h" #include <rtl/ustrbuf.hxx> +#include <sal/log.hxx> #include <vcl/svapp.hxx> #include <o3tl/char16_t2wchar_t.hxx> #include <comphelper/AccessibleImplementationHelper.hxx> @@ -293,7 +294,15 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_accChildCount(long *pcountCh m_xAccessible->getAccessibleContext(); if( pRContext.is() ) { - *pcountChildren = pRContext->getAccessibleChildCount(); + sal_Int64 nChildCount = pRContext->getAccessibleChildCount(); + if (nChildCount > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CMAccessible::get_accChildCount: Child count exceeds maximum long value, " + "returning max long."); + nChildCount = std::numeric_limits<long>::max(); + } + + *pcountChildren = nChildCount; } return S_OK; @@ -981,7 +990,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::accHitTest(long xLeft, long yTop accLocation(&x,&y,&w,&h,varSelf); if( (x < xLeft && (x + w) >xLeft) && (y < yTop && (y + h) >yTop) ) { - int i, nCount; + sal_Int64 i, nCount; pvarChild->vt = VT_EMPTY; Reference< XAccessibleContext > pRContext = GetContextByXAcc(m_xAccessible.get()); nCount = pRContext->getAccessibleChildCount(); @@ -1356,7 +1365,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) return nullptr; } - int count = pXContext->getAccessibleChildCount(); + sal_Int64 count = pXContext->getAccessibleChildCount(); if(count<1) { return nullptr; @@ -1369,7 +1378,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) }; Reference<XAccessible> pRChildXAcc; XAccessibleContext* pChildContext = nullptr; - int index = 0,delta=0; + sal_Int64 index = 0, delta = 0; switch(flags) { case DM_FIRSTCHILD: @@ -1870,7 +1879,9 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR Sequence< Reference< XInterface > > xTargets = accRelation.TargetSet; Reference<XInterface> pRAcc = xTargets[0]; - for(int j=0; j<pRParentContext->getAccessibleChildCount(); j++) + sal_Int64 nChildCount = pRParentContext->getAccessibleChildCount(); + assert(nChildCount < std::numeric_limits<long>::max()); + for (sal_Int64 j = 0; j< nChildCount; j++) { if( getTheParentOfMember(pRParentContext->getAccessibleChild(j).get()) == static_cast<XAccessible*>(pRAcc.get()) && @@ -1893,8 +1904,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR *similarItemsInGroup = 0; *positionInGroup = -1; - long nCount = pRContext->getAccessibleChildCount(); - if( 2 != nCount) + if (pRContext->getAccessibleChildCount() != 2) { return S_OK; } @@ -1913,7 +1923,9 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR { return S_OK; } - *similarItemsInGroup = xListContext->getAccessibleChildCount(); + sal_Int64 nChildCount = xListContext->getAccessibleChildCount(); + assert(nChildCount < std::numeric_limits<long>::max()); + *similarItemsInGroup = nChildCount; if (*similarItemsInGroup > 0 ) { try @@ -1937,8 +1949,9 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR else if ( PAGE_TAB == Role ) { *groupLevel = 1; - *similarItemsInGroup = pRParentContext->getAccessibleChildCount(); - + sal_Int64 nChildCount = pRParentContext->getAccessibleChildCount(); + assert(nChildCount < std::numeric_limits<long>::max()); + *similarItemsInGroup = nChildCount; if (*similarItemsInGroup > 0 ) { *positionInGroup=pRContext->getAccessibleIndexInParent() + 1 ; @@ -1967,7 +1980,9 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR Reference< XAccessible> pTempAcc = pRContext->getAccessibleParent(); pRParentContext = pTempAcc->getAccessibleContext(); *groupLevel = level; - *similarItemsInGroup = pRParentContext->getAccessibleChildCount(); + sal_Int64 nChildCount = pRParentContext->getAccessibleChildCount(); + assert(nChildCount < std::numeric_limits<long>::max()); + *similarItemsInGroup = nChildCount; *positionInGroup = pRContext->getAccessibleIndexInParent() + 1; } else @@ -2091,8 +2106,7 @@ HRESULT CMAccessible::SelectChild(XAccessible* pItem) Reference< XAccessibleSelection > pRSelection = GetSelection(); if( !pRSelection.is() ) return E_FAIL; - long Index = pContext->getAccessibleIndexInParent(); - pRSelection->selectAccessibleChild( Index ); + pRSelection->selectAccessibleChild(pContext->getAccessibleIndexInParent()); return S_OK; } catch(...) { return E_FAIL; } @@ -2117,8 +2131,7 @@ HRESULT CMAccessible::DeSelectChild(XAccessible* pItem) Reference< XAccessibleSelection > pRSelection = GetSelection(); if( !pRSelection.is() ) return E_FAIL; - long Index = pContext->getAccessibleIndexInParent(); - pRSelection->deselectAccessibleChild( Index ); + pRSelection->deselectAccessibleChild(pContext->getAccessibleIndexInParent()); return S_OK; @@ -2278,7 +2291,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARI if( flagsSelect & SELFLAG_EXTENDSELECTION ) { - long indexInParrent = pRContext->getAccessibleIndexInParent(); + sal_Int64 indexInParrent = pRContext->getAccessibleIndexInParent(); if( pRParentSelection->isAccessibleChildSelected( indexInParrent + 1 ) || pRParentSelection->isAccessibleChildSelected( indexInParrent - 1 ) ) @@ -2978,7 +2991,14 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_indexInParent(long __RPC_FAR if (!m_xContext.is()) return E_FAIL; - *accParentIndex = m_xContext->getAccessibleIndexInParent(); + sal_Int64 nIndex = m_xContext->getAccessibleIndexInParent(); + if (nIndex > std::numeric_limits<long>::max()) + { + SAL_WARN("iacc2", "CMAccessible::get_indexInParent: Child index exceeds maximum long value, " + "returning max long."); + nIndex = std::numeric_limits<long>::max(); + } + *accParentIndex = nIndex; return S_OK; diff --git a/winaccessibility/source/service/AccContainerEventListener.cxx b/winaccessibility/source/service/AccContainerEventListener.cxx index 2dd45d2fb616..da150f457bd8 100644 --- a/winaccessibility/source/service/AccContainerEventListener.cxx +++ b/winaccessibility/source/service/AccContainerEventListener.cxx @@ -487,8 +487,8 @@ void AccContainerEventListener::UpdateAllChildrenState(XAccessible* pXAccessible return; } - int count = pAccessibleContext->getAccessibleChildCount(); - for (int i=0;i<count;i++) + const sal_Int64 nCount = pAccessibleContext->getAccessibleChildCount(); + for (sal_Int64 i = 0; i < nCount; i++) { Reference<css::accessibility::XAccessible> mxAccessible = pAccessibleContext->getAccessibleChild(i); diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index c404223fb73a..4967ecb4ee4e 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -516,8 +516,8 @@ bool AccObjectWinManager::InsertChildrenAccObj( css::accessibility::XAccessible* } } - int count = pRContext->getAccessibleChildCount(); - for (int i=0;i<count;i++) + const sal_Int64 nCount = pRContext->getAccessibleChildCount(); + for (sal_Int64 i = 0; i < nCount; i++) { Reference<XAccessible> mxAccessible = pRContext->getAccessibleChild(i); @@ -1023,8 +1023,8 @@ void AccObjectWinManager::UpdateChildState(css::accessibility::XAccessible* pAcc { return; } - sal_Int32 nCount = xContext->getAccessibleChildCount(); - for (sal_Int32 i = 0 ; i < nCount ; ++i) + const sal_Int64 nCount = xContext->getAccessibleChildCount(); + for (sal_Int64 i = 0 ; i < nCount; ++i) { Reference<css::accessibility::XAccessible> xChild = xContext->getAccessibleChild(i); if (xChild.is()) diff --git a/winaccessibility/source/service/AccTopWindowListener.cxx b/winaccessibility/source/service/AccTopWindowListener.cxx index a828c36c0413..a6b935d55798 100644 --- a/winaccessibility/source/service/AccTopWindowListener.cxx +++ b/winaccessibility/source/service/AccTopWindowListener.cxx @@ -158,9 +158,8 @@ void AccTopWindowListener::AddAllListeners(css::accessibility::XAccessible* pAcc } } - - int count = pAccessibleContext->getAccessibleChildCount(); - for (int i=0;i<count;i++) + sal_Int64 nCount = pAccessibleContext->getAccessibleChildCount(); + for (sal_Int64 i = 0; i < nCount; i++) { Reference<css::accessibility::XAccessible> mxAccessible = pAccessibleContext->getAccessibleChild(i); diff --git a/winaccessibility/source/service/msaaservice_impl.cxx b/winaccessibility/source/service/msaaservice_impl.cxx index 13f10a6d7d74..ed9f88062720 100644 --- a/winaccessibility/source/service/msaaservice_impl.cxx +++ b/winaccessibility/source/service/msaaservice_impl.cxx @@ -164,8 +164,8 @@ static void AccessBridgeHandleExistingWindow(const Reference< XMSAAService > &xA { // O.k. - this is a combo box floating window corresponding to the child of role LIST of the parent. // Let's not rely on a specific child order, just search for the child with the role LIST - sal_Int32 nCount = xParentAC->getAccessibleChildCount(); - for ( sal_Int32 n = 0; (n < nCount) && !xAccessible.is(); n++) + sal_Int64 nCount = xParentAC->getAccessibleChildCount(); + for (sal_Int64 n = 0; (n < nCount) && !xAccessible.is(); n++) { css::uno::Reference< css::accessibility::XAccessible > xChild = xParentAC->getAccessibleChild(n); if ( xChild.is() ) |