Use Word object model to report distances when available#14575
Conversation
|
@cary-rowen would you mind using the test build of this PR when it is ready to check if it fixes #14542? Thanks. |
See test results for failed build of commit 3b72d100ad |
|
Hi @CyrilleB79 |
7be5af1 to
b946e2a
Compare
b946e2a to
15468c9
Compare
|
@CyrilleB79 |
I confirm that the user can use any unit in the paragraph formatting dialog. But internally Word stores it in the preferred unit, i.e. the one defined in Word's advanced options. To view an evidence of it, you can do as follows:
So IMO, this makes no sense for NVDA to report the distance with a unit other than the preferred option in any case. Also, keep in mind that the preferred unit option is the one that sighted people will see on the rulers on the side of the pages when Word is in page mode. |
|
Hello, I saw the following two setting items in the advanced options of MS Word: Show measurements in units of:
This option includes the following items, Centimeters is selected by default but does not contain the character (ch) Show measurements in width of charactersThe checkbox is checked
No, since the units in the advanced options don't contain characters, it still shows centimeters even though I also ticked "Show measurements in width of characters". |
|
(note: edited to be still clearer) OK, I have not been extra clear. Let me try to rephrase the explanations and the steps. Word uses only one unit internally to store distances such as the one shown in paragraph formatting dialog. The unit in paragraph formatting dialog can be: characters, inches, centimeters, millimeters, points or picas.
Now, here are steps to see which unit Word uses internally without looking at the options:
So it makes sense for NVDA to report distances in the units as defined in Word's advanced option. That is, In case the checkbox "Show measurements in width of characters" is checked in the advanced options, the preferred unit is characters and not the one defined in "Show measurements in units of:", which has no effect in the paragraph formatting dialog when the checkbox "Show measurements in width of characters" is checked. |
|
Hi, Thanks for your patience in clarifying.
The actual situation:
A question arises from this:
|
|
@cary-rowen thanks for these details. I am a bit confused. I am now able to reproduce your result with the same steps as you on Microsoft® Word 2016 (16.0.5369.1000) MSO (16.0.5366.1000) 32 bits. I will try to confirm tonight that I can also reproduce on a newer version of Office 2016. The only situation where the unit is not kept in memory is when you enter "0 cm"; it is memorized as 0 character. Not problematic for NVDA reporting however. If we want the information of the unit from the paragraph formatting dialog, it's probably available via the document's object model. When the user selects UIA to access Word document, getting this information would mean using the document objet model anyway if available. In any case, if object model is not available, the application will use the unit defined in the system regional settings. Before going further, I would like to hear NVAccess point of view before getting information from the document object model while in UIA. |
|
Thank you for your efforts, Let's wait for what NV Access thinks. |
|
Hi, I'm heavily working on Word in these days, with object model and even with C++ part. So, this discussion caught my curiosity The point, I think, is that method getLocalizedMeasurementTextForPointSize takes care of Word options, but has no check on current paragraph in any way. I won't suggest a coded solution (I appreciate a lot Cyrille's participation), but observe this test:
So, with a bit of if-elif-else to decide whether a conversion is needed, there could be a solution. If this will be considered too slow, I could look to get these information via C++ component. Hth. |
|
Yes I agree that there is a solution and that's what I had in mind when writing:
On my side, the questions still open are:
I can still change my mind in the future, but for now, I would answer "No" to these two questions and keep this PR as is. |
Sure, this is a good point, and I'm interested too. Personally, now I discovered it, I'd like to keep measurements in character width even with UIA enabled, so I'm favorable to this PR effects, regardless of the second question or technical details. |
Co-authored-by: Michael Curran <mick@nvaccess.org>
See test results for failed build of commit 97e48089cb |
|
Thanks @michaelDCurran for your review. I have accepted your modifications and tested the case when Word object model is unavailable (on commit 63a5319) by forcing manually the if statement of |
Link to issue number:
Fixes #14542
Summary of the issue:
When pressing NVDA+F, for Chinese people, paragraph indent is reported in number of characters by default when NVDA is using Word object model to access Word documents. But it is reported in centimeter when NVDA is using UIA to access Word documents.
When using object model, the way NVDA reports indent in Word honours the two following advanced options of Word:
These options should be also honoured when using UIA for Word documents. Especially, Chinese people are used to express measurements in characters, what NVDA does not when using UIA for Word documents.
Description of user facing changes
Word's advanced options are now used instead of system options also when using UIA to access Word documents. Thus, the option "Show measurements in character width" in Word advanced options is now honoured also when using UIA for Word documents.
Description of development approach
The only way I've found to know how distances are reported in Word (according to this option) is to use Word object model. Thus, if possible, we use Word object model to access Word's options, even if NVDA uses UIA to access Word document.
When object model is not available however, Windows regional setting is used as a fallback as it was before this PR.
Testing strategy:
Manual tests:
In a paragraph having indentation, press NVDA+F in the 4 following combined cases:
Known issues with pull request:
None
Change log entries:
Changes
Distance reported in Word will now honour the unit defined in Word's advanced options even when using UIA to access Word documents. (#14542)Code Review Checklist: