summaryrefslogtreecommitdiff
path: root/vcl/qt5/QtAccessibleWidget.cxx
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2022-08-19 16:15:07 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2022-08-19 21:49:19 +0200
commit31e40de94c2e1c54b80ba963e26207125ee365e7 (patch)
tree4f03bd7c96fffccffd221c3160ef6f26e4bf78ea /vcl/qt5/QtAccessibleWidget.cxx
parent1188364a28324b50ce40983fe5890cc960c7649f (diff)
qt a11y: Report underline text attribute
The IAccessible2 doc for text attributes [1] that specifies the format of text attributes also generally used by Qt has three different attributes for underlined text: * "text-underline-style" * "text-underline-type" * "text-underline-width" Map from LO's underline type to all of them where possible. Note however that Qt's AT-SPI adapter only actually maps "text-underline-type" to an AT-SPI equivalent, so e.g. `awt::FontUnderline::WAVE` will just be reported by the Orca screen reader as "underline: single". [1] https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes Change-Id: I8fdca8ff23e0ca9f3e400617b03843439e8e8304 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138532 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5/QtAccessibleWidget.cxx')
-rw-r--r--vcl/qt5/QtAccessibleWidget.cxx99
1 files changed, 99 insertions, 0 deletions
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 41d4a81a1b15..e9106f32785a 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -47,6 +47,7 @@
#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/FontUnderline.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
@@ -866,6 +867,88 @@ OUString lcl_ConvertFontSlant(awt::FontSlant eFontSlant)
}
}
+// s. https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes
+// for values
+void lcl_ConvertFontUnderline(sal_Int16 nFontUnderline, OUString& rUnderlineStyle,
+ OUString& rUnderlineType, OUString& rUnderlineWidth)
+{
+ rUnderlineStyle = u"";
+ rUnderlineType = u"single";
+ rUnderlineWidth = u"auto";
+
+ switch (nFontUnderline)
+ {
+ case awt::FontUnderline::BOLD:
+ rUnderlineWidth = u"bold";
+ return;
+ case awt::FontUnderline::BOLDDASH:
+ rUnderlineWidth = u"bold";
+ rUnderlineStyle = u"dash";
+ return;
+ case awt::FontUnderline::BOLDDASHDOT:
+ rUnderlineWidth = u"bold";
+ rUnderlineStyle = u"dot-dash";
+ return;
+ case awt::FontUnderline::BOLDDASHDOTDOT:
+ rUnderlineWidth = u"bold";
+ rUnderlineStyle = u"dot-dot-dash";
+ return;
+ case awt::FontUnderline::BOLDDOTTED:
+ rUnderlineWidth = u"bold";
+ rUnderlineStyle = u"dotted";
+ return;
+ case awt::FontUnderline::BOLDLONGDASH:
+ rUnderlineWidth = u"bold";
+ rUnderlineStyle = u"long-dash";
+ return;
+ case awt::FontUnderline::BOLDWAVE:
+ rUnderlineWidth = u"bold";
+ rUnderlineStyle = u"wave";
+ return;
+ case awt::FontUnderline::DASH:
+ rUnderlineStyle = u"dash";
+ return;
+ case awt::FontUnderline::DASHDOT:
+ rUnderlineStyle = u"dot-dash";
+ return;
+ case awt::FontUnderline::DASHDOTDOT:
+ rUnderlineStyle = u"dot-dot-dash";
+ return;
+ case awt::FontUnderline::DONTKNOW:
+ rUnderlineWidth = u"";
+ rUnderlineStyle = u"";
+ rUnderlineType = u"";
+ return;
+ case awt::FontUnderline::DOTTED:
+ rUnderlineStyle = u"dotted";
+ return;
+ case awt::FontUnderline::DOUBLE:
+ rUnderlineType = u"double";
+ return;
+ case awt::FontUnderline::DOUBLEWAVE:
+ rUnderlineStyle = u"wave";
+ rUnderlineType = u"double";
+ return;
+ case awt::FontUnderline::LONGDASH:
+ rUnderlineStyle = u"long-dash";
+ return;
+ case awt::FontUnderline::NONE:
+ rUnderlineWidth = u"none";
+ rUnderlineStyle = u"none";
+ rUnderlineType = u"none";
+ return;
+ case awt::FontUnderline::SINGLE:
+ rUnderlineType = u"single";
+ return;
+ case awt::FontUnderline::SMALLWAVE:
+ case awt::FontUnderline::WAVE:
+ rUnderlineStyle = u"wave";
+ return;
+ default:
+ assert(false && "Unhandled font underline type");
+ }
+}
+
/** Converts Color to "rgb(r,g,b)" as specified in https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes. */
OUString lcl_ConvertColor(Color aColor)
{
@@ -939,6 +1022,22 @@ QString QtAccessibleWidget::attributes(int offset, int* startOffset, int* endOff
const awt::FontSlant eFontSlant = *o3tl::doAccess<awt::FontSlant>(prop.Value);
sValue = lcl_ConvertFontSlant(eFontSlant);
}
+ else if (prop.Name == "CharUnderline")
+ {
+ OUString sUnderlineStyle;
+ OUString sUnderlineType;
+ OUString sUnderlineWidth;
+ const sal_Int16 nUnderline = *o3tl::doAccess<sal_Int16>(prop.Value);
+ lcl_ConvertFontUnderline(nUnderline, sUnderlineStyle, sUnderlineType, sUnderlineWidth);
+
+ // leave 'sAttribute' and 'sName' empty, set all attributes here
+ if (!sUnderlineStyle.isEmpty())
+ aRet += u"text-underline-style:" + sUnderlineStyle + ";";
+ if (!sUnderlineType.isEmpty())
+ aRet += u"text-underline-type:" + sUnderlineType + ";";
+ if (!sUnderlineWidth.isEmpty())
+ aRet += u"text-underline-width:" + sUnderlineWidth + ";";
+ }
else if (prop.Name == "CharWeight")
{
sAttribute = "font-weight";