https://bugs.documentfoundation.org/show_bug.cgi?id=136760

--- Comment #3 from Michael Weghorn <[email protected]> ---
Pasting my comment from
https://github.com/nvaccess/nvda/issues/11696#issuecomment-1463575359 :

>From a first analysis, I haven't seen any way to expose/retrieve the
information at what position in the page the cursor currently is via the
accessibility interfaces (`IAccessible2` in the case of LibreOffice).

The `IAccessibleComponent` interface has a way to [get the position in pixels
relative to the
parent](https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/interface_i_accessible_component.html#a8709fdbf3f51ae079af274854a8bffd4)
, but that's not really helpful here. From a first look, the Writer page itself
also has no a11y object in the a11y tree.

What NVDA seems to do for MS Word is to use the Microsoft Office COM API to
interact with MS Office, not the accessibility APIs:
https://github.com/nvaccess/nvda/blob/d2d4bfce2d31de8fca3c6df16caf93350b26374d/source/NVDAObjects/window/winword.py#L597-L614

It queries for the `wdHorizontalPositionRelativeToPage` and
`wdVerticalPositionRelativeToPage` attributes described here:
https://learn.microsoft.com/en-us/office/vba/api/word.wdinformation

This page has some more infos on using the COM with NVDA and Word:
https://github.com/nvaccess/nvda/wiki/Using-COM-with-NVDA-and-Microsoft-Word

So if there's no way to retrieve the information via the accessibility APIs, I
see no "easy" way of implementing this to work with LibreOffice Writer as well.

What *might* work is to not use the accessibility APIs, but LibreOffice's UNO
API (which also has a Python binding), but adding support for doing this would
presumably be quite a lot of work.

Possibly, there are ways to retrieve the required information (or retrieve
information from which the position in the page could then be calculated).
Potentially helpful UNO interfaces might be (but that would need a closer
look):

* `XTextViewCursor::getPosition()` to retrieve cursor pos relative to top left
position of the first page of the document
* `XPageCursor::getPage()` can be used to retrieve the page that the cursor is
currently on
* `offapi/com/sun/star/style/PageProperties.idl` to access properties of the
page,...
* ...

Looking into the implementation of `SwXTextViewCursor::getPosition` (which is
the LO-internal implementation of one of the interfaces) might give some more
ideas.

If that's an approach to investigate further, it would probably be a good idea
to start with a macro to run from within LO to see whether it's possible to
calculate the position from the information accessible via the UNO API.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to