Skip to content

soffice: Report page-relative caret position when available#14727

Merged
michaelDCurran merged 3 commits into
nvaccess:masterfrom
michaelweghorn:michaelweghorn/nvda11696_tdf136760_soffice_better_position_reporting
Mar 20, 2023
Merged

soffice: Report page-relative caret position when available#14727
michaelDCurran merged 3 commits into
nvaccess:masterfrom
michaelweghorn:michaelweghorn/nvda11696_tdf136760_soffice_better_position_reporting

Conversation

@michaelweghorn

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #11696
Related LibreOffice bug report:
https://bugs.documentfoundation.org/show_bug.cgi?id=136760

Summary of the issue:

When reporting the review cursor location in LibreOffice Writer, the announced position was not particularly useful to determine where in the document/page the cursor is currently located.

Description of user facing changes

Similar to how it is done for Microsoft Word, report the current cursor/caret location relative to the current page when that information is available for LibreOffice Writer.

Description of development approach

To retrieve the page-relative cursor/caret location, this introduces and makes use of a new SymphonyDocumentTextInfo class that retrieves the page-relative cursor position via accessible attributes from the document object.

These attributes are added to LibreOffice in this corresponding LibreOffice change:
https://gerrit.libreoffice.org/c/core/+/149051

The values returned by LibreOffice Writer are in twips, so convert that to inches or centimetres, depending on whether or not imperial measurement units are expected.

If the attributes are not available, fall back to the handling that was already used so far.

Testing strategy:

Testing strategy:

  • use a LibreOffice build that includes the changes from https://gerrit.libreoffice.org/c/core/+/149051
  • start LibreOffice Writer
  • trigger reporting the review cursor location by pressing NVDA+shift+numpadDelete
  • verify that the current caret position is announced in centimetres or inches from the left and top edge of the page

Known issues with pull request:

none

Change log entries:

