vcl/source/accessibility/AccessibleTextAttributeHelper.cxx |   53 +++++++++++++
 1 file changed, 53 insertions(+)

New commits:
commit c0a284541fad2c4609d418a5002550f6f9581d51
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Oct 13 15:51:56 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Oct 13 21:09:15 2023 +0200

    tdf#157696 a11y Translate "CharStrikeout" to IA2 equivalents
    
    The IAccessible2 text attributes specification [1]
    has several different "text-line-through-*"
    attributes for indicating strikethrough.
    
    With this change in place, NVDA on Windows (with the WIP branches
    to switch both LO's winaccessibility and NVDA to the
    IAccessible2 text attributes) announces the striked out
    text in the tdf#157696 sample document as expected.
    
    For the qt6 VCL plugin on Linux, this is not the
    case yet, because Qt's AT-SPI adaptor does not support
    the attributes yet; s.a. QTBUG-118106 [2].
    
    Pending qtbase change implementing that: [3]
    
    While the gtk3 VCL plugin reports 2 attributes, e.g.
    "strikethrough: single" and "text-decoration: line-through",
    the ATK text attribute specification [4] only mentions a
    `ATK_TEXT_ATTR_STRIKETHROUGH` that can be either
    "true" or "false", and that is also what e.g.
    the gtk4-demo "Text View" -> "Markup" example does,
    so the suggested Qt change also does this, which means
    that just "strikethrough: true" will be reported when
    any kind of strikethrough is in place with the qt6 VCL
    plugin and both, this LibreOffice change and the
    pending Qt Gerrit change applied.
    
    [1] 
https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes
    [2] https://bugreports.qt.io/browse/QTBUG-118106
    [3] https://codereview.qt-project.org/c/qt/qtbase/+/511758
    [4] https://gnome.pages.gitlab.gnome.org/atk/AtkText.html#AtkTextAttribute
    
    Change-Id: Ib4ebba183be233aacfcf33a4fff29b27711d2e1e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157939
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/accessibility/AccessibleTextAttributeHelper.cxx 
b/vcl/source/accessibility/AccessibleTextAttributeHelper.cxx
index d8ffa5161930..ccd900e9edc1 100644
--- a/vcl/source/accessibility/AccessibleTextAttributeHelper.cxx
+++ b/vcl/source/accessibility/AccessibleTextAttributeHelper.cxx
@@ -20,6 +20,7 @@
 #include <vcl/accessibility/AccessibleTextAttributeHelper.hxx>
 
 #include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
 #include <com/sun/star/awt/FontUnderline.hpp>
 #include <com/sun/star/awt/FontWeight.hpp>
 #include <o3tl/any.hxx>
@@ -37,6 +38,53 @@ OUString lcl_ConvertCharEscapement(sal_Int16 nEscapement)
     return "baseline";
 }
 
+OUString lcl_ConverCharStrikeout(sal_Int16 nStrikeout)
+{
+    OUString sTextLineThroughStyle;
+    OUString sTextLineThroughText;
+    OUString sTextLineThroughType;
+    OUString sTextLineThroughWidth;
+
+    switch (nStrikeout)
+    {
+        case css::awt::FontStrikeout::BOLD:
+            sTextLineThroughType = "single";
+            sTextLineThroughWidth = "bold";
+            break;
+        case css::awt::FontStrikeout::DONTKNOW:
+            break;
+        case css::awt::FontStrikeout::DOUBLE:
+            sTextLineThroughType = "double";
+            break;
+        case css::awt::FontStrikeout::NONE:
+            sTextLineThroughStyle = "none";
+            break;
+        case css::awt::FontStrikeout::SINGLE:
+            sTextLineThroughType = "single";
+            break;
+        case css::awt::FontStrikeout::SLASH:
+            sTextLineThroughText = u"/"_ustr;
+            break;
+        case css::awt::FontStrikeout::X:
+            sTextLineThroughText = u"X"_ustr;
+            break;
+        default:
+            assert(false && "Unhandled strikeout type");
+    }
+
+    OUString sResult;
+    if (!sTextLineThroughStyle.isEmpty())
+        sResult += u"text-line-through-style:"_ustr + sTextLineThroughStyle + 
";";
+    if (!sTextLineThroughText.isEmpty())
+        sResult += u"text-line-through-text:"_ustr + sTextLineThroughText + 
";";
+    if (!sTextLineThroughType.isEmpty())
+        sResult += u"text-line-through-type:"_ustr + sTextLineThroughType + 
";";
+    if (!sTextLineThroughWidth.isEmpty())
+        sResult += u"text-line-through-width:"_ustr + sTextLineThroughWidth + 
";";
+
+    return sResult;
+}
+
 OUString lcl_convertFontWeight(double fontWeight)
 {
     if (fontWeight == css::awt::FontWeight::THIN || fontWeight == 
css::awt::FontWeight::ULTRALIGHT)
@@ -212,6 +260,11 @@ OUString 
AccessibleTextAttributeHelper::ConvertUnoToIAccessible2TextAttributes(
             const css::awt::FontSlant eFontSlant = 
*o3tl::doAccess<css::awt::FontSlant>(prop.Value);
             sValue = lcl_ConvertFontSlant(eFontSlant);
         }
+        else if (prop.Name == "CharStrikeout")
+        {
+            const sal_Int16 nStrikeout = 
*o3tl::doAccess<sal_Int16>(prop.Value);
+            aRet += lcl_ConverCharStrikeout(nStrikeout);
+        }
         else if (prop.Name == "CharUnderline")
         {
             OUString sUnderlineStyle;

Reply via email to