X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=backend%2Fpdf%2Fev-poppler.cc;h=6d1c937a9401d231b6e1cec1d9d73831c7657f41;hb=1ff4db77238ee4f3b89c5cd7b94e3178e11fb543;hp=917529e100e92daf80e47938f10fe8e5c5c1ac30;hpb=516c4e3273b664ee2b10d6348d3484726f4461fd;p=evince.git diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc index 917529e1..6d1c937a 100644 --- a/backend/pdf/ev-poppler.cc +++ b/backend/pdf/ev-poppler.cc @@ -144,12 +144,16 @@ static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails gint *height); static int pdf_document_get_n_pages (EvDocument *document); -static EvLinkDest *ev_link_dest_from_dest (PdfDocument *pdf_document, - PopplerDest *dest); -static EvLink *ev_link_from_action (PdfDocument *pdf_document, - PopplerAction *action); -static void pdf_document_search_free (PdfDocumentSearch *search); -static void pdf_print_context_free (PdfPrintContext *ctx); +static EvLinkDest *ev_link_dest_from_dest (PdfDocument *pdf_document, + PopplerDest *dest); +static EvLink *ev_link_from_action (PdfDocument *pdf_document, + PopplerAction *action); +static void pdf_document_search_free (PdfDocumentSearch *search); +static void pdf_print_context_free (PdfPrintContext *ctx); +static gboolean attachment_save_to_buffer (PopplerAttachment *attachment, + gchar **buffer, + gsize *buffer_size, + GError **error); EV_BACKEND_REGISTER_WITH_CODE (PdfDocument, pdf_document, { @@ -1256,7 +1260,7 @@ pdf_document_links_get_links_model (EvDocumentLinks *document_links) static GList * pdf_document_links_get_links (EvDocumentLinks *document_links, - gint page) + EvPage *page) { PdfDocument *pdf_document; PopplerPage *poppler_page; @@ -1266,8 +1270,7 @@ pdf_document_links_get_links (EvDocumentLinks *document_links, double height; pdf_document = PDF_DOCUMENT (document_links); - poppler_page = poppler_document_get_page (pdf_document->document, - page); + poppler_page = POPPLER_PAGE (page->backend_page); mapping_list = poppler_page_get_link_mapping (poppler_page); poppler_page_get_size (poppler_page, NULL, &height); @@ -1289,7 +1292,6 @@ pdf_document_links_get_links (EvDocumentLinks *document_links, } poppler_page_free_link_mapping (mapping_list); - g_object_unref (poppler_page); return g_list_reverse (retval); } @@ -1324,7 +1326,7 @@ pdf_document_document_links_iface_init (EvDocumentLinksIface *iface) static GList * pdf_document_images_get_image_mapping (EvDocumentImages *document_images, - gint page) + EvPage *page) { GList *retval = NULL; PdfDocument *pdf_document; @@ -1333,7 +1335,7 @@ pdf_document_images_get_image_mapping (EvDocumentImages *document_images, GList *list; pdf_document = PDF_DOCUMENT (document_images); - poppler_page = poppler_document_get_page (pdf_document->document, page); + poppler_page = POPPLER_PAGE (page->backend_page); mapping_list = poppler_page_get_image_mapping (poppler_page); for (list = mapping_list; list; list = list->next) { @@ -1344,7 +1346,7 @@ pdf_document_images_get_image_mapping (EvDocumentImages *document_images, ev_image_mapping = g_new (EvMapping, 1); - ev_image_mapping->data = ev_image_new (page, image_mapping->image_id); + ev_image_mapping->data = ev_image_new (page->index, image_mapping->image_id); ev_image_mapping->area.x1 = image_mapping->area.x1; ev_image_mapping->area.y1 = image_mapping->area.y1; ev_image_mapping->area.x2 = image_mapping->area.x2; @@ -1354,7 +1356,6 @@ pdf_document_images_get_image_mapping (EvDocumentImages *document_images, } poppler_page_free_image_mapping (mapping_list); - g_object_unref (poppler_page); return g_list_reverse (retval); } @@ -2008,15 +2009,15 @@ pdf_selection_get_selection_region (EvSelection *selection, } static GdkRegion * -pdf_selection_get_selection_map (EvSelection *selection, - EvRenderContext *rc) +pdf_selection_get_selection_map (EvSelection *selection, + EvPage *page) { PopplerPage *poppler_page; PopplerRectangle points; GList *region; GdkRegion *retval; - poppler_page = POPPLER_PAGE (rc->page->backend_page); + poppler_page = POPPLER_PAGE (page->backend_page); points.x1 = 0.0; points.y1 = 0.0; @@ -2507,7 +2508,7 @@ ev_annot_from_poppler_annot (PopplerAnnot *poppler_annot, const gchar *unimplemented_annot = NULL; switch (poppler_annot_get_annot_type (poppler_annot)) { - case POPPLER_ANNOT_TEXT: + case POPPLER_ANNOT_TEXT: { PopplerAnnotText *poppler_text; EvAnnotationText *ev_annot_text; @@ -2517,8 +2518,41 @@ ev_annot_from_poppler_annot (PopplerAnnot *poppler_annot, ev_annot_text = EV_ANNOTATION_TEXT (ev_annot); ev_annot_text->is_open = poppler_annot_text_get_is_open (poppler_text); + } + break; +#ifdef HAVE_POPPLER_ANNOT_FILE_ATTACHMENT_GET_ATTACHMENT + case POPPLER_ANNOT_FILE_ATTACHMENT: { + PopplerAnnotFileAttachment *poppler_annot_attachment; + EvAnnotationAttachment *ev_annot_attachment; + PopplerAttachment *poppler_attachment; + gchar *data = NULL; + gsize size; + GError *error = NULL; + + poppler_annot_attachment = POPPLER_ANNOT_FILE_ATTACHMENT (poppler_annot); + poppler_attachment = poppler_annot_file_attachment_get_attachment (poppler_annot_attachment); + + if (poppler_attachment && + attachment_save_to_buffer (poppler_attachment, &data, &size, &error)) { + EvAttachment *ev_attachment; + + ev_attachment = ev_attachment_new (poppler_attachment->name, + poppler_attachment->description, + poppler_attachment->mtime, + poppler_attachment->ctime, + size, data); + ev_annot = ev_annotation_attachment_new (page, ev_attachment); + g_object_unref (ev_attachment); + } else if (error) { + g_warning ("%s", error->message); + g_error_free (error); + } + if (poppler_attachment) + g_object_unref (poppler_attachment); + } break; +#endif /* HAVE_POPPLER_ANNOT_FILE_ATTACHMENT_GET_ATTACHMENT */ case POPPLER_ANNOT_LINK: case POPPLER_ANNOT_WIDGET: /* Ignore link and widgets annots since they are already handled */