* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
*
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
{
SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
- if (!object)
- {
- return NULL;
- }
-
- return ATK_TEXT (object->atko);
+ g_return_val_if_fail (object, NULL);
+ g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL);
+ return ATK_TEXT (object->gobj);
}
static CORBA_string
g_return_val_if_fail (text != NULL, CORBA_string_dup (""));
- txt = atk_text_get_text (text, (gint) startOffset, (gint) endOffset);
+ txt = atk_text_get_text (text, startOffset, endOffset);
if (txt)
{
rv = CORBA_string_dup (txt);
g_return_val_if_fail (text != NULL, CORBA_string_dup (""));
txt = atk_text_get_text_after_offset (text,
- (gint) offset, (AtkTextBoundary) type,
+ offset, (AtkTextBoundary) type,
&intStartOffset, &intEndOffset);
- *startOffset = (CORBA_long) intStartOffset;
- *endOffset = (CORBA_long) intEndOffset;
+ *startOffset = intStartOffset;
+ *endOffset = intEndOffset;
if (txt)
{
CORBA_long * endOffset,
CORBA_Environment *ev)
{
- CORBA_char *txt;
+ gchar *txt;
CORBA_char *rv;
gint intStartOffset, intEndOffset;
AtkText *text = get_text_from_servant (servant);
g_return_val_if_fail (text != NULL, CORBA_string_dup (""));
- txt = (CORBA_char *) atk_text_get_text_at_offset (
+ txt = atk_text_get_text_at_offset (
text,
- (gint) offset, (AtkTextBoundary) type,
+ offset, (AtkTextBoundary) type,
&intStartOffset, &intEndOffset);
- *startOffset = (CORBA_long) intStartOffset;
- *endOffset = (CORBA_long) intEndOffset;
+ *startOffset = intStartOffset;
+ *endOffset = intEndOffset;
if (txt)
{
g_return_val_if_fail (text != NULL, 0);
- return (CORBA_unsigned_long)
- atk_text_get_character_at_offset (text, (gint) offset);
+ return atk_text_get_character_at_offset (text, offset);
}
g_return_val_if_fail (text != NULL, CORBA_string_dup (""));
txt = atk_text_get_text_before_offset (text,
- (gint) offset, (AtkTextBoundary) type,
+ offset, (AtkTextBoundary) type,
&intStartOffset, &intEndOffset);
- *startOffset = (CORBA_long) intStartOffset;
- *endOffset = (CORBA_long) intEndOffset;
+ *startOffset = intStartOffset;
+ *endOffset = intEndOffset;
if (txt)
{
g_return_val_if_fail (text != NULL, -1);
- return (CORBA_long) atk_text_get_caret_offset (text);
+ return atk_text_get_caret_offset (text);
+}
+
+
+static CORBA_char *
+_string_from_attribute_set (AtkAttributeSet *set)
+{
+ gchar *attributes, *tmp, *tmp2;
+ CORBA_char *rv;
+ GSList *cur_attr;
+ AtkAttribute *at;
+
+ attributes = g_strdup ("");
+ cur_attr = (GSList *) set;
+ while (cur_attr)
+ {
+ at = (AtkAttribute *) cur_attr->data;
+ tmp = g_strdup_printf ("%s%s:%s%s",
+ ((GSList *)(set) == cur_attr) ? "" : " ",
+ at->name, at->value,
+ (cur_attr->next) ? ";" : "");
+ tmp2 = g_strconcat (attributes, tmp, NULL);
+ g_free (tmp);
+ g_free (attributes);
+ attributes = tmp2;
+ cur_attr = cur_attr->next;
+ }
+ rv = CORBA_string_dup (attributes);
+ g_free (attributes);
+ return rv;
}
+
static CORBA_string
impl_getAttributes (PortableServer_Servant servant,
const CORBA_long offset,
CORBA_long * endOffset,
CORBA_Environment *ev)
{
+ AtkAttributeSet *set;
+ gint intstart_offset, intend_offset;
+ CORBA_char *rv;
AtkText *text = get_text_from_servant (servant);
g_return_val_if_fail (text != NULL, CORBA_string_dup (""));
- g_print ("getAttributes not yet implemented.\n");
-
- return CORBA_string_dup ("");
+ set = atk_text_get_run_attributes (text, offset,
+ &intstart_offset, &intend_offset);
+ *startOffset = intstart_offset;
+ *endOffset = intend_offset;
+ rv = _string_from_attribute_set (set);
+ atk_attribute_set_free (set);
+ return rv;
}
CORBA_Environment *ev)
{
AtkText *text = get_text_from_servant (servant);
+ gint ix, iy, iw, ih;
g_return_if_fail (text != NULL);
- /* FIXME: Casting a CORBA_long to a gint * is inherantly risky */
atk_text_get_character_extents (
- text, (gint) offset,
- (gint *) x, (gint *) y, (gint *) width, (gint *) height,
+ text, offset,
+ &ix, &iy, &iw, &ih,
(AtkCoordType) coordType);
+ *x = ix;
+ *y = iy;
+ *width = iw;
+ *height = ih;
}
impl__get_characterCount (PortableServer_Servant servant,
CORBA_Environment *ev)
{
- CORBA_long retval;
AtkText *text = get_text_from_servant (servant);
g_return_val_if_fail (text != NULL, 0);
- retval = (CORBA_long) atk_text_get_character_count (text);
-
- return retval;
+ return atk_text_get_character_count (text);
}
g_return_val_if_fail (text != NULL, -1);
- return (CORBA_long)
- atk_text_get_offset_at_point (text,
- (gint) x, (gint) y,
+ return atk_text_get_offset_at_point (text,
+ x, y,
(AtkCoordType) coordType);
}
g_return_val_if_fail (text != NULL, 0);
- return (CORBA_long) atk_text_get_n_selections (text);
+ return atk_text_get_n_selections (text);
}
CORBA_Environment *ev)
{
AtkText *text = get_text_from_servant (servant);
-
+ gint intStartOffset, intEndOffset;
+
g_return_if_fail (text != NULL);
- atk_text_get_selection (text, (gint) selectionNum,
- (gint *) startOffset, (gint *) endOffset);
+ /* atk_text_get_selection returns gchar* which we discard */
+ g_free (atk_text_get_selection (text, selectionNum,
+ &intStartOffset, &intEndOffset));
+
+ *startOffset = intStartOffset;
+ *endOffset = intEndOffset;
}
g_return_val_if_fail (text != NULL, FALSE);
- return (CORBA_boolean)
- atk_text_add_selection (text,
- (gint) startOffset, (gint) endOffset);
+ return atk_text_add_selection (text,
+ startOffset, endOffset);
}
g_return_val_if_fail (text != NULL, FALSE);
- return (CORBA_boolean)
- atk_text_remove_selection (text, (gint) selectionNum);
+ return atk_text_remove_selection (text, selectionNum);
}
g_return_val_if_fail (text != NULL, FALSE);
- return (CORBA_boolean)
- atk_text_set_selection (text,
- (gint) selectionNum, (gint) startOffset, (gint) endOffset);
+ return atk_text_set_selection (text,
+ selectionNum, startOffset, endOffset);
}
g_return_val_if_fail (text != NULL, FALSE);
- return (CORBA_boolean)
- atk_text_set_caret_offset (text, (gint) value);
-}
-
-
-static void
-impl_getRowColAtOffset (PortableServer_Servant servant,
- const CORBA_long offset, CORBA_long * row,
- CORBA_long * column, CORBA_Environment *ev)
-{
- AtkText *text = get_text_from_servant (servant);
-
- g_return_if_fail (text != NULL);
-
- g_print ("getRowColAtOffset not yet implemented\n");
+ return atk_text_set_caret_offset (text, value);
}
static void
void
spi_text_construct (SpiText *text, AtkObject *obj)
{
- spi_base_construct (SPI_BASE (text), obj);
+ spi_base_construct (SPI_BASE (text), G_OBJECT(obj));
}
+
SpiText *
spi_text_interface_new (AtkObject *obj)
{