From 3ceaf13474076b0be042c4f5d0e2a5d905c00027 Mon Sep 17 00:00:00 2001 From: Anuj Khare Date: Mon, 21 Jul 2014 00:03:11 +0530 Subject: [PATCH] glib: Add PopplerAnnotAppearance boxed type This type will be used to represent the attributes in the DA of FreeText annotations. --- glib/poppler-annot.cc | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 14 ++++++++++++ glib/poppler.h | 1 + 3 files changed, 77 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 13bc768..df55601 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -1808,6 +1808,68 @@ poppler_annot_callout_line_free (PopplerAnnotCalloutLine *callout) g_free (callout); } +/* PopplerAnnotAppearance */ +POPPLER_DEFINE_BOXED_TYPE (PopplerAnnotAppearance, poppler_annot_appearance, + poppler_annot_appearance_copy, + poppler_annot_appearance_free) + +/** + * poppler_annot_appearance_new: + * + * Creates a new empty #PopplerAnnotAppearance. + * + * Return value: a new allocated #PopplerAnnotAppearance, %NULL in other case. + * It must be freed with poppler_annot_appearance_free when done. + **/ +PopplerAnnotAppearance * +poppler_annot_appearance_new (void) +{ + return g_new0 (PopplerAnnotAppearance, 1); +} + +/** + * poppler_annot_appearance_copy: + * @font: the #PopplerAnnotAppearance to be copied. + * + * It does copy @font to a new #PopplerAnnotAppearance. + * + * Return value: a new allocated #PopplerAnnotAppearance as exact copy of + * @font, %NULL in other case. It must be freed with + poppler_annot_appearance_free when done. + **/ +PopplerAnnotAppearance * +poppler_annot_appearance_copy (PopplerAnnotAppearance *appearance) +{ + PopplerAnnotAppearance *new_appearance; + + g_return_val_if_fail (appearance != NULL, NULL); + + new_appearance = g_new0 (PopplerAnnotAppearance, 1); + + *new_appearance = *appearance; + new_appearance->font_name = g_strdup (appearance->font_name); + return new_appearance; +} + +/** + * poppler_annot_appearance_free: + * @appearance: a #PopplerAnnotAppearance + * + * Frees the memory used by #PopplerAnnotAppearance. + **/ +void +poppler_annot_appearance_free (PopplerAnnotAppearance *appearance) +{ + if (appearance->font_name) + g_free (appearance->font_name); + + if (appearance->color) + g_free (appearance->color); + + g_free (appearance); +} + + /* PopplerAnnotMovie */ /** diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h index 441563e..c0bf42c 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -64,6 +64,7 @@ G_BEGIN_DECLS #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 ()) +#define POPPLER_TYPE_ANNOT_APPEARANCE (poppler_annot_appearance_get_type ()) #define POPPLER_TYPE_ANNOT_CIRCLE (poppler_annot_circle_get_type ()) #define POPPLER_ANNOT_CIRCLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_CIRCLE, PopplerAnnotCircle)) @@ -170,6 +171,13 @@ struct _PopplerAnnotCalloutLine gdouble y3; }; +struct _PopplerAnnotAppearance +{ + PopplerColor *color; + gdouble font_size; + gchar *font_name; +}; + GType poppler_annot_get_type (void) G_GNUC_CONST; PopplerAnnotType poppler_annot_get_annot_type (PopplerAnnot *poppler_annot); gchar *poppler_annot_get_contents (PopplerAnnot *poppler_annot); @@ -275,6 +283,12 @@ PopplerAnnotCalloutLine *poppler_annot_callout_line_new ( PopplerAnnotCalloutLine *poppler_annot_callout_line_copy (PopplerAnnotCalloutLine *callout); void poppler_annot_callout_line_free (PopplerAnnotCalloutLine *callout); +/* PopplerAnnotAppearance */ +GType poppler_annot_appearance_get_type (void) G_GNUC_CONST; +PopplerAnnotAppearance *poppler_annot_appearance_new (void); +PopplerAnnotAppearance *poppler_annot_appearance_copy (PopplerAnnotAppearance *appr); +void poppler_annot_appearance_free (PopplerAnnotAppearance *appr); + /* PopplerAnnotCircle */ GType poppler_annot_circle_get_type (void) G_GNUC_CONST; PopplerAnnot *poppler_annot_circle_new (PopplerDocument *doc, diff --git a/glib/poppler.h b/glib/poppler.h index 4df9c0e..7fd8977 100644 --- a/glib/poppler.h +++ b/glib/poppler.h @@ -205,6 +205,7 @@ typedef struct _PopplerAnnotFileAttachment PopplerAnnotFileAttachment; typedef struct _PopplerAnnotMovie PopplerAnnotMovie; typedef struct _PopplerAnnotScreen PopplerAnnotScreen; typedef struct _PopplerAnnotCalloutLine PopplerAnnotCalloutLine; +typedef struct _PopplerAnnotAppearance PopplerAnnotAppearance; typedef struct _PopplerAnnotLine PopplerAnnotLine; typedef struct _PopplerAnnotCircle PopplerAnnotCircle; typedef struct _PopplerAnnotSquare PopplerAnnotSquare; -- 1.9.1