diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-19 14:46:25 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-19 21:48:54 +0200 |
commit | 1188364a28324b50ce40983fe5890cc960c7649f (patch) | |
tree | ac7811a164fe474fc585d7ab9a4b218e2ad98837 /vcl/qt5/QtAccessibleWidget.cxx | |
parent | 99841da686625428b8ad2e219dd19e5fbfb145f5 (diff) |
qt a11y: Report (background) color text attribute
... using the "rgb(r,g,b)" format as specified in
the IAccessible2 spec.
Tested that Orca correctly announced both, text and
background color in Writer when requesting it to announce
the formatting using the Orca_Key+F keyboard shortcut
(with Orca_Key being Numpad_Insert by default).
Change-Id: Ie8b90dff872d7719617d68cd074efdab10d44dd5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138531
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5/QtAccessibleWidget.cxx')
-rw-r--r-- | vcl/qt5/QtAccessibleWidget.cxx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index 9064335c7157..41d4a81a1b15 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -865,6 +865,13 @@ OUString lcl_ConvertFontSlant(awt::FontSlant eFontSlant) return ""; } } + +/** Converts Color to "rgb(r,g,b)" as specified in https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes. */ +OUString lcl_ConvertColor(Color aColor) +{ + return u"rgb(" + OUString::number(aColor.GetRed()) + u"," + OUString::number(aColor.GetGreen()) + + u"," + OUString::number(aColor.GetBlue()) + u")"; +} } // Text attributes are returned in format specified in IAccessible2 spec, since that @@ -904,7 +911,19 @@ QString QtAccessibleWidget::attributes(int offset, int* startOffset, int* endOff { OUString sAttribute; OUString sValue; - if (prop.Name == "CharFontName") + if (prop.Name == "CharBackColor") + { + sAttribute = "background-color"; + sValue = lcl_ConvertColor( + Color(ColorTransparency, *o3tl::doAccess<sal_Int32>(prop.Value))); + } + else if (prop.Name == "CharColor") + { + sAttribute = "color"; + sValue = lcl_ConvertColor( + Color(ColorTransparency, *o3tl::doAccess<sal_Int32>(prop.Value))); + } + else if (prop.Name == "CharFontName") { sAttribute = "font-family"; sValue = *o3tl::doAccess<OUString>(prop.Value); |