diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-09-26 16:26:40 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-09-27 09:04:04 +0000 |
commit | b744b427966644df4464af4ef99b01410ff12380 (patch) | |
tree | 9b15496c9a64c9a49858b6028bb3c6a094c6d1dd /sc | |
parent | 60f87b899ba856b1c71a73e12f169f4fed3da121 (diff) |
Resolves: rhbz#1378521 csv dialog a11y returns a new accessible on every query
the gtk a11y rather assumes that the a11y things "belong" to the matching
widget/component and those owners will dispose them, so follow that pattern
here and dispose the a11y objects when the parent is disposed
to reproduce, enable a11y, load a csv, click once in the first column
of the preview area and cancel the dialog and close libreoffice
Reviewed-on: https://gerrit.libreoffice.org/29301
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit f626fd5f897796451685c06ce5f397a90aeaa8e6)
Change-Id: Ib830da499e9f2d6fed94fb12ede7c929b607ab10
Reviewed-on: https://gerrit.libreoffice.org/29303
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleCsvControl.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/inc/AccessibleCsvControl.hxx | 9 |
2 files changed, 38 insertions, 4 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx index 61d32ee2aaf5..39ab0c4817df 100644 --- a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx +++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx @@ -865,6 +865,15 @@ ScAccessibleCsvGrid::~ScAccessibleCsvGrid() implDispose(); } +void ScAccessibleCsvGrid::disposing() +{ + SolarMutexGuard aGuard; + for (XAccessibleSet::iterator aI = maAccessibleChildren.begin(); aI != maAccessibleChildren.end(); ++aI) + aI->second->dispose(); + maAccessibleChildren.clear(); + ScAccessibleCsvControl::disposing(); +} + // XAccessibleComponent ------------------------------------------------------- Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleAtPoint( const css::awt::Point& rPoint ) @@ -882,7 +891,7 @@ Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleAtPoint( con lcl_GetApiColumn( rGrid.GetColumnFromX( rPoint.X ) ) : 0; sal_Int32 nRow = (rPoint.Y >= rGrid.GetHdrHeight()) ? (rGrid.GetLineFromY( rPoint.Y ) - rGrid.GetFirstVisLine() + 1) : 0; - xRet = implCreateCellObj( nRow, nColumn ); + xRet = getAccessibleCell(nRow, nColumn); } return xRet; } @@ -912,13 +921,30 @@ sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleChildCount() throw( Runtime return implGetCellCount(); } +Reference<XAccessible> ScAccessibleCsvGrid::getAccessibleCell(sal_Int32 nRow, sal_Int32 nColumn) +{ + sal_Int32 nIndex = implGetIndex(nRow, nColumn); + + XAccessibleSet::iterator aI = maAccessibleChildren.lower_bound(nIndex); + if (aI != maAccessibleChildren.end() && !(maAccessibleChildren.key_comp()(nIndex, aI->first))) + { + // key already exists + return Reference<XAccessible>(aI->second.get()); + } + // key does not exist + rtl::Reference<ScAccessibleCsvControl> xNew = implCreateCellObj(nRow, nColumn); + maAccessibleChildren.insert(aI, XAccessibleSet::value_type(nIndex, xNew)); + return Reference<XAccessible>(xNew.get()); +} + Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleChild( sal_Int32 nIndex ) throw( IndexOutOfBoundsException, RuntimeException, std::exception ) { SolarMutexGuard aGuard; ensureAlive(); ensureValidIndex( nIndex ); - return implCreateCellObj( implGetRow( nIndex ), implGetColumn( nIndex ) ); + + return getAccessibleCell(implGetRow(nIndex), implGetColumn(nIndex)); } Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleRelationSet() @@ -1066,7 +1092,7 @@ Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCellAt( sal_ SolarMutexGuard aGuard; ensureAlive(); ensureValidPosition( nRow, nColumn ); - return implCreateCellObj( nRow, nColumn ); + return getAccessibleCell(nRow, nColumn); } Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCaption() @@ -1235,7 +1261,6 @@ Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvGrid::getImplementationId() throw( void ScAccessibleCsvGrid::SendFocusEvent( bool bFocused ) { ScAccessibleCsvControl::SendFocusEvent( bFocused ); - AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.Source = Reference< XAccessible >( this ); diff --git a/sc/source/ui/inc/AccessibleCsvControl.hxx b/sc/source/ui/inc/AccessibleCsvControl.hxx index 9b8838fc37c9..ea8553a48e49 100644 --- a/sc/source/ui/inc/AccessibleCsvControl.hxx +++ b/sc/source/ui/inc/AccessibleCsvControl.hxx @@ -31,6 +31,7 @@ #include <comphelper/uno3.hxx> #include <vcl/vclptr.hxx> #include "AccessibleContextBase.hxx" +#include <map> class ScCsvControl; namespace utl { class AccessibleStateSetHelper; } @@ -285,10 +286,16 @@ class ScAccessibleCsvGrid : public ScAccessibleCsvControl, public ScAccessibleCs { protected: typedef css::uno::Reference< css::accessibility::XAccessibleTable > XAccessibleTableRef; + typedef std::map< sal_Int32, rtl::Reference<ScAccessibleCsvControl> > XAccessibleSet; + +private: + XAccessibleSet maAccessibleChildren; public: explicit ScAccessibleCsvGrid( ScCsvGrid& rGrid ); virtual ~ScAccessibleCsvGrid(); + using ScAccessibleContextBase::disposing; + virtual void SAL_CALL disposing() override; // XAccessibleComponent --------------------------------------------------- @@ -512,6 +519,8 @@ private: OUString implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const; /** Creates a new accessible object of the specified cell. Indexes must be valid. */ ScAccessibleCsvControl* implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const; + + css::uno::Reference<css::accessibility::XAccessible> getAccessibleCell(sal_Int32 nRow, sal_Int32 nColumn); }; /** Accessible class representing a cell of the CSV grid control. */ |