From 40967e2b78434312b5024c304664afb637574251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Sun, 17 Nov 2013 23:38:32 -0800 Subject: [PATCH] glib: Add support for simple line annotations https://bugs.freedesktop.org/show_bug.cgi?id=70981 --- glib/poppler-annot.cc | 79 +++++++++++++++++++++++++++++++++++ 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, 103 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 9c8551b..9112f30 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -36,6 +36,7 @@ typedef struct _PopplerAnnotTextClass PopplerAnnotTextClass; typedef struct _PopplerAnnotFileAttachmentClass PopplerAnnotFileAttachmentClass; typedef struct _PopplerAnnotMovieClass PopplerAnnotMovieClass; typedef struct _PopplerAnnotScreenClass PopplerAnnotScreenClass; +typedef struct _PopplerAnnotLineClass PopplerAnnotLineClass; struct _PopplerAnnotClass { @@ -106,6 +107,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) @@ -114,6 +124,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) @@ -325,6 +336,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 */ /** @@ -1432,3 +1485,29 @@ poppler_annot_screen_get_action (PopplerAnnotScreen *poppler_annot) { return poppler_annot->action; } + +/* PopplerAnnotLine */ +/** + * poppler_annot_line_set_vertices: + * @poppler_annot: a #PopplerAnnotLine + * @start: a #PopplerPoint of the starting vertice + * @end: a #PopplerPoint of the ending vertice + * + * Set the coordinate points 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)); + g_return_if_fail (start != NULL); + g_return_if_fail (end != NULL); + + 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 1f23822..6302be5 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 ()) @@ -225,6 +229,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 e891b9f..fbab9b4 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 ce7bd00..ce829e3 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 @@ -431,6 +432,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 @@ -446,6 +449,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 @@ -481,6 +487,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