1
//========================================================================
5
// Copyright 1996-2003 Glyph & Cog, LLC
7
//========================================================================
9
//========================================================================
11
// Modified under the Poppler project - http://poppler.freedesktop.org
13
// All changes made under the Poppler project to this file are licensed
14
// under GPL version 2 or later
16
// Copyright (C) 2006, 2008 Pino Toscano <pino@kde.org>
17
// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
18
// Copyright (C) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
20
// To see a description of the changes please see the Changelog file that
21
// came with your tarball or type make ChangeLog if you are building from git
23
//========================================================================
28
#ifdef USE_GCC_PRAGMAS
41
//------------------------------------------------------------------------
43
//------------------------------------------------------------------------
46
actionGoTo, // go to destination
47
actionGoToR, // go to destination in new file
48
actionLaunch, // launch app (or open document)
50
actionNamed, // named action
51
actionMovie, // movie action
53
actionSound, // sound action
54
actionJavaScript, // JavaScript action
55
actionOCGState, // Set-OCG-State action
56
actionUnknown // anything else
63
virtual ~LinkAction() {}
65
// Was the LinkAction created successfully?
66
virtual GBool isOk() = 0;
68
// Check link action type.
69
virtual LinkActionKind getKind() = 0;
71
// Parse a destination (old-style action) name, string, or array.
72
static LinkAction *parseDest(Object *obj);
74
// Parse an action dictionary.
75
static LinkAction *parseAction(Object *obj, GooString *baseURI = NULL);
78
//------------------------------------------------------------------------
80
//------------------------------------------------------------------------
96
// Build a LinkDest from the array.
100
LinkDest *copy() { return new LinkDest(this); }
102
// Was the LinkDest created successfully?
103
GBool isOk() { return ok; }
106
LinkDestKind getKind() { return kind; }
107
GBool isPageRef() { return pageIsRef; }
108
int getPageNum() { return pageNum; }
109
Ref getPageRef() { return pageRef; }
110
double getLeft() { return left; }
111
double getBottom() { return bottom; }
112
double getRight() { return right; }
113
double getTop() { return top; }
114
double getZoom() { return zoom; }
115
GBool getChangeLeft() { return changeLeft; }
116
GBool getChangeTop() { return changeTop; }
117
GBool getChangeZoom() { return changeZoom; }
121
LinkDestKind kind; // destination type
122
GBool pageIsRef; // is the page a reference or number?
124
Ref pageRef; // reference to page
125
int pageNum; // one-relative page number
127
double left, bottom; // position
129
double zoom; // zoom factor
130
GBool changeLeft, changeTop; // for destXYZ links, which position
131
GBool changeZoom; // components to change
132
GBool ok; // set if created successfully
134
LinkDest(LinkDest *dest);
137
//------------------------------------------------------------------------
139
//------------------------------------------------------------------------
141
class LinkGoTo: public LinkAction {
144
// Build a LinkGoTo from a destination (dictionary, name, or string).
145
LinkGoTo(Object *destObj);
150
// Was the LinkGoTo created successfully?
151
virtual GBool isOk() { return dest || namedDest; }
154
virtual LinkActionKind getKind() { return actionGoTo; }
155
LinkDest *getDest() { return dest; }
156
GooString *getNamedDest() { return namedDest; }
160
LinkDest *dest; // regular destination (NULL for remote
161
// link with bad destination)
162
GooString *namedDest; // named destination (only one of dest and
163
// and namedDest may be non-NULL)
166
//------------------------------------------------------------------------
168
//------------------------------------------------------------------------
170
class LinkGoToR: public LinkAction {
173
// Build a LinkGoToR from a file spec (dictionary) and destination
174
// (dictionary, name, or string).
175
LinkGoToR(Object *fileSpecObj, Object *destObj);
178
virtual ~LinkGoToR();
180
// Was the LinkGoToR created successfully?
181
virtual GBool isOk() { return fileName && (dest || namedDest); }
184
virtual LinkActionKind getKind() { return actionGoToR; }
185
GooString *getFileName() { return fileName; }
186
LinkDest *getDest() { return dest; }
187
GooString *getNamedDest() { return namedDest; }
191
GooString *fileName; // file name
192
LinkDest *dest; // regular destination (NULL for remote
193
// link with bad destination)
194
GooString *namedDest; // named destination (only one of dest and
195
// and namedDest may be non-NULL)
198
//------------------------------------------------------------------------
200
//------------------------------------------------------------------------
202
class LinkLaunch: public LinkAction {
205
// Build a LinkLaunch from an action dictionary.
206
LinkLaunch(Object *actionObj);
209
virtual ~LinkLaunch();
211
// Was the LinkLaunch created successfully?
212
virtual GBool isOk() { return fileName != NULL; }
215
virtual LinkActionKind getKind() { return actionLaunch; }
216
GooString *getFileName() { return fileName; }
217
GooString *getParams() { return params; }
221
GooString *fileName; // file name
222
GooString *params; // parameters
225
//------------------------------------------------------------------------
227
//------------------------------------------------------------------------
229
class LinkURI: public LinkAction {
232
// Build a LinkURI given the URI (string) and base URI.
233
LinkURI(Object *uriObj, GooString *baseURI);
238
// Was the LinkURI created successfully?
239
virtual GBool isOk() { return uri != NULL; }
242
virtual LinkActionKind getKind() { return actionURI; }
243
GooString *getURI() { return uri; }
247
GooString *uri; // the URI
250
//------------------------------------------------------------------------
252
//------------------------------------------------------------------------
254
class LinkNamed: public LinkAction {
257
// Build a LinkNamed given the action name.
258
LinkNamed(Object *nameObj);
260
virtual ~LinkNamed();
262
virtual GBool isOk() { return name != NULL; }
264
virtual LinkActionKind getKind() { return actionNamed; }
265
GooString *getName() { return name; }
273
//------------------------------------------------------------------------
275
//------------------------------------------------------------------------
277
class LinkMovie: public LinkAction {
287
LinkMovie(Object *obj);
288
virtual ~LinkMovie();
290
virtual GBool isOk() { return annotRef.num >= 0 || annotTitle != NULL; }
291
virtual LinkActionKind getKind() { return actionMovie; }
293
// a movie action stores either an indirect reference to a movie annotation
294
// or the movie annotation title
296
GBool hasAnnotRef() { return annotRef.num >= 0; }
297
GBool hasAnnotTitle() { return annotTitle != NULL; }
298
Ref *getAnnotRef() { return &annotRef; }
299
GooString *getAnnotTitle() { return annotTitle; }
301
OperationType getOperation() { return operation; }
305
Ref annotRef; // Annotation
306
GooString *annotTitle; // T
308
OperationType operation; // Operation
312
//------------------------------------------------------------------------
314
//------------------------------------------------------------------------
316
class LinkRendition: public LinkAction {
319
LinkRendition(Object *Obj);
321
virtual ~LinkRendition();
323
virtual GBool isOk() { return true; }
325
virtual LinkActionKind getKind() { return actionRendition; }
327
GBool hasRenditionObject() { return renditionObj.isDict(); }
328
Object* getRenditionObject() { return &renditionObj; }
330
GBool hasScreenAnnot() { return screenRef.isRef(); }
331
Ref getScreenAnnot() { return screenRef.getRef(); }
333
int getOperation() { return operation; }
335
MediaRendition* getMedia() { return media; }
337
GooString *getScript() { return js; }
345
MediaRendition* media;
350
//------------------------------------------------------------------------
352
//------------------------------------------------------------------------
354
class LinkSound: public LinkAction {
357
LinkSound(Object *soundObj);
359
virtual ~LinkSound();
361
virtual GBool isOk() { return sound != NULL; }
363
virtual LinkActionKind getKind() { return actionSound; }
365
double getVolume() { return volume; }
366
GBool getSynchronous() { return sync; }
367
GBool getRepeat() { return repeat; }
368
GBool getMix() { return mix; }
369
Sound *getSound() { return sound; }
380
//------------------------------------------------------------------------
382
//------------------------------------------------------------------------
384
class LinkJavaScript: public LinkAction {
387
// Build a LinkJavaScript given the action name.
388
LinkJavaScript(Object *jsObj);
390
virtual ~LinkJavaScript();
392
virtual GBool isOk() { return js != NULL; }
394
virtual LinkActionKind getKind() { return actionJavaScript; }
395
GooString *getScript() { return js; }
402
//------------------------------------------------------------------------
404
//------------------------------------------------------------------------
405
class LinkOCGState: public LinkAction {
407
LinkOCGState(Object *obj);
409
virtual ~LinkOCGState();
411
virtual GBool isOk() { return stateList != NULL; }
413
virtual LinkActionKind getKind() { return actionOCGState; }
415
enum State { On, Off, Toggle};
417
StateList() { list = NULL; }
423
GooList *getStateList() { return stateList; }
424
GBool getPreserveRB() { return preserveRB; }
431
//------------------------------------------------------------------------
433
//------------------------------------------------------------------------
435
class LinkUnknown: public LinkAction {
438
// Build a LinkUnknown with the specified action type.
439
LinkUnknown(char *actionA);
442
virtual ~LinkUnknown();
444
// Was the LinkUnknown create successfully?
445
virtual GBool isOk() { return action != NULL; }
448
virtual LinkActionKind getKind() { return actionUnknown; }
449
GooString *getAction() { return action; }
453
GooString *action; // action subtype
456
//------------------------------------------------------------------------
458
//------------------------------------------------------------------------
463
// Construct a link, given its dictionary.
464
Link(Dict *dict, GooString *baseURI);
469
// Was the link created successfully?
470
GBool isOk() { return ok; }
472
// Check if point is inside the link rectangle.
473
GBool inRect(double x, double y)
474
{ return x1 <= x && x <= x2 && y1 <= y && y <= y2; }
477
LinkAction *getAction() { return action; }
479
// Get the link rectangle.
480
void getRect(double *xa1, double *ya1, double *xa2, double *ya2)
481
{ *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; }
485
double x1, y1; // lower left corner
486
double x2, y2; // upper right corner
487
LinkAction *action; // action
488
GBool ok; // is link valid?
491
//------------------------------------------------------------------------
493
//------------------------------------------------------------------------
498
// Extract links from array of annotations.
499
Links(Object *annots, GooString *baseURI);
504
// Iterate through list of links.
505
int getNumLinks() const { return numLinks; }
506
Link *getLink(int i) const { return links[i]; }
508
// If point <x>,<y> is in a link, return the associated action;
510
LinkAction *find(double x, double y) const;
512
// Return true if <x>,<y> is in a link.
513
GBool onLink(double x, double y) const;