From a0e78afbe90adbf875101ccae617f6ff0c19d239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Mon, 28 Oct 2013 22:56:14 -0700 Subject: [PATCH 7/9] glib: Add PopplerQuadrilateral boxed type --- glib/poppler-annot.cc | 54 +++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 41 ++++++++++++++++++++++++++ glib/poppler.h | 1 + glib/reference/poppler-sections.txt | 7 ++++- 4 files changed, 102 insertions(+), 1 deletion(-) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 5f61b59..d6a8d7d 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 566748c..8ba82a0 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -384,6 +384,7 @@ PopplerAnnotMarkupReplyType PopplerAnnotTextState PopplerAnnotCalloutLine PopplerAnnotFreeTextQuadding +PopplerAnnotQuadrilateral poppler_annot_get_annot_type poppler_annot_get_flags poppler_annot_get_name @@ -444,7 +445,10 @@ poppler_annot_line_ending_style_get_type poppler_annot_line_get_end_style poppler_annot_line_get_start_style poppler_annot_line_set_ending_style - +poppler_annot_quadrilateral_copy +poppler_annot_quadrilateral_free +poppler_annot_quadrilateral_get_type +poppler_annot_quadrilateral_new POPPLER_ANNOT @@ -481,6 +485,7 @@ POPPLER_TYPE_ANNOT_LINE_ENDING_STYLE 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