summaryrefslogtreecommitdiff
path: root/sw/source/core/access/accmap.cxx
AgeCommit message (Collapse)Author
2024-01-26sw a11y: Return MapMode instead of using out paramMichael Weghorn
Change-Id: I116e006e3fcdb3c6993adf7c99860bdd952af6e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162633 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-25sw a11y: Send SELECTION_CHANGED_{ADD,REMOVE} event for docMichael Weghorn
`AccessibleEventId::SELECTION_CHANGED_ADD` and `AccessibleEventId::SELECTION_CHANGED_REMOVE` events need to be sent for the selection container whose selection changed, not the child that was (un)selected. The latter should be set as the `NewValue` of the event, see the doc in offapi/com/sun/star/accessibility/AccessibleEventId.idl . Therefore, adjust the handling for (un)selected shapes in Writer: Set the doc view's a11y object as the source, just as it is already done for the `AccessibleEventId::SELECTION_CHANGED_WITHIN` case, and set the (un)selected shape as the `NewValue`. With a Writer doc having two shapes and the first one selected, clicking on the other one to switch selection to that one would previously result in this warning when using the qt6 VCL plugin with Orca running: warn:vcl.qt:114611:114611:vcl/qt6/../qt5/QtAccessibleEventListener.cxx:363: Selection add/remove event without the (un)selected accessible set warn:vcl.qt:114611:114611:vcl/qt6/../qt5/QtAccessibleEventListener.cxx:363: Selection add/remove event without the (un)selected accessible set Using gtk3 and this pyatspi script: #!/usr/bin/python3 import pyatspi def listener(e): try: if e.host_application.name != 'soffice': return except: return print(e) pyatspi.Registry.registerEventListener(listener, 'object:state-changed:selected') pyatspi.Registry.registerEventListener(listener, 'object:selection-changed') pyatspi.Registry.start() would previously give this output for that case: object:state-changed:selected(0, 0, 0) source: [panel | Shape 1] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [panel | Shape 1] host_application: [application | soffice] sender: [application | soffice] object:state-changed:selected(1, 0, 0) source: [panel | Shape 2] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [panel | Shape 2] host_application: [application | soffice] sender: [application | soffice] (i.e. both, the "state-changed:selected" as well as the "selection-changed" AT-SPI events were previously sent for the shapes.) With this change in place, this gives the expected output: object:state-changed:selected(0, 0, 0) source: [panel | Shape 1] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [document text | Untitled 1 - LibreOfficeDev Document] host_application: [application | soffice] sender: [application | soffice] object:state-changed:selected(1, 0, 0) source: [panel | Shape 2] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [document text | Untitled 1 - LibreOfficeDev Document] host_application: [application | soffice] sender: [application | soffice] Change-Id: Id2017f70a8e53043b4c303f69464ddd39f280097 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162519 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-25sw a11y: Drop special event handling for single selected shapeMichael Weghorn
If shape selecion changed, just send the same `AccessibleEventId::SELECTION_CHANGED_ADD` event(s) regardless of whether only a single or multiple shapes are selected. This unifies the handling and also prepares for sending the event with the correct source and `NewValue` set. The `AccessibleEventId::SELECTION_CHANGED` doc doesn't expclicitly mention whether the source should be the selection container (i.e. the parent, which is the doc view in the case here) or the selected object, and this is currently handled inconsistently across the codebase. I tend to think that this event should have the container as the source (just as for the `AccessibleEventId::SELECTION_CHANGED_ADD` case, that will be fixed in an upcoming commit), and this is at least what the handling e.g. in the gtk3 a11y bridge assumes (s. `AtkListener::notifyEvent`), but there seems to be no added value in handling the case of a single selected shape specially here in the first place. This may have been inspired by the MSAA/IAccessible equivalent, `EVENT_OBJECT_SELECTION` [1]: > The selection within a container object has changed. (...) This event > signals a single selection: either a child is selected in a container > that previously did not contain any selected children, or the selection > has changed from one child to another. But then, the selection taking place here might also be from multiple objects being selected to just a single one, and `SELECTION_CHANGED_REMOVE` is sent for any previously selected but now unselected shape anyway, so using `AccessibleEventId::SELECTION_CHANGED_ADD` seems more consistent to me anyway. [1] https://learn.microsoft.com/en-us/windows/win32/winauto/event-constants Change-Id: I1525ed27434bbbb4cf181df2148669c7bc6850b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162518 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-25sw a11y: Drop unnecessary cast to SwAccessiblePreviewMichael Weghorn
With Change-Id: I32d5bd2f81e7a69eacf92af1cf24249eb3a9f2a0 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Wed Jan 24 12:10:32 2024 +0100 sw a11y: Return SwAccessibleContext to avoid casting in place, `SwAccessibleMap::GetDocumentView_` returns the more concrete `rtl::Reference<SwAccessibleContext>`, and `SwAccessibleContext::InvalidateFocus` is what gets called here, so there's no need to cast to `SwAccessiblePreview` here. (The previous `static_cast` wasn't type-safe, so the extra null check after the cast didn't really add much value.) Change-Id: I4788d5e96570ceb0ffe97abfa9c48722cc90dc63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162517 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-25sw a11y: Return SwAccessibleContext to avoid castingMichael Weghorn
Let `SwAccessibleMap::GetDocumentView_` return the more concrete `rtl::Reference<SwAccessibleContext>` instead of `uno::Reference<XAccessible>`, which avoids having to cast in one place in `SwAccessibleMap::DoInvalidateShapeSelection` (and more places in upcoming changes). Replace the null check by an assert, as `SwAccessibleMap::GetDocumentView_` never returns an empty reference. Change-Id: I32d5bd2f81e7a69eacf92af1cf24249eb3a9f2a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162516 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-01-25sw a11y: Drop VEC_SHAPE typedefMichael Weghorn
Change-Id: Icd52756c729c5f8f4da1e6096e776a3a0d1a6260 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162515 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-12-22cid#1546500 COPY_INSTEAD_OF_MOVECaolán McNamara
and cid#1546492 COPY_INSTEAD_OF_MOVE cid#1546468 COPY_INSTEAD_OF_MOVE cid#1546431 COPY_INSTEAD_OF_MOVE cid#1546382 COPY_INSTEAD_OF_MOVE cid#1546350 COPY_INSTEAD_OF_MOVE cid#1546336 COPY_INSTEAD_OF_MOVE cid#1546314 COPY_INSTEAD_OF_MOVE cid#1546152 COPY_INSTEAD_OF_MOVE cid#1546094 COPY_INSTEAD_OF_MOVE cid#1546077 COPY_INSTEAD_OF_MOVE cid#1546047 COPY_INSTEAD_OF_MOVE cid#1545213 COPY_INSTEAD_OF_MOVE Change-Id: Ia51df9f9cbde755db4d2685e34f22676ed5eceff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161141 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-10cid#1545177 COPY_INSTEAD_OF_MOVECaolán McNamara
and cid#1545179 COPY_INSTEAD_OF_MOVE cid#1545187 COPY_INSTEAD_OF_MOVE cid#1545188 COPY_INSTEAD_OF_MOVE cid#1545189 COPY_INSTEAD_OF_MOVE cid#1545196 COPY_INSTEAD_OF_MOVE cid#1545197 COPY_INSTEAD_OF_MOVE cid#1545204 COPY_INSTEAD_OF_MOVE cid#1545223 COPY_INSTEAD_OF_MOVE cid#1545236 COPY_INSTEAD_OF_MOVE cid#1545239 COPY_INSTEAD_OF_MOVE cid#1545253 COPY_INSTEAD_OF_MOVE cid#1545274 COPY_INSTEAD_OF_MOVE cid#1545286 COPY_INSTEAD_OF_MOVE cid#1545309 COPY_INSTEAD_OF_MOVE cid#1545311 COPY_INSTEAD_OF_MOVE cid#1545345 COPY_INSTEAD_OF_MOVE cid#1545358 COPY_INSTEAD_OF_MOVE cid#1545361 COPY_INSTEAD_OF_MOVE cid#1545365 COPY_INSTEAD_OF_MOVE cid#1545367 COPY_INSTEAD_OF_MOVE cid#1545372 COPY_INSTEAD_OF_MOVE cid#1545373 COPY_INSTEAD_OF_MOVE cid#1545377 COPY_INSTEAD_OF_MOVE cid#1545392 COPY_INSTEAD_OF_MOVE cid#1545399 COPY_INSTEAD_OF_MOVE cid#1545404 COPY_INSTEAD_OF_MOVE cid#1545408 COPY_INSTEAD_OF_MOVE cid#1545430 COPY_INSTEAD_OF_MOVE cid#1545439 COPY_INSTEAD_OF_MOVE cid#1545449 COPY_INSTEAD_OF_MOVE Change-Id: I3afe836a0bbc8bd70937035e60eb020435e413d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160539 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-10-28tdf#135586 sw a11y: Use BLOCK_QUOTE role for "Block Quotation" paraMichael Weghorn
If a paragraph is using the "Block Quotation" paragraph style, report the newly introduced BLOCK_QUOTE a11y role for it instead of the PARAGRAPH role. This is similar to how the HEADING role is reported when one of the paragraph styles for headings is used (s. `SwAccessibleParagraph::GetRealHeadingLevel`). This is also in line with what is documented for mapping LO elements to tagged PDF elements in sw/inc/EnhancedPDFExportHelper.hxx: > * Mapping of OOo elements to tagged pdf elements: > * > * OOo element tagged pdf element > * ----------- ------------------ > * [...] > * SwFormat Quotations BlockQuote This makes the Orca screen reader with the gtk3 VCL plugin on Linux and the NVDA screen reader on Windows explicitly announce a paragraph as block quote when moving there with the cursor. Adapt some places that have specific handling for the PARAGRAPH role to take into account the BLOCK_QUOTE role as well. Change-Id: I4a89625c2a3f07d37df09e68cb7045a59cfff633 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158574 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-10-18use more SdrObjList::begin/end in swNoel Grandin
Change-Id: If882c1c7863618a313b2e06abacdbfa756dfff3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158114 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-09-01use concrete type for SwAccessibleShapeMap_ImplNoel Grandin
avoid some unnecessary casting Change-Id: I422428fa3c31141d73171a22c6c58242a1c1be2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156319 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-09-01use concrete type for SwAccessibleMap::mxCursorContextNoel Grandin
avoid some unnecessary casting Change-Id: I354ac67aa7a0c7f8ebe676315c66c97af31dc4e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156318 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-08-02split Point/Size/Rectangle into AbsoluteScreenPixel* typesNoel Grandin
to attempt to make it obvious in code what kind of coordinate system we are dealing with. The idea is that by doing this, the compile-time type checking will flush out inconsistencies between different code. I started with vcl::Window::OutputToAbsoluteScreenPixel and worked outwards from there. Change-Id: Ia967d7a0bb38886695f3a761b85c8b9340ddb1c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154676 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-05-17fire less "index hint out of range, ignoring" warningsNoel Grandin
after commit 3b7db802731826b6cc3b55100470b0c61c1f2dfa Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Thu May 4 10:06:14 2023 +0200 tdf#105404 [API CHANGE] add index to accessiblity change event Change-Id: I52d6b7b7368b780c1c9fdf60628311cb02429eff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151872 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-05-09Resolves: tdf#138512 don't crash on removing already Disposed a11y contextCaolán McNamara
Change-Id: I2a8f3d10a1349de233e11d841f7f244e4e513b2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151582 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-05-07improve some usage of OInterfaceIteratorHelper4Noel Grandin
we can drop the lock immediately after construction (since the iterator holds a thread-safe COW link to the underlying listener container) Change-Id: I08f8fa9ed7393747938572097f3c25f5f3f847fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151440 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-05-04tdf#105404 [API CHANGE] add index to accessiblity change eventNoel Grandin
Which shaves 80% off the time off breaking up a vector image on Linux. Change-Id: Id8e7daad001b6120d1fb98e382357da5b55e92ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151352 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-28fix type checks of raw SdrObject's in writerNoel Grandin
Which are no longer possible since SdrObject is abstract now. I assume the original code was gunning for the kind of objects that were being created before commit 24a374ebc9da56cc6721e8feaa1e15ba850bf41d tdf#154040 use a SdrObjKind::NewFrame for frame creation in writer Instead of (ab)using SdrObjKind::NONE for the temporary, empty Since that is only explanation that makes sense Change-Id: I0c3a26cc303ab7d54193beacb285c69aaf98a63e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151170 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
2023-04-28Revert "remove dead code in SwDrawModellListener_Impl::Notify"Noel Grandin
This reverts commit e8c265d06a9f34fec382d67c65c38189f16ee323. Reason for revert: I misunderstood how the isType is working here Change-Id: Ic4fcedd02affa6df58b74b4cad231cfdf6288592 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151124 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-28fix regression in "tdf#119388 add new UNO listener/broadcaster"Noel Grandin
Upon further inspection, I note that part of the the code I added in commit ec940941e0bd7db15c5cf7d43df82226e0d849dc Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Tue Aug 20 17:03:13 2019 +0200 tdf#119388 add new UNO listener/broadcaster would never have been able to be hit. Re-arrange a little to fix that. Change-Id: I537102d768591e5fa0ec2fb4b52b05dad4d26f29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151140 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-28remove dead code in SwDrawModellListener_Impl::NotifyNoel Grandin
The isType<SdrObject>(pSdrHint->GetObject()) ) ) code has always been unconditionally true, because SdrHint has always returned an SdrObject, ever since it was introduced in commit 12b8488b9cf659adcafd4b998227397c57cf51ba Author: Vladimir Glazounov <vg@openoffice.org> Date: Wed Jul 9 08:16:20 2003 +0000 INTEGRATION: CWS sw020 (1.44.80); FILE MERGED 2003/07/01 11:50:20 od 1.44.80.1: #110554# <SwDrawModellListener_Impl::Notify(..)> - correction: no broadcast of notifications for writer fly frames and plane <SdrObject>-objects. Change-Id: I67e6576f0670856259edee35aaf001401e67d98d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151139 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-27tdf#136749 no need to use maMutex in SwAccessibleMapNoel Grandin
we already need to be running under the SolarMutex, so just use that. Shaves some 5% off time here. Change-Id: Ife13f44d2e52171638bebcee946f5a1f07248cb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151062 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-26tdf#136749 std::map -> unordered_mapNoel Grandin
considerably faster when looking up pointers, shaves 10% of time off here Change-Id: I521f8d557a30e4f430caab6b0701ad8da65f99f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151063 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-20tdf#153754 "Insert" - "Chart" in Writer hangsNoel Grandin
Revert "osl::Mutex->std::mutex in SwAccessibleMap" This reverts commit 2442fc19400e0e82b0375d3772a2e0b34a511600. We have a recursive call stack that does not look easy to fix #7 0x00007fffc2214c18 in std::unique_lock<std::mutex>::unique_lock(std::mutex&) (this=0x7fffffff1c28, __m=...) at /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_lock.h:69 #8 0x00007fffc22b6c06 in SwAccessibleMap::AppendEvent(SwAccessibleEvent_Impl const&) (this=0x55555b7e3aa0, rEvent=...) at sw/source/core/access/accmap.cxx:980 #9 0x00007fffc22b7f8c in SwAccessibleMap::InvalidateCursorPosition(com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> const&) (this=0x55555b7e3aa0, rAcc=uno::Reference to (SwAccessibleParagraph *) 0x55555b7cff00) at sw/source/core/access/accmap.cxx:1117 #10 0x00007fffc22bd595 in SwAccessibleMap::GetContext(SwFrame const*, bool) (this=0x55555b7e3aa0, pFrame=0x55555b6e68a0, bCreate=true) at sw/source/core/access/accmap.cxx:1924 #11 0x00007fffc22bd83f in SwAccessibleMap::GetContextImpl(SwFrame const*, bool) (this=0x55555b7e3aa0, pFrame=0x55555b6e68a0, bCreate=true) at sw/source/core/access/accmap.cxx:1935 #12 0x00007fffc228c8e8 in SwAccessibleContext::InvalidateChildPosOrSize(sw::access::SwAccessibleChild const&, SwRect const&) (this=0x55555b7e0630, rChildFrameOrObj=..., rOldFrame=SwRect = {...}) at sw/source/core/access/acccontext.cxx:1227 #13 0x00007fffc22b5540 in SwAccessibleMap::FireEvent(SwAccessibleEvent_Impl const&) (this=0x55555b7e3aa0, rEvent=...) at sw/source/core/access/accmap.cxx:936 #14 0x00007fffc22b8216 in SwAccessibleMap::FireEvents() (this=0x55555b7e3aa0) at sw/source/core/access/accmap.cxx:3019 Change-Id: If058cecf7bc7503d0767526c07c0ca2840b3638a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147314 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-17osl::Mutex->std::mutex in SwAccessibleMapNoel Grandin
Change-Id: If7499b3fb165c904d32c9404161a7cdb2e29e5d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147187 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-16osl::Mutex->std::mutex in SwDrawModellListener_ImplNoel Grandin
Change-Id: I150ac67a3f053046a6d6a7cd79323fa4595078c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147105 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-13tdf#150708 if the old is CARET_OR_STATES then try updating itCaolán McNamara
with the additional states. Hard to know if this is a sensible approach. Change-Id: I0d55d41c4dd9cbb17fb736e5145671cd6a8b25ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145460 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-31use more GetAnchorContentOffsetNoel Grandin
Change-Id: I0c5f1bbe04a1888bb20a0aaba207d3787bff250b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144884 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-11-25use more SwFormatAnchor::GetAnchorNode methodNoel Grandin
as a step towards switching away from using SwPosition inside SwFormatAnchor (because SwFormatAnchor wants to do weird stuff with the internals of SwPosition) Change-Id: Ie6d4f45c959f87599d1cd0890ca8a693dd147be1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143294 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-02[API CHANGE] tdf#150683 a11y: Switch a11y child index to 64 bitMichael Weghorn
With 16k column support in Calc enabled by default in commit 4c5f8ccf0a2320432b8fe91add1dcadf54d9fd58 Date: Tue Mar 8 12:44:49 2022 +0100 change default Calc number of columns to 16384 (tdf#50916) , the number of Calc cells in a spreadsheet is larger than SAL_MAX_INT32, meaning that a 32-bit a11y child index is no more enough and using it resulted in integer overflows in methods handling corresponding Calc cells in the a11y layer. This e.g. had the effect of the Orca and NVDA screen readers not announcing focused or selected cells properly when their a11y child index was out of the 32-bit integer range. Switch the internal a11y child indices to 64 bit to be able to handle this properly internally. Since the platform APIs (at least AT-SPI on Linux and IAccessible2 on Windows; from what I can see LO's macOS a11y bridge doesn't directly expose the child index) are still restricted to 32 bit, larger child indices still cannot be exposed via the platform APIs. As a consequence, use of the the IAccessible2 and AT-SPI methods that use the child index remains problematic in those cases where the child index is larger. However, as an alternative to using the AT-SPI Table interface and the IAccessibleTable/ IAccessibleTable2 interfaces with the child index to retrieve information about a specific cell, both AT-SPI and IAccessible2 also provide interfaces to retrieve that information directly from the cell object (TableCell interface for AT-SPI, IAccessibleTableCell for IAccessible2). Those interfaces are already implemented/exposed for winaccessibility (s. `CAccTable`) and the qt5/qt6/kf5 VCL plugins (s. the `QAccessibleTableCellInterface` methods implemented in `QtAccessibleInterface`). With the switch to 64-bit internal a11y child indices, these now behave correctly for cells with a child index that doesn't fit into 32 bit as well. NVDA on Windows already uses the IAccessibleTableCell interface and thus announcing focused cells works fine with this change in place. Orca on Linux currently doesn't make use of the AT-SPI TableCell interface yet, but with a suggested change to do so [1], announcement of selected cells works with the qt6 VCL plugin with a current qtbase dev branch as well - when combined with the suggested changes to implement support for the AT-SPI TableCell interface in Qt [2] [3] and the LO change based on that [4] and a fix for a nullptr dereference [5]. The gtk3 VCL plugin doesn't expose the AT-SPI TableCell interface yet, but once it does so (via `AtkTableCell`), it also works with the suggested Orca change [1] in place. (Adding that is planned for an upcoming change, works with a local WIP patch.) For handling return values that are larger than what platform APIs support, the following approach has been chosen for now: 1) When the return value is for the count of (selected) children, the maximum value N supported by the platform API is returned. (This is what `ScAccessibleTableBase::getAccessibleChildCount` did previously.) The first N elements can be accessed by their actual (selection) indices. 2) When the return value is the child/cell index, -2 is returned for objects whose index is greater than the maximum value supported by the platform API. Using a non-negative value would mean that the index would refer to *another* actually existing child. A child index of -1 on the other hand tends to be interpreted as "child is invalid" or "object isn't actually a child of its (previous) parent any more)". For the Orca case, this would result in objects with a child index of -1 not being announced, as they are considered "zombies" [6]. What's still somewhat problematic is the case where more than 2^31 children are *selected*, since access to those children still happens by the index into the selection in the platform APIs, and not all selected items are accessible this way. (Screen readers usually just retrieve the first and last element from the selection and announce those.) Orca already seems to apply different handling for the case for fully selected rows and columns, so "All cells selected" or "Columns ... to ... selected" is announced just fine even if more than 2^31 cells are selected. (Side note: While Microsoft User Interface Automation - UIA - also uses 32-bit indices, it also has specific methods in the ISelectionProvider2 interface that allow to explicitly retrieve the first and last selected item, `ISelectionProvider2::get_FirstSelectedItem` and `ISelectionProvider2::get_LastSelectedItem`, but we currently don't support UIA on Windows.) Bound checks at the beginning of the methods from the `XAccessibleContext`, `XAccessibleSelection` and `XAccessibleTable` interfaces that take a child index (or in helper methods called by those) should generally already prevent too large indices from being passed to the methods in the lower layer code that take smaller integer types. Such bound checking has been been added in various places where it wasn't present yet. If there any remaining issues of this kind that show after this commit, they can probably be solved in a similar way (s.e.g. the change to `AccessibleBrowseBox::getAccessibleChild` in this commit). A few asserts were also added at places where my understanding is that values shouldn't be larger than what is supported by a called method anyway. A test case will be added in a following change. [1] https://gitlab.gnome.org/GNOME/orca/-/merge_requests/131 [2] https://codereview.qt-project.org/c/qt/qtbase/+/428566 [3] https://codereview.qt-project.org/c/qt/qtbase/+/428567 [4] https://gerrit.libreoffice.org/c/core/+/138750 [5] https://codereview.qt-project.org/c/qt/qtbase/+/430157 [6] https://gitlab.gnome.org/GNOME/orca/-/blob/82c8542002e36e0d3d918088d583162d25136143/src/orca/script_utilities.py#L5155 Change-Id: I3af590c988b0e6754fc72545918412f39e8fea07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139258 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-08-31tdf#150676 sw a11y: Remove item from selection list on disposeMichael Weghorn
As reported in tdf#150676, selecting a table (or also just simple text paragraphs) in Writer, then deleting the selection would result in the following warning when using the gtk3 VCL plugin: warn:legacy.osl:100403:100403:sw/source/core/access/acccontext.cxx:442: fire event for disposed frame? This is because the code responsible for sending a11y events for selection updates gets called after the a11y objects of the previous selection have been disposed already and wants to send an event that the object has been unselected: > 1 SwAccessibleContext::FireAccessibleEvent acccontext.cxx 444 0x7f4ffc5be7a2 > 2 SwAccessibleContext::FireStateChangedEvent acccontext.cxx 475 0x7f4ffc5be8c2 > 3 SwAccessibleContext::SetSelectedState acccontext.cxx 1508 0x7f4ffc5c3752 > 4 SwAccessibleMap::InvalidateShapeInParaSelection accmap.cxx 1428 0x7f4ffc5ea0fd > 5 SwAccessibleMap::InvalidateCursorPosition accmap.cxx 2671 0x7f4ffc5f119d > 6 SwViewShellImp::InvalidateAccessibleCursorPosition viewimp.cxx 415 0x7f4ffd515c32 > 7 SwCursorShell::UpdateCursor crsrsh.cxx 2029 0x7f4ffc745e06 > 8 SwCursorShell::EndAction crsrsh.cxx 278 0x7f4ffc73d4a7 > 9 SwActContext::~SwActContext edws.cxx 169 0x7f4ffccd45d4 > 10 SwWrtShell::DelRight delete.cxx 322 0x7f4ffdc5a454 > 11 SwBaseShell::ExecDelete basesh.cxx 229 0x7f4ffd9e304d > 12 SfxStubSwBaseShellExecDelete swslots.hxx 2173 0x7f4ffd9e2784 > 13 SfxDispatcher::Call_Impl dispatch.cxx 254 0x7f5039ab6f72 > 14 SfxDispatcher::Execute_ dispatch.cxx 753 0x7f5039aba37c > 15 SfxBindings::Execute_Impl bindings.cxx 1060 0x7f5039aa62b7 > 16 SfxDispatchController_Impl::dispatch unoctitm.cxx 701 0x7f5039b7a55e > 17 SfxOfficeDispatch::dispatch unoctitm.cxx 263 0x7f5039b7840d > 18 svt::(anonymous namespace)::AsyncAccelExec::impl_ts_asyncCallback acceleratorexecute.cxx 481 0x7f5036a40cfc > 19 svt::(anonymous namespace)::AsyncAccelExec::LinkStubimpl_ts_asyncCallback acceleratorexecute.cxx 473 0x7f5036a40c1d > 20 Link<LinkParamNone *, void>::Call link.hxx 111 0x7f50336ac77f > ... To prevent that, remove the entry from the map of selected frames as well right when the object gets disposed. If necessary, sending the corresponding event that the item has been unselected should probably be done here, but it currently seems to be of little value to me when the object gets deleted anyway, so this commit doesn't add sending an additional event here. While at it, convert the `OSL_ENSURE` to a `SAL_WARN`. Warning in case `FireAccessibleEvent` gets called on an already disposed object generally seems reasonable to me. Change-Id: I879ba4e6399ffdc61e38093c5a9bd2ae620888e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139039 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-08-26cid#1500578 silence Dereference after null checkCaolán McNamara
Change-Id: I693efc4707d8ce8e0aacb43f86581cb4fcbdc1df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138863 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-08-22cid#1500530 return early to silence Dereference after null checkCaolán McNamara
Change-Id: Ia549ae31c7f13d70228620ffb4bce78ea95ba083 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138673 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-08-22cid#1500675 return early to silence Dereference after null checkCaolán McNamara
Change-Id: If43b82c9db4517e24cc3c6d8b61a38624e6243b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138663 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-08-20cid#1500474 rearrange to avoid Dereference after null checkCaolán McNamara
Change-Id: I0cb4a8bc80b73fe6048540fc368096131ae0c231 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138575 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-08-18Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxxStephan Bergmann
...so that its TOOLS_WARN_EXCEPTION can be used in comphelper/source/misc/logging.cxx in a follow-up commit. (And while at it, rename from diangose_ex.h to the more appropriate diagnose_ex.hxx. The comphelper module is sufficiently low-level for this immediate use case, so use that at least for now; o3tl might be even more suitable but doesn't have a Library until now. Also, for the immediate use case it would have sufficed to only break DbgGetCaughtException, exceptionToString, TOOLS_WARN_EXCEPTION, TOOLS_WARN_EXCEPTION_IF, and TOOLS_INFO_EXCEPTION out of include/tools/diagnose_ex.h into an additional new include/comphelper/diagnose_ex.hxx, but its probably easier overall to just move the complete include file as is.) Change-Id: I9f3222d4ccf1a9ac29d7eb9ba1530d53e2affaee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138451 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-18loplugin:moveitNoel Grandin
Change-Id: I34de7408553e4ca702cab9aa611c03dc60b9b6a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138472 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-14use more SwPosition::GetNode instead of nNodeNoel Grandin
as part of the process of hiding the internals of SwPosition. This just changes the places we are passing nNode to the constructor of SwNodeIndex Change-Id: I3dffba5df6c044a69da27b6a1254592695b976af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138200 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-12clang-tidy modernize-pass-by-value in swNoel Grandin
Change-Id: I9a3b33595e34a264baeede33672a0c090ae85157 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138134 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-02introduce SwPosition::GetContentIndexNoel Grandin
as part of the process of hiding the internals of SwPosition largely done by doing: git grep -lF 'nContent.GetIndex' | xargs perl -pi -e 's/\bnContent\.GetIndex/GetContentIndex/g' Change-Id: I12684071a6666c365dbadbab2a4b37cf51b274d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137695 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-02introduce SwPosition::GetNodeIndexNoel Grandin
as part of the process of hiding the internals of SwPosition largely done by doing: git grep -lF 'nNode.GetIndex' | xargs perl -pi -e 's/\bnNode\.GetIndex/GetNodeIndex/g' Change-Id: I3616cea4c47595afe74f1aa8e3be553279f25d44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137694 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-02introduce SwPosition::GetNodeNoel Grandin
as part of the process of hiding the internals of SwPosition largely done by doing: git grep -lF 'nNode.GetNode' | xargs perl -pi -e 's/nNode\.GetNode/GetNode/g' Change-Id: Id1937df1bd5a54677c2c1bbfb2d693a4e22a7b98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137671 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-29use more SwPaM::StartEndNoel Grandin
which is more efficient than calling Start() and End() separately Change-Id: I41c99527bcb37728bb9a87f63ed654e0be3d1f0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137614 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-03-28Recheck sw/ cxx files with IWYUGabor Kelemen
See tdf#42949 for motivation Change-Id: I8a8df68946297fad517b753d73e4373203a45ed6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132150 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-02-12Fix some tautological std::type_info (in-)equality comparisonsStephan Bergmann
...which could never succeed. I became aware of this when Clang 15 trunk -std=c++2b, implementing <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1328r1.html> "Making std::type_info::operator== constexpr", pointed at two of the broken comparisons with > sw/source/uibase/app/docsh2.cxx:478:25: error: code will never be executed [-Werror,-Wunreachable-code] > pTmpFrame->GetFrame().Appear(); > ^~~~~~~~~ > sw/source/uibase/app/docsh2.cxx:475:33: error: code will never be executed [-Werror,-Wunreachable-code] > bOnly = false; > ^~~~~ (It didn't emit warnings pointing at any of the other broken comparisons, though.) All of these broken comparisons were regressions introduced with 89d39bc100aabf5dccbe77c0b5c0c85736e85b39 "tdf#94559: 4th step to remove rtti.hxx", replacing uses of the IS_TYPE macro (from include/tools/rtti.hxx, meanwhile removed with d64e535fe9a00b671cf1be3eb5632c0d5f4b8bea "Remove unused rtti.hxx"). I now added loplugin:typeidcomparison to also find the other broken comparisons introduced by that commit. (The remaining cases where that commit replaced uses of TYPE_INFO with typeid comparisons were correct and/or have meanwhile been replaced with code not using typeid, see 553ee72041d6f66e26156eb1ad0d9e3c13457f7a "simplify some use of typeid" and d656da9bc4f2df0bb99c65a288847e3fdd43a37c "~SwModify: do not silently tolerate clients registered past death".) The original IS_TYPE macro made sure not to dereference null pointers, > #define IS_TYPE(T,pObj) \ > ( pObj && (pObj)->Type() == TYPE(T) ) I don't know if any of the pointers now dereferenced in those typeid expressions can legitimately be null. But to be on the safe side, I replicated that check in the newly introduced isType (sw/inc/istype.hxx). (It is interesting to note that none of the static analysis that we routinely employ seems to have noticed these broken comparisons.) Change-Id: I65baffdd27bac1abf744283ff98c2dc864fa63b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129865 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-02-09sw a11y: Drop custom implementations of std::lessMichael Weghorn
SwFrameFunc's operator() just applied the less-than operator which is the same as 'std::less<const SwFrame*>' does. The latter is the default for the 'Compare' template argument of a 'std::map' with key type 'const SwFrame*>' anyway, so there's no need to specify any explicitly. The same applies for 'SwShapeFunc' accordingly. Change-Id: I2472b38d04dd6d280bfb825d750a6d67c2d9797c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129682 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-01-22Use o3tl::convert instead of OutputDevice::LogicToLogicMike Kaganski
Change-Id: Ifb7be992c6e951692a741d10ed24ec8b3836982a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128782 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-12-21Typo: "seleted" instead of "selected"Julien Nabet
Except "getSeletedPositionStart" and "getSeletedPositionEnd" defined in offapi/com/sun/star/accessibility/XAccessibleTextSelection.idl since e5618f1707626a8c096ea2ca8da3cbe2c5f3db16 author Steve Yin <steve_y@apache.org> 2013-11-16 23:58:19 +0100 committer Michael Meeks <michael.meeks@collabora.com> 2013-11-19 10:02:25 +0000 commit e5618f1707626a8c096ea2ca8da3cbe2c5f3db16 (patch) tree de014d37b3de5a7ab505a86a6e6ce46ade4bdc1f parent 1263b20f56d896706c982ad1b91d2936abf5d617 (diff) Integrate branch of IAccessible2 Change-Id: I814923003bb247c4ef66f296ac4033bae9073988 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127227 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-12-01use more OInterfaceContainerHelper3 in swNoel Grandin
Change-Id: Icb194de0521bf60f3db623c35e695afc3a3edbcc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125982 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-10-21introduce SwNodeOffset strong typedefNoel Grandin
for indexing into node children. Replaces various usage of sal_uLong, tools::Long, sal_uInt32 with an underlying type of sal_Int32. Also add a NODE_OFFSET_MAX constant to replace usage of ULONG_MAX Change-Id: I2f466922e1ebc19029bb2883d2b29aa4c0614170 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123892 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>