From 62536a97cd29019c7055c927746da72435d12b95 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 2 Jun 2023 08:18:53 +0300 Subject: [PATCH] soffice: Implement methods for status bar announcement (#14933) Fixes #11698 Summary of the issue: Announcement of the status bar in LibreOffice (e.g. triggered by NVDA+End) didn't work because the default implementations do not work for the LibreOffice case. Description of user facing changes Announcement of the status bar (e.g. triggered by NVDA+End) works for LibreOffice. Description of development approach Override the default app module implementation to retrieve the status bar and announce its text in the LibreOffice app module, since the default implementations are not sufficient for the LibreOffice case: To retrieve the status bar object, locate the descendant with the corresponding role, but only descend into children of role ROOTPANE and WINDOW for performance reasons. To generate text from the status bar object, retrieve the text of each status bar child using the IAccessibleText interface. (The default implementation in api.py only uses the object names and values, which are both empty.) --- source/appModules/soffice.py | 29 +++++++++++++++++++++++++++++ user_docs/en/changes.t2t | 7 +++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/source/appModules/soffice.py b/source/appModules/soffice.py index ede16a9645a..1706f1d946a 100755 --- a/source/appModules/soffice.py +++ b/source/appModules/soffice.py @@ -4,6 +4,7 @@ # Copyright (C) 2006-2022 NV Access Limited, Bill Dengler, Leonard de Ruijter from typing import ( + Optional, Union ) @@ -17,6 +18,7 @@ import textInfos import colors from compoundDocuments import CompoundDocument, TreeCompoundTextInfo +from NVDAObjects import NVDAObject from NVDAObjects.IAccessible import IAccessible, IA2TextTextInfo from NVDAObjects.behaviors import EditableText from logHandler import log @@ -340,3 +342,30 @@ def event_NVDAObject_init(self, obj): # This is a word processor document. obj.description = None obj.treeInterceptorClass = SymphonyDocument + + def searchStatusBar(self, obj: NVDAObject, max_depth: int = 5) -> Optional[NVDAObject]: + """Searches for and returns the status bar object + if either the object itself or one of its recursive children + (up to the given depth) has the corresponding role.""" + if obj.role == controlTypes.Role.STATUSBAR: + return obj + if max_depth < 1 or obj.role not in {controlTypes.Role.ROOTPANE, controlTypes.Role.WINDOW}: + return None + for child in obj.children: + status_bar = self.searchStatusBar(child, max_depth - 1) + if status_bar: + return status_bar + return None + + def _get_statusBar(self) -> Optional[NVDAObject]: + return self.searchStatusBar(api.getForegroundObject()) + + def getStatusBarText(self, obj: NVDAObject) -> str: + text = "" + for child in obj.children: + textObj = child.IAccessibleTextObject + if textObj: + if text: + text += " " + text += textObj.textAtOffset(0, IA2.IA2_TEXT_BOUNDARY_ALL)[2] + return text diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 36edd77f286..ebc6a4c776a 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -33,8 +33,11 @@ There are now gestures for showing the braille settings dialog, accessing the st - Updated LibLouis braille translator to [3.25.0 https://github.com/liblouis/liblouis/releases/tag/v3.25.0]. (#14719) - CLDR has been updated to version 43.0. (#14918) - Dash and em-dash symbols will always be sent to the synthesizer. (#13830) +- LibreOffice changes: + - When reporting the review cursor location, the current cursor/caret location is now reported relative to the current page in LibreOffice Writer for LibreOffice versions >= 7.6, similar to what is done for Microsoft Word. (#11696) + - Announcement of the status bar (e.g. triggered by ``NVDA+end``) works for LibreOffice. (#11698) + - - Distance reported in Microsoft Word will now honour the unit defined in Word's advanced options even when using UIA to access Word documents. (#14542) -- When reporting the review cursor location, the current cursor/caret location is now reported relative to the current page in LibreOffice Writer for LibreOffice versions >= 7.6, similar to what is done for Microsoft Word. (#11696) - NVDA responds faster when moving the cursor in edit controls. (#14708) - Baum Braille driver: addes several Braille chord gestures for performing common keyboard commands such as windows+d, alt+tab etc. Please refer to the NVDA user guide for a full list. (#14714) - When using a Braille Display via the Standard HID braille driver, the dpad can be used to emulate the arrow keys and enter. Also space+dot1 and space+dot4 now map to up and down arrow respectively. (#14713) @@ -112,7 +115,7 @@ Instead, functions should be weakly referenceable. (#14627) Instead import from ``hwIo.ioThread``. (#14627) - ``IoThread.autoDeleteApcReference`` is deprecated. It was introduced in NVDA 2023.1 and was never meant to be part of the public API. -Until removal, it behaves as a no-op, i.e. a context manager yielding nothing. +Until removal, it behaves as a no-op, i.e. a context manager yielding nothing. (#14924) - = 2023.1 =