File: poppler-action.h

package info (click to toggle)
poppler 20.09.0-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 16,092 kB
  • sloc: cpp: 151,577; ansic: 30,155; python: 367; makefile: 42; sh: 36
file content (347 lines) | stat: -rw-r--r-- 9,870 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/* poppler-action.h: glib interface to poppler
 * Copyright (C) 2004, Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __POPPLER_ACTION_H__
#define __POPPLER_ACTION_H__

#include <glib-object.h>
#include "poppler.h"

G_BEGIN_DECLS

/**
 * PopplerActionType:
 * @POPPLER_ACTION_UNKNOWN: unknown action
 * @POPPLER_ACTION_NONE: no action specified
 * @POPPLER_ACTION_GOTO_DEST: go to destination
 * @POPPLER_ACTION_GOTO_REMOTE: go to destination in another document
 * @POPPLER_ACTION_LAUNCH: launch app (or open document
 * @POPPLER_ACTION_URI: URI
 * @POPPLER_ACTION_NAMED: predefined action
 * @POPPLER_ACTION_MOVIE: play movies. Since 0.14
 * @POPPLER_ACTION_RENDITION: play multimedia content. Since 0.14
 * @POPPLER_ACTION_OCG_STATE: state of layer. Since 0.14
 * @POPPLER_ACTION_JAVASCRIPT: Javascript. Since 0.18
 * @POPPLER_ACTION_RESET_FORM: resets form. Since 0.90
 *
 * Action types
 */
typedef enum
{
    POPPLER_ACTION_UNKNOWN, /* unknown action */
    POPPLER_ACTION_NONE, /* no action specified */
    POPPLER_ACTION_GOTO_DEST, /* go to destination */
    POPPLER_ACTION_GOTO_REMOTE, /* go to destination in new file */
    POPPLER_ACTION_LAUNCH, /* launch app (or open document) */
    POPPLER_ACTION_URI, /* URI */
    POPPLER_ACTION_NAMED, /* named action*/
    POPPLER_ACTION_MOVIE, /* movie action */
    POPPLER_ACTION_RENDITION, /* rendition action */
    POPPLER_ACTION_OCG_STATE, /* Set-OCG-State action */
    POPPLER_ACTION_JAVASCRIPT, /* Javascript action */
    POPPLER_ACTION_RESET_FORM /* ResetForm action */
} PopplerActionType;

/**
 * PopplerDestType:
 * @POPPLER_DEST_UNKNOWN: unknown destination
 * @POPPLER_DEST_XYZ: go to page with coordinates (left, top)
 * positioned at the upper-left corner of the window and the contents of
 * the page magnified by the factor zoom
 * @POPPLER_DEST_FIT: go to page with its contents magnified just
 * enough to fit the entire page within the window both horizontally and
 * vertically
 * @POPPLER_DEST_FITH: go to page with the vertical coordinate top
 * positioned at the top edge of the window and the contents of the page
 * magnified just enough to fit the entire width of the page within the window
 * @POPPLER_DEST_FITV: go to page with the horizontal coordinate
 * left positioned at the left edge of the window and the contents of the
 * page magnified just enough to fit the entire height of the page within the window
 * @POPPLER_DEST_FITR: go to page with its contents magnified just
 * enough to fit the rectangle specified by the coordinates left, bottom,
 * right, and top entirely within the window both horizontally and vertically
 * @POPPLER_DEST_FITB: go to page with its contents magnified just enough to fit
 * its bounding box entirely within the window both horizontally and vertically
 * @POPPLER_DEST_FITBH: go to page with the vertical
 * coordinate top positioned at the top edge of the window and the
 * contents of the page magnified just enough to fit the entire width of its
 * bounding box within the window
 * @POPPLER_DEST_FITBV: go to page with the horizontal
 * coordinate left positioned at the left edge of the window and the
 * contents of the page magnified just enough to fit the entire height of its
 * bounding box within the window
 * @POPPLER_DEST_NAMED: got to page specified by a name. See poppler_document_find_dest()
 *
 * Destination types
 */
typedef enum
{
    POPPLER_DEST_UNKNOWN,
    POPPLER_DEST_XYZ,
    POPPLER_DEST_FIT,
    POPPLER_DEST_FITH,
    POPPLER_DEST_FITV,
    POPPLER_DEST_FITR,
    POPPLER_DEST_FITB,
    POPPLER_DEST_FITBH,
    POPPLER_DEST_FITBV,
    POPPLER_DEST_NAMED
} PopplerDestType;

/**
 * PopplerActionMovieOperation:
 * @POPPLER_ACTION_MOVIE_PLAY: play movie
 * @POPPLER_ACTION_MOVIE_PAUSE: pause playing movie
 * @POPPLER_ACTION_MOVIE_RESUME: resume paused movie
 * @POPPLER_ACTION_MOVIE_STOP: stop playing movie
 *
 * Movie operations
 *
 * Since: 0.14
 */
typedef enum
{
    POPPLER_ACTION_MOVIE_PLAY,
    POPPLER_ACTION_MOVIE_PAUSE,
    POPPLER_ACTION_MOVIE_RESUME,
    POPPLER_ACTION_MOVIE_STOP
} PopplerActionMovieOperation;

/**
 * PopplerActionLayerAction:
 * @POPPLER_ACTION_LAYER_ON: set layer visibility on
 * @POPPLER_ACTION_LAYER_OFF: set layer visibility off
 * @POPPLER_ACTION_LAYER_TOGGLE: reverse the layer visibility state
 *
 * Layer actions
 *
 * Since: 0.14
 */
