Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UIA in MS Word by default on MS Word version 16.0.15000 or higher #13437

Merged
merged 10 commits into from
Mar 8, 2022

Conversation

michaelDCurran
Copy link
Member

@michaelDCurran michaelDCurran commented Mar 6, 2022

Link to issue number:

Summary of the issue:

Microsoft Word 2016 exposes a rich UI Automation implementation. For some time now, users have been able to optionally turn this on with an advanced setting. NVDA's support for MS Word via UIA has major performance advantages over the older object model support, so NVDA should use the UIA support by default where available. However, as the UIA implementation improved throughout Office 2016's lifetime, we should only enable our support for recent builds of Office 2016, specifically for build 15000 and higher, and when only on Windows 11.
This was previously tried in pr #12770 but reverted in pr #12989
The main argument for reverting was the lack of math support, and ability to report line column and section numbers.
These have all been since addressed.

Description of how this pull request fixes the issue:

NVDA now uses UI Automation to access Microsoft Word document controls by default when on Windows 11, for Microsoft Word version 16.0.15000 and higher.
The Use UI Automation to access Microsoft Word document controls when available checkbox has been replaced with a combo box with the following values:

  • Default (where suitable)
  • Only where necessary: where the Microsoft Word object model is not available at all
  • Where suitable: Windows 11 / Microsoft Word version 16.0.15000 or higher, or where the Microsoft Word object model is unavailable
  • Always: where ever UI automation is available in Microsoft word (no matter how complete).
    If the older checkbox was previously checked, the setting will be set to Always.

Testing strategy:

With MS Word 16.0.15000 on Windows 11:

  • With the setting set to Only where necessary: confirm that NvDA is not using UIA to access Microsoft Word by focusing on a Word document and viewing NVDA dev info in the log.
  • With the setting set to Where Suitable, ensure that NVDA is using UIA with Microsoft Word by focusing a Microsoft Word document and viewing the dev info in the NVDA log.
  • With the setting set to Always, ensure that NVDA is using UIA with Microsoft Word by focusing a Microsoft Word document and viewing the dev info in the NVDA log.
    Make sure that with the old checkbox checked, and then running the new NvDA, that the profile upgrade steps run and that the new setting is set to Always.

Known issues with pull request:

None known.

Change log entries:

New features

  • For Microsoft Word 16.0.15000 and higher on Windows 11, NVDA will use UI Automation to access the document by default, providing a significant performance improvement over the old Object model access.
    Changes
    Bug fixes
    For Developers

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English

Replace the `Use UI Automation to access Microsoft Word document controls when available` checkbox with a combo box allowing to change from Default (where suitable), Only where necessary, Where suitable, and Always.
If the older checbox was already checked, the setting becomes `Always`.
@michaelDCurran michaelDCurran requested review from a team as code owners March 6, 2022 23:58
@michaelDCurran michaelDCurran added this to the 2022.1 milestone Mar 6, 2022
@CyrilleB79
Copy link
Collaborator

Typo in change log (in case you copy/paste):
Mcirosoft -> Microsoft

Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General approach looks good to me. I'm awaiting confirmation that #13006 does not block this PR, as it is not reproducible in Word 16.0.15000 or higher.

source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/UIAHandler/__init__.py Outdated Show resolved Hide resolved
except KeyError:
useInMSWord = False
if useInMSWord:
profile['UIA']['allowInMSWord'] = 3 # ALWAYS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the enum here?

Suggested change
profile['UIA']['allowInMSWord'] = 3 # ALWAYS
profile['UIA']['allowInMSWord'] = AllowUiaInMSWord.ALWAYS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree using an enum here makes this much more readable the suggestion cannot be applied as is:

  1. We have to use .value on an enum member when adding its value to config.
  2. More importantly importing UIAHandler in config (that is much earier in NVDA's startup process than it is done now) would almost certainly prevent NVDA from starting. This suggest to me that the enum in question should be placed in config rather than in UIAHandler and UIAHandler can just reuse it from there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move both AllowInMSWord and AllowInChromium enums to configspec.py and rename them to reflect they are for UIA.

source/config/profileUpgradeSteps.py Outdated Show resolved Hide resolved
@codeofdusk
Copy link
Contributor

I'm awaiting confirmation that #13006 does not block this PR, as it is not reproducible in Word 16.0.15000 or higher.

I recommend not blocking for #13006 and deprecating setting columns/rows via bookmarks as UIA provides first column/row as headers automatically.

@josephsl
Copy link
Collaborator

josephsl commented Mar 7, 2022

Hi,

I think #13006 will not block this PR because:

  1. Testing it with Microsoft 365 beta 16.0.15018 shows that it can still be reproduced.
  2. More importantly, NVDA+Shift+C/R isn't even a part of UIA Word document scripts list as evidenced by input help being silent about these commands when performed from Word with UIA enabled.

I think Bill raises an important point: if we are going to use UIA from Microsoft 365 version 2203 or later, then we might as well take advantage of what UIA says provided that we can communicate issues with Microsoft Word team. This obviously requires comparing with Narrator and other AT's which can provide another data point to consider when refining NVDA's support for Office via UIA.

Thanks.

@cary-rowen
Copy link
Contributor

Hi,
Yes, I agree with Joseph's point, another reason is that if the row and column headers are set in non-uia mode, they are still valid in UIA mode.
Thanks

@Neurrone
Copy link

Neurrone commented Mar 7, 2022

Would #12998 block this? Tables are painful to navigate with UIA enabled.

@michaelDCurran
Copy link
Member Author

michaelDCurran commented Mar 8, 2022 via email

Co-authored-by: Sean Budd <sean@nvaccess.org>
Copy link
Member

@Qchristensen Qchristensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User guide looks good. Are there places where a Microsoft Word control is used outside these two examples? "This applies to documents in Microsoft word itself, plus messages in Microsoft Outlook" implies it is likely to be found ONLY in those two situations, though I'm sure there might be other places it is used. (Not blocking in any case, that's just a comment / question).

… config and make use of AllowUiaInMSWord in profileUpgradeSteps.
Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AppVeyorBot
Copy link

@LeonarddeR
Copy link
Collaborator

May be change the changelog to reflect that the mail editor/reading in Outlook is also affected by this change?

@LeonarddeR
Copy link
Collaborator

    Actually, when testing this, I noticed that NVDA is very obnoxious in logging `MathPlayer 4 not available` from mathPres.ensureInit. Could we avoid calling `mathPres.ensureInit()` in WordDocumentTextInfo.getTextWithFields? I assume checking for mathPres.speechProvider or mathPres.brailleProvider should be enough as long as we ensure init of math presentation somewhere earlier, preferably when initialising NVDA as everything else.

@michaelDCurran
Copy link
Member Author

@LeonarddeR If we only call ensureInit on NvDA startup, the user would have to restart NvDA if later installing mathPlayer.
I think we should deal with this separately. The issue is not new to this pr.

@michaelDCurran michaelDCurran merged commit 0d9a280 into master Mar 8, 2022
@michaelDCurran michaelDCurran deleted the wordWithUIAByDefault branch March 8, 2022 07:29
@LeonarddeR
Copy link
Collaborator

I'm fine with that, as long as it is addressed pre 2022.1 release.

@michaelDCurran
Copy link
Member Author

michaelDCurran commented Mar 8, 2022 via email

@CyrilleB79
Copy link
Collaborator

Hello

FYI there is an other issue regarding Word with UIA reported on NVDA mailing list; it's here.
I have not tested myself, but @Qchristensen did.

Cyrille

@Qchristensen
Copy link
Member

That issue has been reported as #13458 - but I don't think it is a blocker here. The majority of users likely don't have colour reporting enabled, and reading tables using the table navigation commands do work as expected.

Using UIA by default is also different to disabling NOT using UIA - For some time there have been some users for whom UIA provides a better experience in Word. Similarly, for some time yet, there will be some users for whom disabling UIA is the better experience. The key is to change over at a point where the UIA experience will be better for the majority of users. Those who need to, can then turn the feature off, just as currently, those who need it, can turn the feature on.

In any case, it is, of course, important to capture those issues like #13458, so they can be addressed.

@LittleStar-VIP
Copy link

Hello, based on my further testing, the issue is not limited to report of color #13459
But the UIA issue with reporting of color is really a trouble to me.
In my daoly work, sighted staffs require me to hightlight certain text in certain color, so I really need to enable UIA to edit a word file.
Hmm, disabling the UIA can fix the problem temporarily, but I am unable to check if which text is hightlighted.

CyrilleB79 added a commit to CyrilleB79/nvda that referenced this pull request Mar 30, 2022
seanbudd pushed a commit that referenced this pull request Apr 1, 2022
…13563)

Fix-up of #13437.

Summary of the issue:
With #13437, the option "Use UI Automation to access Microsoft Word document controls" in Advanced settings panel has become a combo-box; it was a checkbox before.
In the same time, the accelerator key (mapped to W) has been removed for this option: "&" removed from the label.
When testing Word with and without UIA, it was handy to focus the Advanced panel, check the first checkbox and press alt+W to jump directly to this option.
Now tabbing between the options is required.

Description of how this pull request fixes the issue:
Just add the "&" in the label to restore the accelerator key for this option.
CyrilleB79 added a commit to CyrilleB79/nvda that referenced this pull request Apr 7, 2022
…13437). (nvaccess#13563)

Fix-up of nvaccess#13437.

Summary of the issue:
With nvaccess#13437, the option "Use UI Automation to access Microsoft Word document controls" in Advanced settings panel has become a combo-box; it was a checkbox before.
In the same time, the accelerator key (mapped to W) has been removed for this option: "&" removed from the label.
When testing Word with and without UIA, it was handy to focus the Advanced panel, check the first checkbox and press alt+W to jump directly to this option.
Now tabbing between the options is required.

Description of how this pull request fixes the issue:
Just add the "&" in the label to restore the accelerator key for this option.
michaelDCurran pushed a commit that referenced this pull request Apr 11, 2022
…13563) (#13590)

PR #13563 restores an accelerator key that has been removed by #13437 during NVDA 2022.1 release cycle.
Unfortunately, PR #13563 has been opened after translation freeze and thus could not integrate 2022.1.
However in #13563, I have written:
I would have wished to open this PR against beta to fix the issue immediately before the stable release. However, we are already in the translation freeze, thus this is not possible to change a translatable string, unfortunately. If a new translation freeze should occur, please reconsider merging this PR in beta.
According to this thread, an extension translation freeze is in preparation with new translatable strings.
Thus this allow to integrate this fix for 2022.1 considering that the accelerator key was removed during 2022.1 dev cycle.

Description of how this pull request fixes the issue:
Cherry-pick the commit corresponding to #13563, i.e. c446688.
@LittleStar-VIP
Copy link

Not sure if this temporary fix is possible.
nvda can offer an input gesture so that user can temporary switch the uia support for word or excel on or off

@codeofdusk
Copy link
Contributor

codeofdusk commented May 18, 2022

@LittleStar-VIP This is possible by creating a config profile with UIA deactivated, then binding the profile's activation to an input gesture. Note that, as the active accessibility API for a window is chosen on focus, it is necessary to switch away from (Alt+Tab) then back to Word for the change to take effect.

@LittleStar-VIP
Copy link

@codeofdusk
Understood, thanks for your instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.