Bug 150683 - Calc: With >16k column support, screen readers don't announce all cells
Summary: Calc: With >16k column support, screen readers don't announce all cells
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Michael Weghorn
URL:
Whiteboard: target:7.5.0
Keywords: accessibility
Depends on:
Blocks: a11y, Accessibility
  Show dependency treegraph
 
Reported: 2022-08-30 08:35 UTC by Michael Weghorn
Modified: 2022-09-03 21:21 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Screencast with Orca/gtk3 (7.54 MB, video/webm)
2022-08-30 08:35 UTC, Michael Weghorn
Details
Screencast with NVDA/Windows (3.23 MB, video/webm)
2022-08-30 08:35 UTC, Michael Weghorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weghorn 2022-08-30 08:35:07 UTC
Created attachment 182091 [details]
Screencast with Orca/gtk3

With the support for > 16000 columns enabled by default (in commit 4c5f8ccf0a2320432b8fe91add1dcadf54d9fd58, "change default Calc number of columns to 16384 (tdf#50916)"), screen readers have issues announcing some cells properly, e.g. in the last row.

# Sample steps to reproduce with either NVDA on Windows or Orca on Linux:

0) start the screen reader
1) start Calc, open a new spreadsheet
2) move focus from cell A1 to A2 by using the arrow key, then to A3
3) select a few cells by using Shift+arrow key
4) move focus to the last row (Ctrl+Down)
5) move focus from the current cell to another one in the last row by using the arrow key
6) select a few cells in the last row by using Shift+arrow key

# Actual behavior:

* up to step 3: focused and selected cells are announced just fine with both, Orca and NVDA
* with Orca: selection in step 6) is not announced, stderr shows below output for a debug build
* with NVDA: focus in step 5) is not announced properly:
    * when using NVDA 2022.2.2, the *previously* selected cell is announced
    * when using a development version of NVDA (I tried master as of commit 8c982cd16c6461c34abd56f1777a56ae704997ea), NVDA "beeps" to indicate that there was an error and shows the below backtrace

Screencasts will be attached (slightly different cells selected there than in the "Steps to reproduce", but same pattern).

# Expected behavior:

Focused/Selected cells should properly be announced by screen readers in all steps.


Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: 5bf4f36b509ae2bdc507074d53af007b4852013d
CPU threads: 12; OS: Linux 5.18; UI render: default; VCL: gtk3
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: threaded

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 79ccc9172c9f7c16d636b21a85f548ed4db6e864
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

(The Windows build is essentially also master as of 5bf4f36b509ae2bdc507074d53af007b4852013d with just some local unrelated patches on top.)


## Additional information

LO output with gtk3 VCL plugin:

> ** (soffice:37345): WARNING **: 08:53:05.840: Exception in getAccessibleRow()
> 
> ** (soffice:37345): WARNING **: 08:53:05.840: Exception in getAccessibleColumn()


NVDA backtrace:

ERROR - eventHandler.executeEvent (08:55:03.927) - MainThread (8360):
error executing event: gainFocus on <NVDAObjects.Dynamic_SymphonyIATableCellEditableTextWithAutoSelectDetectionIAccessible object at 0x07C03930> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.py", line 301, in executeEvent
    _EventExecuter(eventName,obj,kwargs)
  File "eventHandler.py", line 102, in __init__
    self.next()
  File "eventHandler.py", line 111, in next
    return func(*args, **self.kwargs)
  File "NVDAObjects\behaviors.py", line 242, in event_gainFocus
    super().event_gainFocus()
  File "NVDAObjects\__init__.py", line 1197, in event_gainFocus
    self.reportFocus()
  File "NVDAObjects\__init__.py", line 1094, in reportFocus
    speech.speakObject(self, reason=controlTypes.OutputReason.FOCUS)
  File "speech\speech.py", line 608, in speakObject
    _prefixSpeechCommand,
  File "speech\speech.py", line 653, in getObjectSpeech
    **allowProperties
  File "speech\speech.py", line 500, in getObjectPropertiesSpeech
    newPropertyValues[name]=getattr(obj,tryName)
  File "baseObject.py", line 42, in __get__
    return instance._getPropertyViaCache(self.fget)
  File "baseObject.py", line 146, in _getPropertyViaCache
    val=getterMethod(self)
  File "NVDAObjects\IAccessible\__init__.py", line 1171, in _get_rowNumber
    return tableCell.rowIndex+1
  File "monkeyPatches\comtypesMonkeyPatches.py", line 32, in __call__
    return super().__call__(*args,**kwargs)
