vcl/unx/gtk4/a11y.cxx              |    2 +-
 vcl/unx/gtk4/gtkaccessibletext.cxx |   22 +++++++++++++++++++++-
 vcl/unx/gtk4/gtkaccessibletext.hxx |    2 +-
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 8a0543f9fec90b0b7538fa5f219c9dc38b07ea34
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Mar 15 10:19:55 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Mar 15 14:00:37 2024 +0100

    gtk4 a11y: Report default text attributes
    
    Implement handling of default text attributes
    by implementing the GtkAccessibleTextInterface
    method `get_default_attributes` recently added to
    the GTK 4 API in GTK commit [1]
    
        commit fe64c998f82c218e46211984485a7a824a781426
        Author: Emmanuele Bassi <eba...@gnome.org>
        Date:   Sun Mar 3 14:23:37 2024 +0000
    
            a11y: Add GtkAccessibleText.get_default_attributes
    
    With this in place, the default font family for a Writer
    paragraph is now reported as expected.
    
    With the paragraph selected in Accerciser's treeview of
    the LO a11y hierarchy, this can be seen as follows using
    Accerciser's IPython console:
    
        In [4]: acc.queryText().getDefaultAttributes()
        Out[4]: 'family-name:Liberation Serif'
    
    This API is available from GTK 4.14.0 on, so bump
    the version check for the GtkAccessibleText
    implementation to that minimum version.
    
    [1] 
https://gitlab.gnome.org/GNOME/gtk/-/commit/fe64c998f82c218e46211984485a7a824a781426
    
    Change-Id: Id22bee4b7db542ddde241a4d94a7eb916090ba92
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164860
    Tested-by: Michael Weghorn <m.wegh...@posteo.de>
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx
index 41e49bf2845b..bfb6e38b0038 100644
--- a/vcl/unx/gtk4/a11y.cxx
+++ b/vcl/unx/gtk4/a11y.cxx
@@ -411,7 +411,7 @@ const struct
     GetGIfaceType const aGetGIfaceType;
     const css::uno::Type& (*aGetUnoType)();
 } TYPE_TABLE[] = {
-#if GTK_CHECK_VERSION(4, 13, 8)
+#if GTK_CHECK_VERSION(4, 14, 0)
     { "Text", reinterpret_cast<GInterfaceInitFunc>(lo_accessible_text_init),
       gtk_accessible_text_get_type, 
cppu::UnoType<css::accessibility::XAccessibleText>::get },
 #endif
diff --git a/vcl/unx/gtk4/gtkaccessibletext.cxx 
b/vcl/unx/gtk4/gtkaccessibletext.cxx
index 4d7853c054d4..51091e735327 100644
--- a/vcl/unx/gtk4/gtkaccessibletext.cxx
+++ b/vcl/unx/gtk4/gtkaccessibletext.cxx
@@ -19,7 +19,7 @@
 #include "a11y.hxx"
 #include "gtkaccessibletext.hxx"
 
-#if GTK_CHECK_VERSION(4, 13, 8)
+#if GTK_CHECK_VERSION(4, 14, 0)
 
 namespace
 {
@@ -202,6 +202,25 @@ static gboolean 
lo_accessible_text_get_attributes(GtkAccessibleText* self, unsig
     return true;
 }
 
+static void lo_accessible_text_get_default_attributes(GtkAccessibleText* self,
+                                                      char*** attribute_names,
+                                                      char*** attribute_values)
+{
+    css::uno::Reference<css::accessibility::XAccessibleText> xText = 
getXText(self);
+    if (!xText.is())
+        return;
+
+    css::uno::Reference<css::accessibility::XAccessibleTextAttributes> 
xAttributes(
+        xText, com::sun::star::uno::UNO_QUERY);
+    if (!xAttributes.is())
+        return;
+
+    css::uno::Sequence<css::beans::PropertyValue> aAttribs
+        = xAttributes->getDefaultAttributes(css::uno::Sequence<OUString>());
+
+    convertUnoTextAttributesToGtk(aAttribs, attribute_names, attribute_values);
+}
+
 void lo_accessible_text_init(GtkAccessibleTextInterface* iface)
 {
     iface->get_contents = lo_accessible_text_get_contents;
@@ -209,6 +228,7 @@ void lo_accessible_text_init(GtkAccessibleTextInterface* 
iface)
     iface->get_caret_position = lo_accessible_text_get_caret_position;
     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;
 }
 
 #endif
diff --git a/vcl/unx/gtk4/gtkaccessibletext.hxx 
b/vcl/unx/gtk4/gtkaccessibletext.hxx
index 3e8a08db0d73..82acc7db418f 100644
--- a/vcl/unx/gtk4/gtkaccessibletext.hxx
+++ b/vcl/unx/gtk4/gtkaccessibletext.hxx
@@ -11,7 +11,7 @@
 
 #include <gtk/gtk.h>
 
-#if GTK_CHECK_VERSION(4, 13, 8)
+#if GTK_CHECK_VERSION(4, 14, 0)
 
 void lo_accessible_text_init(GtkAccessibleTextInterface* iface);
 

Reply via email to