Word with UIA: Retrieve Page Numbers from Custom Attributes API (#19394)#19394
Merged
seanbudd merged 1 commit intonvaccess:masterfrom Dec 29, 2025
Merged
Word with UIA: Retrieve Page Numbers from Custom Attributes API (#19394)#19394seanbudd merged 1 commit intonvaccess:masterfrom
seanbudd merged 1 commit intonvaccess:masterfrom
Conversation
…numbers via custom attribute API When navigating table rows in Word documents using UIA mode, page changes were not announced because page control elements are not reliably present in the UIA tree for table cells. This fix retrieves page numbers directly via Word's custom attribute API, ensuring accurate page reporting regardless of UIA tree structure. Fixes nvaccess#19386
seanbudd
approved these changes
Dec 29, 2025
Merged
5 tasks
Somsubhra-Nandi
pushed a commit
to Somsubhra-Nandi/nvda
that referenced
this pull request
Jan 9, 2026
…cess#19386) (nvaccess#19394) Fixes nvaccess#19386 Summary of the issue: When using UIA to access Microsoft Word documents, page change announcements do not occur when navigating between table rows that span different pages. Page changes are only announced after exiting the table. This does not occur in IAccessible mode ("only where necessary" setting), where page changes are announced correctly within tables. Description of user facing changes: When navigating table rows in Word documents using UIA, NVDA will now correctly announce page changes (e.g., "page 2") when moving between rows on different pages. Description of developer facing changes: Description of development approach: The WordDocumentTextInfo._getFormatFieldAtRange method now retrieves page numbers via Word's custom attribute API (UIACustomAttributeID.PAGE_NUMBER), similar to how line numbers and section numbers are already retrieved. The fallback mechanism in getTextWithFields has been updated to only propagate page numbers from control elements when UIARemote is not supported, preserving the more accurate custom attribute values.
SaschaCowley
pushed a commit
that referenced
this pull request
Jan 11, 2026
… of page (#19424) Fixes #19423 ### Summary of the issue: When using UIA to access Microsoft Word documents, NVDA reports "page -1" when navigating to the final line of a page. This regression was introduced in PR #19394 which added support for retrieving page numbers via Word's Custom Attributes API. The issue occurs because Word's Custom Attributes API returns `-1` when the page number value is not yet available. The original code accepted any integer value without validation, causing NVDA to announce "page -1" to users. ### Description of user facing changes: NVDA will now correctly announce the page number (e.g., "page 2") instead of "page -1" when reaching the final line of a page. ### Description of developer facing changes: N/A ### Description of development approach: The fix implements a two-layer validation and fallback mechanism: 1. **Custom Attributes API Validation**: Page numbers from the Custom Attributes API are now validated to reject invalid values (< 1). When Word returns -1, the value is not used. 2. **Enhanced Fallback Mechanism**: The existing control field fallback (which uses automation IDs like `UIA_AutomationId_Word_Page_2`) now: - Runs regardless of UIARemote support status (previously it was disabled when UIARemote was supported) - Only propagates page numbers from control fields, not format fields - Only fills in missing page numbers, preserving valid Custom Attributes API values - Converts control field page numbers (strings) to integers to match Custom Attributes API type This ensures type consistency and prevents false page change detections due to type mismatches between string `"2"` and integer `2`. Since this is a fixup pr, I did not include a changelog entry. ### Testing strategy: Manual testing with: - Multi-page Word documents - Forward navigation (down arrow) - page changes announced correctly - Backward navigation (up arrow) - page changes announced correctly - Navigation within tables - continues to work as fixed in #19394 - Navigation outside tables - now works correctly in both directions ### Known issues with pull request: None known
tareh7z
pushed a commit
to tareh7z/nvda
that referenced
this pull request
Feb 16, 2026
…cess#19386) (nvaccess#19394) Fixes nvaccess#19386 Summary of the issue: When using UIA to access Microsoft Word documents, page change announcements do not occur when navigating between table rows that span different pages. Page changes are only announced after exiting the table. This does not occur in IAccessible mode ("only where necessary" setting), where page changes are announced correctly within tables. Description of user facing changes: When navigating table rows in Word documents using UIA, NVDA will now correctly announce page changes (e.g., "page 2") when moving between rows on different pages. Description of developer facing changes: Description of development approach: The WordDocumentTextInfo._getFormatFieldAtRange method now retrieves page numbers via Word's custom attribute API (UIACustomAttributeID.PAGE_NUMBER), similar to how line numbers and section numbers are already retrieved. The fallback mechanism in getTextWithFields has been updated to only propagate page numbers from control elements when UIARemote is not supported, preserving the more accurate custom attribute values.
tareh7z
pushed a commit
to tareh7z/nvda
that referenced
this pull request
Feb 16, 2026
…nal line of page (nvaccess#19424) Fixes nvaccess#19423 ### Summary of the issue: When using UIA to access Microsoft Word documents, NVDA reports "page -1" when navigating to the final line of a page. This regression was introduced in PR nvaccess#19394 which added support for retrieving page numbers via Word's Custom Attributes API. The issue occurs because Word's Custom Attributes API returns `-1` when the page number value is not yet available. The original code accepted any integer value without validation, causing NVDA to announce "page -1" to users. ### Description of user facing changes: NVDA will now correctly announce the page number (e.g., "page 2") instead of "page -1" when reaching the final line of a page. ### Description of developer facing changes: N/A ### Description of development approach: The fix implements a two-layer validation and fallback mechanism: 1. **Custom Attributes API Validation**: Page numbers from the Custom Attributes API are now validated to reject invalid values (< 1). When Word returns -1, the value is not used. 2. **Enhanced Fallback Mechanism**: The existing control field fallback (which uses automation IDs like `UIA_AutomationId_Word_Page_2`) now: - Runs regardless of UIARemote support status (previously it was disabled when UIARemote was supported) - Only propagates page numbers from control fields, not format fields - Only fills in missing page numbers, preserving valid Custom Attributes API values - Converts control field page numbers (strings) to integers to match Custom Attributes API type This ensures type consistency and prevents false page change detections due to type mismatches between string `"2"` and integer `2`. Since this is a fixup pr, I did not include a changelog entry. ### Testing strategy: Manual testing with: - Multi-page Word documents - Forward navigation (down arrow) - page changes announced correctly - Backward navigation (up arrow) - page changes announced correctly - Navigation within tables - continues to work as fixed in nvaccess#19394 - Navigation outside tables - now works correctly in both directions ### Known issues with pull request: None known
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fixes #19386
Summary of the issue:
When using UIA to access Microsoft Word documents, page change announcements do not occur when navigating between table rows that span different pages. Page changes are only announced after exiting the table. This does not occur in IAccessible mode ("only where necessary" setting), where page changes are announced correctly within tables.
Description of user facing changes:
When navigating table rows in Word documents using UIA, NVDA will now correctly announce page changes (e.g., "page 2") when moving between rows on different pages.
Description of developer facing changes:
Description of development approach:
The
WordDocumentTextInfo._getFormatFieldAtRangemethod now retrieves page numbers via Word's custom attribute API (UIACustomAttributeID.PAGE_NUMBER), similar to how line numbers and section numbers are already retrieved. The fallback mechanism ingetTextWithFieldshas been updated to only propagate page numbers from control elements when UIARemote is not supported, preserving the more accurate custom attribute values.Testing strategy:
Manual testing with UIA enabled and disabled.
Known issues with pull request:
None known.
Code Review Checklist: