From c4c312ed3bbfed1692e38a37da8dfd8829df21de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Mon, 18 Nov 2013 16:26:27 -0800 Subject: [PATCH] glib: Add PopplerQuadrilateral boxed type https://bugs.freedesktop.org/show_bug.cgi?id=51487 --- glib/poppler-page.cc | 53 +++++++++++++++++++++++++++++++++++ glib/poppler-page.h | 33 ++++++++++++++++++++++ glib/poppler.h | 1 + glib/reference/poppler-sections.txt | 6 ++++ 4 files changed, 93 insertions(+) diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc index 7619d90..991d546 100644 --- a/glib/poppler-page.cc +++ b/glib/poppler-page.cc @@ -1590,6 +1590,59 @@ poppler_point_free (PopplerPoint *point) g_slice_free (PopplerPoint, point); } +/* PopplerQuadrilateral type */ + +POPPLER_DEFINE_BOXED_TYPE (PopplerQuadrilateral, poppler_quadrilateral, + poppler_quadrilateral_copy, + poppler_quadrilateral_free) + +/** + * poppler_quadrilateral_new: + * + * Creates a new #PopplerQuadrilateral. It must be freed with poppler_quadrilateral_free() after use. + * + * Returns: a new #PopplerQuadrilateral. + * + * Since: 0.26 + **/ +PopplerQuadrilateral * +poppler_quadrilateral_new (void) +{ + return g_slice_new0 (PopplerQuadrilateral); +} + +/** + * poppler_quadrilateral_copy: + * @quad: a #PopplerQuadrilateral to copy + * + * Creates a copy of @quad. The copy must be freed with poppler_quadrilateral_free() after use. + * + * Returns: a new allocated copy of @quad + * + * Since: 0.26 + **/ +PopplerQuadrilateral * +poppler_quadrilateral_copy (PopplerQuadrilateral *quad) +{ + g_return_val_if_fail (quad != NULL, NULL); + + return g_slice_dup (PopplerQuadrilateral, quad); +} + +/** + * poppler_quadrilateral_free: + * @quad: a #PopplerQuadrilateral + * + * Frees the memory used by @quad + * + * Since: 0.26 + **/ +void +poppler_quadrilateral_free (PopplerQuadrilateral *quad) +{ + g_slice_free (PopplerQuadrilateral, quad); +} + /* PopplerTextAttributes type */ POPPLER_DEFINE_BOXED_TYPE (PopplerTextAttributes, poppler_text_attributes, diff --git a/glib/poppler-page.h b/glib/poppler-page.h index 46a7c1d..6073246 100644 --- a/glib/poppler-page.h +++ b/glib/poppler-page.h @@ -147,6 +147,39 @@ PopplerPoint *poppler_point_new (void); PopplerPoint *poppler_point_copy (PopplerPoint *point); void poppler_point_free (PopplerPoint *point); +/* PopplerQuadrilateral */ + +/* 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_QUADRILATERAL (poppler_quadrilateral_get_type ()) +/** + * PopplerQuadrilateral: + * @p1: a #PopplerPoint with the first vertex coordinates + * @p2: a #PopplerPoint with the second vertex coordinates + * @p3: a #PopplerPoint with the third vertex coordinates + * @p4: a #PopplerPoint with the fourth vertex coordinates + * + * A #PopplerQuadrilateral is used to describe rectangle-like polygon + * with arbitrary inclination on a page. + * + * Since: 0.26 + **/ +struct _PopplerQuadrilateral +{ + PopplerPoint p1; + PopplerPoint p2; + PopplerPoint p3; + PopplerPoint p4; +}; + +GType poppler_quadrilateral_get_type (void) G_GNUC_CONST; +PopplerQuadrilateral *poppler_quadrilateral_new (void); +PopplerQuadrilateral *poppler_quadrilateral_copy (PopplerQuadrilateral *quad); +void poppler_quadrilateral_free (PopplerQuadrilateral *quad); + /* A color in RGB */ #define POPPLER_TYPE_COLOR (poppler_color_get_type ()) diff --git a/glib/poppler.h b/glib/poppler.h index 92121f6..4313e5e 100644 --- a/glib/poppler.h +++ b/glib/poppler.h @@ -206,6 +206,7 @@ typedef struct _PopplerAnnotCalloutLine PopplerAnnotCalloutLine; typedef struct _PopplerAnnotLine PopplerAnnotLine; typedef struct _PopplerAnnotCircle PopplerAnnotCircle; typedef struct _PopplerAnnotSquare PopplerAnnotSquare; +typedef struct _PopplerQuadrilateral PopplerQuadrilateral; typedef enum { diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index 7293c8f..5a9139d 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -385,6 +385,7 @@ PopplerAnnotCalloutLine PopplerAnnotFreeTextQuadding PopplerAnnotSquare PopplerPoint +PopplerQuadrilateral poppler_annot_get_annot_type poppler_annot_get_flags poppler_annot_get_name @@ -446,6 +447,10 @@ poppler_point_copy poppler_point_free poppler_point_get_type poppler_point_new +poppler_quadrilateral_copy +poppler_quadrilateral_free +poppler_quadrilateral_get_type +poppler_quadrilateral_new POPPLER_ANNOT @@ -485,6 +490,7 @@ POPPLER_TYPE_ANNOT_MARKUP_REPLY_TYPE POPPLER_TYPE_ANNOT_TEXT_STATE POPPLER_TYPE_ANNOT_FREE_TEXT_QUADDING POPPLER_TYPE_ANNOT_TYPE +POPPLER_TYPE_QUADRILATERAL poppler_annot_get_type -- 1.7.9.5