diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-09 11:31:30 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-09 13:33:07 +0200 |
commit | 892bd0dfc1b107a5b00af36a0d0db1f9f9c05147 (patch) | |
tree | 3614c006bf05280352ade94f45487037994a0c09 /vcl | |
parent | 1052ec9cff72e2810fdb934a85ab500d3b4ace35 (diff) |
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.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/QtAccessibleWidget.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
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); } |