120 Commits
Author SHA1 Message Date
Mike Kaganski af8c524790 tdf#166875: Don't notify broadcaster from its disposing notification
An assert failed in debugging, when closing print preview in Writer:

  ucrtbased.dll!_wassert(const wchar_t * expression, const wchar_t * file_name, unsigned int line_number) Line 443
  comphelper.dll!`anonymous namespace'::implLookupClient(const unsigned long nClient, std::_List_iterator<std::_List_val<std::_List_simple_types<std::pair<unsigned long const ,comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>>>>> & rPos) Line 140
  comphelper.dll!comphelper::AccessibleEventNotifier::removeEventListener(const unsigned long _nClient, const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener> & _rxListener) Line 229
  swlo.dll!SwAccessibleContext::removeAccessibleEventListener(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener> & xListener) Line 746
  winaccessibility.dll!AccEventListener::RemoveMeFromBroadcaster(bool isNotifyDestroy) Line 262
  winaccessibility.dll!AccEventListener::disposing(const com::sun::star::lang::EventObject & __formal) Line 287
  comphelper.dll!comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>::disposeAndClear(std::unique_lock<std::mutex> & rGuard, const com::sun::star::lang::EventObject & rEvt) Line 492
  comphelper.dll!comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(const unsigned long _nClient, const com::sun::star::uno::Reference<com::sun::star::uno::XInterface> & _rxEventSource) Line 204
  swlo.dll!SwAccessibleContext::Dispose(bool bRecursive, bool bCanSkipInvisible) Line 1050
  swlo.dll!SwAccessibleMap::~SwAccessibleMap() Line 1571
  swlo.dll!SwAccessibleMap::`scalar deleting destructor'(unsigned int)
  swlo.dll!std::_Destroy_in_place<SwAccessibleMap>(SwAccessibleMap & _Obj) Line 324
  swlo.dll!std::_Ref_count_obj2<SwAccessibleMap>::_Destroy() Line 2118
  swlo.dll!std::_Ref_count_base::_Decref() Line 1161
  swlo.dll!std::_Ptr_base<SwAccessibleMap>::_Decref() Line 1385
  swlo.dll!std::shared_ptr<SwAccessibleMap>::~shared_ptr<SwAccessibleMap>() Line 1690
  swlo.dll!std::shared_ptr<SwAccessibleMap>::reset() Line 1737
  swlo.dll!SwViewShellImp::~SwViewShellImp() Line 108
  swlo.dll!SwViewShellImp::`scalar deleting destructor'(unsigned int)
  swlo.dll!std::default_delete<SwViewShellImp>::operator()(SwViewShellImp * _Ptr) Line 3309
  swlo.dll!std::unique_ptr<SwViewShellImp,std::default_delete<SwViewShellImp>>::reset(SwViewShellImp * _Ptr) Line 3471
  swlo.dll!SwViewShell::~SwViewShell() Line 324
  swlo.dll!SwViewShell::`scalar deleting destructor'(unsigned int)
  swlo.dll!SwPagePreview::~SwPagePreview() Line 1235
  swlo.dll!SwPagePreview::`vector deleting destructor'(unsigned int)
  sfxlo.dll!SfxViewFrame::SwitchToViewShell_Impl(unsigned short nViewIdOrNo, bool bIsIndex) Line 2690

SwAccessibleContext::Dispose called revokeClientNotifyDisposing,
which removed the SwAccessibleContext's id from its map, and then
called disposing() for all listenera of the SwAccessibleContext.

When one of the listeners, in its disposing(), tried to call
broadcaster's removeAccessibleEventListener, this violated the
API: XEventListener::disposing documentation directly prohibits
calling any methods of the broadcaster.

This was obviously a confusion, already present in commit
a18bdb3bc0 (Integrate branch of
IAccessible2, 2013-11-19), where the semantics of disposing()
was thought as "the listener is disposing", when in fact, it's
broadcaster notification about broadcaster's disposal.

Change-Id: Ib7f79b2214ffeedec6b4a4c75813e4ffa2d43270
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186242
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-06-07 11:46:45 +02:00
Michael Weghorn e7a34dbaec wina11y: Simplify SELECTION_CHANGED_* handlers a bit
Drop the unused `oldValue` param from the methods
handling the SELECTION_CHANGED_* events, and make
them non-virtual, as they don't need to be overriden
in any subclass.

Change-Id: Ic4a248a6dedaa0a6b25b22dd5673be2bb27a4fc8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183791
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-04-08 08:21:55 +02:00
Michael Weghorn b608604d0b tdf#164093 tdf#157001 wina11y: Use vcl::Window's actual XAccessible
By default, a vcl::Window's XAccessible is its
VCLXWindow (toolkit peer):

    css::uno::Reference< css::accessibility::XAccessible > Window::CreateAccessible()
    {
        css::uno::Reference< css::accessibility::XAccessible > xAcc( GetComponentInterface(), css::uno::UNO_QUERY );
        return xAcc;
    }

However, that's a virtual method and subclasses can
return a different XAccessible.
MenuFloatingWindow::CreateAccessible returns the
accessible of its menu.

However, winaccessibility's AccTopWindowListener
code was relying on the Window's XAccessible always
being its VCLXWindow.

The VLCXWindow is passed as a param in the
XTopWindowListener methods, and AccTopWindowListener
was querying it for the XAccessible interface, and
then calling XAccessible::getAccessibleContext in
order to retrieve the XAccessibleContext for the
window.

This is incorrect if the Window actually has another
XAccessible.

For the df#164093 scenario with NVDA running, opening and
closing the sidebar popup menu would result in the
VCLXWindow's VCLXWindow::getAccessibleContext menu
getting called, which calls VCLXWindow::CreateAccessibleContext
and the VCLXWindow would keep a reference to the
returned XAccessibleContext and dispose it when
the VLCXWindow itself gets disposed.
However, AccessibleFactory::createAccessibleContext
(called by VCLXWindow::CreateAccessibleContext)
doesn't actually create a new object for the
MenuFloatingWindow's accessible, but returns the
existing accessible object of the PopupMenu, which is
owned by the PopupMenu, not the MenuFloatingWindow,
s.a. previous commit

    Change-Id: Ia2931bee23204395e8b3396927acf4fa1d0f077c
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Dec 5 11:06:48 2024 +0000

        tdf#164093 tdf#157001 a11y: Improve menu window disposal

for more details.

Backtrace of how that accessible context was returned:

    1 `anonymous namespace'::AccessibleFactory::createAccessibleContext acc_factory.cxx 305 0x7fffbc160767
    2 VCLXWindow::CreateAccessibleContext vclxwindow.cxx 879 0x7fffc0b1bc67
    3 VCLXWindow::getAccessibleContext vclxwindow.cxx 2418 0x7fffc0b2670b
    4 AccTopWindowListener::HandleWindowOpened AccTopWindowListener.cxx 60 0x7fffe5c32ab6
    5 AccTopWindowListener::windowOpened AccTopWindowListener.cxx 119 0x7fffe5c3375e
    6 ``anonymous namespace'::VCLXToolkit::callTopWindowListeners'::`2'::<lambda_1>::operator() vclxtoolkit.cxx 2364 0x7fffc0af27ef
    7 comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XTopWindowListener>::forEach<``anonymous namespace'::VCLXToolkit::callTopWindowListeners'::`2'::<lambda_1>> interfacecontainer4.hxx 349 0x7fffc0ae7f9e
    8 `anonymous namespace'::VCLXToolkit::callTopWindowListeners vclxtoolkit.cxx 2359 0x7fffc0afeaed
    9 `anonymous namespace'::VCLXToolkit::eventListenerHandler vclxtoolkit.cxx 2295 0x7fffc0b02492
    10 `anonymous namespace'::VCLXToolkit::LinkStubeventListenerHandler vclxtoolkit.cxx 2288 0x7fffc0afbdf6
    11 Link<VclSimpleEvent &,void>::Call link.hxx 111 0x7fffbfba33d3
    12 VclEventListeners::Call vclevent.cxx 47 0x7fffbfba35f1
    13 Application::ImplCallEventListeners svapp.cxx 733 0x7fffbfb76dbb
    14 vcl::Window::CallEventListeners event.cxx 229 0x7fffbf45f841
    15 vcl::Window::ImplSetReallyVisible window.cxx 1331 0x7fffbf566bad
    16 vcl::Window::ImplSetReallyVisible window.cxx 1344 0x7fffbf566c7d
    17 vcl::Window::Show window.cxx 2336 0x7fffbf56a8d1
    18 vcl::Window::Show window.cxx 2349 0x7fffbf56a9ce
    19 FloatingWindow::StartPopupMode floatwin.cxx 825 0x7fffbf46a702
    20 PopupMenu::Run menu.cxx 3018 0x7fffbf4a6f02
    ... <More>

When the MenuFloatingWindow gets disposed, its
VCLXWindow is also disposed. Since it incorrectly
assumes it (or its Window) owns the XAccessibleContext,
it disposes that as well:

    1 OAccessibleMenuBaseComponent::disposing accessiblemenubasecomponent.cxx 608 0x7fffbf300c82
    2 cppu::WeakComponentImplHelperBase::dispose implbase.cxx 104 0x7fffe199964a
    3 cppu::PartialWeakComponentImplHelper<com::sun::star::accessibility::XAccessibleContext2,com::sun::star::accessibility::XAccessibleEventBroadcaster>::dispose compbase.hxx 90 0x7fffdb8d1820
    4 VCLXWindow::dispose vclxwindow.cxx 938 0x7fffc0b24012
    5 UnoWrapper::WindowDestroyed unowrapper.cxx 302 0x7fffc0cfddc6
    6 vcl::Window::dispose window.cxx 220 0x7fffbf56e68f
    7 SystemWindow::dispose syswin.cxx 107 0x7fffbf515606
    8 FloatingWindow::dispose floatwin.cxx 225 0x7fffbf46b751
    9 MenuFloatingWindow::dispose menufloatingwindow.cxx 134 0x7fffbf4bd766
    10 VclReferenceBase::disposeOnce vclreferencebase.cxx 39 0x7fffbf7520d9
    11 VclPtr<vcl::Window>::disposeAndClear vclptr.hxx 207 0x7fffbf3f98d2
    12 PopupMenu::ImplExecute menu.cxx 2947 0x7fffbf4a0ee7
    13 PopupMenu::Execute menu.cxx 2834 0x7fffbf49c392
    14 MenuButton::ExecuteMenu menubtn.cxx 77 0x7fffbf639f1d
    15 MenuButton::MouseButtonDown menubtn.cxx 214 0x7fffbf63a847
    16 ImplHandleMouseEvent winproc.cxx 708 0x7fffbf57ca27
    17 ImplHandleSalMouseButtonDown winproc.cxx 2338 0x7fffbf57e1af
    18 ImplWindowFrameProc winproc.cxx 2683 0x7fffbf57fc07
    19 SalFrame::CallCallback salframe.hxx 312 0x7fffbf3443c6
    20 ImplHandleMouseMsg salframe.cxx 3415 0x7fffbc818e8f
    ... <More>

However, the Menu that actually owns the accessible may
still be alive, and then opening the menu again results
in an attempt to make use of the already disposed object,
triggering a crash due to a DisposedException being thrown:

    1   RaiseException                                            KERNELBASE                           0x7ff808e8b699
    2   CxxThrowException                                         VCRUNTIME140                         0x7fffef535267
    3   comphelper::OCommonAccessibleComponent::ensureAlive       accessiblecomponenthelper.cxx   141  0x7fffdb8d1937
    4   comphelper::OContextEntryGuard::OContextEntryGuard        accessiblecontexthelper.hxx     64   0x7fffbf2fb8eb
    5   comphelper::OExternalLockGuard::OExternalLockGuard        accessiblecontexthelper.hxx     81   0x7fffbf2fb948
    6   OAccessibleMenuBaseComponent::getAccessibleContext        accessiblemenubasecomponent.cxx 641  0x7fffbf301337
    7   VCLXAccessibleComponent::ProcessWindowChildEvent          vclxaccessiblecomponent.cxx     165  0x7fffc0a9596d
    8   VCLXAccessibleComponent::WindowChildEventListener         vclxaccessiblecomponent.cxx     124  0x7fffc0a96669
    9   VCLXAccessibleComponent::LinkStubWindowChildEventListener vclxaccessiblecomponent.cxx     114  0x7fffc0a957f6
    10  Link<VclWindowEvent &,void>::Call                         link.hxx                        111  0x7fffbf45f7d3
    11  vcl::Window::CallEventListeners                           event.cxx                       300  0x7fffbf45fe0c
    12  vcl::Window::ImplSetReallyVisible                         window.cxx                      1331 0x7fffbf566bad
    13  vcl::Window::ImplSetReallyVisible                         window.cxx                      1344 0x7fffbf566c7d
    14  vcl::Window::Show                                         window.cxx                      2336 0x7fffbf56a8d1
    15  vcl::Window::Show                                         window.cxx                      2349 0x7fffbf56a9ce
    16  FloatingWindow::StartPopupMode                            floatwin.cxx                    825  0x7fffbf46a702
    17  PopupMenu::Run                                            menu.cxx                        3018 0x7fffbf4a6f02
    18  PopupMenu::ImplExecute                                    menu.cxx                        3005 0x7fffbf4a1707
    19  PopupMenu::Execute                                        menu.cxx                        2834 0x7fffbf49c392
    20  MenuButton::ExecuteMenu                                   menubtn.cxx                     77   0x7fffbf639f1d
    ... <More>

To fix that, adjust winaccessibility's
AccTopWindowListener to no longer just use
the VCLXWindow for the accessible, but
get the vcl::Window for the VCLXWindow and
query it's actual XAccessible using
vcl::Window::GetAccessible().

This fixes the tdf#164093 crash. The problem of
tdf#157001 where items in the popup menu of Calc's organize
template dialog are only announced the first time the menu
is opened still remains for now, but is also somehow
related to the MenuFloatingWindow being disposed.
(No longer reproducible when no longer calling
the base class FloatingWindow::dispose from
MenuFloatingWindow::dispose in a local test,
still needs further analysis.)

Change-Id: Ic96d2c95128af144c7769aac40707299b1c80f8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177889
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-12-05 20:12:40 +01:00
Michael Weghorn d1c40cfda5 wina11y: Make these 2 methods non-virtual
Change-Id: I791ec6d822573e18c981343d3ce8371acf0b3b38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177878
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-12-05 20:11:10 +01:00
Mike Kaganski 1180b3473a com::sun::star -> css
Change-Id: I890ec73e30d3cc6b210903ecee29431f3cb5f635
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175979
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-11-10 10:50:15 +01:00
Michael Weghorn 7bd37ba0bf wina11y: Rename UNO_MSAA_UNMAPPING to MSAA_NO_STATE
... to make clear that this is a constant with
no state set.

Also, move the definition to the only source file
where it's used.

Change-Id: Iaaba8d7053f71c63caab57c2b692b8e5898d37cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174276
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-30 21:40:28 +02:00
Michael Weghorn 7f2fe1837d wina11y: Drop always default AccObject::InsertChild pos param
This `pos` param never gets passed explicitly, so is
always the default `LAST_CHILD`.

Therefore, drop the param completely to simplify
this.

Change-Id: I8f51fe58b47bb2f0c18a853c81b8b6c85d4a6602
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174275
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-09-30 21:40:20 +02:00
Michael Weghorn fb779c2acf wina11y: Move AccObject::GetExpandedState logic to only caller
Change-Id: I5505abf795c1133b77b9c4ec7bb762401b9a3826
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174274
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-30 21:40:13 +02:00
Michael Weghorn ecae424190 wina11y: Simplify AccObject::GetExpandedState
* Drop the `isExpandable` out param that's unused
  at the only call site.
* Use a bool return value instead of an out param
  for the remaining `isExpandable`.

Change-Id: I2a37f0fec752f5e8e802ec781acf49035b3fbf2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174273
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-30 21:40:05 +02:00
Michael Weghorn 347fe07246 wina11y: sal_Bool -> bool
Change-Id: I348e293981bbaeec650a463c958c5e301a804422
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174272
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-30 21:39:54 +02:00
Michael Weghorn 68f4eaa313 wina11y: Drop unused default params for AccObject ctor
Change-Id: I6a92f442e6540714f8f8f652d67a213e28a1f35a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172650
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 21:05:20 +02:00
Michael Weghorn d48f391a88 wina11y: Drop always null param from AccObject ctor
The param is never explicitly passed, so is always
nullptr.

Change-Id: I7838a9e5e990ebef18f9f622e587aa2a64070e92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172649
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-30 21:05:08 +02:00
Michael Weghorn e8cc4dbd1d wina11y: Drop unused AccObject::getListener
Change-Id: I95c591e2b79e59a50671967e6ab35b384d8d6c23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172648
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-08-30 21:05:01 +02:00
Michael Weghorn 2acf6f4253 wina11y: Query XAccessibleAction iface on demand
Despite the

    // initially m_xAction and m_xContext are the same object
    // but they may be different once AccObject::UpdateAction() is called?

comment in winaccessibility/source/UAccCOM/MAccessible.h,
`MAccessible::m_xAction` is supposed to point to the same
underlying object as `MAccessible::m_xContext`, see
`AccObject::UpdateAction` (which queries for the
`XAccessibleAction` interface and sets that).

Simplify this by just querying `MAccessible::m_xContext`
for the `XAccessibleAction` iface on demand in those
places where it's needed.

Change-Id: Id3d89213937c2c72a936947da69ca7fddc8f1b09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172205
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21 18:49:54 +02:00
Michael Weghorn dfd2312409 wina11y: Retrieve default action description on demand
Instead of doing extra work to keep
`CMAccessible::m_pszActionDescription` up to date,
move the logic to retrieve the action description
from the underlying `XAccessibleAction` into
`CMAccessible::get_accDefaultAction` and do that
on demand.

This is similar to what was done for the accessible
description in this commit:

    commit fcf4a26275
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Jan 5 13:41:53 2022 +0000

        tdf#146306 wina11y: Retrieve accessible desc on demand

As expected, the example mentioned in the commit
message of

    Change-Id: I5569f70739135172ddb604f1f1bd958e32626ab0
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Aug 21 09:49:51 2024 +0100

        wina11y: Unify handling to set action description

still behaves the same as without this commit in place.

Change-Id: I7d1ea0ce302df955314c8e46c530cc24d30fcd4b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172183
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-08-21 18:49:39 +02:00
Michael Weghorn 525ba5e4d7 wina11y: Unify handling to set action description
Drop `AccObject::UpdateDefaultAction` and let
`AccObject::UpdateActionDesc` take care of
setting the action description for all roles.

It's unclear to me

* why the action description would only be set
  for particular roles

* why `AccObject::UpdateActionDesc` would call
  `AccObject::UpdateDefaultAction` for particular
  roles if it was basically setting the description
  the same way that `AccObject::UpdateActionDesc`
  does directly for other roles (except for
  `AccObject::UpdateDefaultAction` not checking
  that there's at least one action).

Also simplify the code a bit while at it.

Testing with the "Don't Save" button in the "Save Document?"
dialog seen when pressing Alt+F4 with a modified Writer doc
gives the expected result in NVDA's Python console:

    >>> focus.role
    <Role.BUTTON: 9>
    >>> focus.name
    'Don’t Save'
    >>> focus.IAccessibleActionObject.nActions()
    1
    >>> focus.IAccessibleActionObject.description(0)
    'press'

If any particular reason for not setting the action description
for particular roles should show up in the future, they can
still be excluded in one central place now.

Change-Id: I5569f70739135172ddb604f1f1bd958e32626ab0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172182
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21 18:49:32 +02:00
Michael Weghorn 0c7a5e6f41 wina11y: Drop AccObjectWinManager::GetRole
For the only in `AccObjectWinManager::InsertAccObj`,
there's already a reference to the `XAccessibleContext`,
so just call `XAccessibleContext::getAccessibleRole`
directly.

Change-Id: I9e0a96d67ac8550b4988de6c3cefc8d6e0b319ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172181
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21 18:49:20 +02:00
Michael Weghorn 114e827c88 wina11y: Drop AccObject::ImplInitializeCreateObj
As the method name and comment suggests, this method
was doing more in the past, but that's no more the case.

The only thing it does is doing an assert, but
there's no need to have a separate method for this,
so just do that right away in the (so far) only caller.

Change-Id: Ief41c8d4ec350622eb043340a4b0bd1079d337a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172177
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-08-21 18:48:41 +02:00
Michael Weghorn a10a99b0c6 wina11y: Retrieve a11y name on demand
Instead of doing extra bookkeeping to keep
`CMAccessible::m_pszName` as a class member up
to date with the current value of the accessible
name, just retrieve the current a11y name directly
from the underlying `XAccessible` when it is requested
via the IAccessible2 API in `CMAccessible::get_accName`.

This is basically the accessible name equivalent of the
the following commit that did similarly for the
accessible description:

    commit fcf4a26275
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Jan 5 13:41:53 2022 +0000

        tdf#146306 wina11y: Retrieve accessible desc on demand

        Adapt 'MAccessible::get_accDescription' to directly
        retrieve the accessible description on demand via the
        corresponding XAccessible, rather than keeping
        track of it in a class member.

        This simplifies the handling and makes it
        unnecessary to "manually" update the description
        on 'accessibility::AccessibleEventId::DESCRIPTION_CHANGED'
        events, since the new value will
        be queried next time it is needed anyway.

        This also fixes the problem that a significant
        amount of time was spent generating accessible
        descriptions for all newly inserted a11y objects when
        entering values into Calc cells with the NVDA
        screen reader in use, resulting in several
        seconds of delay.

        Querying up-to-date values from the underlying
        UNO interfaces on demand instead of doing extra
        manual bookkeeping in the winaccessibility code
        may be possible for more a11y attributes in addition
        to the accessible description handled in this commit,
        but each one will have to be looked at separately.

This also allows to drop the
`AccContainerEventListener::HandleNameChangedEvent` and
`AccObjectContainerEventListener::HandleStateChangedEvent`
overrides of the base class implementations unnecessary,
as the only thing they did in addition was updating the
a11y name.

This commit has no effect on events sent on the platform
layer, those are still sent as before to notify about the
name change.

Change-Id: I4d1df1d0b73ce963cdaec91d642ff5bbf2b371bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172148
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21 07:47:58 +02:00
Michael Weghorn efb4ad9071 wina11y: Query new a11y name instead of passing it around
Drop `AccObject::SetName` et al. taking a string param
with the new a11y name to set in favor of using
`AccObject::UpdateName` et al. that updates the a11y name
by querying the current value from the underlying
`XAccessible`.

This makes it unnecessary to pass the new value
around when a `AccessibleEventId::NAME_CHANGED`
event is received, and the new name has to
already be set on the a11y object at the point in
time that the event is received.

Change-Id: I1510bde22ef6d1271f6aeaffe245441cd9e11f19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172145
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-08-21 07:47:51 +02:00
Michael Weghorn 58de3a5f1c wina11y: Drop unnecessary null check and make static
`AccObject::GetMAccessibleValueFromAny` converts an
Any to a string representation, which is unrelated
to any class members, so drop the null check for the
`m_pIMAcc` member and make the method static.

Change-Id: I07216f87c0fadbe239d1e16a048e2799cebac7bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166184
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-04-17 21:33:06 +02:00
Michael Weghorn 0425b6eb47 tdf#160695 wina11y: Send status change events for toolbar buttons
When the checked or indeterminate state of a toolbar button
changes, forward the corresponding UNO a11y event as
a corresponding MSAA event.

For roles `AccessibleRole::PUSH_BUTTON` and
`AccessibleRole::TOGGLE_BUTTON`, `AccObject::GetMSAAStateFromUNO`
uses `STATE_SYSTEM_PRESSED` instead of
`STATE_SYSTEM_CHECKED`, so also use
`UnoMSAAEvent::STATE_PRESSED` for the event.

It's unclear why sending of such events would generally
be omitted for "special toolbar items" previously.

The events can be used to implement announcement of
toggled font attributes in NVDA, e.g. when the "Bold"
button in the formatting toolbar is toggled via a keyboard
shortcut, similar to how Orca does it (s. tdf#123864).

Related NVDA issue for which I plan to submit a PR: [1]

[1] https://github.com/nvaccess/nvda/issues/4248

Change-Id: Ic2846e338802c3cb7656de5b77e4df23bd5b0703
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166155
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-04-17 08:07:17 +02:00
Michael Weghorn 5100fb1c0e wina11y: Hold AccObjectWinManager by ref, not ptr
Inspired by

    commit 0a2622760a
    Date:   Wed Nov 8 13:54:14 2023 +0100

        Drop presumably redundant null check

Change-Id: Icb2bfb83ebf4146eb3091a6021ecac75aa6626b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160464
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-12-08 17:26:39 +01:00
Andrea Gelmini 7e415a1117 Fix typo
Change-Id: Id34e34b8f2bbd903f60d293783031a728a6da8ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158587
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-10-28 17:11:34 +02:00
Michael Weghorn f44eae4912 tdf#135586 a11y: Add a new BLOCK_QUOTE a11y role
A block quote role exists in all of WAI-ARIA 1.3
(role "blockquote", [1]), IAccessible2
(`IA2_ROLE_BLOCK_QUOTE`,  [2]) and AT-SPI
(`ROLE_BLOCK_QUOTE`, [3]).

Take over the definition that is the same in WAI-ARIA
and IAccessible2:

> A section of content that is quoted from another source.

The intended use for now is for a Writer paragraph using
the "Block Quotation" paragraph style, similar to how the
HEADING role is used for paragraphs using a corresponding
paragraph style.

For gtk3 (ATK) and winaccessibility (IAccessible2),
map the new role to the equivalant roles.

For macOS and the gtk4 as well as the Qt-based VCL plugins
on Linux which currently don't have an equivalent role,
fall back to the same role that the PARAGRAPH role is
mapped to.
This way, the behavior there will remain unchanged
once the BLOCK_QUOTE role is used for Writer paragraphs
with the corresponding style.

In general, treat BLOCK_QUOTE like PARAGRAPH
in code applying special handling for the PARAGRAPH
role.

[1] https://w3c.github.io/aria/#blockquote
[2] https://github.com/LinuxA11y/IAccessible2/blob/3d8c7f0b833453f761ded6b12d8be431507bfe0b/api/AccessibleRole.idl#L318
[3] https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/7cc4cee53ddbd22631fd110f0e5ce045dec2e411/xml/Accessible.xml#L615-616

Change-Id: I248c183a2e7ec5d6f0a89bf3cb4829bbd8588c77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158573
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-10-28 05:45:15 +02:00
Michael Weghorn 63a004f51f wina11y: Use return value instead of out param
... to return the `IAccessible*` in
`AccObjectWinManager::GetIAccessibleFromXAccessible` and
`CMAccessible::get_IAccessibleFromXAccessible` and adapt
the call sites accordingly.
This is more straight-forward and the extra bool return
value didn't add anything, since it was also just
saying whether the pointer was a nullptr, so rather
check that directly.

Also drop `AccObjectWinManager::GetIMAccByXAcc` that
does the same thing and switch the only call site
to use `AccObjectWinManager::GetIAccessibleFromXAccessible`
instead.

Change-Id: I72933df62aa9ac1ff3f2a84c5045dfae354c18e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155505
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-09 15:45:35 +02:00
Michael Weghorn 37b72ba454 wina11y: Drop AccObjectManagerAgent indirection
`AccObjectManagerAgent` was holding an
`AccObjectWinManager` object and forwarding
everything to that one and the event listeners
were holding a pointer to the `AccObjectManagerAgent`
object.

Drop this `AccObjectManagerAgent` indirection
and let all of the classes that were interacting
with the `AccObjectManagerAgent` directly interact
with the `AccObjectWinManager` instead.

The idea of having the agent seems to have been
to have an abstraction layer and implement
different accessible object managers for all
platforms, but the agent already has quite some
Windows-/IAccessible-specific code/interface and by now, the
Linux VCL plugins and macOS have their own
a11y bridges, so the TODO do implement this here
for Linux as well seems outdated to me.

Even if implementing this for Linux and/or macOS
in a similar way, I don't see the need for the
agent layer, but one way might be to
just have an abstract base class
(e.g. `AccObjectManager`) that `AccObjectWinManager`
and implementations for other platforms derive from,
and have the SalInstance return the platform-specific
implementation that the `AccTopWindowListener` would
then retrieve and pass on.

Given that `AccObjectManagerAgent` was forwarding
all calls to `AccObjectWinManager` and the methods
and params are mostly the same by now (s.a. the
preparatory commits), this change is mostly
straightforward.

A few notes:

* `AccObjectManagerAgent::InsertAccObj` had a default
  nullptr value for the HWND that
  `AccObjectWinManager:InsertAccObj` didn't have yet,
  so add that.

* `AccObjectManagerAgent::GetIAccessibleFromResID` had
  an out param instead of a return value; call sites
  were adapted to fit
  `AccObjectWinManager:GetIAccessibleFromResID`.

* The `UpdateValue` and `UpdateAccName` methods
  taking 2 params are called `SetValue` and
  `SetAccName` in `AccObjectWinManager` instead,
  so adapt call sites accordingly.

* prewin.h and postwin.h includes had to be added
  around the windows.h include in AccObjectWinManager.hxx
  (build would otherwise fail)

* A few `AccObjectWinManager` methods had to be made
  virtual to make linking work.

Change-Id: I88741bf416d4db25d78e973c0db060a828f27926
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155440
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-08 08:18:28 +02:00
Michael Weghorn 0724cb04e7 wina11y: Align param order with other methods
Switch the param order in `AccObjectManagerAgent::NotifyAccEvent`
to be consistent with all of its other methods that take the
`XAccessible*` first, and also with
`AccObjectWinManager::NotifyAccEvent` that is called by the
method.

This is also in preparation of dropping
AccObjectManagerAgent altogether.

Change-Id: I83d331176971cc728524266d87939f33acd375f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155438
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-08 08:18:13 +02:00
Michael Weghorn b45481d689 wina11y: Drop unused default nullptr arg
Calling this without passing an actual XAccessible*
wouldn't make any sense anyway.

Change-Id: Ie8d8aecc0c0a3a8a2c1ef62015fba7ad242059b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155437
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-08 08:18:06 +02:00
Michael Weghorn b9a981e88f wina11y: Move and simplify casting for Get_ToATInterface
Move the casting from AccObjectManagerAgent::Get_ToATInterface to
AccObjectWinManager::Get_ToATInterface and just do a
`reinterpret_cast<HWND>(...)` right away instead of a
`static_cast<HWND>(reinterpret_cast<void*>(...))`.

This is in preparation of dropping the AccObjectManagerAgent
indirection altogether.

Change-Id: Iad759f856f727418aab0d20b479fc38feac714ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155436
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-08 08:17:59 +02:00
Michael Weghorn e5aab6900f wina11y: Move GetIAccessibleFromXAccessible logic
Move the logic from AccObjectManagerAgent::GetIAccessibleFromXAccessible
to the new AccObjectWinManager::GetIAccessibleFromXAccessible and just
forward to that one.

This is in preparation of dropping the AccObjectManagerAgent
indirection altogether.

Change-Id: Ic276a04cf7dda3762cee0d3932962e2a0947cfde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155435
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-08 08:17:52 +02:00
Michael Weghorn 2f41574c34 wina11y: Drop AccObjectManagerAgent indirection to get a11y role
Just retrieve it from the context directly here, and drop the now
unused `AccObjectWinManager::GetRole`.

Change-Id: I4c14d2f9b6fb1df9c58149576897c8585ba4a437
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155433
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-08 08:17:37 +02:00
Michael Weghorn f9631765c9 wina11y: Drop/Clean up CHILD event handling in subclasses
Now that Change-Id I62ab32342ef67c770ced9f0d2be867dc9355bd4a
("tdf#156561 wina11y: Handle CHILD event") has implemented
handling for the CHILD event in `AccEventListener`,
drop the overrides in child classes that effectively
do the same.

For the case that a new child gets added,
`AccFrameEventListener::HandleChildChangedEvent`
also passes the HWND, so leave that and only
forward to the base class for the other case.

Change-Id: I68d836abedbf3563df84187d56851820c043866f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155127
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-01 13:14:46 +02:00
Michael Weghorn 1d92445fca tdf#156561 wina11y: Handle CHILD event
So far, `AccessibleEventId::CHILD` events were ignored by
`AccComponentEventListener` and its base class,
`AccEventListener`.
As a result, no event listener would be created when
e.g. a child that was previously hidden got shown,
resulting e.g. in NVDA not announcing that object
when it receives focus later.

Handle the event and register a listener when notified
about a new child and drop the old child when one gets
removed, like some of the derived classes already do
in pretty much the same way.
(Those implementations will be cleaned up/dropped
in a separate commit.)

This addresses one of the root causes of why
tdf#140762 ("No text spoken by screen reader for 'Borders'
dropdown button items in Calc's formatting toolbar (NVDA on Windows)")
occured without

    commit dc0706cabfe39ddb6ea23d60ccfb756f2b9e6efb
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Mar 15 17:00:27 2023 +0100

        tdf#140762 tdf#152671 Make dock win visible before showing popup

, i.e. when the window is made visible only after its
parent.

Still, this change at least by itself does not yet solve
tdf#152671 ("ui, accessibility: auto filter drop down menu is not
spoken by the screen reader") and also for the case of the
toolbar popup, the initially focused item would no more
be announced when reverting the above-mentioned commit and
its follow-up commit

    commit 57c2209dd04abfda90e0aba782bc174243633ec9
    Author: Caolán McNamara <caolanm@redhat.com>
    Date:   Thu Apr 6 15:07:15 2023 +0100

        tdf#154470 try moving the Show of the client to after the float positioning

Example backtrace of the font color popup in the formatting
toolbar where no event listener was created previously:

    1   AccEventListener::notifyEvent                                 AccEventListener.cxx          74   0x7ffe4b4ecf14
    2   AccComponentEventListener::notifyEvent                        AccComponentEventListener.cxx 82   0x7ffe4b4ee699
    3   comphelper::AccessibleEventNotifier::addEvent                 accessibleeventnotifier.cxx   256  0x7ffe5e80ebac
    4   comphelper::OCommonAccessibleComponent::NotifyAccessibleEvent accessiblecomponenthelper.cxx 127  0x7ffe5e80443e
    5   VCLXAccessibleToolBoxItem::NotifyChildEvent                   vclxaccessibletoolboxitem.cxx 213  0x7ffe4b337e10
    6   VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl            vclxaccessibletoolbox.cxx     373  0x7ffe4b33334d
    7   VCLXAccessibleToolBox::ProcessWindowEvent                     vclxaccessibletoolbox.cxx     547  0x7ffe4b33263c
    8   VCLXAccessibleComponent::WindowEventListener                  vclxaccessiblecomponent.cxx   112  0x7ffe51e871c5
    9   VCLXAccessibleComponent::LinkStubWindowEventListener          vclxaccessiblecomponent.cxx   98   0x7ffe51e861f6
    10  Link<VclWindowEvent &,void>::Call                             link.hxx                      111  0x7ffe504204b3
    11  vcl::Window::CallEventListeners                               event.cxx                     263  0x7ffe50420860
    12  svt::PopupWindowControllerImpl::WindowEventListener           popupwindowcontroller.cxx     148  0x7ffe53c65593
    13  svt::PopupWindowControllerImpl::LinkStubWindowEventListener   popupwindowcontroller.cxx     89   0x7ffe53c64f76
    14  Link<VclWindowEvent &,void>::Call                             link.hxx                      111  0x7ffe504204b3
    15  vcl::Window::CallEventListeners                               event.cxx                     263  0x7ffe50420860
    16  vcl::Window::ImplResetReallyVisible                           stacking.cxx                  723  0x7ffe5033d6f1
    17  vcl::Window::Show                                             window.cxx                    2234 0x7ffe5053eca7
    18  ImplDockingWindowWrapper::ImplPreparePopupMode                dockmgr.cxx                   769  0x7ffe5041154e
    19  ImplDockingWindowWrapper::StartPopupMode                      dockmgr.cxx                   816  0x7ffe50413d4c
    20  DockingManager::StartPopupMode                                dockmgr.cxx                   349  0x7ffe50413c11
    ... <More>

Change-Id: I62ab32342ef67c770ced9f0d2be867dc9355bd4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155126
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-08-01 13:14:34 +02:00
Michael Stahl ac1099443e tdf#155794 winaccessibility: no SolarMutex in getAccObjectPtr()
MSAAServiceImpl::getAccObjectPtr() is called when processing
WM_GETOBJECT messages, and this can happen (at least when NVDA is
active) during processing SendMessages.

When loading a document on a non-main thread, WinSalFrame::SetTitle()
calls SetWindowTextW which is equivalent to SendMessage(WM_SETTEXT),
while holding SolarMutex, and if the main thread doesn't finish
processing it then that's a deadlock.

Introduce a new mutex in AccObjectWinManager and use it to guard the 2
members that getAccObjectPtr() reads, while keeping the rest of
winaccessibility with the SolarMutex, as the UNO services may be called
on any thread.

This fixes part of the problem, VCL also needs to stop using SolarMutex.

Change-Id: I6df5889fd76f59146b4b0b1e5f4513232f8ab867
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152957
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-06-13 16:06:59 +02:00
Michael Weghorn 02edbf7dc7 tdf#154303 wina11y: Don't truncate 64-bit states
commit 8d8e6c84e5
    Date:   Sun Jul 3 20:29:28 2022 +0200

        [API CHANGE] Drop css::accessibility::XAccessibleStateSet

had introduced the use of a 64-bit integer with
bit flags for the accessible states.

However, `AccObjectWinManager::DecreaseState` and
`AccObjectWinManager::IncreaseState` were still using
unsigned short, resulting in truncation.

As one result, the `AccessibleEventId::STATE_CHANGED`
event with state `AccessibleStateType::VISIBLE`
from `OAccessibleMenuBaseComponent::SetVisible` would no
longer result in the `STATE_SYSTEM_INVISIBLE` being unset
and thus the the JAWS screen reader would no longer announce
the focused (but considered invisible) menu item.

Fix this by switching the param for those two methods to
sal_Int64 as well.

Change-Id: I714573e2691e82c6287a4b83f872f87568e46495
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149255
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-03-22 06:36:58 +00:00
Stephan Bergmann 4521cb0c40 Drop redundant -Wnon-virtual-dtor
Inspired by
<https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607102.html> "[PATCH]
doc: -Wdelete-non-virtual-dtor supersedes -Wnon-virtual-dtor", drop explicitly
enabling -Wnon-virtual-dtor in favor of -Wdelete-non-virtual-dtor, which is
already enabled by -Wall.

(-Wdelete-non-virtual-dtor first appeared in Clang 3.0,
<https://github.com/llvm/llvm-project/commit/8bd428574c717e68a8274739d2ba0f6dc16fd0fb>
"Add new warning that warns when invoking 'delete' on a polymorphic, non-final,
class without a virtual destructor", and GCC 4.7,
<https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=014ab419efc12a59efebd2720d79e1c055675c85>
"invoke.texi: Document -Wdelete-non-virtual-dtor. [...]")

Dropping the explicit setting of -Wnon-virtual-dtor (and nowhere setting it
implicitly via -Weffc++) means we can get rid of lots of places that either set
-Wno-non-virtual-dtor or use some pragma to ignore -Wnon-virtual-dtor.

(In various places across extensions/source/activex/ and winaccessibility/, the
commits f26996bd33 "Silence
-Werror,-Wnon-virtual-dtor in generated so_activex.h (clang-cl)" and
c6086ca653 "Silence -Werror,-Wnon-virtual-dtor in
generated UAccCOM.h (clang-cl)" had singled out some includes to wrap them in
pragmas.  Now that those pragmas are gone again, move those includes back to
where they had been prior to being singled out.  And the -Wno-non-virtual-dtor
in external/firebird/macos-arm64.patch.0 appeared first in
ccd0e5f445 "Make firebird build for macOS on
arm64", which, though it doesn't state it explicitly, apparently created that
patch's builds/posix/prefix.darwin_arm64 as a copy of firebird's already
existing builds/posix/prefix.* files, which routinely include that warning
option too, so keep it there too even if it is probably irrelevant throughout.)

Change-Id: I7e4fa9f2c07e267b2ed15607905027f6b78142f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143182
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-24 10:38:28 +01:00
Michael Weghorn 7d873ed704 wina11y: Drop unused member and methods related to selection
Those were only used by
`AccObjectWinManager::UpdateAccSelection`,
which has been dropped in
Change-Id I49bfddb636721d9142a88b7ce1eb3ee3a2f9c695
("wina11y: Drop unused AccObjectWinManager::UpdateAccSelection").

Change-Id: I11d1ad3f01929a68e341f910ec6382f91227e3c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139124
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-08-31 23:38:11 +02:00
Michael Weghorn 58649c1db4 wina11y: Drop unused AccObjectWinManager::UpdateAccSelection
It was already unused when it was added in

    commit a18bdb3bc0
    Date:   Thu Nov 14 08:18:05 2013 +0000

        Integrate branch of IAccessible2

`CMAccessible::get_accSelection` already queries
information on demand.

The dropped method looks like another one of the methods that
could be used for manual bookkeeping of information
instead of querying them from the underlying UNO
interfaces on demand. But retrieving them on demand
seems preferable, s.a. the commit message in

    commit fcf4a26275
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Jan 5 13:41:53 2022 +0000
    tdf#146306 wina11y: Retrieve accessible desc on demand

> Querying up-to-date values from the underlying
> UNO interfaces on demand instead of doing extra
> manual bookkeeping in the winaccessibility code
> may be possible for more a11y attributes in addition
> to the accessible description handled in this commit,
> but each one will have to be looked at separately.

Change-Id: I49bfddb636721d9142a88b7ce1eb3ee3a2f9c695
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139123
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-08-31 23:37:56 +02:00
Michael Weghorn f03b908e28 wina11y: Drop extra location bookkeeping
The location is already retrieved on demand from the
underlying `XAccessible` in `CMAccessible::accLocation`
and the separately remembered location was just used
as fallback in case `m_xAccessible` was not (no more)
set.
However, when there is no valid associated `XAccessible`,
there is probably no value in returning any location
anyway, so just return `S_FALSE` for that case, as
other `CMAccessible` methods also do.

Whether the separately remembered `m_sLocation`
was up to date is also questionable, s.a.
Change-Id I04d0230d3599466aaa92082caba54da22a3b1a28,
"wina11y: Drop AccObjectManagerAgent::UpdateLocation".

This is also in line with what's mentioned in

    commit fcf4a26275
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Jan 5 13:41:53 2022 +0000
    tdf#146306 wina11y: Retrieve accessible desc on demand

> Querying up-to-date values from the underlying
> UNO interfaces on demand instead of doing extra
> manual bookkeeping in the winaccessibility code
> may be possible for more a11y attributes in addition
> to the accessible description handled in this commit,
> but each one will have to be looked at separately.

Change-Id: I2fc51939a5db1896e02efacb1cf5fbc90ce87c04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137858
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-08-05 16:38:18 +02:00
Michael Weghorn 0c3a159807 wina11y: Drop AccObjectManagerAgent::UpdateLocation
That static method doesn't do anything.

`_IMPL_WIN` is not defined, so the

    #ifdef _IMPL_WIN
       if( pWinManager )
           pWinManager->SetLocation( pXAcc, top, left, width, height );
    #endif

in the method is unused.

Since `CMAccessible::accLocation` already retrieves the
current location from the underlying `XAccessible` on demand,
I don't see a need to update the location manually
in the first place, so there should be no need to enable that,
code, just drop it.

Also drop `AccObjectWinManager::SetLocation` which was
unused since `AccObjectManagerAgent::UpdateLocation`
(s. above) would have been the only call site.

Change-Id: I04d0230d3599466aaa92082caba54da22a3b1a28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137857
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-08-05 16:36:17 +02:00
Noel Grandin 8d8e6c84e5 [API CHANGE] Drop css::accessibility::XAccessibleStateSet
which is internal API, unused (as far as I can tell) by external
users.
This state is purely a bitset
  (as implemented by utl::AccessibleStateSetHelper)
so we can just return it as a 64-bit value.

This shaves significant time off the performance profiles
of code that loads very complex shapes, because this state
is frequently used, and we no longer need to allocate a return
value on the heap for every call.

Change-Id: Icf1b3bd367c256646ae9015f9127025f59459c2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136786
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-08 10:10:11 +02:00
Michael Weghorn 6c5257b680 wina11y: Slightly clean up WinResIDGenerator
Changes:

* drop the optional `maxNum` param for the
  constructor, it's never set to anything
  different than the default value
* store negative number in member (renamed
  from `max` to `m_nMin`) instead of storing
  positive number and inverting that when returning
  it in `ResIDGenerator::GenerateNewResID`
* Use -1 as the first resource ID instead of -2.

Also, add a comment that negative child IDs
are used because it's common to use such ones
to indicate unique resource IDs in
IAccessible2.

Quoting James Teh's comment on an NVDA
pull request of mine [1]:

> The use of negative child ids doesn't fit well into the IAccessible
> spec, but it has been done by IAccessible2 for a very long time and
> should be considered standard for all intents and purposes. A negative
> child id should be treated as a unique id, while a positive child id
> should be treated as a child index.
>
> That said, as noted in #13277 (comment), IAccessible2 elements are
> always full IAccessible objects, not "simple elements". Thus, anything
> that returns an accessible (including accSelection) really should return
> an object pointer. In the case of accSelection, this means VT_DISPATCH
> for a single selection or VT_UNKNOWN and iEnumVARIANT (with VT_DISPATCH
> elements) for multiple selection.
>
> In short, NVDA supporting negative child ids returned from accSelection
> isn't necessarily "wrong", but ideally, LibreOffice would be fixed to
> return full objects.

The latter (returning full objects) has already been addressed in

    commit 00c0ee8cf0
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Mon Jan 31 07:41:14 2022 +0000

        tdf#147083 wina11y: Return a11y object instead of child ID

but a unique ID is still relevant, s. e.g. the documentation
of `IAccessible2::uniqueID` [2], which also mentions potential
ways to implement unique IDs:

> One means of implementing this would be to create a factory with a 32
> bit number generator and a reuse pool. The number generator would emit
> numbers starting at 1. Each time an object's life cycle ended, its
> number would be saved into a reuse pool. The number generator would be
> used whenever the reuse pool was empty.
>
> Another way to create a unique ID is to generate it from a pointer
> value, e.g. an object's address. That would be unique because no two
> active objects can use the same allocated memory space.

The first approach is what the LO implementation currently does,
except that negative numbers are used.

[1] https://github.com/nvaccess/nvda/pull/13277#issuecomment-1024622871
[2] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/interface_i_accessible2.html#aac1342376cf195a6a6e9ee3b7e30ae3b

Change-Id: I6c0a6c4a4e3a69396205fe2d69cd66af6525a273
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131927
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-03-22 13:26:54 +01:00
Michael Weghorn 95e2e5190c wina11y: Rename IsSpecialToolboItem -> IsSpecialToolbarItem
Change-Id: I972a65783fcb481e91db68e6e58124d46f78ee66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130698
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-02-28 17:43:04 +01:00
Michael Weghorn 6723203528 wina11y: Convert unomsaaevent.hxx constants to enum class UnoMSAAEvent
Also drop the previous comments for the constants that add
little value and are partially outdated.
See the actual implementation to see how values are mapped
to send out actual MSAA events, e.g. the previous comment

    // CARET_CHANGED --> EVENT_OBJECT_LOCATIONCHANGED

was no longer correct by now, since that is by now mapped to
`IA2_EVENT_TEXT_CARET_MOVED` in `AccObjectWinManager::NotifyAccEvent`.

Change-Id: I38111ccb60c06f73ce53b18a6ca32e13dbd629b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130697
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-02-28 17:42:47 +01:00
Stephan Bergmann 3b48e20b01 -Werror,-Wunused-parameter
...since fcf4a26275 "tdf#146306 wina11y: Retrieve
accessible desc on demand"

Change-Id: I8acdca5fac481ca7b970fb9c3660470c5febdf99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128307
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-01-12 09:26:10 +01:00
Michael Weghorn fd78753879 wina11y: Drop now unused AccObject::SetRole
Change-Id: I04db43ac49d7bc6ff42157cdd0c94087c454c981
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128009
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-01-06 10:10:38 +01:00
Michael Weghorn e60406b087 wina11y: Drop unused AccObjectWinManager::SetRole
Change-Id: Ic2d470a137e4d0c907f28e24c58ba19a937a8b4b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128008
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-01-06 10:10:25 +01:00
Michael Weghorn fcf4a26275 tdf#146306 wina11y: Retrieve accessible desc on demand
Adapt 'MAccessible::get_accDescription' to directly
retrieve the accessible description on demand via the
corresponding XAccessible, rather than keeping
track of it in a class member.

This simplifies the handling and makes it
unnecessary to "manually" update the description
on 'accessibility::AccessibleEventId::DESCRIPTION_CHANGED'
events, since the new value will
be queried next time it is needed anyway.

This also fixes the problem that a significant
amount of time was spent generating accessible
descriptions for all newly inserted a11y objects when
entering values into Calc cells with the NVDA
screen reader in use, resulting in several
seconds of delay.

Querying up-to-date values from the underlying
UNO interfaces on demand instead of doing extra
manual bookkeeping in the winaccessibility code
may be possible for more a11y attributes in addition
to the accessible description handled in this commit,
but each one will have to be looked at separately.

Change-Id: I57f4c523ca8b10afad3f9c347c8ff5e9420ad968
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128006
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-01-06 10:10:11 +01:00
Stephan Bergmann 955ccb669c loplugin:nullptr (clang-cl)
Change-Id: I47ac4ff7d82eb5732ad54e3b42c18c3665c83b82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122845
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-10-01 08:32:40 +02:00