Skip to content

Commit 7cfc6cc

Browse files
authored
Merge fc6d204 into f436d4d
2 parents f436d4d + fc6d204 commit 7cfc6cc

3 files changed

Lines changed: 58 additions & 5 deletions

File tree

source/NVDAObjects/IAccessible/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,8 @@ def _get_value(self):
20262026
("AkelEditW",oleacc.ROLE_SYSTEM_CLIENT):"akelEdit.AkelEdit",
20272027
("AkelEditA",oleacc.ROLE_SYSTEM_CLIENT):"akelEdit.AkelEdit",
20282028
("MSOUNISTAT",oleacc.ROLE_SYSTEM_CLIENT):"msOffice.MSOUNISTAT",
2029+
("NetUIHWND", oleacc.ROLE_SYSTEM_PROPERTYPAGE): "msOffice.StatusBar",
2030+
("NetUIHWND", oleacc.ROLE_SYSTEM_TOOLBAR): "msOffice.RibbonSection",
20292031
("QWidget",oleacc.ROLE_SYSTEM_CLIENT):"qt.Client",
20302032
("QWidget",oleacc.ROLE_SYSTEM_LIST):"qt.Container",
20312033
("Qt5QWindowIcon",oleacc.ROLE_SYSTEM_LIST):"qt.Container",

source/NVDAObjects/IAccessible/msOffice.py

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#NVDAObjects/IAccessible/msOffice.py
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#This file is covered by the GNU General Public License.
4-
#See the file COPYING for more details.
5-
#Copyright (C) 2006-2010 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net>
1+
# -*- coding: UTF-8 -*-
2+
# A part of NonVisual Desktop Access (NVDA)
3+
# Copyright (C) 2006-2020 NV Access Limited, Manish Agrawal, Łukasz Golonka
4+
# This file may be used under the terms of the GNU General Public License, version 2 or later.
5+
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html
66

77
import oleacc
88
import IAccessibleHandler
@@ -180,3 +180,36 @@ def script_selectGraphic(self, gesture):
180180
"kb:leftArrow": "selectGraphic",
181181
"kb:rightArrow": "selectGraphic",
182182
}
183+
184+
185+
class StatusBar (IAccessible):
186+
187+
def _get_role(self):
188+
""" #4257: Status bar in Office applications does not expose proper role via IAccessible.
189+
We cannot acces it via UIA because it does not fire focus events when focused for the first time.
190+
Fortunately accValue contains "status bar" and is not localized.
191+
"""
192+
accValue = self.IAccessibleObject.accValue(self.IAccessibleChildID)
193+
if accValue == 'Ribbon Tab':
194+
return controlTypes.ROLE_TAB
195+
if accValue == 'Status Bar':
196+
return controlTypes.ROLE_STATUSBAR
197+
return super()._get_role()
198+
199+
def _get_description(self):
200+
return ""
201+
202+
def _get_isPresentableFocusAncestor(self):
203+
accValue = self.IAccessibleObject.accValue(self.IAccessibleChildID)
204+
if accValue == "Ribbon":
205+
return False
206+
return super().isPresentableFocusAncestor
207+
208+
209+
class RibbonSection (IAccessible):
210+
211+
def _get_role(self):
212+
accValue = self.IAccessibleObject.accValue(self.IAccessibleChildID)
213+
if accValue == "Group":
214+
return controlTypes.ROLE_GROUPING
215+
return super()._get_role()

source/_UIAHandler.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,24 @@ def _isUIAWindowHelper(self,hwnd):
538538
# allow the appModule for the window to also choose if this window is bad
539539
if appModule and appModule.isBadUIAWindow(hwnd):
540540
return False
541+
if windowClass == "NetUIHWND":
542+
# NetUIHWND is used for various controls in MS Office.
543+
# IAccessible should be used for NetUIHWND in versions older than 2016
544+
# Fixes: lack of focus reporting (#4207),
545+
# Fixes: strange reporting of context menu items(#9252),
546+
# fixes: not being able to report ribbon sections when they starts with an edit field (#7067)
547+
# Note that #7067 is not fixed for Office 2016 and never.
548+
# Using IAccessible for NetUIHWND controls causes focus changes not to be reported when the ribbon is collabsed.
549+
# Testing shows that these controls emits proper events but they are ignored by NVDA.
550+
if(
551+
appModule.productName.startswith(("Microsoft Office", "Microsoft Outlook"))
552+
and int(appModule.productVersion.split(".")[0]) < 16
553+
):
554+
parentHwnd = winUser.getAncestor(hwnd, winUser.GA_PARENT)
555+
while parentHwnd:
556+
if winUser.getClassName(parentHwnd) in ("Net UI Tool Window", "MsoCommandBar",):
557+
return False
558+
parentHwnd = winUser.getAncestor(parentHwnd, winUser.GA_PARENT)
541559
# Ask the window if it supports UIA natively
542560
res=windll.UIAutomationCore.UiaHasServerSideProvider(hwnd)
543561
if res:

0 commit comments

Comments
 (0)