Skip to content

MS Word with UIA: heading quicknav no longer keeps repeating the last heading#13013

Merged
michaelDCurran merged 5 commits into
masterfrom
i9540
Nov 4, 2021
Merged

MS Word with UIA: heading quicknav no longer keeps repeating the last heading#13013
michaelDCurran merged 5 commits into
masterfrom
i9540

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #9540

Summary of the issue:

When accessing MS Word documents with UIA, if the last bit of text is formatted as a heading, pressing quicknav by heading (h) in browse mode keeps repeating that heding. Similarly, The elements list when set to show headings, lists the final heading twice.

This is due to the fact that most UIA providers when on the last unit, move to the collapsed exclusive end if asked to move forward 1 by that unit. Only after that does the move fail.
We could add some specific checks in the UIABrowseMode.UIAHeadingQuicknavIterator function to take this into account, or we can rewrite that algorithm to make use of iterUIARangeByUnit which is used in many other places and avoids that bug all together.

Description of how this pull request fixes the issue:

Rewrite the UIABrowseMode.UIAHeadingQuicknavIterator function to make use of iterUIARangeByUnit. It is now much more similar to the UIABrowseMode.UIATextAttributeQuicknavIterator function, which we know does not have the repeating bug.

Testing strategy:

  • Ensure NVDA's use UIA to access MS Word document controls when available is on
  • Open a new blank document in MS Word
  • Type Test and press enter
  • Press alt+shift+rightArrow to start formatting as heading 2 style and type First heading and press enter
  • Type Test and press enter
  • Press alt+shift+rightArrow to start formatting as heading 3, type Second heading and press enter
  • Second heading should be the final line of text in the document, I.e. the heading ends at the end of the document.
  • Switch to browse mode with NVDA+space
  • Move to the top of the document with control+home
  • Press h to jump to the First heading
  • Press h to jump to the Second heading
  • Press h and ensure that NVDA reports that there is no next heading.
  • Press shift+h to move to the First heading
  • Press shift+h and ensure NVDA reports that there is no previous heading
  • Press NVDA+f7 to open the NVDA elements list, and select Headings from the Type radio buttons
  • Ensure that just two headings are listed in the treeview: First heading and Second heading.

Known issues with pull request:

None known.

Change log entries:

New features
Changes
Bug fixes

  • MS word with UIA: heading quick nav in browse mode no longer gets stuck on the final heading of a document, nor is this heading shown twice in the NVDA elements list.

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

…ch the algorithm in UIATextAttributeQuicknavIterator, so as to stop yielding the final heading of a document twice. It now loops using iterUIARangeByUnit, rather than manually moving through the range.
@michaelDCurran michaelDCurran requested a review from a team as a code owner November 2, 2021 06:28
@LeonarddeR

Copy link
Copy Markdown
Collaborator

Would it help to do some timings with huge documents with many headings to see how performance is affected?

@michaelDCurran

Copy link
Copy Markdown
Member Author

To test timing:
I Created a new blank document.
I generated a paragraph of auto text by typing =rand() and pressing enter.
I then copied and pasted this many times to produce a document of 285 pages.
I typed a heading on the very last line of the document.
I then jumped back to the top of the document, switched to browse mode, and pressed h to jump to the heading.
Before this pr, time since input logging shows that it took 7.6 seconds to jump to and start speaking the heading.
With this pr, the time was 4.5 seconds.
This pr reduces the amount of TextInfo instantiations, and I think the iterUIARangeByUnit function requires less calls to move and compare methods.

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Wow, these are the timings I was hoping for!

Comment thread source/UIABrowseMode.py Outdated
@@ -152,27 +152,34 @@ def isChild(self,parent):
return self.level>parent.level

def UIAHeadingQuicknavIterator(itemType,document,position,direction="next"):

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.

Would you be able to add type hints? See below

Comment thread source/UIABrowseMode.py Outdated
Check for None rather than if not

Co-authored-by: Leonard de Ruijter <leonardder@users.noreply.github.com>
Comment thread source/UIABrowseMode.py
curPosition=position
reverse = bool(direction == "previous")
entireDocument = document.makeTextInfo(textInfos.POSITION_ALL)
if position is None:

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.

@LeonarddeR position will be None if called by the Elements list to list all headings. Position is a TextInfo if called by quicknav to jump from a specific location.

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 for clarifying!

@michaelDCurran michaelDCurran merged commit 5657960 into master Nov 4, 2021
@michaelDCurran michaelDCurran deleted the i9540 branch November 4, 2021 22:20
@nvaccessAuto nvaccessAuto added this to the 2022.1 milestone Nov 4, 2021
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.

UIA in Word: When document ends with a heading, the heading is duplicated in quick nav

4 participants