summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-04-04 11:08:10 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-04-04 17:16:12 +0200
commit89f272c8bbcdb5e46ed051564735b46cc0023b8b (patch)
tree1a7433ccd0fc2c52f1c9eb805b2b336f62819d25 /vcl/unx
parent164f344312768771a2e120236648e224322b4a2a (diff)
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 <mclasen@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 <mclasen@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.weghorn@posteo.de>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk4/gtkaccessibletext.cxx35
1 files changed, 35 insertions, 0 deletions
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