UIA text formatting: support paragraph indenting attributes#12908
Conversation
Also add a useImperialMeasurements function to languageHandler.
Absolutely. Windows allows users to set their measurement system independent of region (for instance, I'm in the US and use metric) and this should be respected. From this page:
|
| localeName = normalizeLocaleForWin32(localeName) | ||
| bufLength = 2 | ||
| buf = ctypes.create_unicode_buffer(bufLength) | ||
| if not winKernel.kernel32.GetLocaleInfoEx(localeName, LOCALE.IMEASURE, buf, bufLength): |
There was a problem hiding this comment.
Ah, looks like you're already doing this.
…time setting by providing NULL (LOCALE_USER_DEFAULT) to GetLocaleInfoEx. No longer support an optional localeName argument (over enginerring).
|
This pr now honors the user's current regional preferences. |
See test results for failed build of commit 2543d7cb21 |
In the object model code version, paragraph indent used the Office option to determine which unit was used to report the indent; cf. the method Now with this PR, the user's regional preference (of the system) is used. This may lead to strange situations where:
Using object model may have the advantage that the reported measurements are expressed in the same unit of what is shown visually on the UI (in case of collaboration with a sighted person). |
Fixes #12899 Fix-up of #12908 Relates to #12770 Summary of the issue: Historically, the indent in NVDA is reported via object model and its terminology is similar to what is found in Word's paragraph formatting dialog. In #12908, reporting indant via UIA has been introduced. A mapping between UIA text attributes relative to indent and the type of indent that is reported was used. This mapping was doing the following assumption: UIA first line indent corresponds to Word's first line indent UIA leading indent corresponds to Word's left indent UIA trailing indent corresponds to Word's right indent This assumption is not always correct for the first two points. And you can seen that object model access. And UIA access give not the same results in the following examples: left indent = 2.5cm and first line indent = 2.5cm left indent = 2.5cm and first line negative indent = 2.5cm Moreover, first line negative was reported in the object model code, whereas it does not appear at all in the UIA code, what evidences missing code. Description of how this pull request fixes the issue: Correct matching between Word's and UIA terminology has been implemented. To clarify: Word's terminology left indent = distance from the left margin to the left-most start of a line (it may be the first line or the following lines) right indent = distance from the right margin to the end of the paragraph's lines (except the last that may be incomplete) first line indent = distance between the start of the first line and the start of the other lines when the first line starts after the other ones hanging indent = distance between the start of the first line and the start of the other lines when the first line starts before the other ones UIA terminology first line indent = distance from the left margin to the start of the first line of the paragraph leading indent: distance from the left margin to the start of the following lines (2nd, 3rd, etc.) trailing indent = distance from the right margin to the end of the paragraph's lines (except the last that may be incomplete) Addition: do not report zero indent In addition, I have removed reporting any type of indent when its value is zero. Indeed, it was not reported in this case with the object model access, and I felt it was worth continuing in this way. Moreover, in #12908, nothing has been indicated that zero values should now be reported, so I assumed that it was unintentional. Possible alternative design I have aligned what is reported to what preexisted with the object model access, since in #12908 no information was indicating that it should have been modified. But another option may have been to report indentation as provided by UIA and to align the object model access code to what is provided by UIA. I have also not chosen this alternative design because I think that today, only Word provides indentation information via UIA. Thus, this makes sense to follow with Words conventions. If another provider should provide indent information one day, maybe the way indentation is reported should be reconsidered and uniformed. Should you however prefer this alternative design, just let me know. Testing strategy: Tested various paragraph formatting with non-zero left indent and the 3 following cases: no first line indent first line indent > 0 negative indent > 0
Link to issue number:
Fixes #12899
Summary of the issue:
When NVDA accessed Microsoft Word documents with the Word object model, it was able to report paragraph indenting.
If the user configures NvDA to access MS Word via UIA, ro it is used by default in MS Word build 13901 or higher, paragraph indenting is no longer reported.
Description of how this pull request fixes the issue:
Report paragraph indenting in UIA text controls (including MS Word documents) by fetching and processing the appropriate UIA text attribute values.
These include:
indentationFirstLine, indentationLeading and indentationTrailing.
These values are all given by the UIA provider in points (1/72 of an inch) thus NvDA converts these to either inches or centermetres first.
this pr also adds a new useImperialMeasurements function to languageHandler which returns true if imperial measuremts (inches) should be used according to the user's current Regional preferences, otherwise metric (centermetres).
Testing strategy:
Ensured NVDA was using UIA to access MS Word.
Created a new Word document. Typed a line of text. Opened Paragraph properties from the context menu and set values for left indent, right indent and first line indent. Back in the Word document, pressed NVDA+f to report the formatting including paragraph indentation.
Ensured that the values were in inches if The measurement soption in Regional settings was set to U.S. or Centermetres if the setting was Metric.
Known issues with pull request:
None known.
Change log entries:
Bug fixes
Code Review Checklist: