UI Automation in Microsoft Word: Use move by sentence custom pattern when available instead of the legacy model#19367
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds support for UI Automation remote operations to enable sentence navigation in Microsoft Word when the legacy object model is unavailable. The implementation uses Word's custom UIA extension patterns (MoveBySentence and ExpandToEnclosingSentence) when available on Windows 11 with remote operations support, falling back to the existing legacy object model approach otherwise.
- Adds a new function
msWord_moveTextRangeBySentenceinUIAHandler/remote.pyto handle sentence navigation via UIA remote operations - Refactors
_caretMoveBySentenceHelperin Word document handling to prefer UIA remote operations, with legacy fallback - Extracts common pattern retrieval logic into a reusable helper function
_msWord_remote_getExtendedTextRangePattern
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| user_docs/en/changes.md | Adds changelog entry documenting the new sentence navigation capability in Word with UIA on Windows 11 |
| source/UIAHandler/remote.py | Implements msWord_moveTextRangeBySentence function using Word UIA custom patterns and extracts _msWord_remote_getExtendedTextRangePattern helper function |
| source/NVDAObjects/UIA/wordDocument.py | Updates _caretMoveBySentenceHelper to attempt UIA remote sentence navigation first before falling back to legacy object model |
Comments suppressed due to low confidence (2)
source/NVDAObjects/UIA/wordDocument.py:675
- The
exc_info=Trueparameter is redundant when usinglog.exception(). Thelog.exception()method automatically includes exception information, so explicitly passingexc_info=Trueis unnecessary. Consider removing this parameter.
TextInfo = WordDocumentTextInfo
def _get_mathMl(self):
try:
source/NVDAObjects/UIA/wordDocument.py:653
- Typo in comment: "overide" should be "override".
pos,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f82061b to
150d7ff
Compare
|
@codeofdusk, it may be interesting to test #9002, in case this PR changes something or even fixes it. |
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
…when available instead of the legacy model (nvaccess#19367) <!-- Please read and fill in the following template, for an explanation of the sections see: https://github.com/nvaccess/nvda/blob/master/projectDocs/dev/githubPullRequestTemplateExplanationAndExamples.md Please also note that the NVDA project has a Citizen and Contributor Code of Conduct which can be found at https://github.com/nvaccess/nvda/blob/master/CODE_OF_CONDUCT.md. NV Access expects that all contributors and other community members read and abide by the rules set out in this document while participating or contributing to this project. This includes creating or commenting on issues and pull requests. Please initially open PRs as a draft. When you would like a review, mark the PR as "ready for review". See https://github.com/nvaccess/nvda/blob/master/.github/CONTRIBUTING.md. --> ### Link to issue number: Closes nvaccess#13517. ### Summary of the issue: NVDA exclusively uses Word's legacy object model for sentence navigation, even when UIA is enabled. ### Description of how this pull request fixes the issue: Added support for the [UIA custom extension](https://docs.microsoft.com/en-gb/office/uia/word/wordcustompatterns) to move and expand by sentence in supported scenarios. The legacy implementation remains as a fallback on systems without remote ops support (Windows below 11/Cobalt platform) or older Office versions. ### Testing strategy: Moved by sentence in a large document and verified functionality.
Link to issue number:
Closes #13517.
Summary of the issue:
NVDA exclusively uses Word's legacy object model for sentence navigation, even when UIA is enabled.
Description of how this pull request fixes the issue:
Added support for the UIA custom extension to move and expand by sentence in supported scenarios. The legacy implementation remains as a fallback on systems without remote ops support (Windows below 11/Cobalt platform) or older Office versions.
Testing strategy:
Moved by sentence in a large document and verified functionality.
Known issues with pull request:
None known
Code Review Checklist: