toolkit/source/awt/vclxaccessiblecomponent.cxx |    8 +++++++-
 toolkit/source/helper/unowrapper.cxx           |    7 +++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 2cd1408dd7d6688357257f4a58a8b467628b1884
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Aug 17 13:15:46 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 18 06:05:23 2023 +0200

    tdf#156561 a11y: Create VCLXTopWindow peer for border win frame
    
    If a border window is a "native frame", i.e. a top level
    window, then also create a `VCLXTopWindow` for it instead
    of just a simple `VCLXWindow`.
    
    This also addresses another cause why the Calc autofilter
    popup would not be announced by the NVDA screen reader
    before
    
        commit dc0706cabfe39ddb6ea23d60ccfb756f2b9e6efb
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Wed Mar 15 17:00:27 2023 +0100
    
            tdf#140762 tdf#152671 Make dock win visible before showing popup
    
    For winaccessibility, an accessible event listener
    is registered for an object when either
    `AccTopWindowListener::windowOpened` gets an event
    with the top level window set or the parent of
    the window sends an `AccessibleEventId::CHILD` event
    for the child object.
    
    In case of the autofilter popup in Calc, the top-level
    border window of the work window (created and set in
    `WorkWindow::ImplInit` and retrieved via `Window::GetFrameWeld`
    in `ScGridWindow::LaunchAutoFilterMenu`) is set as the
    parent window of the popup, but since it is a top-level
    window and was so far not considered as such due to its
    peer/component interface not implementing `XTopWindow`
    (s. `Window::IsTopWindow` and the corresponding check
    in `VCLXToolkit::callTopWindowListeners`), it would
    not have any accessible listener set, and thus no
    child event for its new popup child would be sent
    to the winaccessibility layer. Therefore, no
    accessible events would be sent for the popup
    and it's children either, resulting in NVDA not
    announcing any focus changes, etc.
    
    With this change in place, NVDA announces focused
    items in the auto filter popup even with a revert
    of the above-mentioned commit (and follow-up commits),
    except for submenu entries (which still suffer from
    another problem that will be addressed separately).
    
    Change-Id: I69c6066127c8b853a27cc1f692f139572541f8eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155800
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/toolkit/source/helper/unowrapper.cxx 
b/toolkit/source/helper/unowrapper.cxx
index e2aaa55dbe63..82b4dd17338a 100644
--- a/toolkit/source/helper/unowrapper.cxx
+++ b/toolkit/source/helper/unowrapper.cxx
@@ -91,6 +91,13 @@ static rtl::Reference<VCLXWindow> CreateXWindow( vcl::Window 
const * pWindow )
 
         case WindowType::HEADERBAR:     return new VCLXHeaderBar;
 
+        case WindowType::BORDERWINDOW:
+        {
+            if (pWindow->IsNativeFrame())
+                return new VCLXTopWindow;
+            return new VCLXWindow(true);
+        }
+
         // case WindowType::FIXEDLINE:
         // case WindowType::FIXEDBITMAP:
         // case WindowType::DATEBOX:
commit 4d27d2c5f9d83112b6db9b6234e2ae617ffced22
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Aug 17 11:51:11 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 18 06:05:14 2023 +0200

    tdf#141101 tdf#156561 a11y: Handle a11y child events in win parent
    
    `VCLXAccessibleComponent::ProcessWindowChildEvent` was only
    processing `WindowShow` and `WindowHide` events when the
    `vcl::Window::GetAccessibleParent()` for the window sent in
    the event would return the window that the `VCLXAccessibleComponent`
    refers to.
    
    This generally seems reasonable, but when the child events
    are sent for the corresponding window, the window's hierarchy
    is iterated over using `vcl::Window::GetParent()`, so if the
    accessible window is not in that hierarchy, no window would
    take care of the child events.
    (Note e.g. how `Window::GetParent` uses `mpWindowImpl->mpRealParent`
    while `Window::getAccessibleParentWindow` uses `mpWindowImpl->mpParent`
    and has some special handling.)
    
    Due to the way that `ImplDockingWindowWrapper::ImplPreparePopupMode`
    reparents the windows, this is at least the case for the auto
    filter popup in Calc and the font color popup in Writer's "Character"
    dialog, so the `VclEventId::WindowShow` event would not be forwarded
    to the a11y layer as an `AccessibleEventId::CHILD` event, and thus no
    listener would be registered for the children. As a result, the NVDA
    screen reader would not announce these objects when they receive
    focus.
    
    Make sure that the child event gets handled by making
    `VCLXAccessibleComponent::GetChildAccessible` also take
    into account the `vcl::Window::GetParent()`.
    
    This addresses one of the underlying issues why the Calc autofilter
    was not announced by NVDA before
    
        commit dc0706cabfe39ddb6ea23d60ccfb756f2b9e6efb
        Author: Michael Weghorn
        Date:   Wed Mar 15 17:00:27 2023 +0100
    
            tdf#140762 tdf#152671 Make dock win visible before showing popup
    
    It might make sense to reconsider the way of
    reparenting in `ImplDockingWindowWrapper` and general
    a11y parent handling at some point, but that will need
    further analysis and would presumably require more
    fundamental changes elsewhere, too.
    
    Change-Id: I83cf5732bfc9d4886e4f7fa75d4ff462e4d4af6d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155799
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx 
b/toolkit/source/awt/vclxaccessiblecomponent.cxx
index 2d290e1ad5e1..2c353fd801eb 100644
--- a/toolkit/source/awt/vclxaccessiblecomponent.cxx
+++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx
@@ -133,7 +133,13 @@ uno::Reference< accessibility::XAccessible > 
VCLXAccessibleComponent::GetChildAc
 
     // MT: Change this later, normally a show/hide event shouldn't have the 
vcl::Window* in pData.
     vcl::Window* pChildWindow = static_cast<vcl::Window 
*>(rVclWindowEvent.GetData());
-    if( pChildWindow && GetWindow() == 
pChildWindow->GetAccessibleParentWindow() )
+    // tdf#141101/tdf#156561 Handle the event if this is either the a11y 
parent or the
+    // vcl::Window parent, since child events are sent for the vcl::Window 
hierarchy
+    // (s. Window::CallEventListeners) and e.g. DockingManager does manual 
partial reparenting
+    // that would cause child events to not be forwarded to the a11y level when
+    // not taking GetParent() into account here
+    if (pChildWindow && (GetWindow() == 
pChildWindow->GetAccessibleParentWindow()
+                         || GetWindow() == pChildWindow->GetParent()))
         return pChildWindow->GetAccessible( rVclWindowEvent.GetId() == 
VclEventId::WindowShow );
     else
         return uno::Reference< accessibility::XAccessible > ();

Reply via email to