Skip to content

Word with UIA: Retrieve Page Numbers from Custom Attributes API (#19394)#19394

Merged
seanbudd merged 1 commit intonvaccess:masterfrom
akj:is19386
Dec 29, 2025
Merged

Word with UIA: Retrieve Page Numbers from Custom Attributes API (#19394)#19394
seanbudd merged 1 commit intonvaccess:masterfrom
akj:is19386

Conversation

@akj
Copy link
Copy Markdown
Contributor

@akj akj commented Dec 17, 2025

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._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.

Testing strategy:

Manual testing with UIA enabled and disabled.

Known issues with pull request:

None known.

Code Review Checklist:

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

…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
@akj akj requested a review from a team as a code owner December 17, 2025 17:01
@akj akj requested a review from seanbudd December 17, 2025 17:01
@akj akj changed the title UIA Word: Retrieve Page Numbers from Custom Attributes API (#19386) Word with UIA: Retrieve Page Numbers from Custom Attributes API (#19386) Dec 17, 2025
Copy link
Copy Markdown
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.

Thanks @akj - nice fix

@seanbudd seanbudd enabled auto-merge (squash) December 29, 2025 08:02
@seanbudd seanbudd merged commit d154ffc into nvaccess:master Dec 29, 2025
41 checks passed
@github-actions github-actions Bot added this to the 2026.2 milestone Dec 29, 2025
@akj akj changed the title Word with UIA: Retrieve Page Numbers from Custom Attributes API (#19386) Word with UIA: Retrieve Page Numbers from Custom Attributes API (#19394) Dec 30, 2025
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
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.

Word UIA: Page changes not announced when navigating within tables

2 participants