From c60ec7d5ebccd466f20f7aafc3563ff97f1076da 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] glib: Add PopplerQuadrilateral boxed type --- glib/poppler-annot.cc | 54 +++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 41 ++++++++++++++++++++++++++ glib/poppler.h | 1 + glib/reference/poppler-sections.txt | 6 ++++ 4 files changed, 102 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 2c0f45d..92f4f66 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -202,6 +202,60 @@ 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 #PopplerAnnotQuadrilateral. + * + * Since: 0.25 + **/ +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.25 + **/ +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.25 + **/ +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 0b547f9..e38f937 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -194,6 +194,47 @@ gboolean poppler_annot_get_rectangle ( void poppler_annot_set_rectangle (PopplerAnnot *poppler_annot, PopplerRectangle poppler_rect); +/* 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.25 + **/ +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 db92752..f278681 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 struct _PopplerAnnotLine PopplerAnnotLine; typedef struct _PopplerAnnotGeometry PopplerAnnotGeometry; diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index b152eca..2dd0274 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -382,6 +382,7 @@ PopplerAnnotMarkupReplyType PopplerAnnotTextState PopplerAnnotCalloutLine PopplerAnnotFreeTextQuadding +PopplerAnnotQuadrilateral poppler_annot_get_annot_type poppler_annot_get_flags poppler_annot_get_name @@ -436,6 +437,10 @@ poppler_annot_geometry_new_circle poppler_annot_geometry_new_square poppler_annot_geometry_get_interior_color poppler_annot_geometry_set_interior_color +poppler_annot_quadrilateral_copy +poppler_annot_quadrilateral_free +poppler_annot_quadrilateral_get_type +poppler_annot_quadrilateral_new POPPLER_ANNOT @@ -467,6 +472,7 @@ POPPLER_TYPE_ANNOT_FLAG POPPLER_TYPE_ANNOT_MARKUP_REPLY_TYPE POPPLER_TYPE_ANNOT_TEXT_STATE POPPLER_TYPE_ANNOT_FREE_TEXT_QUADDING +POPPLER_TYPE_ANNOT_QUADRILATERAL POPPLER_TYPE_ANNOT_TYPE -- 1.7.9.5