Poppler Qt5 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 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_QT5_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
161 QString destinationName() const;
162
167
168private:
169 QSharedDataPointer<LinkDestinationPrivate> d;
170};
171
179class POPPLER_QT5_EXPORT Link
180{
181public:
183 explicit Link(const QRectF &linkArea);
185
205
209 virtual LinkType linkType() const;
210
214 virtual ~Link();
215
222 QRectF linkArea() const;
223
229 QVector<Link *> nextLinks() const;
230
231protected:
233 explicit Link(LinkPrivate &dd);
234 Q_DECLARE_PRIVATE(Link)
235 LinkPrivate *d_ptr;
237
238private:
239 Q_DISABLE_COPY(Link)
240};
241
250class POPPLER_QT5_EXPORT LinkGoto : public Link
251{
252public:
260 // TODO Next ABI break, make extFileName const &
261 LinkGoto(const QRectF &linkArea, QString extFileName, const LinkDestination &destination);
265 ~LinkGoto() override;
266
271 bool isExternal() const;
272 // query for goto parameters
277 QString fileName() const;
282 LinkType linkType() const override;
283
284private:
285 Q_DECLARE_PRIVATE(LinkGoto)
286 Q_DISABLE_COPY(LinkGoto)
287};
288
297class POPPLER_QT5_EXPORT LinkExecute : public Link
298{
299public:
303 QString fileName() const;
307 QString parameters() const;
308
316 LinkExecute(const QRectF &linkArea, const QString &file, const QString &params);
320 ~LinkExecute() override;
321 LinkType linkType() const override;
322
323private:
324 Q_DECLARE_PRIVATE(LinkExecute)
325 Q_DISABLE_COPY(LinkExecute)
326};
327
336class POPPLER_QT5_EXPORT LinkBrowse : public Link
337{
338public:
342 QString url() const;
343
350 LinkBrowse(const QRectF &linkArea, const QString &url);
354 ~LinkBrowse() override;
355 LinkType linkType() const override;
356
357private:
358 Q_DECLARE_PRIVATE(LinkBrowse)
359 Q_DISABLE_COPY(LinkBrowse)
360};
361
368class POPPLER_QT5_EXPORT LinkAction : public Link
369{
370public:
375 {
376 PageFirst = 1,
377 PagePrev = 2,
378 PageNext = 3,
379 PageLast = 4,
380 HistoryBack = 5,
381 HistoryForward = 6,
382 Quit = 7,
383 Presentation = 8,
384 EndPresentation = 9,
385 Find = 10,
386 GoToPage = 11,
387 Close = 12,
388 Print = 13,
389 SaveAs = 14
390 };
391
396
404 LinkAction(const QRectF &linkArea, ActionType actionType);
408 ~LinkAction() override;
409 LinkType linkType() const override;
410
411private:
412 Q_DECLARE_PRIVATE(LinkAction)
413 Q_DISABLE_COPY(LinkAction)
414};
415
421class POPPLER_QT5_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
474class POPPLER_QT5_EXPORT LinkRendition : public Link
475{
476public:
483 {
484 NoRendition,
485 PlayRendition,
486 StopRendition,
487 PauseRendition,
488 ResumeRendition
489 };
490
501 // TODO Next ABI break, remove & from annotationReference
502 LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference);
503
507 ~LinkRendition() override;
508
509 LinkType linkType() const override;
510
514 MediaRendition *rendition() const;
515
522
528 QString script() const;
529
535 bool isReferencedAnnotation(const ScreenAnnotation *annotation) const;
536
537private:
538 Q_DECLARE_PRIVATE(LinkRendition)
539 Q_DISABLE_COPY(LinkRendition)
540};
541
547class POPPLER_QT5_EXPORT LinkJavaScript : public Link
548{
549public:
556 LinkJavaScript(const QRectF &linkArea, const QString &js);
560 ~LinkJavaScript() override;
561
562 LinkType linkType() const override;
563
567 QString script() const;
568
569private:
570 Q_DECLARE_PRIVATE(LinkJavaScript)
571 Q_DISABLE_COPY(LinkJavaScript)
572};
573
579class POPPLER_QT5_EXPORT LinkMovie : public Link
580{
581public:
586 {
587 Play,
588 Stop,
589 Pause,
590 Resume
591 };
592
603 // TODO Next ABI break, remove & from annotationReference
604 LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference);
608 ~LinkMovie() override;
609 LinkType linkType() const override;
617 bool isReferencedAnnotation(const MovieAnnotation *annotation) const;
618
619private:
620 Q_DECLARE_PRIVATE(LinkMovie)
621 Q_DISABLE_COPY(LinkMovie)
622};
623
629class POPPLER_QT5_EXPORT LinkOCGState : public Link
630{
631 friend class OptContentModel;
632
633public:
637 explicit LinkOCGState(LinkOCGStatePrivate *ocgp);
641 ~LinkOCGState() override;
642
643 LinkType linkType() const override;
644
645private:
646 Q_DECLARE_PRIVATE(LinkOCGState)
647 Q_DISABLE_COPY(LinkOCGState)
648};
649
655class POPPLER_QT5_EXPORT LinkHide : public Link
656{
657public:
661 explicit LinkHide(LinkHidePrivate *lhidep);
665 ~LinkHide() override;
666
667 LinkType linkType() const override;
668
672 QVector<QString> targets() const;
673
677 bool isShowAction() const;
678
679private:
680 Q_DECLARE_PRIVATE(LinkHide)
681 Q_DISABLE_COPY(LinkHide)
682};
683
684}
685
686#endif
"Standard" action request.
Definition poppler-link.h:369
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:375
An URL to browse.
Definition poppler-link.h:337
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:298
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:251
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:656
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:548
~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:580
~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:586
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:630
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.
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.
RenditionAction
Describes the possible rendition actions.
Definition poppler-link.h:483
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: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:2400
The Poppler Qt5 binding.
Definition poppler-annotation.h:50