diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2019-05-30 23:41:10 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-06-03 18:12:45 +0200 |
commit | 0b904a8b3ceb648cf6466cb33f07310a3c70f793 (patch) | |
tree | 1c06287d0dee2e8190ba641c8ab0fc078d78e001 /vcl/qt5 | |
parent | SmartArt: more constraints used in linear algorithm (diff) | |
download | core-0b904a8b3ceb648cf6466cb33f07310a3c70f793.tar.gz core-0b904a8b3ceb648cf6466cb33f07310a3c70f793.zip |
tdf#122200 Qt5AccessibleWidget: Handle special offset values
Handle special values for offset in 'Qt5AccessibleWidget::attributes'
the same way that the base class's 'QAccessibleTextWidget::attributes'
does, s. [1].
In particular, an offset matching the text length can
be passed e.g. by "accerciser" or screen readers,
which previously resulted in an 'IndexOutOfBoundsException'
being thrown when the index was later checked in the
call to 'VCLXAccessibleStatusBarItem::getCharacterAttributes'.
See also 'IAccessibleText::attributes' documentation at [2] and
the page on special offset values referenced there [3].
[1] https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/accessible/qaccessiblewidgets.cpp?h=5.12.4#n791
[2] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/interface_i_accessible_text.html#a29e5c8f69ec13c683ed6bca53333e6a5
[3] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/_general_info.html#_specialOffsets
Change-Id: I623995aeb689b31c5b49fb3ace8e4dd4c18927d2
Reviewed-on: https://gerrit.libreoffice.org/73225
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit 93c81657c6111b4bb97a2bb9ec155465f9a6f523)
Reviewed-on: https://gerrit.libreoffice.org/73379
Diffstat (limited to 'vcl/qt5')
-rw-r--r-- | vcl/qt5/Qt5AccessibleWidget.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx index b76acb4a1c57..e2cc0a31765c 100644 --- a/vcl/qt5/Qt5AccessibleWidget.cxx +++ b/vcl/qt5/Qt5AccessibleWidget.cxx @@ -830,6 +830,22 @@ QString Qt5AccessibleWidget::attributes(int offset, int* startOffset, int* endOf if (!xText.is()) return QString(); + // handle special values for offset the same way base class's QAccessibleTextWidget::attributes does + // (as defined in IAccessible 2: -1 -> length, -2 -> cursor position) + if (offset == -2) + offset = cursorPosition(); // currently always returns 0 + + const int nTextLength = characterCount(); + if (offset == -1 || offset == nTextLength) + offset = nTextLength - 1; + + if (offset < 0 || offset > nTextLength) + { + *startOffset = -1; + *endOffset = -1; + return QString(); + } + Sequence<PropertyValue> attribs = xText->getCharacterAttributes(offset, Sequence<OUString>()); const PropertyValue* pValues = attribs.getConstArray(); OUString aRet; |