Poppler Qt5 24.11.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 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_QT5_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
166 QString destinationName() const;
167
172
173private:
174 QSharedDataPointer<LinkDestinationPrivate> d;
175};
176
184class POPPLER_QT5_EXPORT Link
185{
186public:
188 explicit Link(const QRectF &linkArea);
190
212
216 virtual LinkType linkType() const;
217
221 virtual ~Link();
222
229 QRectF linkArea() const;
230
236 QVector<Link *> nextLinks() const;
237
238protected:
240 explicit Link(LinkPrivate &dd);
241 Q_DECLARE_PRIVATE(Link)
242 LinkPrivate *d_ptr;
244
245private:
246 Q_DISABLE_COPY(Link)
247};
248
257class POPPLER_QT5_EXPORT LinkGoto : public Link
258{
259public:
267 // TODO Next ABI break, make extFileName const &
268 LinkGoto(const QRectF &linkArea, QString extFileName, const LinkDestination &destination);
272 ~LinkGoto() override;
273
278 bool isExternal() const;
279 // query for goto parameters
284 QString fileName() const;
289 LinkType linkType() const override;
290
291private:
292 Q_DECLARE_PRIVATE(LinkGoto)
293 Q_DISABLE_COPY(LinkGoto)
294};
295
304class POPPLER_QT5_EXPORT LinkExecute : public Link
305{
306public:
310 QString fileName() const;
314 QString parameters() const;
315
323 LinkExecute(const QRectF &linkArea, const QString &file, const QString &params);
327 ~LinkExecute() override;
328 LinkType linkType() const override;
329
330private:
331 Q_DECLARE_PRIVATE(LinkExecute)
332 Q_DISABLE_COPY(LinkExecute)
333};
334
343class POPPLER_QT5_EXPORT LinkBrowse : public Link
344{
345public:
349 QString url() const;
350
357 LinkBrowse(const QRectF &linkArea, const QString &url);
361 ~LinkBrowse() override;
362 LinkType linkType() const override;
363
364private:
365 Q_DECLARE_PRIVATE(LinkBrowse)
366 Q_DISABLE_COPY(LinkBrowse)
367};
368
375class POPPLER_QT5_EXPORT LinkAction : public Link
376{
377public:
382 {
383 PageFirst = 1,
384 PagePrev = 2,
385 PageNext = 3,
386 PageLast = 4,
387 HistoryBack = 5,
388 HistoryForward = 6,
389 Quit = 7,
390 Presentation = 8,
391 EndPresentation = 9,
392 Find = 10,
393 GoToPage = 11,
394 Close = 12,
395 Print = 13,
396 SaveAs = 14
397 };
398
403
411 LinkAction(const QRectF &linkArea, ActionType actionType);
415 ~LinkAction() override;
416 LinkType linkType() const override;
417
418private:
419 Q_DECLARE_PRIVATE(LinkAction)
420 Q_DISABLE_COPY(LinkAction)
421};
422
428class POPPLER_QT5_EXPORT LinkSound : public Link
429{
430public:
431 // create a Link_Sound
432 LinkSound(const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound);
436 ~LinkSound() override;
437
438 LinkType linkType() const override;
439
447 double volume() const;
452 bool synchronous() const;
457 bool repeat() const;
465 bool mix() const;
470
471private:
472 Q_DECLARE_PRIVATE(LinkSound)
473 Q_DISABLE_COPY(LinkSound)
474};
475
481class POPPLER_QT5_EXPORT LinkRendition : public Link
482{
483public:
490 {
491 NoRendition,
492 PlayRendition,
493 StopRendition,
494 PauseRendition,
495 ResumeRendition
496 };
497
508 // TODO Next ABI break, remove & from annotationReference
509 [[deprecated]] LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference);
510
520 LinkRendition(const QRectF &linkArea, std::unique_ptr<::MediaRendition> &&rendition, int operation, const QString &script, const Ref annotationReference);
521
525 ~LinkRendition() override;
526
527 LinkType linkType() const override;
528
532 MediaRendition *rendition() const;
533
540
546 QString script() const;
547
553 bool isReferencedAnnotation(const ScreenAnnotation *annotation) const;
554
555private:
556 Q_DECLARE_PRIVATE(LinkRendition)
557 Q_DISABLE_COPY(LinkRendition)
558};
559
565class POPPLER_QT5_EXPORT LinkJavaScript : public Link
566{
567public:
574 LinkJavaScript(const QRectF &linkArea, const QString &js);
578 ~LinkJavaScript() override;
579
580 LinkType linkType() const override;
581
585 QString script() const;
586
587private:
588 Q_DECLARE_PRIVATE(LinkJavaScript)
589 Q_DISABLE_COPY(LinkJavaScript)
590};
591
597class POPPLER_QT5_EXPORT LinkMovie : public Link
598{
599public:
604 {
605 Play,
606 Stop,
607 Pause,
608 Resume
609 };
610
621 // TODO Next ABI break, remove & from annotationReference
622 LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference);
626 ~LinkMovie() override;
627 LinkType linkType() const override;
635 bool isReferencedAnnotation(const MovieAnnotation *annotation) const;
636
637private:
638 Q_DECLARE_PRIVATE(LinkMovie)
639 Q_DISABLE_COPY(LinkMovie)
640};
641
647class POPPLER_QT5_EXPORT LinkOCGState : public Link
648{
649 friend class OptContentModel;
650
651public:
655 explicit LinkOCGState(LinkOCGStatePrivate *ocgp);
659 ~LinkOCGState() override;
660
661 LinkType linkType() const override;
662
663private:
664 Q_DECLARE_PRIVATE(LinkOCGState)
665 Q_DISABLE_COPY(LinkOCGState)
666};
667
673class POPPLER_QT5_EXPORT LinkHide : public Link
674{
675public:
679 explicit LinkHide(LinkHidePrivate *lhidep);
683 ~LinkHide() override;
684
685 LinkType linkType() const override;
686
690 QVector<QString> targets() const;
691
695 bool isShowAction() const;
696
697private:
698 Q_DECLARE_PRIVATE(LinkHide)
699 Q_DISABLE_COPY(LinkHide)
700};
701
707class POPPLER_QT5_EXPORT LinkResetForm : public Link
708{
709 friend class Document;
710
711public:
715 explicit LinkResetForm(LinkResetFormPrivate *lrfp);
716 /*
717 * Destructor
718 */
719 ~LinkResetForm() override;
720
721 LinkType linkType() const override;
722
723private:
724 Q_DECLARE_PRIVATE(LinkResetForm)
725 Q_DISABLE_COPY(LinkResetForm)
726};
727
733class POPPLER_QT5_EXPORT LinkSubmitForm : public Link
734{
735public:
736 enum SubmitFormFlag
737 {
738 NoOpFlag = 0,
739 ExcludeFlag = 1,
740 IncludeNoValueFieldsFlag = 1 << 1,
741 ExportFormatFlag = 1 << 2,
742 GetMethodFlag = 1 << 3,
743 SubmitCoordinatesFlag = 1 << 4,
744 XFDFFlag = 1 << 5,
745 IncludeAppendSavesFlag = 1 << 6,
746 IncludeAnnotationsFlag = 1 << 7,
747 SubmitPDFFlag = 1 << 8,
748 CanonicalFormatFlag = 1 << 9,
749 ExclNonUserAnnotsFlag = 1 << 10,
750 ExclFKeyFlag = 1 << 11,
751 // 13th high bit flag is undefined
752 EmbedFormFlag = 1 << 13,
753 };
754 Q_DECLARE_FLAGS(SubmitFormFlags, SubmitFormFlag)
755
756
759 explicit LinkSubmitForm(LinkSubmitFormPrivate *lsfp);
763 ~LinkSubmitForm() override;
764
765 LinkType linkType() const override;
766
770 QVector<int> getFieldIds() const;
771
775 QString getUrl() const;
776
780 SubmitFormFlags getFlags() const;
781
782private:
783 Q_DECLARE_PRIVATE(LinkSubmitForm)
784 Q_DISABLE_COPY(LinkSubmitForm)
785};
786}
787
788#endif
PDF document.
Definition poppler-qt5.h:1146
"Standard" action request.
Definition poppler-link.h:376
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:382
An URL to browse.
Definition poppler-link.h:344
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:305
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:258
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:674
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:566
~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:598
~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:604
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:648
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:482
LinkType linkType() const override
The type of this link.
LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference)
Create a new rendition 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.
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:490
ResetForm: an action to reset form fields.
Definition poppler-link.h:708
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:429
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:734
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:2433
The Poppler Qt5 binding.
Definition poppler-annotation.h:50