summaryrefslogtreecommitdiff
path: root/winaccessibility
AgeCommit message (Collapse)Author
2024-09-17wina11y: Drop unused CAccComponentBase::grabFocusMichael Weghorn
Accessible's `IAccessibleComponent` interface [1] has no `grabFocus` method and `CAccComponentBase::grabFocus`. Therefore, drop it. The `IAccessible` interface has an `IAccessible::accSelect` method that can be used to request focus by passing the `SELFLAG_TAKEFOCUS` flag [3], but that is implemented in `CMAccessible::accSelect`. [1] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/interface_i_accessible_component.html#a8709fdbf3f51ae079af274854a8bffd4 [2] https://learn.microsoft.com/en-us/windows/win32/api/oleacc/nf-oleacc-iaccessible-accselect [3] https://learn.microsoft.com/en-us/windows/win32/winauto/selflag Change-Id: I1ae99fdbf60aa18a041c086a73f9bd7c6a80cace Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173439 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-17wina11y: Drop unused CAccComponentBase::get_locationOnScreenMichael Weghorn
While IAccessible's `IAccessibleComponent` interface [1] has a `get_locationInParent` method and the implementation in `CAccComponent::get_locationInParent` calls the base class one, `CAccComponentBase::get_locationInParent`, there is no `IAccessibleComponent::get_locationOnScreen` equivalent, and `CAccComponentBase::get_locationOnScreen` is simply unused. Therefore, drop it. The `IAccessible` interface has a `IAccessible::accLocation` method to return the location on screen, but that is implemented in `CMAccessible::accLocation`. Therefore, drop `CAccComponentBase::get_locationOnScreen`. [1] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/interface_i_accessible_component.html#a8709fdbf3f51ae079af274854a8bffd4 [2] https://learn.microsoft.com/en-us/windows/win32/api/oleacc/nf-oleacc-iaccessible-acclocation Change-Id: I1a38844101b4eca10afdc6356c46156ad2091f82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173438 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-12tdf#91739 wina11y: Create AccObject for parent as necessaryMichael Weghorn
In `AccObjectWinManager::InsertAccObj`, when no HWND was explicitly passed, it is attempted to retrieve the HWND from the parent's `AccObject`. If no parent AccObject exists yet, create/insert that one first. This fixes the following assert seen when using NVDA's SayAll feature to read the whole document with sample document mentioned in NVDA issue [1], also attached as attachment 196385 in tdf#91739 for reference: Assertion failed: pIAccessible && "Couldn't retrieve IAccessible object for relation target.", file C:/tools/cygwin/home/user/development/git/libreoffice/winaccessibility/source/UAccCOM/MAccessible.cxx, line 2755 It's also reproducible when manually trying to get the next flows-to relation target via NVDA's Python console when the first cell in the table has focus: >>> focus.flowsTo The issue is not reproducible when focus had been in the second cell before, as an accessible object has already been created otherwise in that case. Backtrace: 1 abort ucrtbase 0x7fff3b72286e 2 get_wpgmptr ucrtbase 0x7fff3b7241b5 3 wassert ucrtbase 0x7fff3b7244f1 4 CMAccessible::get_relationTargetsOfType MAccessible.cxx 2755 0x7fff1e028729 5 NdrSendReceive RPCRT4 0x7fff3d4ca2d3 6 NdrStubCall2 RPCRT4 0x7fff3d4625a7 7 CStdStubBuffer_Invoke combase 0x7fff3cfbc4ac 8 RoGetAgileReference combase 0x7fff3cf669c3 9 RoGetAgileReference combase 0x7fff3cf6674e 10 HSTRING_UserSize combase 0x7fff3cfbefb6 11 DllGetClassObject combase 0x7fff3cf470b3 12 CoWaitForMultipleHandles combase 0x7fff3cf6774d 13 RoGetActivatableClassRegistration combase 0x7fff3cf2eb26 14 CoGetMarshalSizeMax combase 0x7fff3cf5cfba 15 CallWindowProcW USER32 0x7fff3ccbef5c 16 DispatchMessageW USER32 0x7fff3ccbe684 17 ImplSalDispatchMessage salinst.cxx 475 0x7ffed452d378 18 ImplSalYield salinst.cxx 552 0x7ffed452da9d 19 WinSalInstance::DoYield salinst.cxx 581 0x7ffed452cfa1 20 ImplYield svapp.cxx 385 0x7ffed78befc4 21 Application::Yield svapp.cxx 474 0x7ffed78c2cd2 22 Application::Execute svapp.cxx 361 0x7ffed78bc656 23 desktop::Desktop::Main app.cxx 1691 0x7ffeecf689b7 24 ImplSVMain svmain.cxx 228 0x7ffed78d3d4c 25 SVMain svmain.cxx 261 0x7ffed78d45a2 26 soffice_main sofficemain.cxx 121 0x7ffeecfb9064 27 sal_main main.c 51 0x7ff782681013 28 main main.c 49 0x7ff78268105a 29 __scrt_common_main_seh exe_common.inl 288 0x7ff782681344 30 BaseThreadInitThunk KERNEL32 0x7fff3bb07374 31 RtlUserThreadStart ntdll 0x7fff3d85cc91 [1] https://github.com/nvaccess/nvda/issues/8152#issuecomment-2342167620 Change-Id: I246251f06d1885e0da96600ffc7dd0549854382f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173224 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-09-12wina11y: Drop superfluous AccObject::m_pIMAcc null checksMichael Weghorn
The `AccObject` ctor already asserts it's non-null, so there's no need to check again in various places. Change-Id: Ibba363d326198a89e391a4da54cff25c95eef776 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173223 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-09-12wina11y: Move var decl to first assignmentMichael Weghorn
... and rename to use the "x" prefix for this uno::Reference. Change-Id: Ibf422aa48d6fbada49975fa8c5f43ad6c4c3ddee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173222 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-12wina11y: Move var declaration to where it's assignedMichael Weghorn
... and rename the variable to use the "x" prefix in line with naming conventions. Change-Id: Ife49161162654efdf1d543909218e31e464d2fc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173221 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-09-10wina11y: Drop suspicious fallthrough caseMichael Weghorn
Don't fallthrough from the `AccessibleEventId::TEXT_CHANGED` case to the `AccessibleEventId::VISIBLE_DATA_CHANGED` one. commit 3ec901fab2cb3e1a1c8222498761e72c28175bd3 Date: Wed May 25 08:38:19 2016 +0200 Mark dubious fallthrough cases as "SAL_FALLTHROUGH; //TODO ???" (in Win-only) had already added a TODO comment. The IAccessible2 IDL describes `IA2_EVENT_VISIBLE_DATA_CHANGED` like this: /** A visible data event indicates the change of the visual appearance of an accessible object. This includes for example most of the attributes available via the IAccessibleComponent interface. */ IA2_EVENT_VISIBLE_DATA_CHANGED, I see no real reason to always send that event as well when text is updated. In particular, since the description of the UNO equivalent `AccessibleEventId::VISIBLE_DATA_CHANGED` matches the IA2 one very closely, it should explicitly be sent by the corresponding XAccessible(Context) implementation in addition to the `AccessibleEventId::TEXT_CHANGED` event if there are cases where both events should actually be emitted on the platform layer rather than being implicitly added in the platform-specific a11y bridge. Change-Id: I00402e08278b0b0c70f8d784939344a952dfa668 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173120 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-09wina11y: Send IA2_EVENT_TEXT_UPDATED when text changesMichael Weghorn
When the text changes, don't only send an MSAA/IAccessible `EVENT_OBJECT_VALUECHANGE` [1] event, but also an IAccessible2 `IA2_EVENT_TEXT_UPDATED` [2] event in the Windows a11y bridge. As described at [2]: > This event indicates general text changes, i.e. changes to > text that are exposed through the IAccessibleText interface. This e.g. makes that event type be sent when the value/text in one of the editable combobox in Writer's "Formatting" toolbar changes, e.g. the font size, which exposes its current text via the IAccessibleText interface. [1] https://learn.microsoft.com/en-us/windows/win32/winauto/event-constants [2] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/_accessible_event_i_d_8idl.html#ae26846b6d521727ab696d20c3f43c0b5af9d3d9355e2cfd10b126d21513241609 Change-Id: I83d3f2299c59bd9da4246723f99d1c55a351e6d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173080 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-09wina11y: Replace deprecated IA2_EVENT_TEXT_CHANGEDMichael Weghorn
Send `IA2_EVENT_TEXT_UPDATED instead of the deprecated `IA2_EVENT_TEXT_CHANGED` event. Quoting from the IAccessible 2 doc [1]: > IA2_EVENT_TEXT_CHANGED: Deprecated. This event is > equivalent to IA2_EVENT_TEXT_UPDATED. [1] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/_accessible_event_i_d_8idl.html#ae26846b6d521727ab696d20c3f43c0b5af9d3d9355e2cfd10b126d21513241609 Change-Id: Iec1ba33ba4591c7608438dfdf7ac597e1746fc52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173079 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-30wina11y: Drop unused default params for AccObject ctorMichael Weghorn
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-30wina11y: Drop always null param from AccObject ctorMichael Weghorn
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-30wina11y: Drop unused AccObject::getListenerMichael Weghorn
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-29wina11y: Update comment now that IAccessible2 PR was mergedMichael Weghorn
IAccessible2 PR [1] was merged now as upstream commit [2] commit 2b8c2c79417bad4b464761a142fab45ffde8bfa8 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Thu Aug 29 07:55:56 2024 +0200 Add an "id" object attribute. (#31) , so is part of the official IAccessible2 object attribute specification now. [1] https://github.com/LinuxA11y/IAccessible2/pull/31 [2] https://github.com/LinuxA11y/IAccessible2/commit/2b8c2c79417bad4b464761a142fab45ffde8bfa8 Change-Id: Ia613a673b832d35bcc6e3801325dc9f55b393a2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172585 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-29tdf#155447 wina11y: Report accessible ID as "id" obj attributeMichael Weghorn
Report the accessible ID as an "id" object attribute. Firefox also already uses that object attribute. Pending PR suggesting to add the "id" attribute to the official IAccessible2 object attribute specification: [1] Sample use in NVDA's Python console, with the caret/focus in the Spelling dialog's "Not in Dictionary" edit: >>> focus.parent.IAccessibleObject.attributes 'id:sentence;' [1] https://github.com/LinuxA11y/IAccessible2/pull/31 Change-Id: I42250c3f46afbb2ab64c884d8bf5f2bf7d2a5ced Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172538 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-23tdf#91739 wina11y: Implement IAccessible2_2::get_relationTargetsOfTypeMichael Weghorn
Implement the `IAccessible2_2::get_relationTargetsOfType` method [1] in the Windows accessibility bridge. As described in NVDA issue comment [2], this method is the preferred way that NVDA uses to get e.g. the target object of the "flowsTo" relation. With this commit in place, retrieving the next Writer paragraph in the NVDA Python console using that relation now also works with the fallback code path in NVDA [3] dropped in a local build of NVDA: >>> focus.flowsTo <NVDAObjects.Dynamic_SymphonyParagraphSymphonyTextEditableTextWithAutoSelectDetectionIAccessible object at 0x0B8F5890> [1] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/interface_i_accessible2__2.html#a63f214b322c663caf01d4bb67277f5af [2] https://github.com/nvaccess/nvda/issues/4115#issuecomment-2299084993 [3] https://github.com/nvaccess/nvda/blob/df6bd0770db12ff73905251054d12f01911030dd/source/NVDAObjects/IAccessible/__init__.py#L1861-L1874 Change-Id: Ifcd15527b4a3f5302168942f19248a0ba9a4d306 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172258 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-23tdf#91739 wina11y: Add skeleton IAccessible2_2 implementationMichael Weghorn
Derive from the `IAccessible2_2` insterface [1] instead of directly from (its base interface) `IAccessible2` and add dummy implementations for the corresponding methods that return `E_NOTIMPL` to indicate that there's no real implementation yet. An actual implementations for at least `CMAccessible::get_relationTargetsOfType` is planned for a separate upcoming commit. Support for the interface can be checked e.g. in Accerciser's Python console: Before: >>> from comInterfaces import IAccessible2Lib as IA2 >>> focus.IAccessibleObject <POINTER(IAccessible2) ptr=0x9667f24 at 6841850> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2) <POINTER(IAccessible2) ptr=0x9667f24 at 6822120> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2_2) Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\tools\cygwin\home\user\development\git\nvda\.venv\Lib\site-packages\comtypes\__init__.py", line 831, in QueryInterface self.__com_QueryInterface(byref(iid), byref(p)) File "C:\tools\cygwin\home\user\development\git\nvda\source\monkeyPatches\comtypesMonkeyPatches.py", line 33, in __call__ return super().__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ctypes.COMError: (-2147467262, 'No such interface supported', (None, None, None, 0, None)) With this commit in place: >>> from comInterfaces import IAccessible2Lib as IA2 >>> focus.IAccessibleObject <POINTER(IAccessible2) ptr=0x988c784 at 6363580> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2) <POINTER(IAccessible2) ptr=0x988c784 at c55d7b0> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2_2) <POINTER(IAccessible2_2) ptr=0x974d824 at 6847f80> And calling one of the methods gives a "Not Implemented" COMError as expected: >>> ia2_2 = focus.IAccessibleObject.QueryInterface(IA2.IAccessible2_2) >>> ia2_2.attribute("dummy") Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\tools\cygwin\home\user\development\git\nvda\.venv\Lib\site-packages\comtypes\_memberspec.py", line 482, in __call__ return self.fget(self.instance, *args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ctypes.COMError: (-2147467263, 'Not implemented', (None, None, None, 0, None)) [1] https://github.com/LinuxA11y/IAccessible2/blob/34f96c2a28f4974ad488703b41599a6c6059a7e0/api/Accessible2_2.idl Change-Id: I77bed1f27353c4d08229ffe17afee03b813a4d4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172256 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-23wina11y: Explicitly map UNO to IA2 relation typeMichael Weghorn
Use switch/case to explicitly map from UNO's `AccessibleRelationType` to the IAccessible2 relation type strings, instead of implicitly using the integer values of the `AccessibleRelationType` as indices into a map. Let the caller allocate the string to return. Use `sal_Int16` for the `AccessibleRelationType` param to match the type of the actual integer values. Change-Id: I8c094d763ca602131a578f20719d00cad53088d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172257 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-23wina11y: Drop misleading commentMichael Weghorn
The methods have actual implementations, not just empty dummy implementations by now, so this // These methods only declare here, and their implementation bodies are empty now. is misleading, maybe was true in an earlier stage of the process of implementing IAccessible2 support? Change-Id: I4a50f7199e18766947322d040cac52c0585c2567 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172255 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-22wina11y: Use sal::systools::BStr::newBSTR here, tooMichael Weghorn
As commit 02c0e5f970dee4d064fcb26b378cbfe6f3a1bc05 Author: Mike Kaganski <mike.kaganski@collabora.com> Date: Wed Aug 21 13:42:28 2024 +0500 Simplify BSTR construction from OUString a bit did in other existing code, switch to using `sal::systools::BStr::newBSTR` in this case newly added in commit dfd23124096b9428f2f7084a24de032750389c79 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Wed Aug 21 10:16:51 2024 +0100 wina11y: Retrieve default action description on demand , merged shortly after existing code was adjusted. Change-Id: Ic27a31ce22410d6d976295336bf97ada3881788b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172236 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21tdf#91739 wina11y: Ensure IAccessible for relation target existsMichael Weghorn
When retrieving the `IAccessible` for the relation target's `XAccessible` and `CMAccessible::get_IAccessibleFromXAccessible` initially returns nullptr, insert the a corresponding object and retrieve it then. The same is already done in most places calling `CMAccessible::get_IAccessibleFromXAccessible`, e.g. `CAccTableCell::get_columnHeaderCells` or `CEnumVariant::Next`. This makes sure that a proper `IAccessible` is returned instead of triggering an error if no such object has been created yet. This is the case e.g. for off-screen paragraph objects in Writer that can still be accessed on the UNO a11y level via the `AccessibleRelationType::CONTENT_FLOWS_TO` relation. However, when testing with the test docs from tdf#91739, the issue even occured much earlier, with on-screen paragraphs already that weren't available via the FLOWS_TO relation from their preceding paragraphs. With this commit in place, having NVDA read out the whole sample documents using the NVDA + Down shortcut works now for the tdf#91739 sample docs, in the same way it already does for Orca on Linux. For more details, see also the previous analysis in NVDA ticket [1]. [1] https://github.com/nvaccess/nvda/issues/4115#issuecomment-2299084993 Change-Id: I2ef06c6efa368f10dcf5d917d781dabc8ce9a65f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172215 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21wina11y: Drop COM indirection to get other CMAccessible's XAccessibleMichael Weghorn
Instead of having a COM method `CMAccessible::GetUNOInterface` to get the `CMAccessible::m_xAccessible` for another `CMAccessible` via COM, simply cast the `IMAccessible` to `CMAccessible` and access the member directly. Change-Id: Ic91c6cde3eb1ebb2bfaabdeb0a5e38017233949c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172214 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Clarify + reduce variable scopeMichael Weghorn
In `CMAccessible::GetNavigateChildForDM`: * reduce scope of local variables and the union used only in one of the cases * don't reuse the `pChildXAcc` union member at the end of the method for something that's completely unrelated Change-Id: I2169bbf5a7af3c806181ab284294514ff68a1506 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172213 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Query XAccessibleAction iface on demandMichael Weghorn
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-21wina11y: Only require action iface for the actual objectMichael Weghorn
Quoting from the `IAccessible::accDoDefaultAction` doc [1] for the `varChild` param: > Specifies whether the default action belongs to the object > or one of the object's child elements. If the default object of a child and not the object itself should be triggered, there's no need for the object itself to also support actions itself. Therefore, only perform such a check in the `CHILDID_SELF` case. Also, return `S_FALSE` in case there's no action, as this is not a case of "An unknown or generic error occurred.", which is the meaning of `E_FAIL` [2]. as other places do move that check in `CMAccessible::get_accDefaultAction`, if a child object is specified instead of requesting [1] https://learn.microsoft.com/en-us/windows/win32/api/oleacc/nf-oleacc-iaccessible-accdodefaultaction [2] https://learn.microsoft.com/en-us/windows/win32/winauto/return-values Change-Id: Idcd3ab8a415e73e496cf027506428518a9f4a203 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172184 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Retrieve default action description on demandMichael Weghorn
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 fcf4a26275d7503835f9aa23cb94938809840300 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-21wina11y: Unify handling to set action descriptionMichael Weghorn
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-21wina11y: Drop AccObjectWinManager::GetRoleMichael Weghorn
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-21wina11y: Drop extra check in AccObjectWinManager::InsertAccObjMichael Weghorn
The `AccObject` ctor asserts that `AccObject::m_pIMAcc` is non-null, so there's no need to check here again. Change-Id: Ieb80dfa4f7229b63dbf53ed77ae54f8d4b1f5211 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172180 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Consistently assert COM obj creation succeedsMichael Weghorn
The `AccObject` ctor already has an assert that creating the COM object succeeded, so be consistent and drop additional checks still handling the theoretical case that it might have failed for some reason. (Running out of memory could be one, but we don't handle that case in other places that construct simple objects, e.g. using the `new` expression, either.) Change-Id: Ic71ca8a256f1e224f0050c2ee9b039d8823e577a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172179 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Add missing include in acccommon.hMichael Weghorn
This makes sure that typedefs like `REFGUID` and `LONG` are known and can e.g. be processed by Qt Creator's code model. The missing include was not causing build problems because the source files including acccommon.h include stdafx.h first themselves. Change-Id: Ifd93cdc263471314f6ed777ba71b15f2bff35417 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172178 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21wina11y: Drop AccObject::ImplInitializeCreateObjMichael Weghorn
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-21Simplify BSTR construction from OUString a bitMike Kaganski
Use the known string length into account (and I definitely like to not rely on the undocumented implementation detail that OUString is null-terminated). Change-Id: I0e7478d25e802f8f8e31f02cf8d77613c1325bc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172170 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-21wina11y: Drop superfluous check in CAccTable::get_accessibleAtMichael Weghorn
There's already a if(!pRAcc.is()) { *accessible = nullptr; return E_FAIL; } further up in that method, so no need to check again. Change-Id: Ifb855dce067b3bff5a654917e79817da72e156be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172153 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Retrieve a11y name on demandMichael Weghorn
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 fcf4a26275d7503835f9aa23cb94938809840300 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-21wina11y: Query new a11y name instead of passing it aroundMichael Weghorn
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-21wina11y: Use UNKNOWN as fallback for a11y roleMichael Weghorn
Let `AccEventListener::GetRole` return `AccessibleRole::UNKNOWN` in case there's no accessible object instead of -1. The latter doesn't map to any a11y role. This doesn't make any difference in practice right now, as none of the callers explicitly handles the UNKNOWN role either, but could e.g. simplify switching `AccessibleRole` from an integer type to an enum in the future. Change-Id: I8b0d78642621ce997d55d12905e31e7978962ec7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172124 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21wina11y: Drop special a11y name handling for paragraph/block quoteMichael Weghorn
The ARIA spec prohibits setting an a11y name for paragraphs [1], which may have been the reason why an empty name was always explicitly set in `AccObject::UpdateName`, and that was just extended to apply for the block quote role when that new role was added in commit f44eae4912e8f2ba34d93a71a609473df976a2cb Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Oct 27 14:53:59 2023 +0200 tdf#135586 a11y: Add a new BLOCK_QUOTE a11y role Wile it makes sense to always report an empty a11y name for paragraphs, ensuring that is not the task of the platform a11y bridge, but it should be done properly in the underlying `XAccessibleContext` implementation already, as this is not specific to Windows/IAccessible2. At least paragraphs in Writer already report an empty a11y name. If anything else doesn't, that should be fixed there. [1] https://w3c.github.io/aria/#paragraph Change-Id: I7ffd42acc02fc41cf73174e60c32e8938161c4d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172123 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Don't set a11y name that gets overwritten right awayMichael Weghorn
It's unclear to me why an a11y object of a TEXT_FRAME role with a SCROLL_PANE parent should be treated specially and use the a11y name of its parent. But the a11y name set this way is unconditionally overwritten right away in the lines below anyway. Therefore, just drop the special handling. Change-Id: I3cfe63e0882803524f51fe760d38880b30105317 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172122 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Just use ref instead of having extra pointer varMichael Weghorn
The extra null check for the pointer is also redundant, as there is a check for `xContext.is()` just above it. Change-Id: I9c0d0ab95c3031d8560506691e78e7994c5dce95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172121 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Drop duplicate check for a11y contextMichael Weghorn
The first thing that `AccTopWindowListener::AddAllListeners` does is to retrieve the accessible context and it returns if it's not valid, so there's no need to do check that already before calling the method. Change-Id: Ie825a9694b5c94bc9f9f2917ba5ae85e50670a66 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172120 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21wina11y: Drop extra pointer vars, just use the refMichael Weghorn
Change-Id: If373619e6b8203d2f2f88fac4d834d44cb6e346d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172119 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21wina11y: Don't use "m" prefix for local varsMichael Weghorn
The "m" prefix is for class members. Using it for local variable names is misleading. Change-Id: I79d62f59ac1093fcd9160ea4d8ae097d32eb40d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172118 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-08-21wina11y: Drop commented code and duplicate commentMichael Weghorn
Change-Id: I192fe62a666c86654b0352d202675c33a72bf89e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172152 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21wina11y: Drop unnecessary try/catchMichael Weghorn
Returning S_OK certainly won't throw. Change-Id: Ided99c26efb42cba21889890fa37d652d1e118ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172151 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-21wina11y: clang-format CAccRelationMichael Weghorn
This in particular ensures that try and catch blocks are indented by an additional indentation level as expected, increasing readability. Change-Id: Ic2c3c1500c07df75e3b606ab957a44b220f52194 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172150 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-13wina11y: clang-format CAccHypertextMichael Weghorn
This in particular ensures that try and catch blocks are indented by an additional indentation level as expected, increasing readability. Change-Id: I82af846dfe9707895d146406b6ed79b5a1f8a467 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171798 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-08-13wina11y: clang-format CAccHyperLinkMichael Weghorn
This in particular ensures that try and catch blocks are indented by an additional indentation level as expected, increasing readability. Change-Id: I8cfe89e80b9d8713a69037f1f5bda9ee7eaf782a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171797 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-06-14wina11y: Fix handling for special text offset -1Michael Weghorn
As described in the IAccessible2 spec [1], -1 can be used as a special text offset: > Using IA2_TEXT_OFFSET_LENGTH (-1) as an offset in any of the > IAccessibleText or IAccessibleEditableText methods is the same > as specifying the length of the string. Replace -1 by the text length *before* doing the check whether end offset is smaller than the start offset. Otherwise, trying to query the whole text of a Writer paragraph containing the text "hello" in NVDA's Python console would incorrectly trigger an error: >>> focus.IAccessibleTextObject.text(0,-1) Traceback (most recent call last): File "<console>", line 1, in <module> File "comtypes\__init__.pyc", line 856, in __call__ File "monkeyPatches\comtypesMonkeyPatches.pyc", line 32, in __call__ _ctypes.COMError: (-2147467259, 'Unspecified error', (None, None, None, 0, None)) With this commit in place, it works as expected: >>> focus.IAccessibleTextObject.text(0,-1) 'hello' [1] https://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/_general_info.html#_specialOffsets Change-Id: I489a42270a56178cc8ee0564eec3dc82e15969c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168853 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-05-07wina11y: Return E_INVALIDARG if out param is nullMichael Weghorn
Change-Id: Ia7abdd7fe1fbc5b1a6eaecf7d842852bc3815e6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167201 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-05-06WaE: C6011 Dereferencing NULL pointer warningsCaolán McNamara
Change-Id: I9659627ce90d6e23bbb3c27e01c365f1167b39ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167171 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>