offapi/com/sun/star/accessibility/XAccessibleEditableText.idl | 2 offapi/com/sun/star/accessibility/XAccessibleMultiLineText.idl | 4 vcl/unx/gtk4/gtkaccessibletext.cxx | 53 ++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-)
New commits: commit 23f13bc8c1aba9e53789180ef09ed06594ea4649 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 4 13:09:51 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 4 17:16:18 2024 +0200 gtk4 a11y: Implement new GtkAccessibleTextInterface::get_offset Implement the new `get_offset` method for `GtkAccessibleTextInterface` newly introduced in GTK 4 in GTK commits commit f802be88e98f817c3d6fa048bf79d82de60173d3 Author: Matthias Clasen <mcla...@redhat.com> Date: Sun Mar 10 10:27:56 2024 -0400 a11y: Use gtk_accessible_text_get_offset Implement GetOffsetAtPoint using gtk_accessible_text_get_offset. commit b9d2049991427e8dee443e9f3b683e52c96d6b83 Author: Matthias Clasen <mcla...@redhat.com> Date: Sun Mar 10 10:27:32 2024 -0400 a11y: Add gtk_accessible_text_get_offset This is not implemented yet. commit cfe35586107d7c42eb3af7aa38ee23df22f718d0 Author: Matthias Clasen <mcla...@redhat.com> Date: Sun Mar 10 10:02:24 2024 -0400 a11y: Add GetOffsetAtPoint We don't handle it yet. In order for this to actually work on the AT-SPI level, this also needs fixes on the GTK side. Pending MR: [1] With this, the previous Change-Id: I7d171b6696037a696f0d767d3134c7a7184f93a3 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Thu Apr 4 11:08:10 2024 +0200 gtk4 a11y: Implement new GtkAccessibleTextInterface::get_extents and the mentioned GTK MR in place, a quick test with a Writer paragraph using Accerciser's IPython console now looks OK: In [1]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW) Out[1]: (483, 219, 4, 18) In [2]: acc.queryText().getOffsetAtPoint(484, 220, pyatspi.XY_WINDOW) Out[2]: 5 [1] https://docs.gtk.org/atk/vfunc.Text.get_range_extents.html Change-Id: Ieb45e3d0d6f37350898ffee081491bf94b6dbea0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165794 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/unx/gtk4/gtkaccessibletext.cxx b/vcl/unx/gtk4/gtkaccessibletext.cxx index 40040fb52f1c..05a8a2fe6ba7 100644 --- a/vcl/unx/gtk4/gtkaccessibletext.cxx +++ b/vcl/unx/gtk4/gtkaccessibletext.cxx @@ -251,6 +251,23 @@ static gboolean lo_accessible_text_get_extents(GtkAccessibleText* self, unsigned return true; } + +static gboolean lo_accessible_text_get_offset(GtkAccessibleText* self, + const graphene_point_t* point, unsigned int* offset) +{ + css::uno::Reference<css::accessibility::XAccessibleText> xText = getXText(self); + if (!xText.is()) + return false; + + css::awt::Point aPoint(point->x, point->y); + const sal_Int32 nIndex = xText->getIndexAtPoint(aPoint); + + if (nIndex < 0) + return false; + + *offset = nIndex; + return true; +} #endif void lo_accessible_text_init(gpointer iface_, gpointer) @@ -264,6 +281,7 @@ void lo_accessible_text_init(gpointer iface_, gpointer) iface->get_default_attributes = lo_accessible_text_get_default_attributes; #if GTK_CHECK_VERSION(4, 15, 0) iface->get_extents = lo_accessible_text_get_extents; + iface->get_offset = lo_accessible_text_get_offset; #endif } commit 89f272c8bbcdb5e46ed051564735b46cc0023b8b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 4 11:08:10 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 4 17:16:12 2024 +0200 gtk4 a11y: Implement new GtkAccessibleTextInterface::get_extents Implement the new `get_extents` method for `GtkAccessibleTextInterface` newly introduced in GTK 4 in GTK commits commit 7955efef6c31d23c8553dc3464e72273886a4417 Author: Matthias Clasen <mcla...@redhat.com> Date: Sun Mar 10 14:28:07 2024 -0400 atspi: Use gtk_accessible_text_get_extents Implement the GetCharacterExtents and GetRangeExtents methods of the atspi Text interface using the new GtkAccessibleText api. commit 3134003376fc37c6d5e7e6eb7c6f36307039a92c Author: Matthias Clasen <mcla...@redhat.com> Date: Sun Mar 10 14:27:42 2024 -0400 a11y: Add gtk_accessible_text_get_extents This will be used to implement GetRangeExtents in atspi. The `XAccessibleText` UNO interface currently only has a way to retrieve the extents of a single character, so just return `false` if the extents for a larger text range is requested. (LO's gtk3/ATK implemenation currently also doesn't implement AtkText.get_range_extents` [1]) To actually work, this also needs changes on GTK side to support non-GtkWidget GtkAccessible implementations. Pending MR: [2] [1] https://docs.gtk.org/atk/vfunc.Text.get_range_extents.html [2] https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7104 Change-Id: I7d171b6696037a696f0d767d3134c7a7184f93a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165793 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/unx/gtk4/gtkaccessibletext.cxx b/vcl/unx/gtk4/gtkaccessibletext.cxx index 0dc9b8cd04a9..40040fb52f1c 100644 --- a/vcl/unx/gtk4/gtkaccessibletext.cxx +++ b/vcl/unx/gtk4/gtkaccessibletext.cxx @@ -221,6 +221,38 @@ static void lo_accessible_text_get_default_attributes(GtkAccessibleText* self, convertUnoTextAttributesToGtk(aAttribs, attribute_names, attribute_values); } +#if GTK_CHECK_VERSION(4, 15, 0) +static gboolean lo_accessible_text_get_extents(GtkAccessibleText* self, unsigned int start, + unsigned int end, graphene_rect_t* extents) +{ + css::uno::Reference<css::accessibility::XAccessibleText> xText = getXText(self); + if (!xText.is()) + return false; + + if (end != start + 1) + { + SAL_WARN("vcl.gtk", "lo_accessible_text_get_extents called for a text range of more than a " + "single character. This is not implemented yet."); + return false; + } + + if (start > o3tl::make_unsigned(xText->getCharacterCount())) + { + SAL_WARN("vcl.gtk", + "lo_accessible_text_get_extents called with invalid start index: " << start); + return false; + } + + com::sun::star::awt::Rectangle aBounds = xText->getCharacterBounds(start); + extents->origin.x = aBounds.X; + extents->origin.y = aBounds.Y; + extents->size.width = aBounds.Width; + extents->size.height = aBounds.Height; + + return true; +} +#endif + void lo_accessible_text_init(gpointer iface_, gpointer) { auto const iface = static_cast<GtkAccessibleTextInterface*>(iface_); @@ -230,6 +262,9 @@ void lo_accessible_text_init(gpointer iface_, gpointer) iface->get_selection = lo_accessible_text_get_selection; iface->get_attributes = lo_accessible_text_get_attributes; iface->get_default_attributes = lo_accessible_text_get_default_attributes; +#if GTK_CHECK_VERSION(4, 15, 0) + iface->get_extents = lo_accessible_text_get_extents; +#endif } #endif commit 164f344312768771a2e120236648e224322b4a2a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 4 11:01:00 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 4 17:16:05 2024 +0200 a11y: Fix XAccessible{Editable,Multiline}Text doc Fix typos and slightly improve wording. Change-Id: Ib58dcb4d6039a55ade76d12d5fed33f4eac84776 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165792 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/offapi/com/sun/star/accessibility/XAccessibleEditableText.idl b/offapi/com/sun/star/accessibility/XAccessibleEditableText.idl index 07d09c2fc00e..f0a0945b8b30 100644 --- a/offapi/com/sun/star/accessibility/XAccessibleEditableText.idl +++ b/offapi/com/sun/star/accessibility/XAccessibleEditableText.idl @@ -23,7 +23,7 @@ module com { module sun { module star { module accessibility { representation. <p>This interface is typically used in conjunction with the - XAccessibleText interface and extents it about the ability + XAccessibleText interface and extends it with the ability to modify the text represented by that interface.</p> @since OOo 1.1.2 diff --git a/offapi/com/sun/star/accessibility/XAccessibleMultiLineText.idl b/offapi/com/sun/star/accessibility/XAccessibleMultiLineText.idl index 048f302e2a96..f55eb20f51d0 100644 --- a/offapi/com/sun/star/accessibility/XAccessibleMultiLineText.idl +++ b/offapi/com/sun/star/accessibility/XAccessibleMultiLineText.idl @@ -19,11 +19,11 @@ module com { module sun { module star { module accessibility { -/** Implement this interface to give provide a mapping between text index +/** Implement this interface to provide a mapping between text index and line numbers. <p>This interface is typically used in conjunction with the - XAccessibleText interface and extents it with a notion + XAccessibleText interface and extends it with a notion of line numbers</p> @since OOo 3.0