#include <config.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <atk/atktext.h>
#include <libspi/text.h>
+#include <libspi/spi-private.h>
/* Our parent Gtk object type */
#define PARENT_TYPE SPI_TYPE_BASE
return rv;
}
+static CORBA_string
+impl_getAttributeValue (PortableServer_Servant servant,
+ const CORBA_long offset,
+ const CORBA_char *attributename,
+ CORBA_long * startOffset,
+ CORBA_long * endOffset,
+ CORBA_boolean * defined,
+ CORBA_Environment *ev)
+{
+ AtkAttributeSet *set;
+ gint intstart_offset, intend_offset;
+ GSList *cur_attr;
+ CORBA_string rv = NULL;
+ AtkText *text = get_text_from_servant (servant);
+ AtkAttribute *at;
+
+ g_return_val_if_fail (text != NULL, CORBA_string_dup (""));
+
+ set = atk_text_get_run_attributes (text, offset,
+ &intstart_offset, &intend_offset);
+ *startOffset = intstart_offset;
+ *endOffset = intend_offset;
+ *defined = FALSE;
+ cur_attr = (GSList *) set;
+ while (cur_attr)
+ {
+ at = (AtkAttribute *) cur_attr->data;
+ if (!strcmp (at->name, attributename))
+ {
+ rv = CORBA_string_dup (at->value);
+ *defined = TRUE;
+ break;
+ }
+ cur_attr = cur_attr->next;
+ }
+ atk_attribute_set_free (set);
+ return (rv ? rv : CORBA_string_dup (""));
+}
+
+static CORBA_string
+impl_getDefaultAttributes (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ AtkAttributeSet *set;
+ CORBA_char *rv;
+ AtkText *text = get_text_from_servant (servant);
+
+ g_return_val_if_fail (text != NULL, CORBA_string_dup (""));
+
+ set = atk_text_get_default_attributes (text);
+
+ rv = _string_from_attribute_set (set);
+ atk_attribute_set_free (set);
+ return rv;
+}
static void
impl_getCharacterExtents (PortableServer_Servant servant,
g_return_if_fail (text != NULL);
+ atk_text_get_character_extents (text, startOffset,
+ &bounds.x, &bounds.y, &bounds.w, &bounds.h,
+ (AtkCoordType) coordType);
/* no equivalent ATK API yet, must do the hard way. :-( */
- for (i = startOffset; i > endOffset; i++)
+ for (i = startOffset + 1; i < endOffset; i++)
{
atk_text_get_character_extents (text, i,
&cbounds.x, &cbounds.y, &cbounds.w, &cbounds.h,
for (i = 0; i < len; ++i)
{
memcpy (&rangeList->_buffer[i], list->data, sizeof (Accessibility_Text_Range));
- spi_init_any_nil (&rangeList->_buffer[i].data);
+ rangeList->_buffer[i].data._type = TC_null;
+ rangeList->_buffer[i].data._value = NULL;
+ rangeList->_buffer[i].data._release = TRUE;
g_free (list->data);
list = g_slist_next (range_list);
}
int curr_offset;
gint minLineStart, minLineEnd, maxLineStart, maxLineEnd;
long bounds_min_offset;
+ long bounds_max_offset;
clip.x = x;
clip.y = y;
/* for horizontal text layouts, at least, the following check helps. */
bounds_min_offset = atk_text_get_offset_at_point (text, x, y,
(AtkCoordType) coordType);
+ bounds_max_offset = atk_text_get_offset_at_point (text, x + width, y + height,
+ (AtkCoordType) coordType);
atk_text_get_text_at_offset (text, bounds_min_offset,
ATK_TEXT_BOUNDARY_LINE_START,
&minLineStart, &minLineEnd);
- atk_text_get_text_at_offset (text, bounds_min_offset,
+ atk_text_get_text_at_offset (text, bounds_max_offset,
ATK_TEXT_BOUNDARY_LINE_START,
&maxLineStart, &maxLineEnd);
startOffset = MIN (minLineStart, maxLineStart);
- endOffset = MIN (minLineEnd, maxLineEnd);
+ endOffset = MAX (minLineEnd, maxLineEnd);
curr_offset = startOffset;
epv->getTextBeforeOffset = impl_getTextBeforeOffset;
epv->_get_caretOffset = impl__get_caretOffset;
epv->getAttributes = impl_getAttributes;
+ epv->getDefaultAttributes = impl_getDefaultAttributes;
epv->getCharacterExtents = impl_getCharacterExtents;
epv->_get_characterCount = impl__get_characterCount;
epv->getOffsetAtPoint = impl_getOffsetAtPoint;
epv->setCaretOffset = impl_setCaretOffset;
epv->getRangeExtents = impl_getRangeExtents;
epv->getBoundedRanges = impl_getBoundedRanges;
+ epv->getAttributeValue = impl_getAttributeValue;
}
static void
BONOBO_TYPE_FUNC_FULL (SpiText,
Accessibility_Text,
PARENT_TYPE,
- spi_text);
+ spi_text)
void
spi_text_construct (SpiText *text, AtkObject *obj)