From e8c9083ab91228656f37ca087cef2309f6547f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Mon, 28 Oct 2013 22:26:49 -0700 Subject: [PATCH] glib: Add support for simple line annotations https://bugs.freedesktop.org/show_bug.cgi?id=70981 --- glib/poppler-annot.cc | 77 +++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 12 ++++++ glib/poppler-page.cc | 3 ++ glib/poppler-private.h | 1 + glib/poppler.h | 1 + glib/reference/poppler-sections.txt | 7 ++++ 6 files changed, 101 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 26d0e6b..cbfcb60 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -35,6 +35,7 @@ typedef struct _PopplerAnnotTextClass PopplerAnnotTextClass; typedef struct _PopplerAnnotFileAttachmentClass PopplerAnnotFileAttachmentClass; typedef struct _PopplerAnnotMovieClass PopplerAnnotMovieClass; typedef struct _PopplerAnnotScreenClass PopplerAnnotScreenClass; +typedef struct _PopplerAnnotLineClass PopplerAnnotLineClass; struct _PopplerAnnotClass { @@ -105,6 +106,15 @@ struct _PopplerAnnotScreenClass PopplerAnnotClass parent_class; }; +struct _PopplerAnnotLine +{ + PopplerAnnotMarkup parent_instance; +}; + +struct _PopplerAnnotLineClass +{ + PopplerAnnotMarkupClass parent_class; +}; G_DEFINE_TYPE (PopplerAnnot, poppler_annot, G_TYPE_OBJECT) G_DEFINE_TYPE (PopplerAnnotMarkup, poppler_annot_markup, POPPLER_TYPE_ANNOT) @@ -113,6 +123,7 @@ G_DEFINE_TYPE (PopplerAnnotFreeText, poppler_annot_free_text, POPPLER_TYPE_ANNOT G_DEFINE_TYPE (PopplerAnnotFileAttachment, poppler_annot_file_attachment, POPPLER_TYPE_ANNOT_MARKUP) G_DEFINE_TYPE (PopplerAnnotMovie, poppler_annot_movie, POPPLER_TYPE_ANNOT) G_DEFINE_TYPE (PopplerAnnotScreen, poppler_annot_screen, POPPLER_TYPE_ANNOT) +G_DEFINE_TYPE (PopplerAnnotLine, poppler_annot_line, POPPLER_TYPE_ANNOT_MARKUP) static PopplerAnnot * _poppler_create_annot (GType annot_type, Annot *annot) @@ -378,6 +389,48 @@ _poppler_annot_screen_new (Annot *annot) return poppler_annot; } +PopplerAnnot * +_poppler_annot_line_new (Annot *annot) +{ + return _poppler_create_annot (POPPLER_TYPE_ANNOT_LINE, annot); +} + +static void +poppler_annot_line_init (PopplerAnnotLine *poppler_annot) +{ +} + +static void +poppler_annot_line_class_init (PopplerAnnotLineClass *klass) +{ +} + +/** + * poppler_annot_line_new: + * @doc: a #PopplerDocument + * @rect: a #PopplerRectangle + * + * Creates a new Line annotation that will be + * located on @rect when added to a page. See + * poppler_page_add_annot() + * + * Return value: A newly created #PopplerAnnotLine annotation + * + * Since: 0.26 + */ +PopplerAnnot * +poppler_annot_line_new (PopplerDocument *doc, + PopplerRectangle *rect) +{ + Annot *annot; + PDFRectangle pdf_rect(rect->x1, rect->y1, + rect->x2, rect->y2); + + annot = new AnnotLine (doc->doc, &pdf_rect); + + return _poppler_annot_line_new (annot); +} + /* Public methods */ /** @@ -1438,3 +1491,27 @@ poppler_annot_screen_get_action (PopplerAnnotScreen *poppler_annot) { return poppler_annot->action; } + +/* PopplerAnnotLine */ +/** + * poppler_annot_line_set_vertices: + * @poppler_annot: a #PopplerAnnotLine + * @start: Coordinates of the starting vertice + * @end: Coordinates of the starting vertice + * + * Set the point the coordinates where the @poppler_annot starts and ends. + * + * Since: 0.26 + */ +void +poppler_annot_line_set_vertices (PopplerAnnotLine *poppler_annot, + PopplerPoint start, + PopplerPoint end) +{ + AnnotLine *annot; + + g_return_if_fail (POPPLER_IS_ANNOT_LINE (poppler_annot)); + + annot = static_cast(POPPLER_ANNOT (poppler_annot)->annot); + annot->setVertices (start.x, start.y, end.x, end.y); +} diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h index bc32e8d..5d0992b 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -54,6 +54,10 @@ G_BEGIN_DECLS #define POPPLER_ANNOT_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_SCREEN, PopplerAnnotScreen)) #define POPPLER_IS_ANNOT_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_SCREEN)) +#define POPPLER_TYPE_ANNOT_LINE (poppler_annot_line_get_type ()) +#define POPPLER_ANNOT_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_LINE, PopplerAnnotLine)) +#define POPPLER_IS_ANNOT_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_LINE)) + #define POPPLER_TYPE_ANNOT_CALLOUT_LINE (poppler_annot_callout_line_get_type ()) @@ -245,6 +249,14 @@ PopplerMovie *poppler_annot_movie_get_movie ( GType poppler_annot_screen_get_type (void) G_GNUC_CONST; PopplerAction *poppler_annot_screen_get_action (PopplerAnnotScreen *poppler_annot); +/* PopplerAnnotLine */ +GType poppler_annot_line_get_type (void) G_GNUC_CONST; +PopplerAnnot *poppler_annot_line_new (PopplerDocument *doc, + PopplerRectangle *rect); +void poppler_annot_line_set_vertices (PopplerAnnotLine *poppler_annot, + PopplerPoint start, + PopplerPoint end); + /* PopplerAnnotCalloutLine */ GType poppler_annot_callout_line_get_type (void) G_GNUC_CONST; PopplerAnnotCalloutLine *poppler_annot_callout_line_new (void); diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc index 9115b78..20fccb6 100644 --- a/glib/poppler-page.cc +++ b/glib/poppler-page.cc @@ -1375,6 +1375,9 @@ poppler_page_get_annot_mapping (PopplerPage *page) case Annot::typeScreen: mapping->annot = _poppler_annot_screen_new (annot); break; + case Annot::typeLine: + mapping->annot = _poppler_annot_line_new (annot); + break; default: mapping->annot = _poppler_annot_new (annot); break; diff --git a/glib/poppler-private.h b/glib/poppler-private.h index ab39b49..bebe0c8 100644 --- a/glib/poppler-private.h +++ b/glib/poppler-private.h @@ -120,6 +120,7 @@ PopplerAnnot *_poppler_annot_free_text_new (Annot *annot); PopplerAnnot *_poppler_annot_file_attachment_new (Annot *annot); PopplerAnnot *_poppler_annot_movie_new (Annot *annot); PopplerAnnot *_poppler_annot_screen_new (Annot *annot); +PopplerAnnot *_poppler_annot_line_new (Annot *annot); char *_poppler_goo_string_to_utf8(GooString *s); gboolean _poppler_convert_pdf_date_to_gtime (GooString *date, diff --git a/glib/poppler.h b/glib/poppler.h index 83531a5..dd0df09 100644 --- a/glib/poppler.h +++ b/glib/poppler.h @@ -203,6 +203,7 @@ typedef struct _PopplerAnnotFileAttachment PopplerAnnotFileAttachment; typedef struct _PopplerAnnotMovie PopplerAnnotMovie; typedef struct _PopplerAnnotScreen PopplerAnnotScreen; typedef struct _PopplerAnnotCalloutLine PopplerAnnotCalloutLine; +typedef struct _PopplerAnnotLine PopplerAnnotLine; typedef enum { diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index aca6370..d932af9 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -372,6 +372,7 @@ PopplerAnnotMarkup PopplerAnnotText PopplerAnnotFreeText PopplerAnnotFileAttachment +PopplerAnnotLine PopplerAnnotMovie PopplerAnnotScreen PopplerAnnotType @@ -429,6 +430,8 @@ poppler_annot_movie_get_title poppler_annot_callout_line_new poppler_annot_callout_line_copy poppler_annot_callout_line_free +poppler_annot_line_new +poppler_annot_line_set_vertices poppler_point_copy poppler_point_free poppler_point_get_type @@ -444,6 +447,9 @@ POPPLER_TYPE_ANNOT_FILE_ATTACHMENT POPPLER_ANNOT_FREE_TEXT POPPLER_IS_ANNOT_FREE_TEXT POPPLER_TYPE_ANNOT_FREE_TEXT +POPPLER_ANNOT_LINE +POPPLER_IS_ANNOT_LINE +POPPLER_TYPE_ANNOT_LINE POPPLER_ANNOT_MARKUP POPPLER_IS_ANNOT_MARKUP POPPLER_TYPE_ANNOT_MARKUP @@ -479,6 +485,7 @@ poppler_annot_markup_reply_type_get_type poppler_annot_callout_line_get_type poppler_annot_text_state_get_type poppler_annot_free_text_quadding_get_type +poppler_annot_line_get_type
-- 1.7.9.5