summaryrefslogtreecommitdiff
path: root/accessibility
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2022-03-09 11:07:55 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2022-03-09 17:46:28 +0100
commit319a5b5b457c46c8a036b99d6f024517bc87be42 (patch)
treea367fadbe9f38a0a868f9c138f98a8d379e24ddb /accessibility
parent63dba12b779dd4d007c8cb8cf4b967bd78077cac (diff)
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.weghorn@posteo.de>
Diffstat (limited to 'accessibility')
-rw-r--r--accessibility/inc/extended/AccessibleGridControlBase.hxx6
-rw-r--r--accessibility/inc/extended/AccessibleGridControlTable.hxx3
-rw-r--r--accessibility/source/extended/AccessibleGridControl.cxx27
-rw-r--r--accessibility/source/extended/AccessibleGridControlTable.cxx30
4 files changed, 35 insertions, 31 deletions
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()