From 4474e9903108b8a4a6d40bf6af1adc879f541736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Aliste?= Date: Wed, 27 Jun 2012 15:38:23 -0400 Subject: [PATCH 1/8] glib: Add PopplerQuadrilateral boxed type --- glib/poppler-annot.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 41 +++++++++++++++++++++++++++++++++++++++ glib/poppler.h | 1 + 3 files changed, 93 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 31cc081..f298be6 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -178,6 +178,57 @@ poppler_annot_text_class_init (PopplerAnnotTextClass *klass) { } +/* PopplerRectangle type */ + +POPPLER_DEFINE_BOXED_TYPE (PopplerAnnotQuadrilateral, poppler_annot_quadrilateral, + poppler_annot_quadrilateral_copy, + poppler_annot_quadrilateral_free) + +/** + * poppler_annot_quadrilateral_new: + * + * Creates a new #PopplerAnnotQuadrilateral. It must be freed with poppler_annot_quadrilateral_free() after use. + * + * Returns: a new #PopplerAnntoQuadrilateral. + * Since: 0.24 + **/ +PopplerAnnotQuadrilateral * +poppler_annot_quadrilateral_new (void) +{ + return g_slice_new0 (PopplerAnnotQuadrilateral); +} + +/** + * poppler_annot_quadrilateral_copy: + * @quad: a #PopplerAnnotQuadrilateral to copy + * + * Creates a copy of @quad. The copy must be freed with poppler_annot_quadrilateral_free() after use. + * + * Returns: a new allocated copy of @quad + * Since: 0.24 + **/ +PopplerAnnotQuadrilateral * +poppler_annot_quadrilateral_copy (PopplerAnnotQuadrilateral *quad) +{ + g_return_val_if_fail (quad != NULL, NULL); + + return g_slice_dup (PopplerAnnotQuadrilateral, quad); +} + +/** + * poppler_annot_quadrilateral_free: + * @quad: a #PopplerAnnotQuadrilateral + * + * Frees the memory used by @quad + * Since: 0.24 + **/ +void +poppler_annot_quadrilateral_free (PopplerAnnotQuadrilateral *quad) +{ + g_slice_free (PopplerAnnotQuadrilateral, quad); +} + + PopplerAnnot * _poppler_annot_text_new (Annot *annot) { diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h index 88f4e46..7478126 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -169,6 +169,47 @@ void poppler_annot_set_color ( PopplerColor *poppler_color); gint poppler_annot_get_page_index (PopplerAnnot *poppler_annot); +/* PopplerAnnotQuadrilateral */ + +/* A quadrilateral encompasses a word or group of contiguous words in the + * text underlying the annotation. The coordinates for each quadrilateral are + * given in the order x1 y1 x2 y2 x3 y3 x4 y4 specifying the quadrilateral’s four + * vertices in counterclockwise order */ + +#define POPPLER_TYPE_ANNOT_QUADRILATERAL (poppler_annot_quadrilateral_get_type ()) +/** + * PopplerAnnotQuadrilateral: + * @x1: x coordinate of the first vertex + * @y1: y coordinate of the first vertex + * @x2: x coordinate of the second vertex + * @y2: y coordinate of the second vertex + * @x3: x coordinate of the third vertex + * @y3: y coordinate of the third vertex + * @x4: x coordinate of the fourth vertex + * @y4: y coordinate of the fourth vertex + * + * A #PopplerAnnotQuadrilateral is used to describe + * locations of annotations on a page. + * + * Since: 0.24 + **/ +struct _PopplerAnnotQuadrilateral +{ + gdouble x1; + gdouble y1; + gdouble x2; + gdouble y2; + gdouble x3; + gdouble y3; + gdouble x4; + gdouble y4; +}; + +GType poppler_annot_quadrilateral_get_type (void) G_GNUC_CONST; +PopplerAnnotQuadrilateral *poppler_annot_quadrilateral_new (void); +PopplerAnnotQuadrilateral *poppler_annot_quadrilateral_copy (PopplerAnnotQuadrilateral *quad); +void poppler_annot_quadrilateral_free (PopplerAnnotQuadrilateral *quad); + /* PopplerAnnotMarkup */ GType poppler_annot_markup_get_type (void) G_GNUC_CONST; gchar *poppler_annot_markup_get_label (PopplerAnnotMarkup *poppler_annot); diff --git a/glib/poppler.h b/glib/poppler.h index 2d190f3..837c414 100644 --- a/glib/poppler.h +++ b/glib/poppler.h @@ -202,6 +202,7 @@ typedef struct _PopplerAnnotFileAttachment PopplerAnnotFileAttachment; typedef struct _PopplerAnnotMovie PopplerAnnotMovie; typedef struct _PopplerAnnotScreen PopplerAnnotScreen; typedef struct _PopplerAnnotCalloutLine PopplerAnnotCalloutLine; +typedef struct _PopplerAnnotQuadrilateral PopplerAnnotQuadrilateral; typedef enum { -- 1.7.9.5