Commit 7127a2c7 authored by Germán Poo-Caamaño's avatar Germán Poo-Caamaño Committed by Carlos Garcia Campos
Browse files

glib: Add support for simple line annotations

https://bugs.freedesktop.org/show_bug.cgi?id=70981
parent 451bac9f
......@@ -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<AnnotLine *>(POPPLER_ANNOT (poppler_annot)->annot);
annot->setVertices (start->x, start->y, end->x, end->y);
}
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......
......@@ -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
{
......
......@@ -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
</SECTION>
<SECTION>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment