Skip to content

Commit 97e4808

Browse files
authored
Merge 204955e into 99a9ea8
2 parents 99a9ea8 + 204955e commit 97e4808

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

source/NVDAObjects/UIA/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# A part of NonVisual Desktop Access (NVDA)
22
# This file is covered by the GNU General Public License.
33
# See the file COPYING for more details.
4-
# Copyright (C) 2009-2022 NV Access Limited, Joseph Lee, Mohammad Suliman,
5-
# Babbage B.V., Leonard de Ruijter, Bill Dengler
4+
# Copyright (C) 2009-2023 NV Access Limited, Joseph Lee, Mohammad Suliman, Babbage B.V., Leonard de Ruijter,
5+
# Bill Dengler, Cyrille Bougot
66

77
"""Support for UI Automation (UIA) controls."""
88
import typing
@@ -388,8 +388,7 @@ def _getFormatFieldIndent(
388388
formatField['right-indent'] = self._getIndentValueDisplayString(uiaIndentTrailing)
389389
return formatField
390390

391-
@staticmethod
392-
def _getIndentValueDisplayString(val: float) -> str:
391+
def _getIndentValueDisplayString(self, val: float) -> str:
393392
"""A function returning the string to display in formatting info.
394393
@param val: an indent value measured in points, fetched via
395394
an UIAHandler.UIA_Indentation*AttributeId attribute.

source/NVDAObjects/UIA/wordDocument.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is covered by the GNU General Public License.
22
# A part of NonVisual Desktop Access (NVDA)
33
# See the file COPYING for more details.
4-
# Copyright (C) 2016-2022 NV Access Limited, Joseph Lee, Jakub Lukowicz
4+
# Copyright (C) 2016-2023 NV Access Limited, Joseph Lee, Jakub Lukowicz, Cyrille Bougot
55

66
from typing import (
77
Optional,
@@ -448,6 +448,24 @@ def _getFormatFieldAtRange(self, textRange, formatConfig, ignoreMixedValues=Fals
448448
if isinstance(textColumnNumber, int):
449449
formatField.field['text-column-number'] = textColumnNumber
450450
return formatField
451+
452+
def _getIndentValueDisplayString(self, val: float) -> str:
453+
"""A function returning the string to display in formatting info in Word documents.
454+
@param val: an indent value measured in points, fetched via
455+
an UIAHandler.UIA_Indentation*AttributeId attribute.
456+
@return: The string used in formatting information to report the length of an indentation.
457+
"""
458+
459+
if self.obj.WinwordApplicationObject:
460+
# When Word object model is available we honour Word's options to report distances so that what is
461+
# reported by NVDA matches Word's UI (rulers, paragraph formatting dialog, etc.)
462+
# Default seem to be inch or centimeters for Western countries localization of Word and characters for
463+
# east Asian localisations.
464+
return self.obj.getLocalizedMeasurementTextForPointSize(val)
465+
466+
# If Word object model is not available, we just fallback to general UIA case, i.e. use Windows regional
467+
# settings.
468+
return super()._getIndentValueDisplayString(val)
451469

452470

453471
class WordBrowseModeDocument(UIABrowseModeDocument):

0 commit comments

Comments
 (0)