tdf#147742 a11y: AccessibleGridControl...: get accessible name on demand
Base class `AccessibleGridControlBase` was retrieving
an accessible name and storing it in class member 'm_aName'.
For the classes representing cells, derived from
`AccessibleGridControlCell`, the index is needed
to get a meaningful name, so the name retrieved in
the `AccessibleGridControlBase` ctor with hard-coded
row/column indices of 0 was replaced again in
the `AccessibleGridControlCell` ctor.
Replace that logic to just retrieve the name
on demand, and override
'getAccessibleName' in `AccessibleGridControlCell`
using the logic used in its ctor previously.
(No functional change intended here, but a
somewhat similar handling for the accessible
description was causing a crash when the Orca screen
reader was active. This will be handled in a following
commit.)
Change-Id: I87eabb2ce3c99d4a622d919ab0fb8d7fb3beed6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130933
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/accessibility/inc/extended/AccessibleGridControlBase.hxx b/accessibility/inc/extended/AccessibleGridControlBase.hxx
index 361c8d4..4075b7f 100644
--- a/accessibility/inc/extended/AccessibleGridControlBase.hxx
+++ b/accessibility/inc/extended/AccessibleGridControlBase.hxx
@@ -61,7 +61,7 @@ class AccessibleGridControlBase :
public AccessibleGridControlImplHelper
{
public:
/** Constructor sets specified name and description.
/** Constructor.
@param rxParent XAccessible interface of the parent object.
@param rTable The Table control.
@param eObjType Type of accessible table control. */
@@ -227,10 +227,6 @@ protected:
/** @throws <type>DisposedException</type> If the object is not alive. */
void ensureIsAlive() const;
/** Changes the name of the object (flat assignment, no notify).
@attention This method requires a locked mutex. */
inline void implSetName( const OUString& rName );
/** Locks all mutex's and calculates the bounding box relative to the
parent window.
@return The bounding box (VCL rect.) relative to the parent object.
@@ -257,8 +253,6 @@ protected:
::vcl::table::AccessibleTableControlObjType m_eObjType;
private:
/** Localized name. */
OUString m_aName;
/** Localized description text. */
OUString m_aDescription;
::comphelper::AccessibleEventNotifier::TClientId m_aClientId;
@@ -315,12 +309,6 @@ inline ::vcl::table::AccessibleTableControlObjType AccessibleGridControlBase::ge
return m_eObjType;
}
inline void AccessibleGridControlBase::implSetName(
const OUString& rName )
{
m_aName = rName;
}
} // namespace accessibility
diff --git a/accessibility/inc/extended/AccessibleGridControlTableCell.hxx b/accessibility/inc/extended/AccessibleGridControlTableCell.hxx
index 7707718..6e3ee33 100644
--- a/accessibility/inc/extended/AccessibleGridControlTableCell.hxx
+++ b/accessibility/inc/extended/AccessibleGridControlTableCell.hxx
@@ -40,6 +40,10 @@ namespace accessibility
// XAccessibleComponent
virtual void SAL_CALL grabFocus() override;
public:
// XAccessibleContext
virtual OUString SAL_CALL getAccessibleName() override;
protected:
AccessibleGridControlCell(
const css::uno::Reference< css::accessibility::XAccessible >& _rxParent,
diff --git a/accessibility/source/extended/AccessibleGridControlBase.cxx b/accessibility/source/extended/AccessibleGridControlBase.cxx
index c118c70..c02d921 100644
--- a/accessibility/source/extended/AccessibleGridControlBase.cxx
+++ b/accessibility/source/extended/AccessibleGridControlBase.cxx
@@ -54,7 +54,6 @@ AccessibleGridControlBase::AccessibleGridControlBase(
m_xParent( rxParent ),
m_aTable( rTable),
m_eObjType( eObjType ),
m_aName( rTable.GetAccessibleObjectName( eObjType, 0, 0 ) ),
m_aDescription( rTable.GetAccessibleObjectDescription( eObjType ) ),
m_aClientId(0)
{
@@ -143,7 +142,7 @@ OUString SAL_CALL AccessibleGridControlBase::getAccessibleName()
SolarMutexGuard g;
ensureIsAlive();
return m_aName;
return m_aTable.GetAccessibleObjectName(m_eObjType, 0, 0);
}
css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL
diff --git a/accessibility/source/extended/AccessibleGridControlTableCell.cxx b/accessibility/source/extended/AccessibleGridControlTableCell.cxx
index cb38725..a3a8afa 100644
--- a/accessibility/source/extended/AccessibleGridControlTableCell.cxx
+++ b/accessibility/source/extended/AccessibleGridControlTableCell.cxx
@@ -59,16 +59,6 @@ namespace accessibility
,m_nRowPos( _nRowPos )
,m_nColPos( _nColPos )
{
// set accessible name here, because for that we need the position of the cell
// and so the base class isn't capable of doing this
OUString aAccName;
if(_eType == TCTYPE_TABLECELL)
aAccName = _rTable.GetAccessibleObjectName( TCTYPE_TABLECELL, _nRowPos, _nColPos );
else if(_eType == TCTYPE_ROWHEADERCELL)
aAccName = _rTable.GetAccessibleObjectName( TCTYPE_ROWHEADERCELL, _nRowPos, 0 );
else if(_eType == TCTYPE_COLUMNHEADERCELL)
aAccName = _rTable.GetAccessibleObjectName( TCTYPE_COLUMNHEADERCELL, 0, _nRowPos );
implSetName( aAccName );
}
void SAL_CALL AccessibleGridControlCell::grabFocus()
@@ -78,6 +68,24 @@ namespace accessibility
m_aTable.GoToCell( m_nColPos, m_nRowPos );
}
OUString SAL_CALL AccessibleGridControlCell::getAccessibleName()
{
SolarMutexGuard g;
ensureIsAlive();
OUString sAccName;
if (m_eObjType == TCTYPE_TABLECELL)
sAccName = m_aTable.GetAccessibleObjectName(TCTYPE_TABLECELL, m_nRowPos, m_nColPos);
else if (m_eObjType == TCTYPE_ROWHEADERCELL)
sAccName = m_aTable.GetAccessibleObjectName(TCTYPE_ROWHEADERCELL, m_nRowPos, 0);
else if (m_eObjType == TCTYPE_COLUMNHEADERCELL)
sAccName = m_aTable.GetAccessibleObjectName(TCTYPE_COLUMNHEADERCELL, 0, m_nRowPos);
else
assert(false && "Unhandled table cell type");
return sAccName;
}
// implementation of a table cell
OUString AccessibleGridControlTableCell::implGetText()
{