Poppler Qt5  21.09.0
poppler-link.h
1 /* poppler-link.h: qt interface to poppler
2  * Copyright (C) 2006, 2013, 2016, 2018, 2019, 2021, Albert Astals Cid <aacid@kde.org>
3  * Copyright (C) 2007-2008, 2010, Pino Toscano <pino@kde.org>
4  * Copyright (C) 2010, 2012, Guillermo Amaral <gamaral@kdab.com>
5  * Copyright (C) 2012, Tobias Koenig <tokoe@kdab.com>
6  * Copyright (C) 2013, Anthony Granger <grangeranthony@gmail.com>
7  * Copyright (C) 2018 Intevation GmbH <intevation@intevation.de>
8  * Copyright (C) 2020 Oliver Sander <oliver.sander@tu-dresden.de>
9  * Adapting code from
10  * Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
25  */
26 
27 #ifndef _POPPLER_LINK_H_
28 #define _POPPLER_LINK_H_
29 
30 #include <QtCore/QString>
31 #include <QtCore/QRectF>
32 #include <QtCore/QSharedDataPointer>
33 #include <QtCore/QVector>
34 #include "poppler-export.h"
35 
36 struct Ref;
37 class MediaRendition;
38 
39 namespace Poppler {
40 
41 class LinkPrivate;
42 class LinkGotoPrivate;
43 class LinkExecutePrivate;
44 class LinkBrowsePrivate;
45 class LinkActionPrivate;
46 class LinkSoundPrivate;
47 class LinkJavaScriptPrivate;
48 class LinkMoviePrivate;
49 class LinkDestinationData;
50 class LinkDestinationPrivate;
51 class LinkRenditionPrivate;
52 class LinkOCGStatePrivate;
53 class LinkHidePrivate;
54 class MediaRendition;
55 class MovieAnnotation;
56 class ScreenAnnotation;
57 class SoundObject;
58 
68 class POPPLER_QT5_EXPORT LinkDestination
69 {
70 public:
74  enum Kind
75  {
82  destXYZ = 1,
83  destFit = 2,
84  destFitH = 3,
85  destFitV = 4,
86  destFitR = 5,
87  destFitB = 6,
88  destFitBH = 7,
89  destFitBV = 8
90  };
91 
93  explicit LinkDestination(const LinkDestinationData &data);
94  explicit LinkDestination(const QString &description);
96 
104 
105  // Accessors.
109  Kind kind() const;
116  int pageNumber() const;
121  double left() const;
122  double bottom() const;
123  double right() const;
128  double top() const;
129  double zoom() const;
136  bool isChangeLeft() const;
143  bool isChangeTop() const;
149  bool isChangeZoom() const;
150 
154  QString toString() const;
155 
161  QString destinationName() const;
162 
167 
168 private:
169  QSharedDataPointer<LinkDestinationPrivate> d;
170 };
171 
179 class POPPLER_QT5_EXPORT Link
180 {
181 public:
183  explicit Link(const QRectF &linkArea);
185 
191  enum LinkType
192  {
204  };
205 
209  virtual LinkType linkType() const;
210 
214  virtual ~Link();
215 
222  QRectF linkArea() const;
223 
229  QVector<Link *> nextLinks() const;
230 
231 protected:
233  explicit Link(LinkPrivate &dd);
234  Q_DECLARE_PRIVATE(Link)
235  LinkPrivate *d_ptr;
237 
238 private:
239  Q_DISABLE_COPY(Link)
240 };
241 
250 class POPPLER_QT5_EXPORT LinkGoto : public Link
251 {
252 public:
260  // TODO Next ABI break, make extFileName const &
261  LinkGoto(const QRectF &linkArea, QString extFileName, const LinkDestination &destination);
265  ~LinkGoto() override;
266 
271  bool isExternal() const;
272  // query for goto parameters
277  QString fileName() const;
282  LinkType linkType() const override;
283 
284 private:
285  Q_DECLARE_PRIVATE(LinkGoto)
286  Q_DISABLE_COPY(LinkGoto)
287 };
288 
297 class POPPLER_QT5_EXPORT LinkExecute : public Link
298 {
299 public:
303  QString fileName() const;
307  QString parameters() const;
308 
316  LinkExecute(const QRectF &linkArea, const QString &file, const QString &params);
320  ~LinkExecute() override;
321  LinkType linkType() const override;
322 
323 private:
324  Q_DECLARE_PRIVATE(LinkExecute)
325  Q_DISABLE_COPY(LinkExecute)
326 };
327 
336 class POPPLER_QT5_EXPORT LinkBrowse : public Link
337 {
338 public:
342  QString url() const;
343 
350  LinkBrowse(const QRectF &linkArea, const QString &url);
354  ~LinkBrowse() override;
355  LinkType linkType() const override;
356 
357 private:
358  Q_DECLARE_PRIVATE(LinkBrowse)
359  Q_DISABLE_COPY(LinkBrowse)
360 };
361 
368 class POPPLER_QT5_EXPORT LinkAction : public Link
369 {
370 public:
375  {
376  PageFirst = 1,
377  PagePrev = 2,
378  PageNext = 3,
379  PageLast = 4,
380  HistoryBack = 5,
381  HistoryForward = 6,
382  Quit = 7,
383  Presentation = 8,
384  EndPresentation = 9,
385  Find = 10,
386  GoToPage = 11,
387  Close = 12,
388  Print = 13
389  };
390 
395 
403  LinkAction(const QRectF &linkArea, ActionType actionType);
407  ~LinkAction() override;
408  LinkType linkType() const override;
409 
410 private:
411  Q_DECLARE_PRIVATE(LinkAction)
412  Q_DISABLE_COPY(LinkAction)
413 };
414 
420 class POPPLER_QT5_EXPORT LinkSound : public Link
421 {
422 public:
423  // create a Link_Sound
424  LinkSound(const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound);
428  ~LinkSound() override;
429 
430  LinkType linkType() const override;
431 
439  double volume() const;
444  bool synchronous() const;
449  bool repeat() const;
457  bool mix() const;
461  SoundObject *sound() const;
462 
463 private:
464  Q_DECLARE_PRIVATE(LinkSound)
465  Q_DISABLE_COPY(LinkSound)
466 };
467 
473 class POPPLER_QT5_EXPORT LinkRendition : public Link
474 {
475 public:
482  {
483  NoRendition,
484  PlayRendition,
485  StopRendition,
486  PauseRendition,
487  ResumeRendition
488  };
489 
500  // TODO Next ABI break, remove & from annotationReference
501  LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference);
502 
506  ~LinkRendition() override;
507 
508  LinkType linkType() const override;
509 
513  MediaRendition *rendition() const;
514 
521 
527  QString script() const;
528 
534  bool isReferencedAnnotation(const ScreenAnnotation *annotation) const;
535 
536 private:
537  Q_DECLARE_PRIVATE(LinkRendition)
538  Q_DISABLE_COPY(LinkRendition)
539 };
540 
546 class POPPLER_QT5_EXPORT LinkJavaScript : public Link
547 {
548 public:
555  LinkJavaScript(const QRectF &linkArea, const QString &js);
559  ~LinkJavaScript() override;
560 
561  LinkType linkType() const override;
562 
566  QString script() const;
567 
568 private:
569  Q_DECLARE_PRIVATE(LinkJavaScript)
570  Q_DISABLE_COPY(LinkJavaScript)
571 };
572 
578 class POPPLER_QT5_EXPORT LinkMovie : public Link
579 {
580 public:
585  {
586  Play,
587  Stop,
588  Pause,
589  Resume
590  };
591 
602  // TODO Next ABI break, remove & from annotationReference
603  LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference);
607  ~LinkMovie() override;
608  LinkType linkType() const override;
616  bool isReferencedAnnotation(const MovieAnnotation *annotation) const;
617 
618 private:
619  Q_DECLARE_PRIVATE(LinkMovie)
620  Q_DISABLE_COPY(LinkMovie)
621 };
622 
628 class POPPLER_QT5_EXPORT LinkOCGState : public Link
629 {
630  friend class OptContentModel;
631 
632 public:
636  explicit LinkOCGState(LinkOCGStatePrivate *ocgp);
640  ~LinkOCGState() override;
641 
642  LinkType linkType() const override;
643 
644 private:
645  Q_DECLARE_PRIVATE(LinkOCGState)
646  Q_DISABLE_COPY(LinkOCGState)
647 };
648 
654 class POPPLER_QT5_EXPORT LinkHide : public Link
655 {
656 public:
660  explicit LinkHide(LinkHidePrivate *lhidep);
664  ~LinkHide() override;
665 
666  LinkType linkType() const override;
667 
671  QVector<QString> targets() const;
672 
676  bool isShowAction() const;
677 
678 private:
679  Q_DECLARE_PRIVATE(LinkHide)
680  Q_DISABLE_COPY(LinkHide)
681 };
682 
683 }
684 
685 #endif
"Standard" action request.
Definition: poppler-link.h:369
ActionType actionType() const
The action of the current LinkAction.
LinkAction(const QRectF &linkArea, ActionType actionType)
Create a new Action link, that executes a specified action on the document.
LinkType linkType() const override
The type of this link.
~LinkAction() override
Destructor.
ActionType
The possible types of actions.
Definition: poppler-link.h:375
An URL to browse.
Definition: poppler-link.h:337
LinkBrowse(const QRectF &linkArea, const QString &url)
Create a new browse link.
QString url() const
The URL to open.
~LinkBrowse() override
Destructor.
LinkType linkType() const override
The type of this link.
A destination.
Definition: poppler-link.h:69
Kind kind() const
The kind of destination.
LinkDestination(const LinkDestination &other)
Copy constructor.
double left() const
The new left for the viewport of the target page, in case it is specified to be changed (see isChange...
bool isChangeTop() const
Whether the top of the viewport on the target page should be changed.
bool isChangeLeft() const
Whether the left of the viewport on the target page should be changed.
QString destinationName() const
Return the name of this destination.
int pageNumber() const
Which page is the target of this destination.
QString toString() const
Return a string repesentation of this destination.
Kind
The possible kind of "viewport destination".
Definition: poppler-link.h:75
double top() const
The new top for the viewport of the target page, in case it is specified to be changed (see isChangeT...
bool isChangeZoom() const
Whether the zoom level should be changed.
~LinkDestination()
Destructor.
LinkDestination & operator=(const LinkDestination &other)
Assignment operator.
Generic execution request.
Definition: poppler-link.h:298
QString parameters() const
The parameters for the command.
LinkType linkType() const override
The type of this link.
QString fileName() const
The file name to be executed.
LinkExecute(const QRectF &linkArea, const QString &file, const QString &params)
Create a new Execute link.
~LinkExecute() override
Destructor.
Viewport reaching request.
Definition: poppler-link.h:251
LinkType linkType() const override
The type of this link.
QString fileName() const
The file name of the document the destination() refers to, or an empty string in case it refers to th...
~LinkGoto() override
Destructor.
LinkGoto(const QRectF &linkArea, QString extFileName, const LinkDestination &destination)
Create a new Goto link.
bool isExternal() const
Whether the destination is in an external document (i.e.
LinkDestination destination() const
The destination to reach.
Hide: an action to show / hide a field.
Definition: poppler-link.h:655
LinkHide(LinkHidePrivate *lhidep)
Create a new Hide link.
QVector< QString > targets() const
The fully qualified target names of the action.
LinkType linkType() const override
The type of this link.
~LinkHide() override
Destructor.
bool isShowAction() const
Should this action change the visibility of the target to true.
JavaScript: a JavaScript code to be interpreted.
Definition: poppler-link.h:547
~LinkJavaScript() override
Destructor.
QString script() const
The JS code.
LinkJavaScript(const QRectF &linkArea, const QString &js)
Create a new JavaScript link.
LinkType linkType() const override
The type of this link.
Movie: a movie to be played.
Definition: poppler-link.h:579
~LinkMovie() override
Destructor.
Operation operation() const
Returns the operation to be performed on the movie.
Operation
Describes the operation to be performed on the movie.
Definition: poppler-link.h:585
LinkType linkType() const override
The type of this link.
LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference)
Create a new Movie link.
bool isReferencedAnnotation(const MovieAnnotation *annotation) const
Returns whether the given annotation is the referenced movie annotation for this movie link.
OCGState: an optional content group state change.
Definition: poppler-link.h:629
LinkType linkType() const override
The type of this link.
~LinkOCGState() override
Destructor.
LinkOCGState(LinkOCGStatePrivate *ocgp)
Create a new OCGState link.
Rendition: Rendition link.
Definition: poppler-link.h:474
LinkType linkType() const override
The type of this link.
MediaRendition * rendition() const
Returns the media rendition object if the redition provides one, 0 otherwise.
LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference)
Create a new rendition link.
bool isReferencedAnnotation(const ScreenAnnotation *annotation) const
Returns whether the given annotation is the referenced screen annotation for this rendition link.
RenditionAction action() const
Returns the action that should be executed if a rendition object is provided.
~LinkRendition() override
Destructor.
QString script() const
The JS code that shall be executed or an empty string.
RenditionAction
Describes the possible rendition actions.
Definition: poppler-link.h:482
Sound: a sound to be played.
Definition: poppler-link.h:421
LinkType linkType() const override
The type of this link.
SoundObject * sound() const
The sound object to be played.
bool synchronous() const
Whether the playback of the sound should be synchronous (thus blocking, waiting for the end of the so...
~LinkSound() override
Destructor.
bool mix() const
Whether the playback of this sound can be mixed with playbacks with other sounds of the same document...
bool repeat() const
Whether the sound should be played continuously (that is, started again when it ends)
double volume() const
The volume to be used when playing the sound.
Movie annotation.
Definition: poppler-annotation.h:1034
Model for optional content.
Definition: poppler-optcontent.h:49
Screen annotation.
Definition: poppler-annotation.h:1078
Container class for a sound file in a PDF document.
Definition: poppler-qt5.h:2356
The Poppler Qt5 binding.
Definition: poppler-annotation.h:50