sc/source/ui/Accessibility/AccessibleCell.cxx |   11 +++++++++++
 sc/source/ui/inc/AccessibleCell.hxx           |    1 +
 2 files changed, 12 insertions(+)

New commits:
commit 8e586c366d0b27646c5bbe7623b6e9bfc4df0e14
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Dec 9 17:27:51 2021 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Dec 10 08:42:40 2021 +0100

    sc a11y: Handle FOCUSED state for cell
    
    Implement handling for the FOCUSED state of a cell, similar to
    how 'ScAccessibleSpreadsheet::IsFocused' does for a
    spreadsheet.
    
    (The fact that the state was not handled before turned out
    to be the cause for the NVDA and Orca screen readers no longer
    announcing the focused cell with some other local WIP changes to
    winaccessibility and qt5/qt6 accessibility in place.)
    
    Change-Id: I0334e98cd306189196cf3ee2e5e48f87eb3748c5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126619
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx 
b/sc/source/ui/Accessibility/AccessibleCell.cxx
index 8c6f330e52fa..01670ca7c560 100644
--- a/sc/source/ui/Accessibility/AccessibleCell.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCell.cxx
@@ -231,6 +231,9 @@ uno::Reference<XAccessibleStateSet> SAL_CALL
         pStateSet->AddState(AccessibleStateType::DEFUNC);
     else
     {
+        if (IsFocused())
+            pStateSet->AddState(AccessibleStateType::FOCUSED);
+
         if (IsFormulaMode())
         {
             pStateSet->AddState(AccessibleStateType::ENABLED);
@@ -337,6 +340,14 @@ bool ScAccessibleCell::IsOpaque() const
     return bOpaque;
 }
 
+bool ScAccessibleCell::IsFocused() const
+{
+    if (mpViewShell && mpViewShell->GetViewData().GetCurPos() == maCellAddress)
+        return mpViewShell->GetActiveWin()->HasFocus();
+
+    return false;
+}
+
 bool ScAccessibleCell::IsSelected()
 {
     if (IsFormulaMode())
diff --git a/sc/source/ui/inc/AccessibleCell.hxx 
b/sc/source/ui/inc/AccessibleCell.hxx
index 629eb4994650..c47b739579f1 100644
--- a/sc/source/ui/inc/AccessibleCell.hxx
+++ b/sc/source/ui/inc/AccessibleCell.hxx
@@ -145,6 +145,7 @@ private:
     virtual bool IsEditable(
         const css::uno::Reference<css::accessibility::XAccessibleStateSet>& 
rxParentStates) override;
     bool IsOpaque() const;
+    bool IsFocused() const;
     bool IsSelected();
 
     static ScDocument* GetDocument(ScTabViewShell* mpViewShell);

Reply via email to