X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=backend%2Fpdf%2Fev-poppler.cc;h=a3549b248b55d949ce44909763c049bda84c2cd6;hb=2fa78c4d755162b65978c1de43568742d075935a;hp=7c2c5281fb25cac868fc30afb879b982a3cfb15f;hpb=d8ed4cd9b3f558e51091632282aaaf39146fcb9b;p=evince.git diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc index 7c2c5281..a3549b24 100644 --- a/backend/pdf/ev-poppler.cc +++ b/backend/pdf/ev-poppler.cc @@ -92,8 +92,7 @@ static void pdf_document_file_exporter_iface_init (EvFileExporterIface static void pdf_selection_iface_init (EvSelectionIface *iface); static void pdf_document_page_transition_iface_init (EvDocumentTransitionIface *iface); static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails, - gint page, - gint size, + EvRenderContext *rc, gint *width, gint *height); static int pdf_document_get_n_pages (EvDocument *document); @@ -191,6 +190,8 @@ pdf_document_dispose (GObject *object) if (pdf_document->fonts_iter) { poppler_fonts_iter_free (pdf_document->fonts_iter); } + + G_OBJECT_CLASS (pdf_document_parent_class)->dispose (object); } static void @@ -1134,7 +1135,6 @@ pdf_document_images_get_images (EvDocumentImages *document_images, gint page) { GList *retval = NULL; -#ifdef HAVE_POPPLER_PAGE_GET_IMAGE_MAPPING PdfDocument *pdf_document; PopplerPage *poppler_page; GList *mapping_list; @@ -1163,7 +1163,7 @@ pdf_document_images_get_images (EvDocumentImages *document_images, poppler_page_free_image_mapping (mapping_list); g_object_unref (poppler_page); -#endif /* HAVE_POPPLER_PAGE_GET_IMAGE_MAPPING */ + return retval; } @@ -1174,32 +1174,15 @@ pdf_document_document_images_iface_init (EvDocumentImagesIface *iface) } static GdkPixbuf * -make_thumbnail_for_size (PdfDocument *pdf_document, - gint page, - int rotation, - gint size) +make_thumbnail_for_page (PdfDocument *pdf_document, + PopplerPage *poppler_page, + EvRenderContext *rc) { - PopplerPage *poppler_page; GdkPixbuf *pixbuf; int width, height; - double scale; - gdouble unscaled_width, unscaled_height; - - poppler_page = poppler_document_get_page (pdf_document->document, page); - g_return_val_if_fail (poppler_page != NULL, NULL); - pdf_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (pdf_document), page, - size, &width, &height); - poppler_page_get_size (poppler_page, &unscaled_width, &unscaled_height); - scale = width / unscaled_width; - - /* rotate */ - if (rotation == 90 || rotation == 270) { - int temp; - temp = width; - width = height; - height = temp; - } + pdf_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (pdf_document), + rc, &width, &height); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); @@ -1208,20 +1191,15 @@ make_thumbnail_for_size (PdfDocument *pdf_document, ev_document_fc_mutex_lock (); poppler_page_render_to_pixbuf (poppler_page, 0, 0, width, height, - scale, rotation, pixbuf); + rc->scale, rc->rotation, pixbuf); ev_document_fc_mutex_unlock (); - - - g_object_unref (poppler_page); return pixbuf; } static GdkPixbuf * pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails, - gint page, - gint rotation, - gint size, + EvRenderContext *rc, gboolean border) { PdfDocument *pdf_document; @@ -1231,18 +1209,17 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails pdf_document = PDF_DOCUMENT (document_thumbnails); - poppler_page = poppler_document_get_page (pdf_document->document, page); + poppler_page = poppler_document_get_page (pdf_document->document, rc->page); g_return_val_if_fail (poppler_page != NULL, NULL); pixbuf = poppler_page_get_thumbnail (poppler_page); - - if (pixbuf == NULL) { + if (!pixbuf) { /* There is no provided thumbnail. We need to make one. */ - pixbuf = make_thumbnail_for_size (pdf_document, page, rotation, size); + pixbuf = make_thumbnail_for_page (pdf_document, poppler_page, rc); } if (border) { - border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, rotation, pixbuf); + border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf); g_object_unref (pixbuf); pixbuf = border_pixbuf; } @@ -1254,8 +1231,7 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails, - gint page, - gint size, + EvRenderContext *rc, gint *width, gint *height) { @@ -1264,10 +1240,8 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail gint has_thumb; pdf_document = PDF_DOCUMENT (document_thumbnails); - poppler_page = poppler_document_get_page (pdf_document->document, page); + poppler_page = poppler_document_get_page (pdf_document->document, rc->page); - g_return_if_fail (width != NULL); - g_return_if_fail (height != NULL); g_return_if_fail (poppler_page != NULL); has_thumb = poppler_page_get_thumbnail_size (poppler_page, width, height); @@ -1276,9 +1250,19 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail double page_width, page_height; poppler_page_get_size (poppler_page, &page_width, &page_height); - *width = size; - *height = (int) (size * page_height / page_width); + + *width = (gint) (page_width * rc->scale); + *height = (gint) (page_height * rc->scale); } + + if (rc->rotation == 90 || rc->rotation == 270) { + gint temp; + + temp = *width; + *width = *height; + *height = temp; + } + g_object_unref (poppler_page); } @@ -1638,13 +1622,14 @@ pdf_selection_render_selection (EvSelection *selection, TRUE, 8, width, height); } - - poppler_page_render_selection (POPPLER_PAGE (rc->data), - rc->scale, rc->rotation, *pixbuf, - (PopplerRectangle *)points, - (PopplerRectangle *)old_points, - text, - base); + + poppler_page_render_selection_to_pixbuf (POPPLER_PAGE (rc->data), + rc->scale, rc->rotation, *pixbuf, + (PopplerRectangle *)points, + (PopplerRectangle *)old_points, + POPPLER_SELECTION_NORMAL, /* SelectionStyle */ + text, + base); } @@ -1700,7 +1685,6 @@ static gdouble pdf_document_get_page_duration (EvDocumentTransition *trans, gint page) { -#ifdef HAVE_POPPLER_PAGE_GET_DURATION PdfDocument *pdf_document; PopplerPage *poppler_page; gdouble duration = -1; @@ -1714,9 +1698,6 @@ pdf_document_get_page_duration (EvDocumentTransition *trans, g_object_unref (poppler_page); return duration; -#else - return -1; -#endif /* HAVE_POPPLER_PAGE_GET_DURATION */ } static void