toolkit/source/controls/unocontrol.cxx |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 5c4b4c2900838602964e995d4118681fec537e31
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed May 21 15:46:03 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu May 22 05:51:00 2025 +0200

    toolkit a11y: Don't rely on control peer being XAccessible
    
    When getting the accessible context for a
    UnoControl in non-design mode, don't rely/depend
    on the implementation detail that the VCLXWindow
    implements the XAccessible interface for its
    vcl::Window, as this is subject to change.
    
    Instead, retrieve the vcl::Window and then
    get its accessible (context).
    
    See also commit messsage of
    
        Change-Id: Id81ab5f90955ecc600e179164b5f9c7a771182d1
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Wed May 21 11:03:56 2025 +0200
    
            sw a11y test: Don't rely on XWindow being XAccessible
    
    for more background.
    
    Sample scenario to trigger this code path:
    
    * start Orca screen reader on Linux
    * start Writer with gtk3 VCL plugin
    * enable "Form Controls" toolbar in "View" -> "Toolbars"
    * insert a Check Box (or radio button) control
    * disable design mode by clicking the corresponding button
      in the form controls toolbar
    * if not already the case: select the control
    
    At the moment, the accessible context is exactly the
    same with or without this commit in place, but
    the previous approach relying on VCLXWindow being
    the vcl::Window's XAccessible would break if that
    no longer is the case in the future.
    
    Change-Id: I9aa697e1d7a25a10ccb5469f5dd2a84a4f00fbfc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185617
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/toolkit/source/controls/unocontrol.cxx 
b/toolkit/source/controls/unocontrol.cxx
index f4757f5d79b6..e91520f9640f 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -1464,10 +1464,14 @@ Reference< XAccessibleContext > SAL_CALL 
UnoControl::getAccessibleContext(  )
     if ( !xCurrentContext.is() )
     {
         if ( !mbDesignMode )
-        {   // in alive mode, use the AccessibleContext of the peer
-            Reference< XAccessible > xPeerAcc( getPeer(), UNO_QUERY );
-            if ( xPeerAcc.is() )
-                xCurrentContext = xPeerAcc->getAccessibleContext( );
+        {
+            // in alive mode, use the accessible context of the window
+            if (vcl::Window* pWindow = VCLUnoHelper::GetWindow(getPeer()))
+            {
+                Reference<XAccessible> xWinAcc = pWindow->GetAccessible();
+                if (xWinAcc.is())
+                    xCurrentContext = xWinAcc->getAccessibleContext();
+            }
         }
         else
             // in design mode, use a fallback

Reply via email to