[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/qt5

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 3 16:16:35 UTC 2019


 vcl/qt5/Qt5AccessibleWidget.cxx |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

New commits:
commit 5b54a62b086726f854a474623e1330b28b7984b7
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu May 30 23:41:10 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Mon Jun 3 18:15:51 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>
    (cherry picked from commit 93c81657c6111b4bb97a2bb9ec155465f9a6f523)
    Reviewed-on: https://gerrit.libreoffice.org/73378
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.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