From 328815b3caf7e136ce6f5f7927bb7cc651a3fb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Sat, 28 Sep 2013 23:18:07 -0700 Subject: [PATCH] glib: Add getter and setter for annotation's rectangle Annotation objects contain at least two keys, Rect and Subtype. The former has the coordinates where the annotation is placed. The getter and setter allows to obtain and modify the position of a given annotation. https://bugs.freedesktop.org/show_bug.cgi?id=70901 --- glib/poppler-annot.cc | 48 +++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 4 +++ glib/reference/poppler-sections.txt | 2 ++ 3 files changed, 54 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 33c17f0..170632c 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -2,6 +2,7 @@ * * Copyright (C) 2007 Inigo Martinez * Copyright (C) 2009 Carlos Garcia Campos + * Copyright (C) 2013 German Poo-Caamano * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -678,6 +679,53 @@ poppler_annot_get_page_index (PopplerAnnot *poppler_annot) return page_num <= 0 ? -1 : page_num - 1; } +/** + * poppler_annot_get_rectangle: + * @poppler_annot: a #PopplerAnnot + * @poppler_rect: (out): a #PopplerRectangle to store the annotation's coordinates + * + * Retrieves the rectangle representing the page coordinates where the + * annotation @poppler_annot is placed. + * + * If @poppler_annot is an invalid annotation, then @poppler_rect is not set. + * + * Since: 0.26 + */ +void +poppler_annot_get_rectangle (PopplerAnnot *poppler_annot, + PopplerRectangle *poppler_rect) +{ + PDFRectangle *annot_rect; + + g_return_if_fail (POPPLER_IS_ANNOT (poppler_annot)); + + annot_rect = poppler_annot->annot->getRect (); + poppler_rect->x1 = annot_rect->x1; + poppler_rect->x2 = annot_rect->x2; + poppler_rect->y1 = annot_rect->y1; + poppler_rect->y2 = annot_rect->y2; +} + +/** + * poppler_annot_set_rectangle: + * @poppler_annot: a #PopplerAnnot + * @poppler_rect: a #PopplerRectangle with the new annotation's coordinates + * + * Move the annotation to the rectangle representing the page coordinates + * where the annotation @poppler_annot should be placed. + * + * Since: 0.26 + */ +void +poppler_annot_set_rectangle (PopplerAnnot *poppler_annot, + PopplerRectangle poppler_rect) +{ + g_return_if_fail (POPPLER_IS_ANNOT (poppler_annot)); + + poppler_annot->annot->setRect (poppler_rect.x1, poppler_rect.y1, + poppler_rect.x2, poppler_rect.y2); +} + /* PopplerAnnotMarkup */ /** * poppler_annot_markup_get_label: diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h index b632acf..15f8634 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -186,6 +186,10 @@ PopplerColor *poppler_annot_get_color ( void poppler_annot_set_color (PopplerAnnot *poppler_annot, PopplerColor *poppler_color); gint poppler_annot_get_page_index (PopplerAnnot *poppler_annot); +void poppler_annot_get_rectangle (PopplerAnnot *poppler_annot, + PopplerRectangle *poppler_rect); +void poppler_annot_set_rectangle (PopplerAnnot *poppler_annot, + PopplerRectangle poppler_rect); /* PopplerAnnotMarkup */ GType poppler_annot_markup_get_type (void) G_GNUC_CONST; diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index 5e5e413..a2fb25f 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -392,6 +392,8 @@ poppler_annot_set_color poppler_annot_get_contents poppler_annot_set_contents poppler_annot_get_modified +poppler_annot_get_rectangle +poppler_annot_set_rectangle poppler_annot_markup_get_label poppler_annot_markup_set_label poppler_annot_markup_get_subject -- 1.7.9.5