From 3ca7333cf4a3fcb85524f635034900cef5526b7f 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/2] glib: Add PopplerQuadrilateral boxed type. --- glib/poppler-annot.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 40 ++++++++++++++++++++++++++++++++++++++++ glib/poppler.h | 1 + 3 files changed, 89 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 728e64b..6b4fd78 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -178,6 +178,54 @@ 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_rectangle_new: + * + * Creates a new #PopplerAnnotQuadrilateral + * + * Returns: a new #PopplerAnntoQuadrilateral, use poppler_annot_quadrilateral_free() to free it + **/ +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 + * + * Returns: a new allocated copy of @quadrilateral + **/ +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 given #PopplerAnnotQuadrilateral + **/ +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 17440fb..9225f97 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -167,6 +167,46 @@ 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. + **/ +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.10.2