From 4471f18895646541db4b1dd61254a3a0023b776e Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Fri, 6 Jun 2008 16:38:06 -0400 Subject: [PATCH] Add getCharacterAtOffset --- atk-adaptor/text.c | 30 +++++++++++++++++++++++++++++- xml/org.freedesktop.atspi.Text.xml | 13 ++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/atk-adaptor/text.c b/atk-adaptor/text.c index aa4f7a6..00ad9a9 100644 --- a/atk-adaptor/text.c +++ b/atk-adaptor/text.c @@ -242,6 +242,33 @@ impl_getTextAfterOffset (DBusConnection * bus, DBusMessage * message, } static DBusMessage * +impl_getCharacterAtOffset (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = get_text (message); + dbus_int32_t offset; + dbus_int32_t ch; + DBusError error; + DBusMessage *reply; + + if (!text) + return spi_dbus_general_error (message); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ch = atk_text_get_character_at_offset (text, offset); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &ch, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * impl_getAttributeValue (DBusConnection * bus, DBusMessage * message, void *user_data) { @@ -808,7 +835,7 @@ impl_getDefaultAttributeSet (DBusConnection * bus, DBusMessage * message, if (attributes) n_attributes = g_slist_length (attributes); - retval = (char **) malloc (n_attributes * sizeof (char *)); + retval = g_new (char *, n_attributes); for (i = 0; i < n_attributes; ++i) { @@ -835,6 +862,7 @@ static DRouteMethod methods[] = { {impl_getTextBeforeOffset, "getTextBeforeOffset"}, {impl_getTextAtOffset, "getTextAtOffset"}, {impl_getTextAfterOffset, "getTextAfterOffset"}, + {impl_getCharacterAtOffset, "getCharacterAtOffset"}, {impl_getAttributeValue, "getAttributeValue"}, {impl_getAttributes, "getAttributes"}, {impl_getDefaultAttributes, "getDefaultAttributes"}, diff --git a/xml/org.freedesktop.atspi.Text.xml b/xml/org.freedesktop.atspi.Text.xml index c27173f..a6f9b95 100644 --- a/xml/org.freedesktop.atspi.Text.xml +++ b/xml/org.freedesktop.atspi.Text.xml @@ -278,11 +278,18 @@ + + + + + an unsigned long integer whose value corresponds to the UCS-4 representation of the + character at the specified text offset, or 0 if offset is out of range. + long instead of wchar, to allow unicode chars > 16 bits + + + -

long instead of wchar, - to allow unicode chars > 16 bits

-

Get the string value of a named attribute at a given offset, if defined. @param offset the offset of the character for which the attribute run is to be obtained. @param attributeName the name of the attribute for which the value is to be returned, if defined. -- 2.7.4