_ctypes.COMError: (-2147467259, 'Unspecified error', (None, None, None, 0, None))
Comment 1 Michael Weghorn 2022-08-30 08:35:39 UTC
Created attachment 182092 [details]
Screencast with NVDA/Windows
Comment 2 Michael Weghorn 2022-08-30 08:49:57 UTC
From what I have seen so far, the problem is an integer overflow. The index currently used for a11y children/cells is sal_Int32 (i.e. 32 bit), but with 16k column support, Calc has more cells than that.

Potential way forward that I'm currently looking into:

1) switch to use of 64-bit child/cell index internally
   * platform a11y APIs still use 32-bit indices, nothing we can change
   * but that can be used to avoid overflows internally and thus also make the table cell interfaces implementations work (currently implemented for qt6, winaccessibility)
2) in screen readers, avoid running into the issue of too large child/cell indices by querying the row/column from the table cell interface (IAccessibleTableCell for IAccessible2, AT-SPI TableCell for Linux), not the table interface
   * from what I have seen so far, NVDA already seems to do that, orca doesn't
3) implement support for the AT-SPI TableCell interface for the gtk3 VCL plugin

That should hopefully *mostly* fix the problem. What's still problematic are cell selections including more than 2^31 cells, since the index into the selection is also limited to 32 bit in the platform a11y APIs and I currently don't see any way than using that for the screen readers to retrieve the first and last cell in the selection.

For the case that whole rows/columns are selected, Orca already seems to apply a different handling (maybe querying the selected rows/columns from the Table interface), so that also works fine (e.g. Orca says "All cells selected", "Columns ... to ... selected".

As a side note, UIA has specific methods in the ISelectionProvider2 interface that allow retrieving the first and last selected item, ISelectionProvider2::get_FirstSelectedItem and ISelectionProvider2::get_LastSelectedItem, but we currently don't support UIA on Windows.
Comment 3 Commit Notification 2022-09-01 13:27:25 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1dbf4a111486ee4e5e2d9da0bbf5544742ae7805

tdf#150683 qt a11y: Avoid using 32-bit child index here

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2022-09-02 08:27:10 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5226e3889155ea22465d488174a6f8720085628a

tdf#150683 qt a11y: Add bound checks for table methods

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2022-09-02 13:48:11 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/206543c7bef58fc559852553a3b2faba0b604259

[API CHANGE] tdf#150683 a11y: Switch a11y child index to 64 bit

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2022-09-02 13:49:20 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d92ad32c98c6a094195e10f066968eb60105dff1

tdf#150683 sc a11y: Add a test case for 64-bit a11y cell index

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Michael Weghorn 2022-09-02 13:58:13 UTC
(In reply to Michael Weghorn from comment #2)

Current status:

> Potential way forward that I'm currently looking into:
> 
> 1) switch to use of 64-bit child/cell index internally
>    * platform a11y APIs still use 32-bit indices, nothing we can change
>    * but that can be used to avoid overflows internally and thus also make
> the table cell interfaces implementations work (currently implemented for
> qt6, winaccessibility)

Done, s. above commits.

> 2) in screen readers, avoid running into the issue of too large child/cell
> indices by querying the row/column from the table cell interface
> (IAccessibleTableCell for IAccessible2, AT-SPI TableCell for Linux), not the
> table interface
>    * from what I have seen so far, NVDA already seems to do that, orca
> doesn't

Done:
* NVDA "just works"
* for Orca, there's https://gitlab.gnome.org/GNOME/orca/-/merge_requests/131 which has been merged today


> 3) implement support for the AT-SPI TableCell interface for the gtk3 VCL
> plugin

That's still WIP, but announcement already works with a WIP change.
Comment 8 Michael Weghorn 2022-09-02 13:59:25 UTC
FWIW, announcement also works with the qt6 VCL plugin with the additional Qt changes mentioned in the commit msg of
https://git.libreoffice.org/core/commit/206543c7bef58fc559852553a3b2faba0b604259
Comment 9 Commit Notification 2022-09-03 21:18:55 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/dd5f021e08b0f6da1b5330c37db4c759e35941c6

tdf#150683 gtk3 a11y: Expose AtkTableCell interface for cells

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Michael Weghorn 2022-09-03 21:21:51 UTC
(In reply to Michael Weghorn from comment #7)
> > 3) implement support for the AT-SPI TableCell interface for the gtk3 VCL
> > plugin
> 
> That's still WIP, but announcement already works with a WIP change.

That's now done too, s. commit from comment 9 -> Closing this bug as FIXED