Skip to content

Correctly read blank cells in MS Word with NVDA's UIA for MS Word option enabled#12731

Merged
michaelDCurran merged 6 commits into
masterfrom
i11043
Aug 16, 2021
Merged

Correctly read blank cells in MS Word with NVDA's UIA for MS Word option enabled#12731
michaelDCurran merged 6 commits into
masterfrom
i11043

Conversation

@michaelDCurran

@michaelDCurran michaelDCurran commented Aug 12, 2021

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #11043
Fixes #11457
Fixes #12490

Summary of the issue:

When using UIA to access Microsoft word documents with NVDA, NVDA failed to announce row and column numbers when arrowing onto blank table cells. Also, navigating a table with the control+alt+arrow keys and landing on blank cells would sometimes announce leaving the table.

This was caused by the fact that when expanding a IUIAutomationTextRange in a blank table cell to any text unit, the range will cover the end-of-cell marker, and therefore span more than the cell itself, thus it looks like the range is not entirely inside the cell.

Description of how this pull request fixes the issue:

Work around this MS Word bug by detecting when in this situation: the range is not collapsed, yet the text in the range is either empty or the end-of-cell marker. And if so, Use a copy of the range, that is collapsed to the start (entirely inside the cell) to fetch the text and fields.

This pr also makes a change to Braille, so that when building a line of rich text in braille, a TextInfo's getTextWithFields method is only called if the textInfo is not collapsed. this stops repeating of fields for collapsed ranges, which was sometimes seen in Microsoft Word with UIA enabled.

Testing strategy:

  • Navigated a Word document containing tables, lists, headings, images, comments, foot notes and end notes, ensuring that noting has changed in speech or braille. Test document:
    Test document.docx

  • Create a new document in MS Word, insert a blank table, and use, arrows, tab and control+alt+arrows to move between the blank cells ensuring that row and column info is reported in both speech and braille.

Known issues with pull request:

None known.

Change log entries:

Bug fixes

  • NVDA correctly announces blank table cells in Microsoft Word when using UI automation.

Code Review Checklist:

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual testing.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers

…play, don't call GetTextWithFields for any textInfo that is collapsed, otherwise in some circomstances such as in MS word with UIA enabled, fields may be repeated.
…g to any text unit when on a blank table cell causes the text range to expand onto the end-of-cell marker and also not treat the range as being inside the cell, causing NVDA to not announce the current row and column and think it is outside the table.
@michaelDCurran michaelDCurran requested a review from a team as a code owner August 12, 2021 23:03
Comment thread source/NVDAObjects/UIA/wordDocument.py Outdated
fields = None
if not self.isCollapsed:
rawText = self._rangeObj.GetText(2)
if not rawText or rawText == '\x07':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does '\x07' represent in this instance? Could it be replaced by a named constant?

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, I really dig this!

fields=super(WordDocumentTextInfo,self).getTextWithFields(formatConfig=formatConfig)
fields = None
if not self.isCollapsed:
rawText = self._rangeObj.GetText(2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why getting 2 characters here instead of just one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fetching 2 characters ensures that that the range does not deliberately span past the end of the cell and into the next cell and or out of the table. I've added a detailed code comment to the change now.

Comment thread source/NVDAObjects/UIA/wordDocument.py Outdated
r.end = r.start
fields = super(WordDocumentTextInfo, r).getTextWithFields(formatConfig=formatConfig)
if fields is None:
fields = super(WordDocumentTextInfo, self).getTextWithFields(formatConfig=formatConfig)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Might as well make this new style super. That also creates a bigger contrast with the super call abbove, that calls super on r.

Suggested change
fields = super(WordDocumentTextInfo, self).getTextWithFields(formatConfig=formatConfig)
fields = super().getTextWithFields(formatConfig=formatConfig)

@michaelDCurran michaelDCurran merged commit 733ead7 into master Aug 16, 2021
@michaelDCurran michaelDCurran deleted the i11043 branch August 16, 2021 00:35
@nvaccessAuto nvaccessAuto added this to the 2021.3 milestone Aug 16, 2021
@brunoprietog

Copy link
Copy Markdown

Thank you very much! I have been waiting for this for a long time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants