Skip to content

Add ability to report the document layout in Microsoft Word#17324

Merged
SaschaCowley merged 23 commits into
nvaccess:masterfrom
nvdaes:wordLayout
Oct 29, 2024
Merged

Add ability to report the document layout in Microsoft Word#17324
SaschaCowley merged 23 commits into
nvaccess:masterfrom
nvdaes:wordLayout

Conversation

@nvdaes

@nvdaes nvdaes commented Oct 24, 2024

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #15088

Summary of the issue:

Knowing the document layout in Microsoft Word may be important, for example, to figure out why a table is not read properly when navigating with NVDA, and in other situations.

Description of user facing changes

WinwordWindowObject.view.Type is used to add the document layout to the document description. It can be announced when the document is focused, and when pressing NVDA+tab.

Description of development approach

In the WinWord app module, a script has been created, using api.getStatusBar() to search for the status bar. If it can be found, and one of the bar status children has the PRESSED state, its name Will be added to the title, assuming that it correspond to the document layout.

Testing strategy:

Tested manually, in Word documents, with the ribbon active and inactive, and with a dialog opened to check that the title without the document layout is reported when the status bar is not found.

Known issues with pull request:

None.

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.

@coderabbitai summary

@AppVeyorBot

Copy link
Copy Markdown
  • FAIL: Translation comments check. Translation comments missing or unexpectedly included. See build log for more information.
  • PASS: License check.
  • PASS: Unit tests.
  • PASS: Lint check.
  • PASS: System tests (tags: installer NVDA).
  • Build (for testing PR): https://ci.appveyor.com/api/buildjobs/yj03ojc4b6wubepw/artifacts/output/l10nUtil.exe nvda_snapshot_pr17324-34415,c51766cc.exe
  • CI timing (mins):
    INIT 0.0,
    INSTALL_START 1.5,
    INSTALL_END 1.0,
    BUILD_START 0.0,
    BUILD_END 26.5,
    TESTSETUP_START 0.0,
    TESTSETUP_END 0.4,
    TEST_START 0.0,
    TEST_END 18.9,
    FINISH_END 0.1

See test results for failed build of commit c51766ccdb

@codeofdusk

codeofdusk commented Oct 25, 2024

Copy link
Copy Markdown
Contributor

I really don't think this should be in the title bar (it isn't visually, right?). Perhaps it could be assigned to a separate script?

@CyrilleB79

Copy link
Copy Markdown
Contributor

Hi Noelia.

Thanks for addressing this issue. It will be very useful.

This approach with the status bar is not the best design choice IMO. Indeed, the view ribbon allow you to select outline or draft mode but there are no corresponding buttons, at least by default, in the status bar. Also, are we sure that the status bar cannot contain any other pressed button?

As suggested in #15088 (comment), I'd rather opt for the Word Object Model approach. Using the macro recorder and playing with the buttons in the view ribbon, you can find the relevant objects/properties/methods; then you can complete your information by googling the corresponding MSDN page (e.g. "VBA word view").

Also, rather than duplicating the NVDA+T script, I'd keep one single script. As for the processing done to read the status bar text (see api.getStatusBar), I'd create a function allowing to get the title in the general case or delegating this task to Word's appModule when in Word. The advantages of a single script are that:

  • the processing done with the text (e.g. spelll if two presses, etc.) remains factorized; so if we change what to do on triple press in the future, we will have to change it only at one place.
  • if someone change the script's gesture NVDA+t to NVDA+shift+t, it will be changed in all context at once. Keeping two separated scripts, people may not understand easily that they have to change the gesture in Word and out of Word.

To be complete, the drawback of having one single script is that you cannot use a separate description in Word.

@CyrilleB79

Copy link
Copy Markdown
Contributor

Re @codeofdusk feedback:
It's true that the title bar does not show this information. Though, a dedicated script is not a better solution IMO.
If we want this feature to be useful, the information should:

  • either be reported along with a frequently used script (current implementation)
  • or reported upon a specific event, e.g. when the application gets the focus

@codeofdusk

Copy link
Copy Markdown
Contributor

What about including it in the name property of the document's NVDAObject?

@CyrilleB79

Copy link
Copy Markdown
Contributor

What about including it in the name property of the document's NVDAObject?

Yes, that seems an interesting option. It would be reported when the document gets focused or when calling NVDA+tab.
It's worth noting that the name seems to be "Document Microsoft Word". We may replace it by "Document {viewMode}". No need to keep the "Microsoft Word" information; I should already know that I am in Word.

@nvdaes

nvdaes commented Oct 25, 2024

Copy link
Copy Markdown
Collaborator Author

For me, adding this to the document name is a good option.
Though, according to #15088, in JAWS this seems to be reported in the title.
I think that this should be reported on demand when the user wants, not just when an event is fired.
Anyway, note that if we report this in the document name, when the ribbon is active it won't be availab.e.
My first approach was to include the script just in the document class, and then I moved it to the app module so that it's available from the ribbon too.
I'll wait for more feedback, or I can mark this as ready for review to see opinions from NV Access too.

@nvdaes

nvdaes commented Oct 25, 2024

