a11y atspi: Bridge IA2 strikeout text attrs to AT-SPI

When the text attributes an accessible interface reports
include one of the various "text-line-through-*"
IAccessible2 text attributes with a value that indicates
that strikethrough is applied [1], bridge that to the
AT-SPI layer via the "strikethrough" attribute with a
value of "true".

See also the ATK documentation [2] for the
`ATK_TEXT_ATTR_STRIKETHROUGH` text attribute.

This will not only be used by an upcoming change
that implements reporting that for Qt's own text
widgets, but is also needed for third-party applications.
Change for LibreOffice that makes use of this: [3]

[1] https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes
[2] https://gnome.pages.gitlab.gnome.org/atk/AtkText.html#AtkTextAttribute
[3] https://gerrit.libreoffice.org/c/core/+/157939

Task-number: QTBUG-118106
Change-Id: Ieb98584a3c6270d8db508d59994f9ba244e2bc64
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
Michael Weghorn 2023-10-13 16:07:49 +02:00
parent 6259f4e7b4
commit 56476947cf

View File

@ -2222,6 +2222,13 @@ namespace
// (on which it produces traceback and fails to read any following text attributes),
// but that is the default value, so omit it anyway
value = QString();
} else if (((ia2Name == "text-line-through-style"_L1 || ia2Name == "text-line-through-type"_L1) && (ia2Value != "none"_L1))
|| (ia2Name == "text-line-through-text"_L1 && !ia2Value.isEmpty())) {
// if any of the above is set, set "strikethrough" to true, but don't explicitly set
// to false otherwise, since any of the others might still be set to indicate strikethrough
// and no strikethrough is assumed anyway when nothing is explicitly set
name = QStringLiteral("strikethrough");
value = QStringLiteral("true");
} else if (ia2Name == "text-position"_L1) {
name = QStringLiteral("vertical-align");
if (value != "baseline"_L1 && value != "super"_L1 && value != "sub"_L1) {