accessibility/inc/extended/AccessibleGridControlBase.hxx | 6 -- accessibility/inc/extended/AccessibleGridControlTable.hxx | 3 + accessibility/source/extended/AccessibleGridControl.cxx | 33 ----------- accessibility/source/extended/AccessibleGridControlTable.cxx | 30 ++++++++++ 4 files changed, 37 insertions(+), 35 deletions(-)
New commits: commit 5977d6b981dcde556450589199c06204009a4a1a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Mar 9 11:23:35 2022 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Mar 9 17:46:42 2022 +0100 a11y: Let AccessibleGridControlTable calculate child index Just call `AccessibleGridControlTable::getAccessibleCellAt`, which already takes care of calculating the proper child index from row and column index. Change-Id: Id463c14108158c5833231f95cf16847764f5b646 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131245 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/source/extended/AccessibleGridControl.cxx b/accessibility/source/extended/AccessibleGridControl.cxx index 09d43f816359..5d4ed3bc767c 100644 --- a/accessibility/source/extended/AccessibleGridControl.cxx +++ b/accessibility/source/extended/AccessibleGridControl.cxx @@ -305,10 +305,8 @@ void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNe const sal_Int32 nCurrentCol = m_aTable.GetCurrentColumn(); css::uno::Reference< css::accessibility::XAccessible > xChild; if (nCurrentRow > -1 && nCurrentCol > -1) - { - sal_Int32 nColumnCount = m_aTable.GetColumnCount(); - xChild = m_xTable->getAccessibleChild(nCurrentRow * nColumnCount + nCurrentCol); - } + xChild = m_xTable->getAccessibleCellAt(nCurrentRow, nCurrentCol); + m_xTable->commitEvent(_nEventId, Any(xChild),_rOldValue); } else commit 319a5b5b457c46c8a036b99d6f024517bc87be42 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Mar 9 11:07:55 2022 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Mar 9 17:46:28 2022 +0100 a11y: Move TABLE_MODEL_CHANGED handling to table Move the handling for the `AccessibleEventId::TABLE_MODEL_CHANGED` event of type `AccessibleTableModelChangeType::DELETE` from `AccessibleGridControl` into `AccessibleGridControlTable`. To do so, make `AccessibleGridControlBase::commitEvent` virtual and override it in `AccessibleGridControlTable`. The method already gets called from `AccessibleGridControl::commitTableEvent` where the event was handled previously. Handling the details of how cells are internally organized in a vector only in the class itself rather than in different places seems to make sense. There are currently more cases where `AccessibleGridControl` deals with the cell vector directly that will be addressed in following commits. Change-Id: I26a7737432ecb198eac00279a8242d22e3c661d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131244 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/inc/extended/AccessibleGridControlBase.hxx b/accessibility/inc/extended/AccessibleGridControlBase.hxx index 7da777d8dac2..f1b2d4b1c85f 100644 --- a/accessibility/inc/extended/AccessibleGridControlBase.hxx +++ b/accessibility/inc/extended/AccessibleGridControlBase.hxx @@ -188,10 +188,8 @@ public: inline ::vcl::table::AccessibleTableControlObjType getType() const; /** Commits an event to all listeners. */ - void commitEvent( - sal_Int16 nEventId, - const css::uno::Any& rNewValue, - const css::uno::Any& rOldValue ); + virtual void commitEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue); /** @return TRUE, if the object is not disposed or disposing. */ bool isAlive() const; diff --git a/accessibility/inc/extended/AccessibleGridControlTable.hxx b/accessibility/inc/extended/AccessibleGridControlTable.hxx index 73c4f6a19050..bada75124257 100644 --- a/accessibility/inc/extended/AccessibleGridControlTable.hxx +++ b/accessibility/inc/extended/AccessibleGridControlTable.hxx @@ -142,6 +142,9 @@ public: /**@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; + private: // internal virtual methods diff --git a/accessibility/source/extended/AccessibleGridControl.cxx b/accessibility/source/extended/AccessibleGridControl.cxx index c90cc0384b46..09d43f816359 100644 --- a/accessibility/source/extended/AccessibleGridControl.cxx +++ b/accessibility/source/extended/AccessibleGridControl.cxx @@ -22,8 +22,6 @@ #include <extended/AccessibleGridControlHeader.hxx> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> -#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> -#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <toolkit/helper/convert.hxx> #include <vcl/accessibletable.hxx> @@ -313,31 +311,6 @@ void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNe } m_xTable->commitEvent(_nEventId, Any(xChild),_rOldValue); } - else if(_nEventId == AccessibleEventId::TABLE_MODEL_CHANGED) - { - AccessibleTableModelChange aChange; - if(_rNewValue >>= aChange) - { - if(aChange.Type == AccessibleTableModelChangeType::DELETE) - { - std::vector< rtl::Reference<AccessibleGridControlTableCell> >& rCells = - m_xTable->getCellVector(); - int nColCount = m_aTable.GetColumnCount(); - // check valid index - entries are inserted lazily - size_t const nStart = nColCount * aChange.FirstRow; - size_t const nEnd = nColCount * aChange.LastRow; - if (nStart < rCells.size()) - { - m_xTable->getCellVector().erase( - rCells.begin() + nStart, - rCells.begin() + std::min(rCells.size(), nEnd)); - } - m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); - } - else - m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); - } - } else m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); } diff --git a/accessibility/source/extended/AccessibleGridControlTable.cxx b/accessibility/source/extended/AccessibleGridControlTable.cxx index 75a17f0bcb00..a08302be6d92 100644 --- a/accessibility/source/extended/AccessibleGridControlTable.cxx +++ b/accessibility/source/extended/AccessibleGridControlTable.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> +#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <extended/AccessibleGridControlTable.hxx> #include <extended/AccessibleGridControlTableCell.hxx> @@ -287,6 +290,33 @@ OUString SAL_CALL AccessibleGridControlTable::getImplementationName() return "com.sun.star.accessibility.AccessibleGridControlTable"; } +void AccessibleGridControlTable::commitEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue) +{ + if (nEventId == AccessibleEventId::TABLE_MODEL_CHANGED) + { + AccessibleTableModelChange aChange; + if (rNewValue >>= aChange) + { + if (aChange.Type == AccessibleTableModelChangeType::DELETE) + { + int nColCount = m_aTable.GetColumnCount(); + // check valid index - entries are inserted lazily + size_t const nStart = nColCount * aChange.FirstRow; + size_t const nEnd = nColCount * aChange.LastRow; + if (nStart < m_aCellVector.size()) + { + m_aCellVector.erase( + m_aCellVector.begin() + nStart, + m_aCellVector.begin() + std::min(m_aCellVector.size(), nEnd)); + } + } + } + } + + AccessibleGridControlBase::commitEvent(nEventId, rNewValue, rOldValue); +} + // internal virtual methods --------------------------------------------------- tools::Rectangle AccessibleGridControlTable::implGetBoundingBox()