office-gobmx/winaccessibility/source
Michael Weghorn 0c7928dc10 wina11y: Fix handling for special text offset -1
As described in the IAccessible2 spec [1], -1 can be used as a
special text offset:

> Using IA2_TEXT_OFFSET_LENGTH (-1) as an offset in any of the
> IAccessibleText or IAccessibleEditableText methods is the same
> as specifying the length of the string.

Replace -1 by the text length *before* doing the
check whether end offset is smaller than the start offset.

Otherwise, trying to query the whole text of a Writer paragraph
containing the text "hello" in NVDA's Python console would
incorrectly trigger an error:

    >>> focus.IAccessibleTextObject.text(0,-1)
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "comtypes\__init__.pyc", line 856, in __call__
      File "monkeyPatches\comtypesMonkeyPatches.pyc", line 32, in __call__
    _ctypes.COMError: (-2147467259, 'Unspecified error', (None, None, None, 0, None))

With this commit in place, it works as expected:

    >>> focus.IAccessibleTextObject.text(0,-1)
    'hello'

[1] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/_general_info.html#_specialOffsets

Change-Id: I489a42270a56178cc8ee0564eec3dc82e15969c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168853
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-06-14 23:26:57 +02:00
..
service
UAccCOM wina11y: Fix handling for special text offset -1 2024-06-14 23:26:57 +02:00
UAccCOMIDL