vcl/qt5/QtAccessibleWidget.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 1db70ac081d73837f526ff3bfae9eeaa221aa8c6
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed May 28 22:54:57 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu May 29 08:10:07 2025 +0200

    qt a11y: Report locale for Qt >= 6.10
    
    Report the locale for accessible objects using
    the Qt API newly introduced in qtbase commit [1]
    that also describes a scenario using LibreOffice:
    
        commit da3422ca150ab52c1c2184cdd467ff105ba1de3c
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Fri May 23 10:59:32 2025 +0200
    
            a11y: Introduce QAccessible::Attribute::Locale, bridge to AT-SPI
    
            Introduce a new Locale value for the QAccessible::Attribute
            enum class that can be used to specify the locale
            of an accessible object.
    
            Use this to implement support for the
            "Locale" property of the AT-SPI Accessible interface. [1]
    
            If no locale has explicitly been specified, report
            the default locale in the AT-SPI adaptor, as is
            already the case in the implementation of the
            "GetLocale" method of the AT-SPI Application
            interface.
    
            Being able to explicitly specify a locale is of
            particular interest when an application contains
            objects whose locale differs from the default
            application locale, e.g. documents or paragraphs
            written in a different language.
    
            Demo LibreOffice change making use of this
            new API: [2]
    
            Sample use case with the above-mentioned LibreOffice
            change in place:
    
            1) start LibreOffice Writer, using English UI
               and document language
            2) type "Hello world" for the first paragraph
            3) press Enter to create a new paragraph
            4) copy-paste "你好世界" ("Hello world" in Chinese)
               into the new paragraph
            5) start Accerciser
            6) select the first paragraph in Accerciser's treeview
               of the LibreOffice a11y hierarchy
            7) query locale in Accerciser's IPython console
    
                In [1]: acc.get_object_locale()
                Out[1]: 'en_GB'
    
            8) select the second paragraph in Accerciser's treeview
               of the LibreOffice a11y hierarchy
            9) query locale in Accerciser's IPython console
    
                In [2]: acc.get_object_locale()
                Out[2]: 'zh_CN'
    
            For UIA on Windows, UIA_CulturePropertyId [3] seems
            to be the equivalent property that the new attribute
            could be mapped to (to be done separately, not implemented
            in this commit).
    
            [1] 
https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/2e65b0877d67667b06e0dc6ad918a6fd4943c371/xml/Accessible.xml#L55-67
            [2] https://gerrit.libreoffice.org/c/core/+/185709
            [3] 
https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids
    
            [ChangeLog][QtGui][QAccessible::Attribute] Added new
            Locale enum value that can be used to specify the
            locale of an accessible object.
    
            Fixes: QTBUG-137144
            Change-Id: Ice11b9e45b512305dbb8195961b8b08e1389c69e
            Reviewed-by: Volker Hilsheimer <volker.hilshei...@qt.io>
    
    [1] 
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=da3422ca150ab52c1c2184cdd467ff105ba1de3c
    
    Change-Id: I33b3bb406da5d84c2353bbeb5bedc7ac0297f31f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185709
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index dcd5a7a40801..835b1ad7f883 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -955,9 +955,15 @@ QHash<QAccessible::Attribute, QVariant> 
QtAccessibleWidget::attributes() const
     if (!xAttributes.is())
         return {};
 
-    const OUString sAttrs = xAttributes->getExtendedAttributes();
-
     QHash<QAccessible::Attribute, QVariant> aQtAttrs;
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
+    const css::lang::Locale aLocale = xContext->getLocale();
+    const QLocale aQLocale(toQString(aLocale.Language + u"_" + 
aLocale.Country));
+    aQtAttrs.insert(QAccessible::Attribute::Locale, aQLocale);
+#endif
+
+    const OUString sAttrs = xAttributes->getExtendedAttributes();
     sal_Int32 nIndex = 0;
     do
     {

Reply via email to