Poppler Qt6 24.04.0
poppler-link.h
1/* poppler-link.h: qt interface to poppler
2 * Copyright (C) 2006, 2013, 2016, 2018, 2019, 2021, 2022, 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, 2021 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
36struct Ref;
37class MediaRendition;
38
39namespace Poppler {
40
41class LinkPrivate;
42class LinkGotoPrivate;
43class LinkExecutePrivate;
44class LinkBrowsePrivate;
45class LinkActionPrivate;
46class LinkSoundPrivate;
47class LinkJavaScriptPrivate;
48class LinkMoviePrivate;
49class LinkDestinationData;
50class LinkDestinationPrivate;
51class LinkRenditionPrivate;
52class LinkOCGStatePrivate;
53class LinkHidePrivate;
54class MediaRendition;
55class MovieAnnotation;
56class ScreenAnnotation;
57class SoundObject;
58
68class POPPLER_QT6_EXPORT LinkDestination
69{
70public:
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
159 QString destinationName() const;
160
165
166private:
167 QSharedDataPointer<LinkDestinationPrivate> d;
168};
169
177class POPPLER_QT6_EXPORT Link
178{
179public:
181 explicit Link(const QRectF &linkArea);
183
203
207 virtual LinkType linkType() const;
208
212 virtual ~Link();
213
220 QRectF linkArea() const;
221
227 QVector<Link *> nextLinks() const;
228
229protected:
231 explicit Link(LinkPrivate &dd);
232 Q_DECLARE_PRIVATE(Link)
233 LinkPrivate *d_ptr;
235
236private:
237 Q_DISABLE_COPY(Link)
238};
239
248class POPPLER_QT6_EXPORT LinkGoto : public Link
249{
250public:
258 LinkGoto(const QRectF &linkArea, const QString &extFileName, const LinkDestination &destination);
262 ~LinkGoto() override;
263
268 bool isExternal() const;
269 // query for goto parameters
274 QString fileName() const;
279 LinkType linkType() const override;
280
281private:
282 Q_DECLARE_PRIVATE(LinkGoto)
283 Q_DISABLE_COPY(LinkGoto)
284};
285
294class POPPLER_QT6_EXPORT LinkExecute : public Link
295{
296public:
300 QString fileName() const;
304 QString parameters() const;
305
313 LinkExecute(const QRectF &linkArea, const QString &file, const QString &params);
317 ~LinkExecute() override;
318 LinkType linkType() const override;
319
320private:
321 Q_DECLARE_PRIVATE(LinkExecute)
322 Q_DISABLE_COPY(LinkExecute)
323};
324
333class POPPLER_QT6_EXPORT LinkBrowse : public Link
334{
335public:
339 QString url() const;
340
347 LinkBrowse(const QRectF &linkArea, const QString &url);
351 ~LinkBrowse() override;
352 LinkType linkType() const override;
353
354private:
355 Q_DECLARE_PRIVATE(LinkBrowse)
356 Q_DISABLE_COPY(LinkBrowse)
357};
358
365class POPPLER_QT6_EXPORT LinkAction : public Link
366{
367public:
372 {
373 PageFirst = 1,
374 PagePrev = 2,
375 PageNext = 3,
376 PageLast = 4,
377 HistoryBack = 5,
378 HistoryForward = 6,
379 Quit = 7,
380 Presentation = 8,
381 EndPresentation = 9,
382 Find = 10,
383 GoToPage = 11,
384 Close = 12,
385 Print = 13,
386 SaveAs = 14
387 };
388
393
401 LinkAction(const QRectF &linkArea, ActionType actionType);
405 ~LinkAction() override;
406 LinkType linkType() const override;
407
408private:
409 Q_DECLARE_PRIVATE(LinkAction)
410 Q_DISABLE_COPY(LinkAction)
411};
412
416class POPPLER_QT6_EXPORT LinkSound : public Link
417{
418public:
419 // create a Link_Sound
420 LinkSound(const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound);
424 ~LinkSound() override;
425
426 LinkType linkType() const override;
427
435 double volume() const;
440 bool synchronous() const;
445 bool repeat() const;
453 bool mix() const;
458
459private:
460 Q_DECLARE_PRIVATE(LinkSound)
461 Q_DISABLE_COPY(LinkSound)
462};
463
467class POPPLER_QT6_EXPORT LinkRendition : public Link
468{
469public:
474 {
475 NoRendition,
476 PlayRendition,
477 StopRendition,
478 PauseRendition,
479 ResumeRendition
480 };
481
491 LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref annotationReference);
492
496 ~LinkRendition() override;
497
498 LinkType linkType() const override;
499
503 MediaRendition *rendition() const;
504
509
513 QString script() const;
514
518 bool isReferencedAnnotation(const ScreenAnnotation *annotation) const;
519
520private:
521 Q_DECLARE_PRIVATE(LinkRendition)
522 Q_DISABLE_COPY(LinkRendition)
523};
524
528class POPPLER_QT6_EXPORT LinkJavaScript : public Link
529{
530public:
537 LinkJavaScript(const QRectF &linkArea, const QString &js);
541 ~LinkJavaScript() override;
542
543 LinkType linkType() const override;
544
548 QString script() const;
549
550private:
551 Q_DECLARE_PRIVATE(LinkJavaScript)
552 Q_DISABLE_COPY(LinkJavaScript)
553};
554
558class POPPLER_QT6_EXPORT LinkMovie : public Link
559{
560public:
565 {
566 Play,
567 Stop,
568 Pause,
569 Resume
570 };
571
582 LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref annotationReference);
586 ~LinkMovie() override;
587 LinkType linkType() const override;
595 bool isReferencedAnnotation(const MovieAnnotation *annotation) const;
596
597private:
598 Q_DECLARE_PRIVATE(LinkMovie)
599 Q_DISABLE_COPY(LinkMovie)
600};
601
605class POPPLER_QT6_EXPORT LinkOCGState : public Link
606{
607 friend class OptContentModel;
608
609public:
613 explicit LinkOCGState(LinkOCGStatePrivate *ocgp);
617 ~LinkOCGState() override;
618
619 LinkType linkType() const override;
620
621private:
622 Q_DECLARE_PRIVATE(LinkOCGState)
623 Q_DISABLE_COPY(LinkOCGState)
624};
625
629class POPPLER_QT6_EXPORT LinkHide : public Link
630{
631public:
635 explicit LinkHide(LinkHidePrivate *lhidep);
639 ~LinkHide() override;
640
641 LinkType linkType() const override;
642
646 QVector<QString> targets() const;
647
651 bool isShowAction() const;
652
653private:
654 Q_DECLARE_PRIVATE(LinkHide)
655 Q_DISABLE_COPY(LinkHide)
656};
657
658}
659
660#endif
"Standard" action request.
Definition poppler-link.h:366
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:372
An URL to browse.
Definition poppler-link.h:334
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 & operator=(const LinkDestination &other)
Assignment operator.
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.
Generic execution request.
Definition poppler-link.h:295
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:249
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, const 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:630
LinkHide(LinkHidePrivate *lhidep)
Create a new Hide link.
LinkType linkType() const override
The type of this link.
~LinkHide() override
Destructor.
QVector< QString > targets() const
The fully qualified target names of the action.
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:529
~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:559
LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref annotationReference)
Create a new Movie link.
~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:565
LinkType linkType() const override
The type of this 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:606
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:468
LinkType linkType() const override
The type of this link.
MediaRendition * rendition() const
Returns the media rendition object if the redition provides one, 0 otherwise.
bool isReferencedAnnotation(const ScreenAnnotation *annotation) const
Returns whether the given annotation is the referenced screen annotation for this rendition link.
LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref annotationReference)
Create a new 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:474
Sound: a sound to be played.
Definition poppler-link.h:417
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:948
Model for optional content.
Definition poppler-optcontent.h:47
Screen annotation.
Definition poppler-annotation.h:988
Container class for a sound file in a PDF document.
Definition poppler-qt6.h:2163
The Poppler Qt6 binding.
Definition poppler-annotation.h:49