Commit eb80ecd1 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[libdocument] Use EvPage instead of EvRenderContext in get_selected_text()

It doesn't depend on scale and rotation so we only need the page.
parent d92e0160
...@@ -443,7 +443,7 @@ djvu_text_copy (DjvuDocument *djvu_document, ...@@ -443,7 +443,7 @@ djvu_text_copy (DjvuDocument *djvu_document,
static gchar * static gchar *
djvu_selection_get_selected_text (EvSelection *selection, djvu_selection_get_selected_text (EvSelection *selection,
EvRenderContext *rc, EvPage *page,
EvSelectionStyle style, EvSelectionStyle style,
EvRectangle *points) EvRectangle *points)
{ {
...@@ -453,13 +453,13 @@ djvu_selection_get_selected_text (EvSelection *selection, ...@@ -453,13 +453,13 @@ djvu_selection_get_selected_text (EvSelection *selection,
gchar *text; gchar *text;
djvu_document_get_page_size (EV_DOCUMENT (djvu_document), djvu_document_get_page_size (EV_DOCUMENT (djvu_document),
rc->page, &width, &height); page, &width, &height);
rectangle.x1 = points->x1 / SCALE_FACTOR; rectangle.x1 = points->x1 / SCALE_FACTOR;
rectangle.y1 = (height - points->y2) / SCALE_FACTOR; rectangle.y1 = (height - points->y2) / SCALE_FACTOR;
rectangle.x2 = points->x2 / SCALE_FACTOR; rectangle.x2 = points->x2 / SCALE_FACTOR;
rectangle.y2 = (height - points->y1) / SCALE_FACTOR; rectangle.y2 = (height - points->y1) / SCALE_FACTOR;
text = djvu_text_copy (djvu_document, rc->page->index, &rectangle); text = djvu_text_copy (djvu_document, page->index, &rectangle);
if (text == NULL) if (text == NULL)
text = g_strdup (""); text = g_strdup ("");
......
...@@ -1960,7 +1960,7 @@ pdf_selection_render_selection (EvSelection *selection, ...@@ -1960,7 +1960,7 @@ pdf_selection_render_selection (EvSelection *selection,
static gchar * static gchar *
pdf_selection_get_selected_text (EvSelection *selection, pdf_selection_get_selected_text (EvSelection *selection,
EvRenderContext *rc, EvPage *page,
EvSelectionStyle style, EvSelectionStyle style,
EvRectangle *points) EvRectangle *points)
{ {
...@@ -1969,7 +1969,7 @@ pdf_selection_get_selected_text (EvSelection *selection, ...@@ -1969,7 +1969,7 @@ pdf_selection_get_selected_text (EvSelection *selection,
double height; double height;
char *retval; char *retval;
poppler_page = POPPLER_PAGE (rc->page->backend_page); poppler_page = POPPLER_PAGE (page->backend_page);
poppler_page_get_size (poppler_page, NULL, &height); poppler_page_get_size (poppler_page, NULL, &height);
r.x1 = points->x1; r.x1 = points->x1;
......
...@@ -53,13 +53,13 @@ ev_selection_render_selection (EvSelection *selection, ...@@ -53,13 +53,13 @@ ev_selection_render_selection (EvSelection *selection,
gchar * gchar *
ev_selection_get_selected_text (EvSelection *selection, ev_selection_get_selected_text (EvSelection *selection,
EvRenderContext *rc, EvPage *page,
EvSelectionStyle style, EvSelectionStyle style,
EvRectangle *points) EvRectangle *points)
{ {
EvSelectionInterface *iface = EV_SELECTION_GET_IFACE (selection); EvSelectionInterface *iface = EV_SELECTION_GET_IFACE (selection);
return iface->get_selected_text (selection, rc, style, points); return iface->get_selected_text (selection, page, style, points);
} }
GdkRegion * GdkRegion *
......
...@@ -61,7 +61,7 @@ struct _EvSelectionInterface ...@@ -61,7 +61,7 @@ struct _EvSelectionInterface
GdkColor *text, GdkColor *text,
GdkColor *base); GdkColor *base);
gchar * (* get_selected_text) (EvSelection *selection, gchar * (* get_selected_text) (EvSelection *selection,
EvRenderContext *rc, EvPage *page,
EvSelectionStyle style, EvSelectionStyle style,
EvRectangle *points); EvRectangle *points);
GdkRegion * (* get_selection_map) (EvSelection *selection, GdkRegion * (* get_selection_map) (EvSelection *selection,
...@@ -82,7 +82,7 @@ void ev_selection_render_selection (EvSelection *selection, ...@@ -82,7 +82,7 @@ void ev_selection_render_selection (EvSelection *selection,
GdkColor *text, GdkColor *text,
GdkColor *base); GdkColor *base);
gchar *ev_selection_get_selected_text (EvSelection *selection, gchar *ev_selection_get_selected_text (EvSelection *selection,
EvRenderContext *rc, EvPage *page,
EvSelectionStyle style, EvSelectionStyle style,
EvRectangle *points); EvRectangle *points);
GdkRegion *ev_selection_get_selection_map (EvSelection *selection, GdkRegion *ev_selection_get_selection_map (EvSelection *selection,
......
...@@ -5523,10 +5523,8 @@ get_selected_text (EvView *view) ...@@ -5523,10 +5523,8 @@ get_selected_text (EvView *view)
GString *text; GString *text;
GList *l; GList *l;
gchar *normalized_text; gchar *normalized_text;
EvRenderContext *rc;
text = g_string_new (NULL); text = g_string_new (NULL);
rc = ev_render_context_new (NULL, view->rotation, view->scale);
ev_document_doc_mutex_lock (); ev_document_doc_mutex_lock ();
...@@ -5536,19 +5534,14 @@ get_selected_text (EvView *view) ...@@ -5536,19 +5534,14 @@ get_selected_text (EvView *view)
gchar *tmp; gchar *tmp;
page = ev_document_get_page (view->document, selection->page); page = ev_document_get_page (view->document, selection->page);
ev_render_context_set_page (rc, page);
g_object_unref (page);
tmp = ev_selection_get_selected_text (EV_SELECTION (view->document), tmp = ev_selection_get_selected_text (EV_SELECTION (view->document),
rc, selection->style, page, selection->style,
&(selection->rect)); &(selection->rect));
g_object_unref (page);
g_string_append (text, tmp); g_string_append (text, tmp);
g_free (tmp); g_free (tmp);
} }
g_object_unref (rc);
ev_document_doc_mutex_unlock (); ev_document_doc_mutex_unlock ();
normalized_text = g_utf8_normalize (text->str, text->len, G_NORMALIZE_NFKC); normalized_text = g_utf8_normalize (text->str, text->len, G_NORMALIZE_NFKC);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment