vcl/inc/salframe.hxx       |    4 ----
 vcl/source/app/salplug.cxx |   19 ++++---------------
 vcl/source/app/svdata.cxx  |   23 +++++++----------------
 winaccessibility/README.md |   10 +++-------
 4 files changed, 14 insertions(+), 42 deletions(-)

New commits:
commit bfbaeb8192447265bdd78d1be4990947d135eb6e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Oct 18 17:01:43 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Oct 19 08:48:46 2024 +0200

    tdf#160982 wina11y: Drop extra screen reader check to enable a11y bridge
    
    When initializing the a11y bridge on Windows, no longer
    check whether the screen reader parameter
    `SPI_GETSCREENREADER` [1] is explicitly set or require
    to explicitly enable by setting an
    `SAL_FORCE_IACCESSIBLE2` environment variable.
    
    For performance reasons, it of course makes sense to only
    enable the a11y bridge when there is actually assistive
    technology that makes use of it.
    
    However, `ImplInitAccessBridge` already only gets called
    when either support for assistive technology has explicitly
    been enabled in the settings (i.e. in "Tools" -> "Options" -> 
"LibreOfficeDev"
    -> "Accessibility", the "Support assistive technology tools (restart
    required" checkbox was checked) or when a `WM_GETOBJECT` message
    is received, whose documentation says [2]:
    
    > Sent by both Microsoft Active Accessibility and Microsoft UI Automation
    > to obtain information about an accessible object contained in a server
    > application.
    >
    > Applications never send this message directly. Microsoft Active
    > Accessibility sends this message in response to calls to
    > AccessibleObjectFromPoint, AccessibleObjectFromEvent, or
    > AccessibleObjectFromWindow. However, server applications handle this
    > message. UI Automation sends this message in response to calls to
    > IUIAutomation::ElementFromHandle, ElementFromPoint, and
    > GetFocusedElement, and when handling events for which a client has
    > registered.
    
    Both of these cases (explicitly enabled, AT requests information) justify
    enabling the a11y bridge by themselves, so drop the extra check.
    
    Qt's UIA bridge for example also gets activated when a WM_GETOBJECT
    message is received [3].
    
    This makes both, Microsoft Narrator (screen reader shipped with
    Windows, but which doesn't set the `SPI_GETSCREENREADER` parameter)
    and Microsoft Accessibility Insights for Windows (a tool for a11y
    analysis/debugging) work - at least to a certain degree - without
    having to explicitly set the environment variable
    `SAL_FORCE_IACCESSIBLE2`.
    
    While LibreOffice doesn't have a UIA bridge at this point in time,
    Windows provides an MSAA (IAccessible) to UIA proxy that provides
    some basic information via UIA at least, see [4]:
    
    > The LegacyIAccessible control pattern is supported by the Microsoft
    > Active Accessibility to Microsoft UI Automation Proxy.
    
    As expected, a breakpoint or assert in `ImplInitAccessBridge`
    only got hit in my testing when either an AT was active or the
    above-mentioned option was explicitly enabled, not otherwise when
    starting or using LO.
    
    [1] 
https://learn.microsoft.com/en-us/windows/win32/winauto/screen-reader-parameter
    [2] https://learn.microsoft.com/en-us/windows/win32/winauto/wm-getobject
    [3] 
https://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp?id=e9662a4b665144a5eca418925d331024ec71fa2c#n40
    [4] 
https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-implementinglegacyiaccessible
    
    Change-Id: Iddafb149b50771412ba59972d0401bada6a9f680
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175172
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index c0300b4083cd..0ea3fce1565b 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -326,10 +326,6 @@ public:
     virtual void  SetTaskBarState(VclTaskBarStates /*eTaskBarState*/) {}
 };
 
-#ifdef _WIN32
-bool HasAtHook();
-#endif
-
 #endif // INCLUDED_VCL_INC_SALFRAME_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/salplug.cxx b/vcl/source/app/salplug.cxx
index bfb04492b108..29722d4a7994 100644
--- a/vcl/source/app/salplug.cxx
+++ b/vcl/source/app/salplug.cxx
@@ -436,14 +436,4 @@ const OUString& SalGetDesktopEnvironment()
     return aDesktopEnvironment;
 }
 
