static AtkAttributeSet* ev_page_accessible_get_run_attributes (AtkText *text, gint offset, gint *start_offset, gint *end_offset) { EvPageAccessible *self = EV_PAGE_ACCESSIBLE (text); EvView *view = ev_page_accessible_get_view (self); PangoAttrList *attrs; const gchar *page_text; if (offset < 0) return NULL; if (!view->page_cache) return NULL; page_text = ev_page_cache_get_text (view->page_cache, self->priv->page); if (!page_text) return NULL; attrs = ev_page_cache_get_text_attrs (view->page_cache, self->priv->page); if (!attrs) return NULL; return get_run_attributes (attrs, page_text, offset, start_offset, end_offset); }
static GtkTextBuffer * ev_view_accessible_get_text_buffer (EvViewAccessible *accessible, EvView *view) { EvPageCache *page_cache; const gchar *retval = NULL; EvViewAccessiblePriv* priv = EV_VIEW_ACCESSIBLE_GET_PRIVATE (accessible); page_cache = view->page_cache; if (!page_cache) { return NULL; } if (view->current_page == priv->current_page && priv->buffer) { return priv->buffer; } priv->current_page = view->current_page; if (!priv->buffer) { priv->buffer = gtk_text_buffer_new (NULL); } retval = ev_page_cache_get_text (page_cache, view->current_page); if (retval) gtk_text_buffer_set_text (priv->buffer, retval, -1); return priv->buffer; }
static gint ev_page_accessible_get_character_count (AtkText *text) { EvPageAccessible *self = EV_PAGE_ACCESSIBLE (text); EvView *view = ev_page_accessible_get_view (self); gint retval; retval = g_utf8_strlen (ev_page_cache_get_text (view->page_cache, self->priv->page), -1); return retval; }
static gchar * ev_page_accessible_get_substring (AtkText *text, gint start_offset, gint end_offset) { EvPageAccessible *self = EV_PAGE_ACCESSIBLE (text); EvView *view = ev_page_accessible_get_view (self); gchar *substring, *normalized; const gchar* page_text; if (!view->page_cache) return NULL; page_text = ev_page_cache_get_text (view->page_cache, self->priv->page); start_offset = MAX (0, start_offset); if (end_offset < 0 || end_offset > g_utf8_strlen (page_text, -1)) end_offset = strlen (page_text); substring = g_utf8_substring (page_text, start_offset, end_offset); normalized = g_utf8_normalize (substring, -1, G_NORMALIZE_NFKC); g_free (substring); return normalized; }