typedef enum
{
    POPPLER_ACTION_LAYER_ON,
    POPPLER_ACTION_LAYER_OFF,
    POPPLER_ACTION_LAYER_TOGGLE
} PopplerActionLayerAction;

/* Define the PopplerAction types */
typedef struct _PopplerActionAny PopplerActionAny;
typedef struct _PopplerActionGotoDest PopplerActionGotoDest;
typedef struct _PopplerActionGotoRemote PopplerActionGotoRemote;
typedef struct _PopplerActionLaunch PopplerActionLaunch;
typedef struct _PopplerActionUri PopplerActionUri;
typedef struct _PopplerActionNamed PopplerActionNamed;
typedef struct _PopplerActionMovie PopplerActionMovie;
typedef struct _PopplerActionRendition PopplerActionRendition;
typedef struct _PopplerActionOCGState PopplerActionOCGState;
typedef struct _PopplerActionJavascript PopplerActionJavascript;
typedef struct _PopplerActionResetForm PopplerActionResetForm;

/**
 * PopplerDest:
 * @type: type of destination
 * @page_num: page number
 * @left: left coordinate
 * @bottom: bottom coordinate
 * @right: right coordinate
 * @top: top coordinate
 * @zoom: scale factor
 * @named_dest: name of the destination (#POPPLER_DEST_NAMED only)
 * @change_left: whether left coordinate should be changed
 * @change_top: whether top coordinate should be changed
 * @change_zoom: whether scale factor should be changed
 *
 * Data structure for holding a destination
 *
 * Note that @named_dest is the string representation of the named
 * destination. This is the right form to pass to poppler functions,
 * e.g. poppler_document_find_dest(), but to get the destination as
 * it appears in the PDF itself, you need to convert it to a bytestring
 * with poppler_named_dest_to_bytestring() first.
 * Also note that @named_dest does not have a defined encoding and
 * is not in a form suitable to be displayed to the user.
 */
struct _PopplerDest
{
    PopplerDestType type;

    int page_num;
    double left;
    double bottom;
    double right;
    double top;
    double zoom;
    gchar *named_dest;
    guint change_left : 1;
    guint change_top : 1;
    guint change_zoom : 1;
};

/**
 * PopplerActionLayer:
 * @action: a #PopplerActionLayerAction
 * @layers: list of #PopplerLayer<!-- -->s
 *
 * Action to perform over a list of layers
 */
struct _PopplerActionLayer
{
    PopplerActionLayerAction action;
    GList *layers;
};

struct _PopplerActionAny
{
    PopplerActionType type;
    gchar *title;
};

struct _PopplerActionGotoDest
{
    PopplerActionType type;
    gchar *title;

    PopplerDest *dest;
};

struct _PopplerActionGotoRemote
{
    PopplerActionType type;
    gchar *title;

    gchar *file_name;
    PopplerDest *dest;
};

struct _PopplerActionLaunch
{
    PopplerActionType type;
    gchar *title;

    gchar *file_name;
    gchar *params;
};

struct _PopplerActionUri
{
    PopplerActionType type;
    gchar *title;

    char *uri;
};

struct _PopplerActionNamed
{
    PopplerActionType type;
    gchar *title;

    gchar *named_dest;
};

struct _PopplerActionMovie
{
    PopplerActionType type;
    gchar *title;

    PopplerActionMovieOperation operation;
    PopplerMovie *movie;
};

struct _PopplerActionRendition
{
    PopplerActionType type;
    gchar *title;

    gint op;
    PopplerMedia *media;
};

struct _PopplerActionOCGState
{
    PopplerActionType type;
    gchar *title;

    GList *state_list;
};

struct _PopplerActionJavascript
{
    PopplerActionType type;
    gchar *title;

    gchar *script;
};

struct _PopplerActionResetForm
{
    PopplerActionType type;
    gchar *title;

    GList *fields;
    gboolean exclude;
};

/**
 * PopplerAction:
 *
 * A data structure for holding actions
 */
union _PopplerAction {
    PopplerActionType type;
    PopplerActionAny any;
    PopplerActionGotoDest goto_dest;
    PopplerActionGotoRemote goto_remote;
    PopplerActionLaunch launch;
    PopplerActionUri uri;
    PopplerActionNamed named;
    PopplerActionMovie movie;
    PopplerActionRendition rendition;
    PopplerActionOCGState ocg_state;
    PopplerActionJavascript javascript;
    PopplerActionResetForm reset_form;
};

#define POPPLER_TYPE_ACTION (poppler_action_get_type())
#define POPPLER_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), POPPLER_TYPE_ACTION, PopplerAction))

POPPLER_PUBLIC
GType poppler_action_get_type(void) G_GNUC_CONST;

POPPLER_PUBLIC
void poppler_action_free(PopplerAction *action);
POPPLER_PUBLIC
PopplerAction *poppler_action_copy(PopplerAction *action);

#define POPPLER_TYPE_DEST (poppler_dest_get_type())
POPPLER_PUBLIC
GType poppler_dest_get_type(void) G_GNUC_CONST;

POPPLER_PUBLIC
void poppler_dest_free(PopplerDest *dest);
POPPLER_PUBLIC
PopplerDest *poppler_dest_copy(PopplerDest *dest);

POPPLER_PUBLIC
char *poppler_named_dest_from_bytestring(const guint8 *data, gsize length);

POPPLER_PUBLIC
guint8 *poppler_named_dest_to_bytestring(const char *name, gsize *length);

G_END_DECLS

#endif /* __POPPLER_GLIB_H__ */