Skip to content

Text alignment reporting and enhancements for MS Excel cells and MS Word text #15205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 29, 2023

Conversation

CyrilleB79
Copy link
Contributor

@CyrilleB79 CyrilleB79 commented Jul 27, 2023

Link to issue number:

Closes #15206
Closes #15220

Summary of the issue:

Various issues for alignment reporting:

  • In MS Excel horizontal or vertical text alignment is not always correctly reported.
  • In MS Word (legacy), text alignment is not correctly reported for "justify" and for "distrubute".

Description of user facing changes

Reporting text alignment in Word and Excel is now handled better in various situations. "Default" is not reported anymore since it does not give any clear indication of the position of the text.

  • In MS Excel (no UIA) the alignment is reported as per Excel's options:
    • for horizontal text alignment in cell: "General", "Centered across columns", "Repeat" and "Distribute" is now reported instead of "Default" or nothing
    • for vertical alignment: "bottom" is reported instead of "default"
  • In MS Word (no UIA):
    • "justify" is now reported instead of "Default"
    • "distribute" is now reported instead of nothing

Description of development approach

Standardized alignments returned by getFormatField* functions around a string enum as done in #11897. Thus, all the interfaces are impacted.

Testing strategy:

Test plan based on #11897, adapted to this PR.

For the following APIs/files, the following test are made:

  • Check that NVDA+F is able to report text alignment
  • Activate the option to report text alignment and navigate with the caret to test the transitions between the various possible text alignments.