Copy link
Copy Markdown
Collaborator Author

Exploring Microsoft Word, pragmatically, I think that including this in the title may be more useful. For example, if we want to change the layout from the ribbon, we may press NVDA+tab to remember the focused button, and we can have the current layout in the title.

@nvdaes

nvdaes commented Oct 25, 2024

Copy link
Copy Markdown
Collaborator Author

I'll mark this as ready for review, and feedback is welcome.

@nvdaes nvdaes marked this pull request as ready for review October 25, 2024 08:16
@nvdaes nvdaes requested a review from a team as a code owner October 25, 2024 08:16
@nvdaes nvdaes requested a review from SaschaCowley October 25, 2024 08:16
@CyrilleB79

Copy link
Copy Markdown
Contributor

@nvdaes regarding the second point in #17324 (comment), namely making NVDA+t a single script, could you share your opinion?

@nvdaes

nvdaes commented Oct 25, 2024

Copy link
Copy Markdown
Collaborator Author

I have thought about a single script, but finally I decided to use a separate script. In this way:

  • The global commands script is more simple. Other app modules, in the future, may implement a report title command for different applications, and having this in a single script is les maintainable imo.
  • If someone prefers to use the standard script, without reading the document layout, this can be achieved by removing NVDA+t gesture for the Word command.
  • If someone wants to have different gestures for the global commands title script and the script for Word, it can be done too.

@codeofdusk

Copy link
Copy Markdown
Contributor

in JAWS this seems to be reported in the title.

@michaelDCurran and @jcsteh hold that NVDA and JAWS are very different products and take very different philosophical approaches. If a user asks for the window title, they should get the window title.

@LeonarddeR

Copy link
Copy Markdown
Collaborator

I wholeheartedly agree with @codeofdusk with regard to his concern about using the title for this.
I like the idea to use the word document object instead, tough may be the description is more suitable than the name of the object.

@LeonarddeR

Copy link
Copy Markdown
Collaborator

@CyrilleB79 wrote:

This approach with the status bar is not the best design choice IMO. Indeed, the view ribbon allow you to select outline or draft mode but there are no corresponding buttons, at least by default, in the status bar. Also, are we sure that the status bar cannot contain any other pressed button?

As suggested in #15088 (comment), I'd rather opt for the Word Object Model approach. Using the macro recorder and playing with the buttons in the view ribbon, you can find the relevant objects/properties/methods; then you can complete your information by googling the corresponding MSDN page (e.g. "VBA word view").

I also tend to agree here. @nvdaes could you please address this as well?

@nvdaes nvdaes marked this pull request as draft October 26, 2024 05:55
@nvdaes

nvdaes commented Oct 26, 2024

Copy link
Copy Markdown
Collaborator Author

Hi reviewers, thanks for your feedback. Now we use WinwordWindowObject.view.Type to set the corresponding display string to the description. Comments are appreciated.

Comment thread source/appModules/winword.py Outdated
@nvdaes nvdaes marked this pull request as ready for review October 26, 2024 18:57
@nvdaes

nvdaes commented Oct 27, 2024

Copy link
Copy Markdown
Collaborator Author

@codeofdusk , I've handled cases where WinwordWindowObject is not available. In this case the description should be empty.

Comment thread source/appModules/winword.py Outdated

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

I like this a lot, thanks @nvdaes

Comment thread source/appModules/winword.py Outdated
@nvdaes

nvdaes commented Oct 28, 2024

Copy link
Copy Markdown
Collaborator Author

@codeofdusk wrote:

If Word adds a description or help text at any point, it'll be thrown away after this PR. Is this desirable?

Probably no. If you have precise suggestions, feel free to provide them.
Thanks.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Oct 28, 2024

@SaschaCowley SaschaCowley left a comment

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.

Thanks for this, @nvdaes

Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
@nvdaes

nvdaes commented Oct 29, 2024

Copy link
Copy Markdown
Collaborator Author

Thanks @SaschaCowley . Probably your suggestion is the best one, i.e., prepending the document view instead of appending it to the possible available description, so that this info is always read after the document name. I've committed your suggestion.
Thanks also to all reviewers.

@nvdaes

nvdaes commented Oct 29, 2024

Copy link
Copy Markdown
Collaborator Author

Thanks @codeofdusk

@SaschaCowley SaschaCowley left a comment

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.

Great work @nvdaes

@SaschaCowley SaschaCowley merged commit a69efb3 into nvaccess:master Oct 29, 2024
@github-actions github-actions Bot added this to the 2025.1 milestone Oct 29, 2024
@LeonarddeR

Copy link
Copy Markdown
Collaborator

@nvdaes With current Alpha, the word document object has a description of Print layout None here.

@nvdaes

nvdaes commented Oct 29, 2024

Copy link
Copy Markdown
Collaborator Author

Thanks so much @LeonarddeR .
I opened issue #17338
When this is triaged I'll fix it.
I opened issue #17338

@SaschaCowley

Copy link
Copy Markdown
Member

@nvdaes no need to wait for NV Access to triage this before submitting a fix. You can triage it yourself though if you like.

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

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to determine current document view in Microsoft Word

7 participants