[evince] Fix add_annotation() to update area based on bounding box
- From: Jose Aliste <jaliste src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] Fix add_annotation() to update area based on bounding box
- Date: Thu, 15 Mar 2018 03:16:50 +0000 (UTC)
commit 838fde1acf8e8c288ebe110ea67020277a10a7f8
Author: Nelson Benítez León <nbenitezl+gnome gmail com>
Date: Sat Dec 9 09:47:14 2017 +0500
Fix add_annotation() to update area based on bounding box
for Text Markup annotations, same way this is done if using
save_annotation().
When pdf_document_annotations_save_annotation() saves a Text Markup
annotation it will, prior to saving, update the area of annotation
to be based on its bounding box. But this was not being done if we
just used pdf_document_annotations_add_annotation() (because we
currently add annotations via a DnD operation that involves both
an initial add_annotation() plus subsequent save_annotation() calls
on motion_notify).
So this fix is needed to be able to correctly create a Text Markup
annotation by a single call to pdf_document_annotations_add_annotation()
Part of https://bugzilla.gnome.org/show_bug.cgi?id=763943
backend/pdf/ev-poppler.cc | 12 +++++++++++-
libview/ev-view.c | 2 ++
2 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index dc726c9..02802f1 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -3316,8 +3316,18 @@ pdf_document_annotations_add_annotation (EvDocumentAnnotations *document_annotat
break;
case EV_ANNOTATION_TYPE_TEXT_MARKUP: {
GArray *quads;
+ PopplerRectangle bbox;
- quads = get_quads_for_area (poppler_page, &rect, NULL);
+ quads = get_quads_for_area (poppler_page, &rect, &bbox);
+
+ if (bbox.x1 != 0 && bbox.y1 != 0 && bbox.x2 != 0 && bbox.y2 != 0) {
+ poppler_rect.x1 = rect.x1 = bbox.x1;
+ poppler_rect.x2 = rect.x2 = bbox.x2;
+ poppler_rect.y1 = rect.y1 = height - bbox.y2;
+ poppler_rect.y2 = rect.y2 = height - bbox.y1;
+
+ ev_annotation_set_area (annot, &rect);
+ }
switch (ev_annotation_text_markup_get_markup_type (EV_ANNOTATION_TEXT_MARKUP
(annot))) {
case EV_ANNOTATION_TEXT_MARKUP_HIGHLIGHT:
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 5a19a75..0156c30 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3397,6 +3397,8 @@ ev_view_create_annotation (EvView *view)
}
ev_document_annotations_add_annotation (EV_DOCUMENT_ANNOTATIONS (view->document),
annot, &doc_rect);
+ /* Re-fetch area as eg. adding Text Markup annots updates area for its bounding box */
+ ev_annotation_get_area (annot, &doc_rect);
ev_document_doc_mutex_unlock ();
/* If the page didn't have annots, mark the cache as dirty */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]