[Libreoffice-commits] core.git: vcl/qt5
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 3 07:59:38 UTC 2019
vcl/qt5/Qt5AccessibleWidget.cxx | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
New commits:
commit 93c81657c6111b4bb97a2bb9ec155465f9a6f523
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu May 30 23:41:10 2019 +0200
Commit: Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Mon Jun 3 09:58:48 2019 +0200
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 at cib.de>
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index 2c31a2bdb92a..9757eab27837 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;
More information about the Libreoffice-commits
mailing list