vcl/qt5/QtAccessibleWidget.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
New commits: commit 99841da686625428b8ad2e219dd19e5fbfb145f5 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 20 13:23:21 2021 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 19 21:48:29 2022 +0200 qt a11y: Report font style text attribute (e.g. italic) While the Qt doc for `QAccessibleTextInterface::attributes` [1] doesn't mention what format the returned string should have to report the attributes, the expected format for the text attributes is as specified in the IAccessible2 doc for text attributes [2], and Qt's AT-SPI adapter then converts that to the format as needed for AT-SPI, s. [3]. Tested that Orca correctly announces "style: italic" when requesting it to announce the formatting using the Orca_Key+F keyboard shortcut (with Orca_Key being Numpad_Insert by default). [1] https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes [2] https://doc.qt.io/qt-6/qaccessibletextinterface.html#attributes [3] https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/accessible/linux/atspiadaptor.cpp?id=4842cc176881ae22e14ca193fba46c6a04d09530#n1924 Change-Id: I9877d1be0b6c9b82815e57f35ae28abe2ed99851 Include Change-Id: Iddf974540c71f91d4078c2f99daa320474a445a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138530 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index 876b735b0e48..9064335c7157 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp> #include <com/sun/star/accessibility/XAccessibleText.hpp> #include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <com/sun/star/awt/FontSlant.hpp> #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/lang/DisposedException.hpp> @@ -845,8 +846,30 @@ OUString lcl_convertFontWeight(double fontWeight) // awt::FontWeight::DONTKNOW || fontWeight == awt::FontWeight::NORMAL return "normal"; } + +OUString lcl_ConvertFontSlant(awt::FontSlant eFontSlant) +{ + switch (eFontSlant) + { + case awt::FontSlant::FontSlant_NONE: + return "normal"; + case awt::FontSlant::FontSlant_OBLIQUE: + case awt::FontSlant::FontSlant_REVERSE_OBLIQUE: + return "oblique"; + case awt::FontSlant::FontSlant_ITALIC: + case awt::FontSlant::FontSlant_REVERSE_ITALIC: + return "italic"; + case awt::FontSlant::FontSlant_DONTKNOW: + case awt::FontSlant::FontSlant_MAKE_FIXED_SIZE: + default: + return ""; + } +} } +// Text attributes are returned in format specified in IAccessible2 spec, since that +// is what Qt handles: +// https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes QString QtAccessibleWidget::attributes(int offset, int* startOffset, int* endOffset) const { if (startOffset == nullptr || endOffset == nullptr) @@ -891,6 +914,12 @@ QString QtAccessibleWidget::attributes(int offset, int* startOffset, int* endOff sAttribute = "font-size"; sValue = OUString::number(*o3tl::doAccess<double>(prop.Value)) + "pt"; } + else if (prop.Name == "CharPosture") + { + sAttribute = "font-style"; + const awt::FontSlant eFontSlant = *o3tl::doAccess<awt::FontSlant>(prop.Value); + sValue = lcl_ConvertFontSlant(eFontSlant); + } else if (prop.Name == "CharWeight") { sAttribute = "font-weight";