[evince/wip/remove-annotations: 5/6] pdf: Implement remove_annotation virtual func



commit 886ae624bfe7ecbcdaef78fec531b89d8c0001f7
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Fri May 2 23:17:04 2014 -0700

    pdf: Implement remove_annotation virtual func
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649044

 backend/pdf/ev-poppler.cc |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index f418191..664c6aa 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -3091,6 +3091,39 @@ pdf_document_annotations_document_is_modified (EvDocumentAnnotations *document_a
 }
 
 static void
+pdf_document_annotations_remove_annotation (EvDocumentAnnotations *document_annotations,
+                                           EvAnnotation          *annot)
+{
+       PopplerPage   *poppler_page;
+       PdfDocument   *pdf_document;
+       EvPage        *page;
+       PopplerAnnot  *poppler_annot;
+       EvMappingList *mapping_list;
+       EvMapping     *annot_mapping;
+       GList         *list;
+
+       poppler_annot = POPPLER_ANNOT (g_object_get_data (G_OBJECT (annot), "poppler-annot"));
+        pdf_document = PDF_DOCUMENT (document_annotations);
+        page = ev_annotation_get_page (annot);
+        poppler_page = POPPLER_PAGE (page->backend_page);
+
+       /* We don't check for pdf_document->annots, if it were NULL
+          then something is really wrong */
+       mapping_list = (EvMappingList *)g_hash_table_lookup (pdf_document->annots,
+                                                            GINT_TO_POINTER (page->index));
+       if (mapping_list) {
+               annot_mapping = ev_mapping_list_find (mapping_list,
+                                                     annot);
+               ev_mapping_list_remove (mapping_list, annot_mapping);
+       }
+
+       poppler_page_remove_annot (poppler_page, poppler_annot);
+       g_object_unref (poppler_annot);
+
+       pdf_document->annots_modified = TRUE;
+}
+
+static void
 pdf_document_annotations_add_annotation (EvDocumentAnnotations *document_annotations,
                                         EvAnnotation          *annot,
                                         EvRectangle           *rect)
@@ -3260,6 +3293,7 @@ pdf_document_document_annotations_iface_init (EvDocumentAnnotationsInterface *if
        iface->document_is_modified = pdf_document_annotations_document_is_modified;
        iface->add_annotation = pdf_document_annotations_add_annotation;
        iface->save_annotation = pdf_document_annotations_save_annotation;
+       iface->remove_annotation = pdf_document_annotations_remove_annotation;
 }
 
 /* Attachments */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]