1
/* poppler-annot.cc: glib interface to poppler
3
* Copyright (C) 2007 Inigo Martinez <inigomartinez@gmail.com>
4
* Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22
#include "poppler-private.h"
25
* SECTION:poppler-annot
26
* @short_description: Annotations
27
* @title: PopplerAnnot
30
typedef struct _PopplerAnnotClass PopplerAnnotClass;
31
typedef struct _PopplerAnnotMarkupClass PopplerAnnotMarkupClass;
32
typedef struct _PopplerAnnotFreeTextClass PopplerAnnotFreeTextClass;
33
typedef struct _PopplerAnnotTextClass PopplerAnnotTextClass;
34
typedef struct _PopplerAnnotFileAttachmentClass PopplerAnnotFileAttachmentClass;
35
typedef struct _PopplerAnnotMovieClass PopplerAnnotMovieClass;
36
typedef struct _PopplerAnnotScreenClass PopplerAnnotScreenClass;
38
struct _PopplerAnnotClass
40
GObjectClass parent_class;
43
struct _PopplerAnnotMarkup
45
PopplerAnnot parent_instance;
48
struct _PopplerAnnotMarkupClass
50
PopplerAnnotClass parent_class;
53
struct _PopplerAnnotText
55
PopplerAnnotMarkup parent_instance;
58
struct _PopplerAnnotTextClass
60
PopplerAnnotMarkupClass parent_class;
63
struct _PopplerAnnotFreeText
65
PopplerAnnotMarkup parent_instance;
68
struct _PopplerAnnotFreeTextClass
70
PopplerAnnotMarkupClass parent_class;
73
struct _PopplerAnnotFileAttachment
75
PopplerAnnotMarkup parent_instance;
78
struct _PopplerAnnotFileAttachmentClass
80
PopplerAnnotMarkupClass parent_class;
83
struct _PopplerAnnotMovie
85
PopplerAnnot parent_instance;
90
struct _PopplerAnnotMovieClass
92
PopplerAnnotClass parent_class;
95
struct _PopplerAnnotScreen
97
PopplerAnnot parent_instance;
99
PopplerAction *action;
102
struct _PopplerAnnotScreenClass
104
PopplerAnnotClass parent_class;
108
G_DEFINE_TYPE (PopplerAnnot, poppler_annot, G_TYPE_OBJECT)
109
G_DEFINE_TYPE (PopplerAnnotMarkup, poppler_annot_markup, POPPLER_TYPE_ANNOT)
110
G_DEFINE_TYPE (PopplerAnnotText, poppler_annot_text, POPPLER_TYPE_ANNOT_MARKUP)
111
G_DEFINE_TYPE (PopplerAnnotFreeText, poppler_annot_free_text, POPPLER_TYPE_ANNOT_MARKUP)
112
G_DEFINE_TYPE (PopplerAnnotFileAttachment, poppler_annot_file_attachment, POPPLER_TYPE_ANNOT_MARKUP)
113
G_DEFINE_TYPE (PopplerAnnotMovie, poppler_annot_movie, POPPLER_TYPE_ANNOT)
114
G_DEFINE_TYPE (PopplerAnnotScreen, poppler_annot_screen, POPPLER_TYPE_ANNOT)
117
poppler_annot_finalize (GObject *object)
119
PopplerAnnot *poppler_annot = POPPLER_ANNOT (object);
121
poppler_annot->annot = NULL;
123
G_OBJECT_CLASS (poppler_annot_parent_class)->finalize (object);
127
poppler_annot_init (PopplerAnnot *poppler_annot)
132
poppler_annot_class_init (PopplerAnnotClass *klass)
134
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
136
gobject_class->finalize = poppler_annot_finalize;
140
_poppler_annot_new (Annot *annot)
142
PopplerAnnot *poppler_annot;
144
poppler_annot = POPPLER_ANNOT (g_object_new (POPPLER_TYPE_ANNOT, NULL));
145
poppler_annot->annot = annot;
147
return poppler_annot;
151
poppler_annot_markup_init (PopplerAnnotMarkup *poppler_annot)
156
poppler_annot_markup_class_init (PopplerAnnotMarkupClass *klass)
161
poppler_annot_text_init (PopplerAnnotText *poppler_annot)
166
poppler_annot_text_class_init (PopplerAnnotTextClass *klass)
171
_poppler_annot_text_new (Annot *annot)
173
PopplerAnnot *poppler_annot;
175
poppler_annot = POPPLER_ANNOT (g_object_new (POPPLER_TYPE_ANNOT_TEXT, NULL));
176
poppler_annot->annot = annot;
178
return poppler_annot;
182
* poppler_annot_text_new:
183
* @doc: a #PopplerDocument
184
* @rect: a #PopplerRectangle
186
* Creates a new Text annotation that will be
187
* located on @rect when added to a page. See
188
* poppler_page_add_annot()
190
* Return value: A newly created #PopplerAnnotText annotation
195
poppler_annot_text_new (PopplerDocument *doc,
196
PopplerRectangle *rect)
199
PDFRectangle pdf_rect(rect->x1, rect->y1,
202
annot = new AnnotText (doc->doc->getXRef(), &pdf_rect, doc->doc->getCatalog());
204
return _poppler_annot_text_new (annot);
208
poppler_annot_free_text_init (PopplerAnnotFreeText *poppler_annot)
213
poppler_annot_free_text_class_init (PopplerAnnotFreeTextClass *klass)
218
_poppler_annot_free_text_new (Annot *annot)
220
PopplerAnnot *poppler_annot;
222
poppler_annot = POPPLER_ANNOT (g_object_new (POPPLER_TYPE_ANNOT_FREE_TEXT, NULL));
223
poppler_annot->annot = annot;
225
return poppler_annot;
229
poppler_annot_file_attachment_init (PopplerAnnotFileAttachment *poppler_annot)
234
poppler_annot_file_attachment_class_init (PopplerAnnotFileAttachmentClass *klass)
239
_poppler_annot_file_attachment_new (Annot *annot)
241
PopplerAnnot *poppler_annot;
243
poppler_annot = POPPLER_ANNOT (g_object_new (POPPLER_TYPE_ANNOT_FILE_ATTACHMENT, NULL));
244
poppler_annot->annot = annot;
246
return poppler_annot;
251
poppler_annot_movie_finalize (GObject *object)
253
PopplerAnnotMovie *annot_movie = POPPLER_ANNOT_MOVIE (object);
255
if (annot_movie->movie) {
256
g_object_unref (annot_movie->movie);
257
annot_movie->movie = NULL;
260
G_OBJECT_CLASS (poppler_annot_movie_parent_class)->finalize (object);
264
poppler_annot_movie_init (PopplerAnnotMovie *poppler_annot)
269
poppler_annot_movie_class_init (PopplerAnnotMovieClass *klass)
271
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
273
gobject_class->finalize = poppler_annot_movie_finalize;
277
_poppler_annot_movie_new (Annot *annot)
279
PopplerAnnot *poppler_annot;
280
AnnotMovie *annot_movie;
282
poppler_annot = POPPLER_ANNOT (g_object_new (POPPLER_TYPE_ANNOT_MOVIE, NULL));
283
poppler_annot->annot = annot;
285
annot_movie = static_cast<AnnotMovie *>(poppler_annot->annot);
286
POPPLER_ANNOT_MOVIE (poppler_annot)->movie = _poppler_movie_new (annot_movie->getMovie());
288
return poppler_annot;
292
poppler_annot_screen_finalize (GObject *object)
294
PopplerAnnotScreen *annot_screen = POPPLER_ANNOT_SCREEN (object);
296
if (annot_screen->action) {
297
poppler_action_free (annot_screen->action);
298
annot_screen->action = NULL;
301
G_OBJECT_CLASS (poppler_annot_screen_parent_class)->finalize (object);
305
poppler_annot_screen_init (PopplerAnnotScreen *poppler_annot)
310
poppler_annot_screen_class_init (PopplerAnnotScreenClass *klass)
312
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
314
gobject_class->finalize = poppler_annot_screen_finalize;
318
_poppler_annot_screen_new (Annot *annot)
320
PopplerAnnot *poppler_annot;
321
AnnotScreen *annot_screen;
324
poppler_annot = POPPLER_ANNOT (g_object_new (POPPLER_TYPE_ANNOT_SCREEN, NULL));
325
poppler_annot->annot = annot;
327
annot_screen = static_cast<AnnotScreen *>(poppler_annot->annot);
328
action = annot_screen->getAction();
330
POPPLER_ANNOT_SCREEN (poppler_annot)->action = _poppler_action_new (NULL, action, NULL);
332
return poppler_annot;
338
* poppler_annot_get_annot_type:
339
* @poppler_annot: a #PopplerAnnot
341
* Gets the type of @poppler_annot
343
* Return value: #PopplerAnnotType of @poppler_annot.
346
poppler_annot_get_annot_type (PopplerAnnot *poppler_annot)
348
g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), POPPLER_ANNOT_UNKNOWN);
350
switch (poppler_annot->annot->getType ())
352
case Annot::typeText:
353
return POPPLER_ANNOT_TEXT;
354
case Annot::typeLink:
355
return POPPLER_ANNOT_LINK;
356
case Annot::typeFreeText:
357
return POPPLER_ANNOT_FREE_TEXT;
358
case Annot::typeLine:
359
return POPPLER_ANNOT_LINE;
360
case Annot::typeSquare:
361
return POPPLER_ANNOT_SQUARE;
362
case Annot::typeCircle:
363
return POPPLER_ANNOT_CIRCLE;
364
case Annot::typePolygon:
365
return POPPLER_ANNOT_POLYGON;
366
case Annot::typePolyLine:
367
return POPPLER_ANNOT_POLY_LINE;
368
case Annot::typeHighlight:
369
return POPPLER_ANNOT_HIGHLIGHT;
370
case Annot::typeUnderline:
371
return POPPLER_ANNOT_UNDERLINE;
372
case Annot::typeSquiggly:
373
return POPPLER_ANNOT_SQUIGGLY;
374
case Annot::typeStrikeOut:
375
return POPPLER_ANNOT_STRIKE_OUT;
376
case Annot::typeStamp:
377
return POPPLER_ANNOT_STAMP;
378
case Annot::typeCaret:
379
return POPPLER_ANNOT_CARET;
381
return POPPLER_ANNOT_INK;
382
case Annot::typePopup:
383
return POPPLER_ANNOT_POPUP;
384
case Annot::typeFileAttachment:
385
return POPPLER_ANNOT_FILE_ATTACHMENT;
386
case Annot::typeSound:
387
return POPPLER_ANNOT_SOUND;
388
case Annot::typeMovie:
389
return POPPLER_ANNOT_MOVIE;
390
case Annot::typeWidget:
391
return POPPLER_ANNOT_WIDGET;
392
case Annot::typeScreen:
393
return POPPLER_ANNOT_SCREEN;
394
case Annot::typePrinterMark:
395
return POPPLER_ANNOT_PRINTER_MARK;
396
case Annot::typeTrapNet:
397
return POPPLER_ANNOT_TRAP_NET;
398
case Annot::typeWatermark:
399
return POPPLER_ANNOT_WATERMARK;
401
return POPPLER_ANNOT_3D;
403
g_warning ("Unsupported Annot Type");
406
return POPPLER_ANNOT_UNKNOWN;
410
* poppler_annot_get_contents:
411
* @poppler_annot: a #PopplerAnnot
413
* Retrieves the contents of @poppler_annot.
415
* Return value: a new allocated string with the contents of @poppler_annot. It
416
* must be freed with g_free() when done.
419
poppler_annot_get_contents (PopplerAnnot *poppler_annot)
423
g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), NULL);
425
contents = poppler_annot->annot->getContents ();
427
return contents ? _poppler_goo_string_to_utf8 (contents) : NULL;
431
* poppler_annot_set_contents:
432
* @poppler_annot: a #PopplerAnnot
433
* @contents: a text string containing the new contents
435
* Sets the contents of @poppler_annot to the given value,
436
* replacing the current contents.
441
poppler_annot_set_contents (PopplerAnnot *poppler_annot,
442
const gchar *contents)
448
g_return_if_fail (POPPLER_IS_ANNOT (poppler_annot));
450
tmp = contents ? g_convert (contents, -1, "UTF-16BE", "UTF-8", NULL, &length, NULL) : NULL;
451
goo_tmp = new GooString (tmp, length);
453
poppler_annot->annot->setContents (goo_tmp);
458
* poppler_annot_get_name:
459
* @poppler_annot: a #PopplerAnnot
461
* Retrieves the name of @poppler_annot.
463
* Return value: a new allocated string with the name of @poppler_annot. It must
464
* be freed with g_free() when done.
467
poppler_annot_get_name (PopplerAnnot *poppler_annot)
471
g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), NULL);
473
name = poppler_annot->annot->getName ();
475
return name ? _poppler_goo_string_to_utf8 (name) : NULL;
479
* poppler_annot_get_modified:
480
* @poppler_annot: a #PopplerAnnot
482
* Retrieves the last modification data of @poppler_annot. The returned
483
* string will be either a PDF format date or a text string.
484
* See also #poppler_date_parse()
486
* Return value: a new allocated string with the last modification data of
487
* @poppler_annot. It must be freed with g_free() when done.
490
poppler_annot_get_modified (PopplerAnnot *poppler_annot)
494
g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), NULL);
496
text = poppler_annot->annot->getModified ();
498
return text ? _poppler_goo_string_to_utf8 (text) : NULL;
502
* poppler_annot_get_flags
503
* @poppler_annot: a #PopplerAnnot
505
* Retrieves the flag field specifying various characteristics of the
508
* Return value: the flag field of @poppler_annot.
511
poppler_annot_get_flags (PopplerAnnot *poppler_annot)
513
g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), (PopplerAnnotFlag) 0);
515
return (PopplerAnnotFlag) poppler_annot->annot->getFlags ();
519
* poppler_annot_get_color:
520
* @poppler_annot: a #PopplerAnnot
522
* Retrieves the color of @poppler_annot.
524
* Return value: a new allocated #PopplerColor with the color values of
525
* @poppler_annot, or %NULL. It must be freed with g_free() when done.
528
poppler_annot_get_color (PopplerAnnot *poppler_annot)
531
PopplerColor *poppler_color = NULL;
533
g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), NULL);
535
color = poppler_annot->annot->getColor ();
538
const double *values = color->getValues ();
540
switch (color->getSpace ())
542
case AnnotColor::colorGray:
543
poppler_color = g_new (PopplerColor, 1);
545
poppler_color->red = (guint16) (values[0] * 65535);
546
poppler_color->green = poppler_color->red;
547
poppler_color->blue = poppler_color->red;
550
case AnnotColor::colorRGB:
551
poppler_color = g_new (PopplerColor, 1);
553
poppler_color->red = (guint16) (values[0] * 65535);
554
poppler_color->green = (guint16) (values[1] * 65535);
555
poppler_color->blue = (guint16) (values[2] * 65535);
558
case AnnotColor::colorCMYK:
559
g_warning ("Unsupported Annot Color: colorCMYK");
560
case AnnotColor::colorTransparent:
565
return poppler_color;
569
* poppler_annot_set_color:
570
* @poppler_annot: a #PopplerAnnot
571
* @poppler_color: (allow-none): a #PopplerColor, or %NULL
573
* Sets the color of @poppler_annot.
578
poppler_annot_set_color (PopplerAnnot *poppler_annot,
579
PopplerColor *poppler_color)
581
AnnotColor *color = NULL;
584
color = new AnnotColor ((double)poppler_color->red / 65535,
585
(double)poppler_color->green / 65535,
586
(double)poppler_color->blue / 65535);
589
/* Annot takes ownership of the color */
590
poppler_annot->annot->setColor (color);
594
* poppler_annot_get_page_index:
595
* @poppler_annot: a #PopplerAnnot
597
* Returns the page index to which @poppler_annot is associated, or -1 if unknown
599
* Return value: page index or -1
604
poppler_annot_get_page_index (PopplerAnnot *poppler_annot)
608
g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), -1);
610
page_num = poppler_annot->annot->getPageNum();
611
return page_num <= 0 ? -1 : page_num - 1;
614
/* PopplerAnnotMarkup */
616
* poppler_annot_markup_get_label:
617
* @poppler_annot: a #PopplerAnnotMarkup
619
* Retrieves the label text of @poppler_annot.
621
* Return value: the label text of @poppler_annot.
624
poppler_annot_markup_get_label (PopplerAnnotMarkup *poppler_annot)
629
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), NULL);
631
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
633
text = annot->getLabel ();
635
return text ? _poppler_goo_string_to_utf8 (text) : NULL;
639
* poppler_annot_markup_set_label:
640
* @poppler_annot: a #PopplerAnnotMarkup
641
* @label: (allow-none): a text string containing the new label, or %NULL
643
* Sets the label text of @poppler_annot, replacing the current one
648
poppler_annot_markup_set_label (PopplerAnnotMarkup *poppler_annot,
656
g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
658
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
660
tmp = label ? g_convert (label, -1, "UTF-16BE", "UTF-8", NULL, &length, NULL) : NULL;
661
goo_tmp = new GooString (tmp, length);
663
annot->setLabel (goo_tmp);
668
* poppler_annot_markup_has_popup:
669
* @poppler_annot: a #PopplerAnnotMarkup
671
* Return %TRUE if the markup annotation has a popup window associated
673
* Return value: %TRUE, if @poppler_annot has popup, %FALSE otherwise
678
poppler_annot_markup_has_popup (PopplerAnnotMarkup *poppler_annot)
682
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), FALSE);
684
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
686
return annot->getPopup () != NULL;
690
* poppler_annot_markup_set_popup:
691
* @poppler_annot: a #PopplerAnnotMarkup
692
* @popup_rect: a #PopplerRectangle
694
* Associates a new popup window for editing contents of @poppler_annot.
695
* Popup window shall be displayed by viewers at @popup_rect on the page.
700
poppler_annot_markup_set_popup (PopplerAnnotMarkup *poppler_annot,
701
PopplerRectangle *popup_rect)
705
PDFRectangle pdf_rect(popup_rect->x1, popup_rect->y1,
706
popup_rect->x2, popup_rect->y2);
708
g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
710
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
711
popup = new AnnotPopup (annot->getXRef(), &pdf_rect, (Catalog *)NULL);
712
annot->setPopup (popup);
716
* poppler_annot_markup_get_popup_is_open:
717
* @poppler_annot: a #PopplerAnnotMarkup
719
* Retrieves the state of the popup window related to @poppler_annot.
721
* Return value: the state of @poppler_annot. %TRUE if it's open, %FALSE in
725
poppler_annot_markup_get_popup_is_open (PopplerAnnotMarkup *poppler_annot)
728
AnnotPopup *annot_popup;
730
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), FALSE);
732
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
734
if ((annot_popup = annot->getPopup ()))
735
return annot_popup->getOpen ();
741
* poppler_annot_markup_set_popup_is_open:
742
* @poppler_annot: a #PopplerAnnotMarkup
743
* @is_open: whether popup window should initially be displayed open
745
* Sets the state of the popup window related to @poppler_annot.
750
poppler_annot_markup_set_popup_is_open (PopplerAnnotMarkup *poppler_annot,
754
AnnotPopup *annot_popup;
756
g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
758
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
760
annot_popup = annot->getPopup ();
764
if (annot_popup->getOpen () != is_open)
765
annot_popup->setOpen (is_open);
769
* poppler_annot_markup_get_popup_rectangle:
770
* @poppler_annot: a #PopplerAnnotMarkup
771
* @poppler_rect: (out): a #PopplerRectangle to store the popup rectangle
773
* Retrieves the rectangle of the popup window related to @poppler_annot.
775
* Return value: %TRUE if #PopplerRectangle was correctly filled, %FALSE otherwise
780
poppler_annot_markup_get_popup_rectangle (PopplerAnnotMarkup *poppler_annot,
781
PopplerRectangle *poppler_rect)
785
PDFRectangle *annot_rect;
787
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), FALSE);
788
g_return_val_if_fail (poppler_rect != NULL, FALSE);
790
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
791
annot_popup = annot->getPopup ();
795
annot_rect = annot_popup->getRect ();
796
poppler_rect->x1 = annot_rect->x1;
797
poppler_rect->x2 = annot_rect->x2;
798
poppler_rect->y1 = annot_rect->y1;
799
poppler_rect->y2 = annot_rect->y2;
805
* poppler_annot_markup_get_opacity:
806
* @poppler_annot: a #PopplerAnnotMarkup
808
* Retrieves the opacity value of @poppler_annot.
810
* Return value: the opacity value of @poppler_annot,
811
* between 0 (transparent) and 1 (opaque)
814
poppler_annot_markup_get_opacity (PopplerAnnotMarkup *poppler_annot)
818
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), 0);
820
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
822
return annot->getOpacity ();
826
* poppler_annot_markup_set_opacity:
827
* @poppler_annot: a #PopplerAnnotMarkup
828
* @opacity: a constant opacity value, between 0 (transparent) and 1 (opaque)
830
* Sets the opacity of @poppler_annot. This value applies to
831
* all visible elements of @poppler_annot in its closed state,
832
* but not to the pop-up window that appears when it's openened
837
poppler_annot_markup_set_opacity (PopplerAnnotMarkup *poppler_annot,
842
g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
844
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
845
annot->setOpacity(opacity);
849
* poppler_annot_markup_get_date:
850
* @poppler_annot: a #PopplerAnnotMarkup
852
* Returns the date and time when the annotation was created
854
* Return value: (transfer full): a #GDate representing the date and time
855
* when the annotation was created, or %NULL
858
poppler_annot_markup_get_date (PopplerAnnotMarkup *poppler_annot)
861
GooString *annot_date;
864
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), NULL);
866
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
867
annot_date = annot->getDate ();
871
if (_poppler_convert_pdf_date_to_gtime (annot_date, &timet)) {
874
date = g_date_new ();
875
g_date_set_time_t (date, timet);
884
* poppler_annot_markup_get_subject:
885
* @poppler_annot: a #PopplerAnnotMarkup
887
* Retrives the subject text of @poppler_annot.
889
* Return value: the subject text of @poppler_annot.
892
poppler_annot_markup_get_subject (PopplerAnnotMarkup *poppler_annot)
897
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), NULL);
899
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
901
text = annot->getSubject ();
903
return text ? _poppler_goo_string_to_utf8 (text) : NULL;
907
* poppler_annot_markup_get_reply_to:
908
* @poppler_annot: a #PopplerAnnotMarkup
910
* Gets the reply type of @poppler_annot.
912
* Return value: #PopplerAnnotMarkupReplyType of @poppler_annot.
914
PopplerAnnotMarkupReplyType
915
poppler_annot_markup_get_reply_to (PopplerAnnotMarkup *poppler_annot)
919
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), POPPLER_ANNOT_MARKUP_REPLY_TYPE_R);
921
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
923
switch (annot->getReplyTo ())
925
case AnnotMarkup::replyTypeR:
926
return POPPLER_ANNOT_MARKUP_REPLY_TYPE_R;
927
case AnnotMarkup::replyTypeGroup:
928
return POPPLER_ANNOT_MARKUP_REPLY_TYPE_GROUP;
930
g_warning ("Unsupported Annot Markup Reply To Type");
933
return POPPLER_ANNOT_MARKUP_REPLY_TYPE_R;
937
* poppler_annot_markup_get_external_data:
938
* @poppler_annot: a #PopplerAnnotMarkup
940
* Gets the external data type of @poppler_annot.
942
* Return value: #PopplerAnnotExternalDataType of @poppler_annot.
944
PopplerAnnotExternalDataType
945
poppler_annot_markup_get_external_data (PopplerAnnotMarkup *poppler_annot)
949
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), POPPLER_ANNOT_EXTERNAL_DATA_MARKUP_UNKNOWN);
951
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
953
switch (annot->getExData ())
955
case annotExternalDataMarkup3D:
956
return POPPLER_ANNOT_EXTERNAL_DATA_MARKUP_3D;
957
case annotExternalDataMarkupUnknown:
958
return POPPLER_ANNOT_EXTERNAL_DATA_MARKUP_UNKNOWN;
960
g_warning ("Unsupported Annot Markup External Data");
963
return POPPLER_ANNOT_EXTERNAL_DATA_MARKUP_UNKNOWN;
966
/* PopplerAnnotText */
968
* poppler_annot_text_get_is_open:
969
* @poppler_annot: a #PopplerAnnotText
971
* Retrieves the state of @poppler_annot.
973
* Return value: the state of @poppler_annot. %TRUE if it's open, %FALSE in
977
poppler_annot_text_get_is_open (PopplerAnnotText *poppler_annot)
981
g_return_val_if_fail (POPPLER_IS_ANNOT_TEXT (poppler_annot), FALSE);
983
annot = static_cast<AnnotText *>(POPPLER_ANNOT (poppler_annot)->annot);
985
return annot->getOpen ();
989
* poppler_annot_text_set_is_open:
990
* @poppler_annot: a #PopplerAnnotText
991
* @is_open: whether annotation should initially be displayed open
993
* Sets whether @poppler_annot should initially be displayed open
998
poppler_annot_text_set_is_open (PopplerAnnotText *poppler_annot,
1003
g_return_if_fail (POPPLER_IS_ANNOT_TEXT (poppler_annot));
1005
annot = static_cast<AnnotText *>(POPPLER_ANNOT (poppler_annot)->annot);
1006
annot->setOpen(is_open);
1010
* poppler_annot_text_get_icon:
1011
* @poppler_annot: a #PopplerAnnotText
1013
* Gets name of the icon of @poppler_annot.
1015
* Return value: a new allocated string containing the icon name
1018
poppler_annot_text_get_icon (PopplerAnnotText *poppler_annot)
1023
g_return_val_if_fail (POPPLER_IS_ANNOT_TEXT (poppler_annot), NULL);
1025
annot = static_cast<AnnotText *>(POPPLER_ANNOT (poppler_annot)->annot);
1027
text = annot->getIcon ();
1029
return text ? _poppler_goo_string_to_utf8 (text) : NULL;
1033
* poppler_annot_text_set_icon:
1034
* @poppler_annot: a #PopplerAnnotText
1035
* @icon: the name of an icon
1037
* Sets the icon of @poppler_annot. The following predefined
1038
* icons are currently supported:
1041
* <term>#POPPLER_ANNOT_TEXT_ICON_NOTE</term>
1044
* <term>#POPPLER_ANNOT_TEXT_ICON_COMMENT</term>
1047
* <term>#POPPLER_ANNOT_TEXT_ICON_KEY</term>
1050
* <term>#POPPLER_ANNOT_TEXT_ICON_HELP</term>
1053
* <term>#POPPLER_ANNOT_TEXT_ICON_NEW_PARAGRAPH</term>
1056
* <term>#POPPLER_ANNOT_TEXT_ICON_PARAGRAPH</term>
1059
* <term>#POPPLER_ANNOT_TEXT_ICON_INSERT</term>
1062
* <term>#POPPLER_ANNOT_TEXT_ICON_CROSS</term>
1065
* <term>#POPPLER_ANNOT_TEXT_ICON_CIRCLE</term>
1072
poppler_annot_text_set_icon (PopplerAnnotText *poppler_annot,
1078
g_return_if_fail (POPPLER_IS_ANNOT_TEXT (poppler_annot));
1080
annot = static_cast<AnnotText *>(POPPLER_ANNOT (poppler_annot)->annot);
1082
text = new GooString(icon);
1083
annot->setIcon(text);
1088
* poppler_annot_text_get_state:
1089
* @poppler_annot: a #PopplerAnnotText
1091
* Retrieves the state of @poppler_annot.
1093
* Return value: #PopplerAnnotTextState of @poppler_annot.
1095
PopplerAnnotTextState
1096
poppler_annot_text_get_state (PopplerAnnotText *poppler_annot)
1100
g_return_val_if_fail (POPPLER_IS_ANNOT_TEXT (poppler_annot), POPPLER_ANNOT_TEXT_STATE_UNKNOWN);
1102
annot = static_cast<AnnotText *>(POPPLER_ANNOT (poppler_annot)->annot);
1104
switch (annot->getState ())
1106
case AnnotText::stateUnknown:
1107
return POPPLER_ANNOT_TEXT_STATE_UNKNOWN;
1108
case AnnotText::stateMarked:
1109
return POPPLER_ANNOT_TEXT_STATE_MARKED;
1110
case AnnotText::stateUnmarked:
1111
return POPPLER_ANNOT_TEXT_STATE_UNMARKED;
1112
case AnnotText::stateAccepted:
1113
return POPPLER_ANNOT_TEXT_STATE_ACCEPTED;
1114
case AnnotText::stateRejected:
1115
return POPPLER_ANNOT_TEXT_STATE_REJECTED;
1116
case AnnotText::stateCancelled:
1117
return POPPLER_ANNOT_TEXT_STATE_CANCELLED;
1118
case AnnotText::stateCompleted:
1119
return POPPLER_ANNOT_TEXT_STATE_COMPLETED;
1120
case AnnotText::stateNone:
1121
return POPPLER_ANNOT_TEXT_STATE_NONE;
1123
g_warning ("Unsupported Annot Text State");
1126
return POPPLER_ANNOT_TEXT_STATE_UNKNOWN;
1129
/* PopplerAnnotFreeText */
1131
* poppler_annot_free_text_get_quadding:
1132
* @poppler_annot: a #PopplerAnnotFreeText
1134
* Retrieves the justification of the text of @poppler_annot.
1136
* Return value: #PopplerAnnotFreeTextQuadding of @poppler_annot.
1138
PopplerAnnotFreeTextQuadding
1139
poppler_annot_free_text_get_quadding (PopplerAnnotFreeText *poppler_annot)
1141
AnnotFreeText *annot;
1143
g_return_val_if_fail (POPPLER_IS_ANNOT_FREE_TEXT (poppler_annot), POPPLER_ANNOT_FREE_TEXT_QUADDING_LEFT_JUSTIFIED);
1145
annot = static_cast<AnnotFreeText *>(POPPLER_ANNOT (poppler_annot)->annot);
1147
switch (annot->getQuadding ())
1149
case AnnotFreeText::quaddingLeftJustified:
1150
return POPPLER_ANNOT_FREE_TEXT_QUADDING_LEFT_JUSTIFIED;
1151
case AnnotFreeText::quaddingCentered:
1152
return POPPLER_ANNOT_FREE_TEXT_QUADDING_CENTERED;
1153
case AnnotFreeText::quaddingRightJustified:
1154
return POPPLER_ANNOT_FREE_TEXT_QUADDING_RIGHT_JUSTIFIED;
1156
g_warning ("Unsupported Annot Free Text Quadding");
1159
return POPPLER_ANNOT_FREE_TEXT_QUADDING_LEFT_JUSTIFIED;
1163
* poppler_annot_free_text_get_callout_line:
1164
* @poppler_annot: a #PopplerAnnotFreeText
1166
* Retrieves a #PopplerCalloutLine of four or six numbers specifying a callout
1167
* line attached to the @poppler_annot.
1169
* Return value: a new allocated #PopplerCalloutLine if the annot has a callout
1170
* line, NULL in other case. It must be freed with g_free() when
1173
PopplerAnnotCalloutLine *
1174
poppler_annot_free_text_get_callout_line (PopplerAnnotFreeText *poppler_annot)
1176
AnnotFreeText *annot;
1177
AnnotCalloutLine *line;
1179
g_return_val_if_fail (POPPLER_IS_ANNOT_FREE_TEXT (poppler_annot), NULL);
1181
annot = static_cast<AnnotFreeText *>(POPPLER_ANNOT (poppler_annot)->annot);
1183
if ((line = annot->getCalloutLine ())) {
1184
AnnotCalloutMultiLine *multiline;
1185
PopplerAnnotCalloutLine *callout = g_new0 (PopplerAnnotCalloutLine, 1);
1187
callout->x1 = line->getX1();
1188
callout->y1 = line->getY1();
1189
callout->x2 = line->getX2();
1190
callout->y2 = line->getY2();
1192
if ((multiline = static_cast<AnnotCalloutMultiLine *>(line))) {
1193
callout->multiline = TRUE;
1194
callout->x3 = multiline->getX3();
1195
callout->y3 = multiline->getY3();
1199
callout->multiline = FALSE;
1206
/* PopplerAnnotFileAttachment */
1208
* poppler_annot_file_attachment_get_attachment:
1209
* @poppler_annot: a #PopplerAnnotFileAttachment
1211
* Creates a #PopplerAttachment for the file of the file attachment annotation @annot.
1212
* The #PopplerAttachment must be unrefed with g_object_unref by the caller.
1214
* Return value: @PopplerAttachment
1219
poppler_annot_file_attachment_get_attachment (PopplerAnnotFileAttachment *poppler_annot)
1221
AnnotFileAttachment *annot;
1222
PopplerAttachment *attachment;
1224
g_return_val_if_fail (POPPLER_IS_ANNOT_FILE_ATTACHMENT (poppler_annot), NULL);
1226
annot = static_cast<AnnotFileAttachment *>(POPPLER_ANNOT (poppler_annot)->annot);
1228
EmbFile *emb_file = new EmbFile (annot->getFile(), annot->getContents());
1229
attachment = _poppler_attachment_new (emb_file);
1236
* poppler_annot_file_attachment_get_name:
1237
* @poppler_annot: a #PopplerAnnotFileAttachment
1239
* Retrieves the name of @poppler_annot.
1241
* Return value: a new allocated string with the name of @poppler_annot. It must
1242
* be freed with g_free() when done.
1246
poppler_annot_file_attachment_get_name (PopplerAnnotFileAttachment *poppler_annot)
1248
AnnotFileAttachment *annot;
1251
g_return_val_if_fail (POPPLER_IS_ANNOT_FILE_ATTACHMENT (poppler_annot), NULL);
1253
annot = static_cast<AnnotFileAttachment *>(POPPLER_ANNOT (poppler_annot)->annot);
1254
name = annot->getName ();
1256
return name ? _poppler_goo_string_to_utf8 (name) : NULL;
1259
/* PopplerAnnotCalloutLine */
1260
POPPLER_DEFINE_BOXED_TYPE (PopplerAnnotCalloutLine, poppler_annot_callout_line,
1261
poppler_annot_callout_line_copy,
1262
poppler_annot_callout_line_free)
1265
* poppler_annot_callout_line_new:
1267
* Creates a new empty #PopplerAnnotCalloutLine.
1269
* Return value: a new allocated #PopplerAnnotCalloutLine, NULL in other case.
1270
* It must be freed when done.
1272
PopplerAnnotCalloutLine *
1273
poppler_annot_callout_line_new (void)
1275
return g_new0 (PopplerAnnotCalloutLine, 1);
1279
* poppler_annot_callout_line_copy:
1280
* @callout: the #PopplerAnnotCalloutline to be copied.
1282
* It does copy @callout to a new #PopplerAnnotCalloutLine.
1284
* Return value: a new allocated #PopplerAnnotCalloutLine as exact copy of
1285
* @callout, NULL in other case. It must be freed when done.
1287
PopplerAnnotCalloutLine *
1288
poppler_annot_callout_line_copy (PopplerAnnotCalloutLine *callout)
1290
PopplerAnnotCalloutLine *new_callout;
1292
g_return_val_if_fail (callout != NULL, NULL);
1294
new_callout = g_new0 (PopplerAnnotCalloutLine, 1);
1295
*new_callout = *callout;
1301
* poppler_annot_callout_line_free:
1302
* @callout: a #PopplerAnnotCalloutLine
1304
* Frees the memory used by #PopplerAnnotCalloutLine.
1307
poppler_annot_callout_line_free (PopplerAnnotCalloutLine *callout)
1313
/* PopplerAnnotMovie */
1315
* poppler_annot_movie_get_title:
1316
* @poppler_annot: a #PopplerAnnotMovie
1318
* Retrieves the movie title of @poppler_annot.
1320
* Return value: the title text of @poppler_annot.
1325
poppler_annot_movie_get_title (PopplerAnnotMovie *poppler_annot)
1330
g_return_val_if_fail (POPPLER_IS_ANNOT_MOVIE (poppler_annot), NULL);
1332
annot = static_cast<AnnotMovie *>(POPPLER_ANNOT (poppler_annot)->annot);
1334
title = annot->getTitle ();
1336
return title ? _poppler_goo_string_to_utf8 (title) : NULL;
1340
* poppler_annot_movie_get_movie:
1341
* @poppler_annot: a #PopplerAnnotMovie
1343
* Retrieves the movie object (PopplerMovie) stored in the @poppler_annot.
1345
* Return value: (transfer none): the movie object stored in the @poppler_annot. The returned
1346
* object is owned by #PopplerAnnotMovie and should not be freed
1351
poppler_annot_movie_get_movie (PopplerAnnotMovie *poppler_annot)
1353
return poppler_annot->movie;
1356
/* PopplerAnnotScreen */
1358
* poppler_annot_screen_get_action:
1359
* @poppler_annot: a #PopplerAnnotScreen
1361
* Retrieves the action (#PopplerAction) that shall be performed when @poppler_annot is activated
1363
* Return value: (transfer none): the action to perform. The returned
1364
* object is owned by @poppler_annot and should not be freed
1369
poppler_annot_screen_get_action (PopplerAnnotScreen *poppler_annot)
1371
return poppler_annot->action;