Changes
When reporting the review cursor location, the current cursor/caret location is now reported relative to the current page in LibreOffice Writer for LibreOffice versions >= 7.6, similar to what is done for Microsoft Word. (#11696)

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.

@michaelweghorn michaelweghorn requested a review from a team as a code owner March 17, 2023 12:31
@michaelweghorn michaelweghorn requested a review from seanbudd March 17, 2023 12:31
@michaelweghorn

Copy link
Copy Markdown
Contributor Author

If there are any suggestions on different approaches or adapting the attributes reported by LibreOffice, I'm happy for any feedback on that and won't merge the corresponding LibreOffice change ( https://gerrit.libreoffice.org/c/core/+/149051 ) before there is an agreed way on how to expose/retrieve the required information.

@AppVeyorBot

Copy link
Copy Markdown
  • FAIL: Translation comments check. Translation comments missing or unexpectedly included. See build log for more information.
  • PASS: Unit tests.
  • PASS: Lint check.
  • FAIL: System tests (tags: installer NVDA). See test results for more information.
  • Build (for testing PR): https://ci.appveyor.com/api/buildjobs/yy7rt79203dshvsn/artifacts/output/nvda_snapshot_pr14727-27849,50f7ebf6.exe
  • CI timing (mins):
    INIT 0.0,
    INSTALL_START 0.9,
    INSTALL_END 0.9,
    BUILD_START 0.0,
    BUILD_END 23.6,
    TESTSETUP_START 0.0,
    TESTSETUP_END 0.3,
    TEST_START 0.0,
    TEST_END 19.1,
    FINISH_END 0.2

See test results for failed build of commit 50f7ebf6fe

@michaelweghorn michaelweghorn force-pushed the michaelweghorn/nvda11696_tdf136760_soffice_better_position_reporting branch from c46af0d to 6fa49c6 Compare March 17, 2023 13:48

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

This looks good, accept that I don't believe you need the __init__ methods on SymphonyDocument or SymphonyDocumentTextInfo. They don't seem to do anything, and Python will automatically call super's constructor if they are not defined.

Fixes nvaccess#11696
Related LibreOffice bug report:
https://bugs.documentfoundation.org/show_bug.cgi?id=136760

Summary of the issue:

When reporting the review cursor location in LibreOffice Writer,
the announced pixel-related coordinates are not particularly useful
to determine where in the document/page the cursor is currently located.

Description of how this pull request fixes the issue:

Similar to how it is done for Microsoft Word, report
the current cursor/caret location relative to the current
page when that information is available.
To retrieve that information, this introduces and makes use of
a new `SymphonyDocumentTextInfo` class that retrieves the
page-relative cursor position via accessible attributes from the
document object.
These attributes are added to LibreOffice in this corresponding
LibreOffice change:
https://gerrit.libreoffice.org/c/core/+/149051
The values returned by LibreOffice Writer are in twips, so
convert that to inches or centimetres, depdending on whether
or not imperial measurement units are expected.
If the attributes are not available, fall back to the handling
that was already used so far.

Testing strategy:
* use a LibreOffice build that includes the changes from
  https://gerrit.libreoffice.org/c/core/+/149051
* start LibreOffice Writer
* trigger reporting the review cursor location by pressing
  NVDA+shift+numpadDelete
* verify that the current caret position is announced
  in centimetres or inches from the left and top edge of the
  page
@michaelweghorn michaelweghorn force-pushed the michaelweghorn/nvda11696_tdf136760_soffice_better_position_reporting branch from 6fa49c6 to 34a3db6 Compare March 20, 2023 08:36
@michaelweghorn

Copy link
Copy Markdown
Contributor Author

This looks good, accept that I don't believe you need the __init__ methods on SymphonyDocument or SymphonyDocumentTextInfo. They don't seem to do anything, and Python will automatically call super's constructor if they are not defined.

Indeed, I've dropped them now. Thanks!

@michaelweghorn michaelweghorn requested review from michaelDCurran and removed request for seanbudd March 20, 2023 11:51
@michaelweghorn

Copy link
Copy Markdown
Contributor Author

@michaelweghorn michaelweghorn requested review from michaelDCurran and removed request for seanbudd

@michaelDCurran I pressed the "Re-request review" (or similarly labeled) button next to your username now that the requested change has been implemented. This resulted in the above action, but I didn't intentionally want to remove any reviewers. Can you give me any hint on what's the proper process?

@michaelDCurran michaelDCurran merged commit bdcffdb into nvaccess:master Mar 20, 2023
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Mar 20, 2023
tdf-gerrit pushed a commit to LibreOffice/core that referenced this pull request Mar 20, 2023
This introduce 2 new extended accessible attributes
"cursor-position-in-page-horizontal" and
"cursor-position-in-page-vertical" to expose
the page-relative position of the cursor in Writer
to assistive technology.

This is similar to how the current page
number is already exposed (attribute "page-number").

Together with a corresponding pull request for the NVDA
screen reader [1], this allows NVDA to announce the position
similar to how it is done for Microsoft Word (where the information
is not retrieved via the accessibility APIs but the
MS Office COM API, s. discussion
in the corresponding NVDA issue [2] for more details).

(Side note: Currently there is no a11y object for a Writer
page in the a11y tree, but "normal" paragraphs are direct
children of the document object.)

For performance reasons, introduce a new method
`SwCursorShell::GetCursorPagePos` to get the position
instead of passing the result from
`SwCursorShell::GetCursorDocPos` to
`SwFEShell::GetRelativePagePosition` to avoid
iterating over the doc pages.

[1] nvaccess/nvda#14727
[2] nvaccess/nvda#11696

Change-Id: I6fd56c5c7d051840bab836ce5fe525fdc061b376
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149051
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
@michaelweghorn michaelweghorn deleted the michaelweghorn/nvda11696_tdf136760_soffice_better_position_reporting branch March 20, 2023 21:43
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.

LibreOffice Writer: Unusable coordinates announced

4 participants