API/files tested:

  • NVDAObjects/IAccessible/init.py:
    * Test with Chrome: data:text/html,<p align="left">left</p><p align="right">right</p><p align="center">center</p><p align="justify">justify</p>
    OK for left, right, center, justify and match-parent; NOK for experimental justify-all, start, end without or with this PR
    * Edge (legacy)
    OK for left, right, center, justify; NOK for experimental justify-all, start, end without or with this PR
  • NVDAObjects/UIA/init.py: test with Word (UIA); left, right, center, justify are supported; but distribute is reported as justify
  • NVDAObjects/window/edit.py, class ITextDocumentTextInfo: Test with Wordpad (left, right, center, justify)
  • NVDAObjects/window/edit.py, class EditTextInfo: Paragraph alignment is not supported by NVDA (probably not natively either; no test done.
  • NVDAObjects/window/excel.py: test with Excel, cell navigation (alignment of full cell).
    • The following horizontal text alignments are reported (these are the ones available in cell formatting dialog): general, left, right, center, centered across multiple columns, justify, fill and distributed.
    • The following vertical text alignments are reported (these are the ones available in cell formatting dialog): top, centered, bottom, justitfy and distributed.
    • Note: When editing the cell's content, no formatting can be reported (neither before this PR nor with this PR).
  • NVDAObjects/window/winword.py: test with Word 2016 (UIA not checked): left, right, center, justify and distribute are reported
  • virtualBuffers/MSHTML.py: Test ui.browseableMessage:
    * Test case:
    ui.browseableMessage('''<p align="left">left</p><p align="right">right</p><p align="center">center</p><p align="justify">justify</p><p align="justify-all">justify-all</p><p align="start">start</p><p align="end">end</p><div align="center"><p align="match-parent">match-parent center</p></div>''', "Test", isHtml=True)
    * Result: no change with respect to NVDA 2023.2beta1, i.e. OK for left, right, center, justify; NOK for start, end and justify-all which are all reported as left.

Tests done with:

  • MS Office 2016 (16.0.16529.20182).
  • Chrome 115.0.5790.110
  • Edge 114.0.1823.82

Special case of Firefox

A part of the work of this PR was done some time ago and was working with Firefox. Today the situation is the following:

  • Reporting text alignment in Firefox 116.0 (installed) is not supported, neither in NVDA 2023.2beta1 nor with this PR
  • With Firefox ESR portable 102.13.0 (portable) and NVDA 2023.2beta1, text alignment is reported for justified text, but "default" is reported for left, right and centered text.
  • With Firefox ESR portable 102.13.0 (portable) and this PR, text alignment is correctly reported for left, right, center and justify.

I imagine that there may be an issue with latest Firefox versions regarding text alignment reporting. @jcsteh any information or confirmation of this?

Known issues with pull request:

  1. With Word no UIA:
    Not all the available alignments have been implemented. The following are missing: wdAlignParagraphJustifyHi, wdAlignParagraphJustifyLow, wdAlignParagraphJustifyMed, wdAlignParagraphThaiJustify. They were not supported before by NVDA and do not know how to use them; maybe with some specific locale?
    (see https://docs.microsoft.com/en-us/office/vba/api/word.wdparagraphalignment)
    If there is a need to implement them in the future, it should be quite easy.

  2. Word with UIA: "distribute" is reported as "justify", since "distribute" does not seem to be a supported alignment in UIA.

  3. In Excel with UIA, text alignment is not supported at all today (in NVDA 2023.2beta1). This PR does not add the support for text alignment in Excel with UIA.

  4. Text alignment reporting is not supported by NVDA in:

This PR does not improve it.

  1. For web text alignment, according to this page, text-align="justify-all" is not supported by any browser. NVDA reports it as "left" before and after this PR.

Change log entries:

Bug fixes
In Word and Excel, text alignment will be correctly reported in more situations. (#15206, #15220)

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
  • Security precautions taken.

…ord text.

Excel noUIA: OK

Excel UIA: not supported; nothing changed.

Word with UIA: OK (left/right/center/justify). Note: Distributed not supported in UIA.

Word no UIA: OK: Fixed "justified" -> "justify" and added "distribute"
Not all the alignments are used; missing: wdAlignParagraphJustifyHi, wdAlignParagraphJustifyLow, wdAlignParagraphJustifyMed, wdAlignParagraphThaiJustify.
(see https://docs.microsoft.com/en-us/office/vba/api/word.wdparagraphalignment)

Test Firefox:
- OK for left/right/center/justify.
- See other values: justify-all, start, end, match
- Test case: data:text/html,<p align="left">left</p><p align="right">right</p><p align="center">center</p><p align="justify">justify</p><p align="justify-all">justify-all</p><p align="start">start</p><p align="end">end</p><p align="match-parent">match-parent</p>
- Code needs to be reworked (remove val and mozilla dic in general file).
@zstanecic
Copy link
Contributor

zstanecic commented Jul 27, 2023 via email

@AppVeyorBot
Copy link

See test results for failed build of commit a6b775bafa

@CyrilleB79 CyrilleB79 marked this pull request as ready for review August 1, 2023 21:24
@CyrilleB79 CyrilleB79 requested a review from a team as a code owner August 1, 2023 21:24
@CyrilleB79 CyrilleB79 requested a review from seanbudd August 1, 2023 21:24
@jcsteh
Copy link
Contributor

jcsteh commented Aug 1, 2023

Alignment is not currently implemented in the Firefox accessibility cache. This is something we'll need to address.

@seanbudd
Copy link
Member

Thanks @CyrilleB79 - this is almost ready

@seanbudd seanbudd marked this pull request as draft August 18, 2023 04:51
@AppVeyorBot
Copy link

See test results for failed build of commit eadfe84bf7

@CyrilleB79 CyrilleB79 marked this pull request as ready for review August 28, 2023 16:38
@CyrilleB79
Copy link
Contributor Author

@seanbudd all the review comments have been implemented; this PR is ready again.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Aug 29, 2023
Copy link
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, I'll get this merged soon

@seanbudd seanbudd merged commit 6dd48c4 into nvaccess:master Aug 29, 2023
@nvaccessAuto nvaccessAuto added this to the 2023.3 milestone Aug 29, 2023
@CyrilleB79 CyrilleB79 deleted the textAlign branch August 29, 2023 06:40
CyrilleB79 added a commit to CyrilleB79/nvda that referenced this pull request Aug 29, 2023
seanbudd pushed a commit that referenced this pull request Aug 30, 2023
Fix-up of #15205

Summary of the issue:
While addressing #15205 review, deprecation code has been added. However, I have forgotten to update the initial description's change log paragraph to mention it.

Description of user facing changes
Updated change log with deprecation information.
Note: a message will have to be sent to the API mailing list.

While at it:

Added formatting to the previous item of the change log.
Fixed a missing end of list causing "Deprecation" paragraph title not being rendered correctly
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.

MS Word - Justified text reported as "default" text alignment Various issues related to text alignment in Excel
6 participants