Poppler Qt6 24.10.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 LinkSubmitFormPrivate;
59class MediaRendition;
60class MovieAnnotation;
61class ScreenAnnotation;
62class SoundObject;
63
73class POPPLER_QT6_EXPORT LinkDestination
74{
75public:
79 enum Kind
80 {
87 destXYZ = 1,
88 destFit = 2,
89 destFitH = 3,
90 destFitV = 4,
91 destFitR = 5,
92 destFitB = 6,
93 destFitBH = 7,
94 destFitBV = 8
95 };
96
98 explicit LinkDestination(const LinkDestinationData &data);
99 explicit LinkDestination(const QString &description);
101
109
110 // Accessors.
114 Kind kind() const;
121 int pageNumber() const;
126 double left() const;
127 double bottom() const;
128 double right() const;
133 double top() const;
134 double zoom() const;
141 bool isChangeLeft() const;
148 bool isChangeTop() const;
154 bool isChangeZoom() const;
155
159 QString toString() const;
160
164 QString destinationName() const;
165
170
171private:
172 QSharedDataPointer<LinkDestinationPrivate> d;
173};
174
182class POPPLER_QT6_EXPORT Link
183{
184public:
186 explicit Link(const QRectF &linkArea);
188
210
214 virtual LinkType linkType() const;
215
219 virtual ~Link();
220
227 QRectF linkArea() const;
228
234 QVector<Link *> nextLinks() const;
235
236protected:
238 explicit Link(LinkPrivate &dd);
239 Q_DECLARE_PRIVATE(Link)
240 LinkPrivate *d_ptr;
242
243private:
244 Q_DISABLE_COPY(Link)
245};
246
255class POPPLER_QT6_EXPORT LinkGoto : public Link
256{
257public:
265 LinkGoto(const QRectF &linkArea, const QString &extFileName, const LinkDestination &destination);
269 ~LinkGoto() override;
270
275 bool isExternal() const;
276 // query for goto parameters
281 QString fileName() const;
286 LinkType linkType() const override;
287
288private:
289 Q_DECLARE_PRIVATE(LinkGoto)
290 Q_DISABLE_COPY(LinkGoto)
291};
292
301class POPPLER_QT6_EXPORT LinkExecute : public Link
302{
303public:
307 QString fileName() const;
311 QString parameters() const;
312
320 LinkExecute(const QRectF &linkArea, const QString &file, const QString &params);
324 ~LinkExecute() override;
325 LinkType linkType() const override;
326
327private:
328 Q_DECLARE_PRIVATE(LinkExecute)
329 Q_DISABLE_COPY(LinkExecute)
330};
331
340class POPPLER_QT6_EXPORT LinkBrowse : public Link
341{
342public:
346 QString url() const;
347
354 LinkBrowse(const QRectF &linkArea, const QString &url);
358 ~LinkBrowse() override;
359 LinkType linkType() const override;
360
361private:
362 Q_DECLARE_PRIVATE(LinkBrowse)
363 Q_DISABLE_COPY(LinkBrowse)
364};
365
372class POPPLER_QT6_EXPORT LinkAction : public Link
373{
374public:
379 {
380 PageFirst = 1,
381 PagePrev = 2,
382 PageNext = 3,
383 PageLast = 4,
384 HistoryBack = 5,
385 HistoryForward = 6,
386 Quit = 7,
387 Presentation = 8,
388 EndPresentation = 9,
389 Find = 10,
390 GoToPage = 11,
391 Close = 12,
392 Print = 13,
393 SaveAs = 14
394 };
395
400
408 LinkAction(const QRectF &linkArea, ActionType actionType);
412 ~LinkAction() override;
413 LinkType linkType() const override;
414
415private:
416 Q_DECLARE_PRIVATE(LinkAction)
417 Q_DISABLE_COPY(LinkAction)
418};
419
423class POPPLER_QT6_EXPORT LinkSound : public Link
424{
425public:
426 // create a Link_Sound
427 LinkSound(const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound);
431 ~LinkSound() override;
432
433 LinkType linkType() const override;
434
442 double volume() const;
447 bool synchronous() const;
452 bool repeat() const;
460 bool mix() const;
465
466private:
467 Q_DECLARE_PRIVATE(LinkSound)
468 Q_DISABLE_COPY(LinkSound)
469};
470
474class POPPLER_QT6_EXPORT LinkRendition : public Link
475{
476public:
481 {
482 NoRendition,
483 PlayRendition,
484 StopRendition,
485 PauseRendition,
486 ResumeRendition
487 };
488
498 [[deprecated]] LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref annotationReference);
499
509 LinkRendition(const QRectF &linkArea, std::unique_ptr<::MediaRendition> &&rendition, int operation, const QString &script, const Ref annotationReference);
510
514 ~LinkRendition() override;
515
516 LinkType linkType() const override;
517
521 MediaRendition *rendition() const;
522
527
531 QString script() const;
532
536 bool isReferencedAnnotation(const ScreenAnnotation *annotation) const;
537
538private:
539 Q_DECLARE_PRIVATE(LinkRendition)
540 Q_DISABLE_COPY(LinkRendition)
541};
542
546class POPPLER_QT6_EXPORT LinkJavaScript : public Link
547{
548public:
555 LinkJavaScript(const QRectF &linkArea, const QString &js);
559 ~LinkJavaScript() override;
560
561 LinkType linkType() const override;
562
566 QString script() const;
567
568private:
569 Q_DECLARE_PRIVATE(LinkJavaScript)
570 Q_DISABLE_COPY(LinkJavaScript)
571};
572
576class POPPLER_QT6_EXPORT LinkMovie : public Link
577{
578public:
583 {
584 Play,
585 Stop,
586 Pause,
587 Resume
588 };
589
600 LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref annotationReference);
604 ~LinkMovie() override;
605 LinkType linkType() const override;
613 bool isReferencedAnnotation(const MovieAnnotation *annotation) const;
614
615private:
616 Q_DECLARE_PRIVATE(LinkMovie)
617 Q_DISABLE_COPY(LinkMovie)
618};
619
623class POPPLER_QT6_EXPORT LinkOCGState : public Link
624{
625 friend class OptContentModel;
626
627public:
631 explicit LinkOCGState(LinkOCGStatePrivate *ocgp);
635 ~LinkOCGState() override;
636
637 LinkType linkType() const override;
638
639private:
640 Q_DECLARE_PRIVATE(LinkOCGState)
641 Q_DISABLE_COPY(LinkOCGState)
642};
643
647class POPPLER_QT6_EXPORT LinkHide : public Link
648{
649public:
653 explicit LinkHide(LinkHidePrivate *lhidep);
657 ~LinkHide() override;
658
659 LinkType linkType() const override;
660
664 QVector<QString> targets() const;
665
669 bool isShowAction() const;
670
671private:
672 Q_DECLARE_PRIVATE(LinkHide)
673 Q_DISABLE_COPY(LinkHide)
674};
675
681class POPPLER_QT6_EXPORT LinkResetForm : public Link
682{
683 friend class Document;
684
685public:
689 explicit LinkResetForm(LinkResetFormPrivate *lrfp);
690 /*
691 * Destructor
692 */
693 ~LinkResetForm() override;
694
695 LinkType linkType() const override;
696
697private:
698 Q_DECLARE_PRIVATE(LinkResetForm)
699 Q_DISABLE_COPY(LinkResetForm)
700};
701
708class POPPLER_QT6_EXPORT LinkSubmitForm : public Link
709{
710public:
711 enum SubmitFormFlag
712 {
713 NoOpFlag = 0,
714 ExcludeFlag = 1,
715 IncludeNoValueFieldsFlag = 1 << 1,
716 ExportFormatFlag = 1 << 2,
717 GetMethodFlag = 1 << 3,
718 SubmitCoordinatesFlag = 1 << 4,
719 XFDFFlag = 1 << 5,
720 IncludeAppendSavesFlag = 1 << 6,
721 IncludeAnnotationsFlag = 1 << 7,
722 SubmitPDFFlag = 1 << 8,
723 CanonicalFormatFlag = 1 << 9,
724 ExclNonUserAnnotsFlag = 1 << 10,
725 ExclFKeyFlag = 1 << 11,
726 // 13th high bit flag is undefined
727 EmbedFormFlag = 1 << 13,
728 };
729 Q_DECLARE_FLAGS(SubmitFormFlags, SubmitFormFlag)
730
731
734 explicit LinkSubmitForm(LinkSubmitFormPrivate *lsfp);
738 ~LinkSubmitForm() override;
739
740 LinkType linkType() const override;
741
745 QVector<int> getFieldIds() const;
746
750 QString getUrl() const;
751
755 SubmitFormFlags getFlags() const;
756
757private:
758 Q_DECLARE_PRIVATE(LinkSubmitForm)
759 Q_DISABLE_COPY(LinkSubmitForm)
760};
761
762}
763
764#endif
PDF document.
Definition poppler-qt6.h:1056
"Standard" action request.
Definition poppler-link.h:373
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:379
An URL to browse.
Definition poppler-link.h:341
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:74
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:80
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:302
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:256
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:648
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: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:577
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:583
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:624
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:475
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:481
ResetForm: an action to reset form fields.
Definition poppler-link.h:682
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:424
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.
SubmitForm : An action to submit a form.
Definition poppler-link.h:709
Movie annotation.
Definition poppler-annotation.h:1034
Model for optional content.
Definition poppler-optcontent.h:47
Screen annotation.
Definition poppler-annotation.h:1074
Container class for a sound file in a PDF document.
Definition poppler-qt6.h:1799
The Poppler Qt6 binding.
Definition poppler-annotation.h:50