Skip to content

Commit 2543d7c

Browse files
Merge 9b80b84 into d8dc04c
2 parents d8dc04c + 9b80b84 commit 2543d7c

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

source/NVDAObjects/UIA/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
import winVersion
4444

4545

46+
paragraphIndentIDs = {
47+
UIAHandler.UIA_IndentationFirstLineAttributeId: "first-line-indent",
48+
UIAHandler.UIA_IndentationLeadingAttributeId: "left-indent",
49+
UIAHandler.UIA_IndentationTrailingAttributeId: "right-indent",
50+
}
51+
4652
class UIATextInfo(textInfos.TextInfo):
4753

4854
_cache_controlFieldNVDAObjectClass=True
@@ -168,6 +174,8 @@ def _getFormatFieldAtRange(self,textRange,formatConfig,ignoreMixedValues=False):
168174
UIAHandler.UIA_IsSuperscriptAttributeId,
169175
UIAHandler.UIA_IsSubscriptAttributeId
170176
})
177+
if formatConfig["reportParagraphIndentation"]:
178+
IDs.update(set(paragraphIndentIDs))
171179
if formatConfig["reportAlignment"]:
172180
IDs.add(UIAHandler.UIA_HorizontalTextAlignmentAttributeId)
173181
if formatConfig["reportColor"]:
@@ -223,6 +231,21 @@ def _getFormatFieldAtRange(self,textRange,formatConfig,ignoreMixedValues=False):
223231
val=fetcher.getValue(UIAHandler.UIA_StyleNameAttributeId,ignoreMixedValues=ignoreMixedValues)
224232
if val!=UIAHandler.handler.reservedNotSupportedValue:
225233
formatField["style"]=val
234+
if formatConfig["reportParagraphIndentation"]:
235+
for ID, fieldAttr in paragraphIndentIDs.items():
236+
val = fetcher.getValue(ID, ignoreMixedValues=ignoreMixedValues)
237+
if isinstance(val, float):
238+
# val is in points (1/72 of an inch)
239+
val /= 72.0
240+
if languageHandler.useImperialMeasurements():
241+
# Translators: a measurement in inches
242+
valText = _("{val:.2f} in").format(val=val)
243+
else:
244+
# Convert from inches to centermetres
245+
val *= 2.54
246+
# Translators: a measurement in centermetres
247+
valText = _("{val:.2f} cm").format(val=val)
248+
formatField[fieldAttr] = valText
226249
if formatConfig["reportAlignment"]:
227250
val=fetcher.getValue(UIAHandler.UIA_HorizontalTextAlignmentAttributeId,ignoreMixedValues=ignoreMixedValues)
228251
if val==UIAHandler.HorizontalTextAlignment_Left:

source/languageHandler.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class LOCALE(enum.IntEnum):
4343
# https://docs.microsoft.com/en-us/windows/win32/intl/locale-information-constants
4444
SLANGUAGE = 0x2
4545
SLIST = 0xC
46+
IMEASURE = 0xD
4647
SLANGDISPLAYNAME = 0x6f
4748
SENGLISHLANGUAGENAME = 0x00001001
4849
SENGLISHCOUNTRYNAME = 0x00001002
@@ -437,6 +438,18 @@ def normalizeLanguage(lang) -> Optional[str]:
437438
ld[1]=ld[1].upper()
438439
return "_".join(ld)
439440

441+
442+
def useImperialMeasurements() -> bool:
443+
"""
444+
Whether or not measurements should be reported as imperial, rather than metric.
445+
"""
446+
bufLength = 2
447+
buf = ctypes.create_unicode_buffer(bufLength)
448+
if not winKernel.kernel32.GetLocaleInfoEx(None, LOCALE.IMEASURE, buf, bufLength):
449+
raise RuntimeError("LOCALE.IMEASURE not supported")
450+
return buf.value == '1'
451+
452+
440453
# Map Windows primary locale identifiers to locale names
441454
# Note these are only primary language codes (I.e. no country information)
442455
# For full locale identifiers we use Python's own locale.windows_locale.

user_docs/en/changes.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ If you need this functionality please assign a gesture to the appropriate script
5353
- When navigating the Windows system tray calendar, NVDA now reports the day of the week in full. (#12757)
5454
- When using a Chinese input method such as Taiwan - Microsoft Quick in Microsoft Word, scrolling the braille display forward and backward no longer incorrectly keeps jumping back to the original caret position. (#12855)
5555
- When accessing Microsoft Word documents via UIA, navigating by sentence (alt+downArrow / alt+upArrow) is again possible. (#9254)
56+
- When accessing MS Word with UIA, paragraph indenting is now reported. (#12899(
5657
-
5758

5859

0 commit comments

Comments
 (0)