+ page_cache = EV_VIEW (widget)->page_cache;
+ if (!page_cache)
+ return;
+
+ ev_view_get_page_extents (EV_VIEW (widget), EV_VIEW (widget)->current_page,
+ &page_area, &border);
+
+ scale = EV_VIEW (widget)->scale;
+ ev_page_cache_get_text_layout (page_cache, EV_VIEW (widget)->current_page, &areas, &n_areas);
+ if (!areas)
+ return;
+
+ if (offset > n_areas)
+ return;
+
+ rect = areas + offset;
+ *x = (int)(rect->x1 * scale);
+ *y = (int)(rect->y1 * scale);
+
+ *width = (int)(fabs (rect->x2 - rect->x1) * scale);
+ *height = (int)(fabs (rect->y2 - rect->y1) * scale);
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ gtk_widget_translate_coordinates (widget, toplevel, 0, 0, &x_widget, &y_widget);
+ *x += x_widget;
+ *y += y_widget;
+
+ if (coords == ATK_XY_SCREEN)
+ {
+ gdk_window_get_origin (toplevel->window, &x_window, &y_window);
+ *x += x_window;
+ *y += y_window;
+ }
+
+ *x -= EV_VIEW (widget)->scroll_x;
+ *y -= EV_VIEW (widget)->scroll_y;
+
+ *x += page_area.x;
+ *y += page_area.y;
+}