vcl/qt5/QtAccessibleWidget.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 892bd0dfc1b107a5b00af36a0d0db1f9f9c05147
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Aug 9 11:31:30 2022 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Aug 9 13:33:07 2022 +0200

    qt a11y: Return actual range of text with same attributes
    
    The start and end offset returned by
    `QAccessibleTextInterface::attributes` should indicate
    the start and end of a text segment where all characters
    have the same text attributes (like font size, color,...).
    
    Calling `XAccessibleText::getTextAtIndex` with type
    `accessibility::AccessibleTextType::ATTRIBUTE_RUN` gives
    exactly that information, so make use of it instead
    of claiming that only the character itself has those
    attributes.
    
    This is e.g. used in Accerciser's "Interface Viewer"
    for the text interface, to display the indices and
    highlight the text portion in which all characters
    have the same attributes.
    
    Change-Id: Iefb096f30c9df74f035d2fda86299d9a5de5d604
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138008
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 940d8c29f513..a7d0457801e6 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -872,8 +872,11 @@ QString QtAccessibleWidget::attributes(int offset, int* 
startOffset, int* endOff
         if (!sAttribute.isEmpty() && !sValue.isEmpty())
             aRet += sAttribute + ":" + sValue + ";";
     }
-    *startOffset = offset;
-    *endOffset = offset + 1;
+
+    accessibility::TextSegment aAttributeRun
+        = xText->getTextAtIndex(offset, 
accessibility::AccessibleTextType::ATTRIBUTE_RUN);
+    *startOffset = aAttributeRun.SegmentStart;
+    *endOffset = aAttributeRun.SegmentEnd;
     return toQString(aRet);
 }
 

Reply via email to