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, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
19 // Copyright (C) 2012 Tobias Koening <tobias.koenig@kdab.com>
21 // To see a description of the changes please see the Changelog file that
22 // came with your tarball or type make ChangeLog if you are building from git
24 //========================================================================
29 #ifdef USE_GCC_PRAGMAS
44 //------------------------------------------------------------------------
46 //------------------------------------------------------------------------
49 actionGoTo
, // go to destination
50 actionGoToR
, // go to destination in new file
51 actionLaunch
, // launch app (or open document)
53 actionNamed
, // named action
54 actionMovie
, // movie action
55 actionRendition
, // rendition action
56 actionSound
, // sound action
57 actionJavaScript
, // JavaScript action
58 actionOCGState
, // Set-OCG-State action
59 actionUnknown
// anything else
66 virtual ~LinkAction() {}
68 // Was the LinkAction created successfully?
69 virtual GBool
isOk() = 0;
71 // Check link action type.
72 virtual LinkActionKind
getKind() = 0;
74 // Parse a destination (old-style action) name, string, or array.
75 static LinkAction
*parseDest(Object
*obj
);
77 // Parse an action dictionary.
78 static LinkAction
*parseAction(Object
*obj
, GooString
*baseURI
= NULL
);
81 //------------------------------------------------------------------------
83 //------------------------------------------------------------------------
99 // Build a LinkDest from the array.
103 LinkDest
*copy() { return new LinkDest(this); }
105 // Was the LinkDest created successfully?
106 GBool
isOk() { return ok
; }
109 LinkDestKind
getKind() { return kind
; }
110 GBool
isPageRef() { return pageIsRef
; }
111 int getPageNum() { return pageNum
; }
112 Ref
getPageRef() { return pageRef
; }
113 double getLeft() { return left
; }
114 double getBottom() { return bottom
; }
115 double getRight() { return right
; }
116 double getTop() { return top
; }
117 double getZoom() { return zoom
; }
118 GBool
getChangeLeft() { return changeLeft
; }
119 GBool
getChangeTop() { return changeTop
; }
120 GBool
getChangeZoom() { return changeZoom
; }
124 LinkDestKind kind
; // destination type
125 GBool pageIsRef
; // is the page a reference or number?
127 Ref pageRef
; // reference to page
128 int pageNum
; // one-relative page number
130 double left
, bottom
; // position
132 double zoom
; // zoom factor
133 GBool changeLeft
, changeTop
; // which position components to change:
134 GBool changeZoom
; // destXYZ uses all three;
135 // destFitH/BH use changeTop;
136 // destFitV/BV use changeLeft
137 GBool ok
; // set if created successfully
139 LinkDest(LinkDest
*dest
);
142 //------------------------------------------------------------------------
144 //------------------------------------------------------------------------
146 class LinkGoTo
: public LinkAction
{
149 // Build a LinkGoTo from a destination (dictionary, name, or string).
150 LinkGoTo(Object
*destObj
);
155 // Was the LinkGoTo created successfully?
156 virtual GBool
isOk() { return dest
|| namedDest
; }
159 virtual LinkActionKind
getKind() { return actionGoTo
; }
160 LinkDest
*getDest() { return dest
; }
161 GooString
*getNamedDest() { return namedDest
; }
165 LinkDest
*dest
; // regular destination (NULL for remote
166 // link with bad destination)
167 GooString
*namedDest
; // named destination (only one of dest and
168 // and namedDest may be non-NULL)
171 //------------------------------------------------------------------------
173 //------------------------------------------------------------------------
175 class LinkGoToR
: public LinkAction
{
178 // Build a LinkGoToR from a file spec (dictionary) and destination
179 // (dictionary, name, or string).
180 LinkGoToR(Object
*fileSpecObj
, Object
*destObj
);
183 virtual ~LinkGoToR();
185 // Was the LinkGoToR created successfully?
186 virtual GBool
isOk() { return fileName
&& (dest
|| namedDest
); }
189 virtual LinkActionKind
getKind() { return actionGoToR
; }
190 GooString
*getFileName() { return fileName
; }
191 LinkDest
*getDest() { return dest
; }
192 GooString
*getNamedDest() { return namedDest
; }
196 GooString
*fileName
; // file name
197 LinkDest
*dest
; // regular destination (NULL for remote
198 // link with bad destination)
199 GooString
*namedDest
; // named destination (only one of dest and
200 // and namedDest may be non-NULL)
203 //------------------------------------------------------------------------
205 //------------------------------------------------------------------------
207 class LinkLaunch
: public LinkAction
{
210 // Build a LinkLaunch from an action dictionary.
211 LinkLaunch(Object
*actionObj
);
214 virtual ~LinkLaunch();
216 // Was the LinkLaunch created successfully?
217 virtual GBool
isOk() { return fileName
!= NULL
; }
220 virtual LinkActionKind
getKind() { return actionLaunch
; }
221 GooString
*getFileName() { return fileName
; }
222 GooString
*getParams() { return params
; }
226 GooString
*fileName
; // file name
227 GooString
*params
; // parameters
230 //------------------------------------------------------------------------
232 //------------------------------------------------------------------------
234 class LinkURI
: public LinkAction
{
237 // Build a LinkURI given the URI (string) and base URI.
238 LinkURI(Object
*uriObj
, GooString
*baseURI
);
243 // Was the LinkURI created successfully?
244 virtual GBool
isOk() { return uri
!= NULL
; }
247 virtual LinkActionKind
getKind() { return actionURI
; }
248 GooString
*getURI() { return uri
; }
252 GooString
*uri
; // the URI
255 //------------------------------------------------------------------------
257 //------------------------------------------------------------------------
259 class LinkNamed
: public LinkAction
{
262 // Build a LinkNamed given the action name.
263 LinkNamed(Object
*nameObj
);
265 virtual ~LinkNamed();
267 virtual GBool
isOk() { return name
!= NULL
; }
269 virtual LinkActionKind
getKind() { return actionNamed
; }
270 GooString
*getName() { return name
; }
278 //------------------------------------------------------------------------
280 //------------------------------------------------------------------------
282 class LinkMovie
: public LinkAction
{
292 LinkMovie(Object
*obj
);
293 virtual ~LinkMovie();
295 virtual GBool
isOk() { return annotRef
.num
>= 0 || annotTitle
!= NULL
; }
296 virtual LinkActionKind
getKind() { return actionMovie
; }
298 // a movie action stores either an indirect reference to a movie annotation
299 // or the movie annotation title
301 GBool
hasAnnotRef() { return annotRef
.num
>= 0; }
302 GBool
hasAnnotTitle() { return annotTitle
!= NULL
; }
303 Ref
*getAnnotRef() { return &annotRef
; }
304 GooString
*getAnnotTitle() { return annotTitle
; }
306 OperationType
getOperation() { return operation
; }
310 Ref annotRef
; // Annotation
311 GooString
*annotTitle
; // T
313 OperationType operation
; // Operation
317 //------------------------------------------------------------------------
319 //------------------------------------------------------------------------
321 class LinkRendition
: public LinkAction
{
324 * Describes the possible rendition operations.
326 enum RenditionOperation
{
334 LinkRendition(Object
*Obj
);
336 virtual ~LinkRendition();
338 virtual GBool
isOk() { return true; }
340 virtual LinkActionKind
getKind() { return actionRendition
; }
342 GBool
hasRenditionObject() { return renditionObj
.isDict(); }
343 Object
* getRenditionObject() { return &renditionObj
; }
345 GBool
hasScreenAnnot() { return screenRef
.isRef(); }
346 Ref
getScreenAnnot() { return screenRef
.getRef(); }
348 RenditionOperation
getOperation() { return operation
; }
350 MediaRendition
* getMedia() { return media
; }
352 GooString
*getScript() { return js
; }
358 RenditionOperation operation
;
360 MediaRendition
* media
;
365 //------------------------------------------------------------------------
367 //------------------------------------------------------------------------
369 class LinkSound
: public LinkAction
{
372 LinkSound(Object
*soundObj
);
374 virtual ~LinkSound();
376 virtual GBool
isOk() { return sound
!= NULL
; }
378 virtual LinkActionKind
getKind() { return actionSound
; }
380 double getVolume() { return volume
; }
381 GBool
getSynchronous() { return sync
; }
382 GBool
getRepeat() { return repeat
; }
383 GBool
getMix() { return mix
; }
384 Sound
*getSound() { return sound
; }
395 //------------------------------------------------------------------------
397 //------------------------------------------------------------------------
399 class LinkJavaScript
: public LinkAction
{
402 // Build a LinkJavaScript given the action name.
403 LinkJavaScript(Object
*jsObj
);
405 virtual ~LinkJavaScript();
407 virtual GBool
isOk() { return js
!= NULL
; }
409 virtual LinkActionKind
getKind() { return actionJavaScript
; }
410 GooString
*getScript() { return js
; }
417 //------------------------------------------------------------------------
419 //------------------------------------------------------------------------
420 class LinkOCGState
: public LinkAction
{
422 LinkOCGState(Object
*obj
);
424 virtual ~LinkOCGState();
426 virtual GBool
isOk() { return stateList
!= NULL
; }
428 virtual LinkActionKind
getKind() { return actionOCGState
; }
430 enum State
{ On
, Off
, Toggle
};
432 StateList() { list
= NULL
; }
438 GooList
*getStateList() { return stateList
; }
439 GBool
getPreserveRB() { return preserveRB
; }
446 //------------------------------------------------------------------------
448 //------------------------------------------------------------------------
450 class LinkUnknown
: public LinkAction
{
453 // Build a LinkUnknown with the specified action type.
454 LinkUnknown(char *actionA
);
457 virtual ~LinkUnknown();
459 // Was the LinkUnknown create successfully?
460 virtual GBool
isOk() { return action
!= NULL
; }
463 virtual LinkActionKind
getKind() { return actionUnknown
; }
464 GooString
*getAction() { return action
; }
468 GooString
*action
; // action subtype
471 //------------------------------------------------------------------------
473 //------------------------------------------------------------------------
478 // Extract links from array of annotations.
479 Links(Annots
*annots
);
484 // Iterate through list of links.
485 int getNumLinks() const { return numLinks
; }
486 AnnotLink
*getLink(int i
) const { return links
[i
]; }
488 // If point <x>,<y> is in a link, return the associated action;
490 LinkAction
*find(double x
, double y
) const;
492 // Return true if <x>,<y> is in a link.
493 GBool
onLink(double x
, double y
) const;