Poppler Qt5 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 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_QT5_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
165 QString destinationName() const;
166
171
172private:
173 QSharedDataPointer<LinkDestinationPrivate> d;
174};
175
183class POPPLER_QT5_EXPORT Link
184{
185public:
187 explicit Link(const QRectF &linkArea);
189
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_QT5_EXPORT LinkGoto : public Link
256{
257public:
265 // TODO Next ABI break, make extFileName const &
266 LinkGoto(const QRectF &linkArea, QString extFileName, const LinkDestination &destination);
270 ~LinkGoto() override;
271
276 bool isExternal() const;
277 // query for goto parameters
282 QString fileName() const;
287 LinkType linkType() const override;
288
289private:
290 Q_DECLARE_PRIVATE(LinkGoto)
291 Q_DISABLE_COPY(LinkGoto)
292};
293
302class POPPLER_QT5_EXPORT LinkExecute : public Link
303{
304public:
308 QString fileName() const;
312 QString parameters() const;
313
321 LinkExecute(const QRectF &linkArea, const QString &file, const QString &params);
325 ~LinkExecute() override;
326 LinkType linkType() const override;
327
328private:
329 Q_DECLARE_PRIVATE(LinkExecute)
330 Q_DISABLE_COPY(LinkExecute)
331};
332
341class POPPLER_QT5_EXPORT LinkBrowse : public Link
342{
343public:
347 QString url() const;
348
355 LinkBrowse(const QRectF &linkArea, const QString &url);
359 ~LinkBrowse() override;
360 LinkType linkType() const override;
361
362private:
363 Q_DECLARE_PRIVATE(LinkBrowse)
364 Q_DISABLE_COPY(LinkBrowse)
365};
366
373class POPPLER_QT5_EXPORT LinkAction : public Link
374{
375public:
380 {
381 PageFirst = 1,
382 PagePrev = 2,
383 PageNext = 3,
384 PageLast = 4,
385 HistoryBack = 5,
386 HistoryForward = 6,
387 Quit = 7,
388 Presentation = 8,
389 EndPresentation = 9,
390 Find = 10,
391 GoToPage = 11,
392 Close = 12,
393 Print = 13,
394 SaveAs = 14
395 };
396
401
409 LinkAction(const QRectF &linkArea, ActionType actionType);
413 ~LinkAction() override;
414 LinkType linkType() const override;
415
416private:
417 Q_DECLARE_PRIVATE(LinkAction)
418 Q_DISABLE_COPY(LinkAction)
419};
420
426class POPPLER_QT5_EXPORT LinkSound : public Link
427{
428public:
429 // create a Link_Sound
430 LinkSound(const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound);
434 ~LinkSound() override;
435
436 LinkType linkType() const override;
437
445 double volume() const;
450 bool synchronous() const;
455 bool repeat() const;
463 bool mix() const;
468
469private:
470 Q_DECLARE_PRIVATE(LinkSound)
471 Q_DISABLE_COPY(LinkSound)
472};
473
479class POPPLER_QT5_EXPORT LinkRendition : public Link
480{
481public:
488 {
489 NoRendition,
490 PlayRendition,
491 StopRendition,
492 PauseRendition,
493 ResumeRendition
494 };
495
506 // TODO Next ABI break, remove & from annotationReference
507 [[deprecated]] LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference);
508
518 LinkRendition(const QRectF &linkArea, std::unique_ptr<::MediaRendition> &&rendition, int operation, const QString &script, const Ref annotationReference);
519
523 ~LinkRendition() override;
524
525 LinkType linkType() const override;
526
530 MediaRendition *rendition() const;
531
538
544 QString script() const;
545
551 bool isReferencedAnnotation(const ScreenAnnotation *annotation) const;
552
553private:
554 Q_DECLARE_PRIVATE(LinkRendition)
555 Q_DISABLE_COPY(LinkRendition)
556};
557
563class POPPLER_QT5_EXPORT LinkJavaScript : public Link
564{
565public:
572 LinkJavaScript(const QRectF &linkArea, const QString &js);
576 ~LinkJavaScript() override;
577
578 LinkType linkType() const override;
579
583 QString script() const;
584
585private:
586 Q_DECLARE_PRIVATE(LinkJavaScript)
587 Q_DISABLE_COPY(LinkJavaScript)
588};
589
595class POPPLER_QT5_EXPORT LinkMovie : public Link
596{
597public:
602 {
603 Play,
604 Stop,
605 Pause,
606 Resume
607 };
608
619 // TODO Next ABI break, remove & from annotationReference
620 LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference);
624 ~LinkMovie() override;
625 LinkType linkType() const override;
633 bool isReferencedAnnotation(const MovieAnnotation *annotation) const;
634
635private:
636 Q_DECLARE_PRIVATE(LinkMovie)
637 Q_DISABLE_COPY(LinkMovie)
638};
639
645class POPPLER_QT5_EXPORT LinkOCGState : public Link
646{
647 friend class OptContentModel;
648
649public:
653 explicit LinkOCGState(LinkOCGStatePrivate *ocgp);
657 ~LinkOCGState() override;
658
659 LinkType linkType() const override;
660
661private:
662 Q_DECLARE_PRIVATE(LinkOCGState)
663 Q_DISABLE_COPY(LinkOCGState)
664};
665
671class POPPLER_QT5_EXPORT LinkHide : public Link
672{
673public:
677 explicit LinkHide(LinkHidePrivate *lhidep);
681 ~LinkHide() override;
682
683 LinkType linkType() const override;
684
688 QVector<QString> targets() const;
689
693 bool isShowAction() const;
694
695private:
696 Q_DECLARE_PRIVATE(LinkHide)
697 Q_DISABLE_COPY(LinkHide)
698};
699
705class POPPLER_QT5_EXPORT LinkResetForm : public Link
706{
707 friend class Document;
708
709public:
713 explicit LinkResetForm(LinkResetFormPrivate *lrfp);
714 /*
715 * Destructor
716 */
717 ~LinkResetForm() override;
718
719 LinkType linkType() const override;
720
721private:
722 Q_DECLARE_PRIVATE(LinkResetForm)
723 Q_DISABLE_COPY(LinkResetForm)
724};
725
726}
727
728#endif
PDF document.
Definition poppler-qt5.h:1146
"Standard" action request.
Definition poppler-link.h:374
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:380
An URL to browse.
Definition poppler-link.h:342
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:303
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, 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:672
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:564
~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:596
~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:602
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:646
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:480
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:488
ResetForm: an action to reset form fields.
Definition poppler-link.h:706
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:427
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:2433
The Poppler Qt5 binding.
Definition poppler-annotation.h:50