From db664bef7881d35c6af156287b9b518130aa2a69 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Wed, 3 Mar 2021 17:10:34 +1000 Subject: [PATCH] Microsoft Word documents (both with UIA enabled and disabled) now get a treeInterceptor created straight way, but with passThrough (focus mode) enabled. Thus, NVDA+f7 (elements list) is now available with out having to switch to browse mode in Microsoft Word first. (#12051) --- source/NVDAObjects/IAccessible/winword.py | 7 +++++-- source/NVDAObjects/UIA/wordDocument.py | 12 ++++++++++-- source/NVDAObjects/window/winword.py | 8 ++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index acc273a6377..72da470d693 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -21,11 +21,14 @@ from NVDAObjects.window import DisplayModelEditableText from ..behaviors import EditableTextWithoutAutoSelectDetection from NVDAObjects.window.winword import * +from NVDAObjects.window.winword import WordDocumentTreeInterceptor + class WordDocument(IAccessible,EditableTextWithoutAutoSelectDetection,WordDocument): - treeInterceptorClass=WordDocumentTreeInterceptor - shouldCreateTreeInterceptor=False + treeInterceptorClass = WordDocumentTreeInterceptor + shouldCreateTreeInterceptor = True + TextInfo=WordDocumentTextInfo def _get_ignoreEditorRevisions(self): diff --git a/source/NVDAObjects/UIA/wordDocument.py b/source/NVDAObjects/UIA/wordDocument.py index bccd3d03783..105843d999c 100644 --- a/source/NVDAObjects/UIA/wordDocument.py +++ b/source/NVDAObjects/UIA/wordDocument.py @@ -298,6 +298,14 @@ def getTextWithFields(self,formatConfig=None): class WordBrowseModeDocument(UIABrowseModeDocument): + # This treeInterceptor starts in focus mode, thus escape should not switch back to browse mode + disableAutoPassThrough = True + + def __init__(self, rootNVDAObject): + super(WordBrowseModeDocument, self).__init__(rootNVDAObject) + self.passThrough = True + browseMode.reportPassThrough.last = True + def shouldSetFocusToObj(self,obj): # Ignore strange editable text fields surrounding most inner fields (links, table cells etc) if obj.role==controlTypes.ROLE_EDITABLETEXT and obj.UIAElement.cachedAutomationID.startswith('UIA_AutomationId_Word_Content'): @@ -341,8 +349,8 @@ def _get_role(self): return role class WordDocument(UIADocumentWithTableNavigation,WordDocumentNode,WordDocumentBase): - treeInterceptorClass=WordBrowseModeDocument - shouldCreateTreeInterceptor=False + treeInterceptorClass = WordBrowseModeDocument + shouldCreateTreeInterceptor = True announceEntireNewLine=True # Microsoft Word duplicates the full title of the document on this control, which is redundant as it appears in the title of the app itself. diff --git a/source/NVDAObjects/window/winword.py b/source/NVDAObjects/window/winword.py index 2d83596adba..cd2449b0195 100755 --- a/source/NVDAObjects/window/winword.py +++ b/source/NVDAObjects/window/winword.py @@ -1069,6 +1069,14 @@ def _get_focusableNVDAObjectAtStart(self): class WordDocumentTreeInterceptor(browseMode.BrowseModeDocumentTreeInterceptor): + # This treeInterceptor starts in focus mode, thus escape should not switch back to browse mode + disableAutoPassThrough = True + + def __init__(self, rootNVDAObject): + super(WordDocumentTreeInterceptor, self).__init__(rootNVDAObject) + self.passThrough = True + browseMode.reportPassThrough.last = True + TextInfo=BrowseModeWordDocumentTextInfo def _activateLongDesc(self,controlField):