Poppler Qt6 24.07.0
poppler-link.h
1/* poppler-link.h: qt interface to poppler
2 * Copyright (C) 2006, 2013, 2016, 2018, 2019, 2021, 2022, 2024, 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 * Copyright (C) 2024 Pratham Gandhi <ppg.1382@gmail.com>
10 * Adapting code from
11 * Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27
28#ifndef _POPPLER_LINK_H_
29#define _POPPLER_LINK_H_
30
31#include <QtCore/QString>
32#include <QtCore/QRectF>
33#include <QtCore/QSharedDataPointer>
34#include <QtCore/QVector>
35#include "poppler-export.h"
36
37#include <memory>
38
39struct Ref;
40class MediaRendition;
41
42namespace Poppler {
43
44class LinkPrivate;
45class LinkGotoPrivate;
46class LinkExecutePrivate;
47class LinkBrowsePrivate;
48class LinkActionPrivate;
49class LinkSoundPrivate;
50class LinkJavaScriptPrivate;
51class LinkMoviePrivate;
52class LinkDestinationData;
53class LinkDestinationPrivate;
54class LinkRenditionPrivate;
55class LinkOCGStatePrivate;
56class LinkHidePrivate;
57class LinkResetFormPrivate;
58class MediaRendition;
59class MovieAnnotation;
60class ScreenAnnotation;
61class SoundObject;
62
72class POPPLER_QT6_EXPORT LinkDestination
73{
74public:
78 enum Kind
79 {
86 destXYZ = 1,
87 destFit = 2,
88 destFitH = 3,
89 destFitV = 4,
90 destFitR = 5,
91 destFitB = 6,
92 destFitBH = 7,
93 destFitBV = 8
94 };
95
97 explicit LinkDestination(const LinkDestinationData &data);
98 explicit LinkDestination(const QString &description);
100
108
109 // Accessors.
113 Kind kind() const;
120 int pageNumber() const;
125 double left() const;
126 double bottom() const;
127 double right() const;
132 double top() const;
133 double zoom() const;
140 bool isChangeLeft() const;
147 bool isChangeTop() const;
153 bool isChangeZoom() const;
154
158 QString toString() const;
159
163 QString destinationName() const;
164
169
170private:
171 QSharedDataPointer<LinkDestinationPrivate> d;
172};
173
181class POPPLER_QT6_EXPORT Link
182{
183public:
185 explicit Link(const QRectF &linkArea);
187
208
212 virtual LinkType linkType() const;
213
217 virtual ~Link();
218
225 QRectF linkArea() const;
226
232 QVector<Link *> nextLinks() const;
233
234protected:
236 explicit Link(LinkPrivate &dd);
237 Q_DECLARE_PRIVATE(Link)
238 LinkPrivate *d_ptr;
240
241private:
242 Q_DISABLE_COPY(Link)
243};
244
253class POPPLER_QT6_EXPORT LinkGoto : public Link
254{
255public:
263 LinkGoto(const QRectF &linkArea, const QString &extFileName, const LinkDestination &destination);
267 ~LinkGoto() override;
268
273 bool isExternal() const;
274 // query for goto parameters
279 QString fileName() const;
284 LinkType linkType() const override;
285
286private:
287 Q_DECLARE_PRIVATE(LinkGoto)
288 Q_DISABLE_COPY(LinkGoto)
289};
290
299class POPPLER_QT6_EXPORT LinkExecute : public Link
300{
301public:
305 QString fileName() const;
309 QString parameters() const;
310
318 LinkExecute(const QRectF &linkArea, const QString &file, const QString &params);
322 ~LinkExecute() override;
323 LinkType linkType() const override;
324
325private:
326 Q_DECLARE_PRIVATE(LinkExecute)
327 Q_DISABLE_COPY(LinkExecute)
328};
329
338class POPPLER_QT6_EXPORT LinkBrowse : public Link
339{
340public:
344 QString url() const;
345
352 LinkBrowse(const QRectF &linkArea, const QString &url);
356 ~LinkBrowse() override;
357 LinkType linkType() const override;
358
359private:
360 Q_DECLARE_PRIVATE(LinkBrowse)
361 Q_DISABLE_COPY(LinkBrowse)
362};
363
370class POPPLER_QT6_EXPORT LinkAction : public Link
371{
372public:
377 {
378 PageFirst = 1,
379 PagePrev = 2,
380 PageNext = 3,
381 PageLast = 4,
382 HistoryBack = 5,
383 HistoryForward = 6,
384 Quit = 7,
385 Presentation = 8,
386 EndPresentation = 9,
387 Find = 10,
388 GoToPage = 11,
389 Close = 12,
390 Print = 13,
391 SaveAs = 14
392 };
393
398
406 LinkAction(const QRectF &linkArea, ActionType actionType);
410 ~LinkAction() override;
411 LinkType linkType() const override;
412
413private:
414 Q_DECLARE_PRIVATE(LinkAction)
415 Q_DISABLE_COPY(LinkAction)
416};
417
421class POPPLER_QT6_EXPORT LinkSound : public Link
422{
423public:
424 // create a Link_Sound
425 LinkSound(const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound);
429 ~LinkSound() override;
430
431 LinkType linkType() const override;
432
440 double volume() const;
445 bool synchronous() const;
450 bool repeat() const;
458 bool mix() const;
463
464private:
465 Q_DECLARE_PRIVATE(LinkSound)
466 Q_DISABLE_COPY(LinkSound)
467};
468
472class POPPLER_QT6_EXPORT LinkRendition : public Link
473{
474public:
479 {
480 NoRendition,
481 PlayRendition,
482 StopRendition,
483 PauseRendition,
484 ResumeRendition
485 };
486
496 [[deprecated]] LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref annotationReference);
497
507 LinkRendition(const QRectF &linkArea, std::unique_ptr<::MediaRendition> &&rendition, int operation, const QString &script, const Ref annotationReference);
508
512 ~LinkRendition() override;
513
514 LinkType linkType() const override;
515
519 MediaRendition *rendition() const;
520
525
529 QString script() const;
530
534 bool isReferencedAnnotation(const ScreenAnnotation *annotation) const;
535
536private:
537 Q_DECLARE_PRIVATE(LinkRendition)
538 Q_DISABLE_COPY(LinkRendition)
539};
540
544class POPPLER_QT6_EXPORT LinkJavaScript : public Link
545{
546public:
553 LinkJavaScript(const QRectF &linkArea, const QString &js);
557 ~LinkJavaScript() override;
558
559 LinkType linkType() const override;
560
564 QString script() const;
565
566private:
567 Q_DECLARE_PRIVATE(LinkJavaScript)
568 Q_DISABLE_COPY(LinkJavaScript)
569};
570
574class POPPLER_QT6_EXPORT LinkMovie : public Link
575{
576public:
581 {
582 Play,
583 Stop,
584 Pause,
585 Resume
586 };
587
598 LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref annotationReference);
602 ~LinkMovie() override;
603 LinkType linkType() const override;
611 bool isReferencedAnnotation(const MovieAnnotation *annotation) const;
612
613private:
614 Q_DECLARE_PRIVATE(LinkMovie)
615 Q_DISABLE_COPY(LinkMovie)
616};
617
621class POPPLER_QT6_EXPORT LinkOCGState : public Link
622{
623 friend class OptContentModel;
624
625public:
629 explicit LinkOCGState(LinkOCGStatePrivate *ocgp);
633 ~LinkOCGState() override;
634
635 LinkType linkType() const override;
636
637private:
638 Q_DECLARE_PRIVATE(LinkOCGState)
639 Q_DISABLE_COPY(LinkOCGState)
640};
641
645class POPPLER_QT6_EXPORT LinkHide : public Link
646{
647public:
651 explicit LinkHide(LinkHidePrivate *lhidep);
655 ~LinkHide() override;
656
657 LinkType linkType() const override;
658
662 QVector<QString> targets() const;
663
667 bool isShowAction() const;
668
669private:
670 Q_DECLARE_PRIVATE(LinkHide)
671 Q_DISABLE_COPY(LinkHide)
672};
673
679class POPPLER_QT6_EXPORT LinkResetForm : public Link
680{
681 friend class Document;
682
683public:
687 explicit LinkResetForm(LinkResetFormPrivate *lrfp);
688 /*
689 * Destructor
690 */
691 ~LinkResetForm() override;
692
693 LinkType linkType() const override;
694
695private:
696 Q_DECLARE_PRIVATE(LinkResetForm)
697 Q_DISABLE_COPY(LinkResetForm)
698};
699
700}
701
702#endif
PDF document.
Definition poppler-qt6.h:1055
"Standard" action request.
Definition poppler-link.h:371
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:377
An URL to browse.
Definition poppler-link.h:339
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:73
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:79
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:300
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:254
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:646
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:545
~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:575
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:581
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:622
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:473
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.
LinkRendition(const QRectF &linkArea, std::unique_ptr<::MediaRendition > &&rendition, int operation, const QString &script, const Ref annotationReference)
Create a new rendition link.
RenditionAction
Describes the possible rendition actions.
Definition poppler-link.h:479
ResetForm: an action to reset form fields.
Definition poppler-link.h:680
LinkResetForm(LinkResetFormPrivate *lrfp)
Creates a new ResetForm link.
LinkType linkType() const override
The type of this link.
Sound: a sound to be played.
Definition poppler-link.h:422
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:2196
The Poppler Qt6 binding.
Definition poppler-annotation.h:49