[poppler] glib/poppler-annot.cc glib/poppler-annot.h glib/reference

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sun Nov 17 01:06:10 PST 2013


 glib/poppler-annot.cc               |   48 ++++++++++++++++++++++++++++++++++++
 glib/poppler-annot.h                |    4 +++
 glib/reference/poppler-sections.txt |    2 +
 3 files changed, 54 insertions(+)

New commits:
commit 4b7c91ea697359751f9abe9ec5e63021c90a60ed
Author: Germán Poo-Caamaño <gpoo at gnome.org>
Date:   Sat Sep 28 23:18:07 2013 -0700

    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

diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 31cc081..9c8551b 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2007 Inigo Martinez <inigomartinez at gmail.com>
  * Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
+ * Copyright (C) 2013 German Poo-Caamano <gpoo at gnome.org>
  *
  * 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
@@ -625,6 +626,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.
+ *
+ * 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));
+  g_return_if_fail (poppler_rect != NULL);
+
+  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));
+  g_return_if_fail (poppler_rect != NULL);
+
+  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 88f4e46..1f23822 100644
--- a/glib/poppler-annot.h
+++ b/glib/poppler-annot.h
@@ -168,6 +168,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 6fb14bc..24c005d 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -390,6 +390,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


More information about the poppler mailing list