-#ifdef _WIN32
-bool HasAtHook()
-{
-    BOOL bIsRunning = FALSE;
-    // pvParam must be BOOL
-    return SystemParametersInfoW(SPI_GETSCREENREADER, 0, &bIsRunning, 0)
-        && bIsRunning;
-}
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 5eef6bc7bbd5..b48fc6695a3a 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -336,25 +336,16 @@ bool ImplInitAccessBridge()
     if( ! pSVData->mxAccessBridge.is() )
     {
         css::uno::Reference< XComponentContext > 
xContext(comphelper::getProcessComponentContext());
-
-        if (!HasAtHook() && !getenv("SAL_FORCE_IACCESSIBLE2"))
+        try
         {
-            SAL_INFO("vcl", "Apparently no running AT -> "
-                     "not enabling IAccessible2 integration");
+            pSVData->mxAccessBridge = 
css::accessibility::MSAAService::create(xContext);
+            SAL_INFO("vcl", "got IAccessible2 bridge");
+            return true;
         }
-        else
+        catch (css::uno::DeploymentException &)
         {
-            try {
-                 pSVData->mxAccessBridge
-                     = css::accessibility::MSAAService::create(xContext);
-                 SAL_INFO("vcl", "got IAccessible2 bridge");
-                 return true;
-             } catch (css::uno::DeploymentException &) {
-                 TOOLS_WARN_EXCEPTION(
-                    "vcl",
-                    "got no IAccessible2 bridge");
-                 return false;
-             }
+            TOOLS_WARN_EXCEPTION("vcl", "got no IAccessible2 bridge");
+            return false;
         }
     }
 
diff --git a/winaccessibility/README.md b/winaccessibility/README.md
index 6abf34a37e16..64937a617848 100644
--- a/winaccessibility/README.md
+++ b/winaccessibility/README.md
@@ -47,14 +47,10 @@ not by actual end users.
 
 ## Debugging / Playing with winaccessibility
 
-If NVDA is running when soffice starts, IA2 should be automatically enabled
-and work as expected. In order to use 'accprobe' to debug
-it is necessary to override the check for whether an AT (like NVDA) is
-running; to do that use:
+If an assistive technology like NVDA is running when soffice starts,
+IA2 should be automatically enabled and work as expected.
 
-    SAL_FORCE_IACCESSIBLE2=1 soffice.exe -writer
-
-Then you can use accprobe to introspect the accessibility hierarchy
+'accprobe' can be used to to introspect the accessibility hierarchy
 remotely, checkout:
 
 <http://accessibility.linuxfoundation.org/a11yweb/util/accprobe/>
commit a2fab652b4001baa9d19e058668dc6400ad482c7
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Oct 18 16:08:32 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Oct 19 08:48:31 2024 +0200

    vcl: Use OUString literals in SalGetDesktopEnvironment
    
    Change-Id: Ibd28148772fcdc64a9fe6ebca38706c0445d38fd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175139
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/app/salplug.cxx b/vcl/source/app/salplug.cxx
index fb43ecd3a101..bfb04492b108 100644
--- a/vcl/source/app/salplug.cxx
+++ b/vcl/source/app/salplug.cxx
@@ -422,14 +422,13 @@ const OUString& SalGetDesktopEnvironment()
     static OUString aDesktopEnvironment("iOS");
 #elif UNIX_DESKTOP_DETECT
     // Order to match desktops.hxx' DesktopType
-    static const char * const desktop_strings[] = {
-        "none", "unknown", "GNOME", "UNITY",
-        "XFCE", "MATE", "PLASMA5", "PLASMA6", "LXQT" };
+    static constexpr OUString desktop_strings[] = {
+        u"none"_ustr, u"unknown"_ustr, u"GNOME"_ustr, u"UNITY"_ustr,
+        u"XFCE"_ustr, u"MATE"_ustr, u"PLASMA5"_ustr, u"PLASMA6"_ustr, 
u"LXQT"_ustr };
     static OUString aDesktopEnvironment;
     if( aDesktopEnvironment.isEmpty())
     {
-        aDesktopEnvironment = OUString::createFromAscii(
-            desktop_strings[get_desktop_environment()]);
+        aDesktopEnvironment = desktop_strings[get_desktop_environment()];
     }
 #else
     static OUString aDesktopEnvironment("unknown");

Reply via email to