From 1188364a28324b50ce40983fe5890cc960c7649f Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 19 Aug 2022 14:46:25 +0200 Subject: 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 --- vcl/qt5/QtAccessibleWidget.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'vcl/qt5/QtAccessibleWidget.cxx') 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(prop.Value))); + } + else if (prop.Name == "CharColor") + { + sAttribute = "color"; + sValue = lcl_ConvertColor( + Color(ColorTransparency, *o3tl::doAccess(prop.Value))); + } + else if (prop.Name == "CharFontName") { sAttribute = "font-family"; sValue = *o3tl::doAccess(prop.Value); -- cgit