tdf#158914 sc a11y: Send TEXT_CHANGED event when text changes
Don't always send an `AccessibleEventId::VALUE_CHANGED` event
when the string value of a Calc cell changes, but send a
`AccessibleEventId::TEXT_CHANGED` event instead.
Only send an `AccessibleEventId::VALUE_CHANGED` event in
addition if the cell actually has value data, as the
`XAccessibleValue` interface and the related `VALUE_CHANGED`
event are meant to handle numerical values only.
Together with changes like the one in PS 11 of [1],
sending the `TEXT_CHANGE` event might help with
missing text updates on the AT side, e.g. the NVDA or
Accerciser scenarios described in [2], s. further
discussion there.
[1] https://gerrit.libreoffice.org/c/core/+/167961
[2] https://gerrit.libreoffice.org/c/core/+/167961/comments/16394c5a_338dbbf2
Change-Id: Ideba61a9200100c66d55fa18e81ea28e75092905
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168526
Reviewed-by: Patrick Luby <guibomacdev@gmail.com>
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index 7296863..64d2206 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <comphelper/accessibletexthelper.hxx>
#include <sal/log.hxx>
#include <tools/gen.hxx>
#include <svtools/colorcfg.hxx>
@@ -682,10 +683,22 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
OUString valStr(pScDoc->GetString(aNewCell.Col(),aNewCell.Row(),aNewCell.Tab()));
if(m_strCurCellValue != valStr)
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::VALUE_CHANGED;
mpAccCell->CommitChange(aEvent);
m_strCurCellValue=valStr;
uno::Any aOldValue;
uno::Any aNewValue;
comphelper::OCommonAccessibleText::implInitTextChangedEvent(m_strCurCellValue, valStr, aOldValue, aNewValue);
AccessibleEventObject aTextChangedEvent;
aTextChangedEvent.EventId = AccessibleEventId::TEXT_CHANGED;
aTextChangedEvent.OldValue = aOldValue;
aTextChangedEvent.NewValue = aNewValue;
mpAccCell->CommitChange(aTextChangedEvent);
if (pScDoc->HasValueData(maActiveCell))
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::VALUE_CHANGED;
mpAccCell->CommitChange(aEvent);
m_strCurCellValue=valStr;
}
}
OUString tabName;
pScDoc->GetName( maActiveCell.Tab(), tabName );