a11y: Leave cell vector handling to AccessibleGridControlTable

Use `AccessibleGridControlTable::getAccessibleCellAt` and
cast to `AccessibleGridControlTableCell*` instead of
directly accessing the cell vector in
`AccessibleGridControl::commitCellEvent`.

`AccessibleGridControlTable::getAccessibleCellAt`
just needs row and column index as parameters,
and already takes care of everything else that's
needed.
This includes creating an accessible object for
the given indices on demand.

Therefore, limiting this to only already existing
a11y objects, which was done to avoid crashes in

    commit 4fc7deb7b0528010ebf644654bf4a36594e03f8c
    Date:   Thu Oct 3 23:16:34 2013 +0200

        fix STL assert in accessibility::AccessibleGridControl::commitTableEvent

is no longer needed.

With this change in place, details of how cells are
organized in the vector only need to be known inside
of the `AccessibleGridControlTable` class itself, so
drop the now unused method
`AccessibleGridControlTable::getCellVector`.

(This code path is e.g. used when using
the macro from tdf#147742.)

Change-Id: I21027f0edc2904475ad6cc5fb136316f387499dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131248
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2022-03-09 13:53:09 +01:00
parent 4e641d9240
commit f56b932487
2 changed files with 4 additions and 12 deletions

View File

@ -142,9 +142,6 @@ public:
// XComponent
virtual void SAL_CALL dispose() override;
/**@return m_pCellVector*/
std::vector< rtl::Reference<AccessibleGridControlTableCell> >& getCellVector() { return m_aCellVector;}
virtual void commitEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue,
const css::uno::Any& rOldValue) override;

View File

@ -270,15 +270,10 @@ void AccessibleGridControl::commitCellEvent(sal_Int16 _nEventId,const Any& _rNew
css::uno::Reference< css::accessibility::XAccessible > xAccessible = getAccessibleChild(i);
if(css::uno::Reference< css::accessibility::XAccessible >(m_xTable) == xAccessible)
{
std::vector< rtl::Reference<AccessibleGridControlTableCell> >& rCells =
m_xTable->getCellVector();
size_t nIndex = m_aTable.GetCurrentRow() * m_aTable.GetColumnCount()
+ m_aTable.GetCurrentColumn();
if (nIndex < rCells.size() && rCells[nIndex])
{
rtl::Reference<AccessibleGridControlTableCell> xCell = rCells[nIndex];
xCell->commitEvent( _nEventId, _rNewValue, _rOldValue );
}
Reference<XAccessible> xCell = m_xTable->getAccessibleCellAt(
m_aTable.GetCurrentRow(), m_aTable.GetCurrentColumn());
AccessibleGridControlTableCell* pCell = static_cast<AccessibleGridControlTableCell*>(xCell.get());
pCell->commitEvent(_nEventId, _rNewValue, _rOldValue);
}
}
}