| 1 |
/* poppler-link.cc: qt interface to poppler |
| 2 |
* Copyright (C) 2006-2007, 2013, 2016-2021, 2024, Albert Astals Cid |
| 3 |
* Copyright (C) 2007-2008, Pino Toscano <[email protected]> |
| 4 |
* Copyright (C) 2010 Hib Eris <[email protected]> |
| 5 |
* Copyright (C) 2012, Tobias Koenig <[email protected]> |
| 6 |
* Copyright (C) 2012, Guillermo A. Amaral B. <[email protected]> |
| 7 |
* Copyright (C) 2018 Intevation GmbH <[email protected]> |
| 8 |
* Copyright (C) 2018 Adam Reichold <[email protected]> |
| 9 |
* Copyright (C) 2020, 2021 Oliver Sander <[email protected]> |
| 10 |
* Copyright (C) 2024 Pratham Gandhi <[email protected]> |
| 11 |
* Adapting code from |
| 12 |
* Copyright (C) 2004 by Enrico Ros <[email protected]> |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or modify |
| 15 |
* it under the terms of the GNU General Public License as published by |
| 16 |
* the Free Software Foundation; either version 2, or (at your option) |
| 17 |
* any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
| 27 |
*/ |
| 28 |
|
| 29 |
#include <poppler-qt6.h> |
| 30 |
#include <poppler-link-private.h> |
| 31 |
#include <poppler-private.h> |
| 32 |
#include <poppler-media.h> |
| 33 |
|
| 34 |
#include <QtCore/QStringList> |
| 35 |
|
| 36 |
#include "poppler-annotation-private.h" |
| 37 |
|
| 38 |
#include "Link.h" |
| 39 |
#include "Rendition.h" |
| 40 |
|
| 41 |
namespace Poppler { |
| 42 |
|
| 43 |
class LinkDestinationPrivate : public QSharedData |
| 44 |
{ |
| 45 |
public: |
| 46 |
LinkDestinationPrivate(); |
| 47 |
|
| 48 |
LinkDestination::Kind kind; // destination type |
| 49 |
QString name; |
| 50 |
int pageNum; // page number |
| 51 |
double left, bottom; // position |
| 52 |
double right, top; |
| 53 |
double zoom; // zoom factor |
| 54 |
bool changeLeft : 1, changeTop : 1; // for destXYZ links, which position |
| 55 |
bool changeZoom : 1; // components to change |
| 56 |
}; |
| 57 |
|
| 58 |
LinkDestinationPrivate::LinkDestinationPrivate() |
| 59 |
{ |
| 60 |
// sane defaults |
| 61 |
kind = LinkDestination::destXYZ; |
| 62 |
pageNum = 0; |
| 63 |
left = 0; |
| 64 |
bottom = 0; |
| 65 |
right = 0; |
| 66 |
top = 0; |
| 67 |
zoom = 1; |
| 68 |
changeLeft = true; |
| 69 |
changeTop = true; |
| 70 |
changeZoom = false; |
| 71 |
} |
| 72 |
|
| 73 |
LinkPrivate::~LinkPrivate() = default; |
| 74 |
|
| 75 |
LinkOCGStatePrivate::~LinkOCGStatePrivate() = default; |
| 76 |
|
| 77 |
LinkHidePrivate::~LinkHidePrivate() = default; |
| 78 |
|
| 79 |
LinkResetFormPrivate::~LinkResetFormPrivate() = default; |
| 80 |
|
| 81 |
LinkSubmitFormPrivate::~LinkSubmitFormPrivate() = default; |
| 82 |
|
| 83 |
class LinkGotoPrivate : public LinkPrivate |
| 84 |
{ |
| 85 |
public: |
| 86 |
LinkGotoPrivate(const QRectF &area, const LinkDestination &dest); |
| 87 |
~LinkGotoPrivate() override; |
| 88 |
|
| 89 |
QString extFileName; |
| 90 |
LinkDestination destination; |
| 91 |
}; |
| 92 |
|
| 93 |
LinkGotoPrivate::LinkGotoPrivate(const QRectF &area, const LinkDestination &dest) : LinkPrivate(area), destination(dest) { } |
| 94 |
|
| 95 |
LinkGotoPrivate::~LinkGotoPrivate() = default; |
| 96 |
|
| 97 |
class LinkExecutePrivate : public LinkPrivate |
| 98 |
{ |
| 99 |
public: |
| 100 |
explicit LinkExecutePrivate(const QRectF &area); |
| 101 |
~LinkExecutePrivate() override; |
| 102 |
|
| 103 |
QString fileName; |
| 104 |
QString parameters; |
| 105 |
}; |
| 106 |
|
| 107 |
LinkExecutePrivate::LinkExecutePrivate(const QRectF &area) : LinkPrivate(area) { } |
| 108 |
|
| 109 |
LinkExecutePrivate::~LinkExecutePrivate() = default; |
| 110 |
|
| 111 |
class LinkBrowsePrivate : public LinkPrivate |
| 112 |
{ |
| 113 |
public: |
| 114 |
explicit LinkBrowsePrivate(const QRectF &area); |
| 115 |
~LinkBrowsePrivate() override; |
| 116 |
|
| 117 |
QString url; |
| 118 |
}; |
| 119 |
|
| 120 |
LinkBrowsePrivate::LinkBrowsePrivate(const QRectF &area) : LinkPrivate(area) { } |
| 121 |
|
| 122 |
LinkBrowsePrivate::~LinkBrowsePrivate() = default; |
| 123 |
|
| 124 |
class LinkActionPrivate : public LinkPrivate |
| 125 |
{ |
| 126 |
public: |
| 127 |
explicit LinkActionPrivate(const QRectF &area); |
| 128 |
~LinkActionPrivate() override; |
| 129 |
|
| 130 |
LinkAction::ActionType type; |
| 131 |
}; |
| 132 |
|
| 133 |
LinkActionPrivate::LinkActionPrivate(const QRectF &area) : LinkPrivate(area) { } |
| 134 |
|
| 135 |
LinkActionPrivate::~LinkActionPrivate() = default; |
| 136 |
|
| 137 |
class LinkSoundPrivate : public LinkPrivate |
| 138 |
{ |
| 139 |
public: |
| 140 |
explicit LinkSoundPrivate(const QRectF &area); |
| 141 |
~LinkSoundPrivate() override; |
| 142 |
|
| 143 |
double volume; |
| 144 |
bool sync : 1; |
| 145 |
bool repeat : 1; |
| 146 |
bool mix : 1; |
| 147 |
SoundObject *sound; |
| 148 |
}; |
| 149 |
|
| 150 |
LinkSoundPrivate::LinkSoundPrivate(const QRectF &area) : LinkPrivate(area), sound(nullptr) { } |
| 151 |
|
| 152 |
LinkSoundPrivate::~LinkSoundPrivate() |
| 153 |
{ |
| 154 |
delete sound; |
| 155 |
} |
| 156 |
|
| 157 |
class LinkRenditionPrivate : public LinkPrivate |
| 158 |
{ |
| 159 |
public: |
| 160 |
LinkRenditionPrivate(const QRectF &area, std::unique_ptr<::MediaRendition> &&r, ::LinkRendition::RenditionOperation operation, const QString &script, const Ref ref); |
| 161 |
~LinkRenditionPrivate() override; |
| 162 |
|
| 163 |
std::unique_ptr<MediaRendition> rendition; |
| 164 |
LinkRendition::RenditionAction action; |
| 165 |
QString script; |
| 166 |
Ref annotationReference; |
| 167 |
}; |
| 168 |
|
| 169 |
LinkRenditionPrivate::LinkRenditionPrivate(const QRectF &area, std::unique_ptr<::MediaRendition> &&r, ::LinkRendition::RenditionOperation operation, const QString &javaScript, const Ref ref) |
| 170 |
: LinkPrivate(area), rendition(r ? new MediaRendition(std::move(r)) : nullptr), action(LinkRendition::PlayRendition), script(javaScript), annotationReference(ref) |
| 171 |
{ |
| 172 |
switch (operation) { |
| 173 |
case ::LinkRendition::NoRendition: |
| 174 |
action = LinkRendition::NoRendition; |
| 175 |
break; |
| 176 |
case ::LinkRendition::PlayRendition: |
| 177 |
action = LinkRendition::PlayRendition; |
| 178 |
break; |
| 179 |
case ::LinkRendition::StopRendition: |
| 180 |
action = LinkRendition::StopRendition; |
| 181 |
break; |
| 182 |
case ::LinkRendition::PauseRendition: |
| 183 |
action = LinkRendition::PauseRendition; |
| 184 |
break; |
| 185 |
case ::LinkRendition::ResumeRendition: |
| 186 |
action = LinkRendition::ResumeRendition; |
| 187 |
break; |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
LinkRenditionPrivate::~LinkRenditionPrivate() = default; |
| 192 |
|
| 193 |
class LinkJavaScriptPrivate : public LinkPrivate |
| 194 |
{ |
| 195 |
public: |
| 196 |
explicit LinkJavaScriptPrivate(const QRectF &area); |
| 197 |
~LinkJavaScriptPrivate() override; |
| 198 |
|
| 199 |
QString js; |
| 200 |
}; |
| 201 |
|
| 202 |
LinkJavaScriptPrivate::LinkJavaScriptPrivate(const QRectF &area) : LinkPrivate(area) { } |
| 203 |
|
| 204 |
LinkJavaScriptPrivate::~LinkJavaScriptPrivate() = default; |
| 205 |
|
| 206 |
class LinkMoviePrivate : public LinkPrivate |
| 207 |
{ |
| 208 |
public: |
| 209 |
LinkMoviePrivate(const QRectF &area, LinkMovie::Operation operation, const QString &title, const Ref reference); |
| 210 |
~LinkMoviePrivate() override; |
| 211 |
|
| 212 |
LinkMovie::Operation operation; |
| 213 |
QString annotationTitle; |
| 214 |
Ref annotationReference; |
| 215 |
}; |
| 216 |
|
| 217 |
LinkMoviePrivate::LinkMoviePrivate(const QRectF &area, LinkMovie::Operation _operation, const QString &title, const Ref reference) : LinkPrivate(area), operation(_operation), annotationTitle(title), annotationReference(reference) { } |
| 218 |
|
| 219 |
LinkMoviePrivate::~LinkMoviePrivate() = default; |
| 220 |
|
| 221 |
static void cvtUserToDev(::Page *page, double xu, double yu, int *xd, int *yd) |
| 222 |
{ |
| 223 |
double ctm[6]; |
| 224 |
|
| 225 |
page->getDefaultCTM(ctm, 72.0, 72.0, 0, false, true); |
| 226 |
*xd = (int)(ctm[0] * xu + ctm[2] * yu + ctm[4] + 0.5); |
| 227 |
*yd = (int)(ctm[1] * xu + ctm[3] * yu + ctm[5] + 0.5); |
| 228 |
} |
| 229 |
|
| 230 |
LinkDestination::LinkDestination(const LinkDestinationData &data) : d(new LinkDestinationPrivate) |
| 231 |
{ |
| 232 |
bool deleteDest = false; |
| 233 |
const LinkDest *ld = data.ld; |
| 234 |
|
| 235 |
if (data.namedDest && !ld && !data.externalDest) { |
| 236 |
deleteDest = true; |
| 237 |
ld = data.doc->doc->findDest(data.namedDest).release(); |
| 238 |
} |
| 239 |
// in case this destination was named one, and it was not resolved |
| 240 |
if (data.namedDest && !ld) { |
| 241 |
d->name = QString::fromLatin1(data.namedDest->c_str()); |
| 242 |
} |
| 243 |
|
| 244 |
if (!ld) { |
| 245 |
return; |
| 246 |
} |
| 247 |
|
| 248 |
if (ld->getKind() == ::destXYZ) { |
| 249 |
d->kind = destXYZ; |
| 250 |
} else if (ld->getKind() == ::destFit) { |
| 251 |
d->kind = destFit; |
| 252 |
} else if (ld->getKind() == ::destFitH) { |
| 253 |
d->kind = destFitH; |
| 254 |
} else if (ld->getKind() == ::destFitV) { |
| 255 |
d->kind = destFitV; |
| 256 |
} else if (ld->getKind() == ::destFitR) { |
| 257 |
d->kind = destFitR; |
| 258 |
} else if (ld->getKind() == ::destFitB) { |
| 259 |
d->kind = destFitB; |
| 260 |
} else if (ld->getKind() == ::destFitBH) { |
| 261 |
d->kind = destFitBH; |
| 262 |
} else if (ld->getKind() == ::destFitBV) { |
| 263 |
d->kind = destFitBV; |
| 264 |
} |
| 265 |
|
| 266 |
if (!ld->isPageRef()) { |
| 267 |
d->pageNum = ld->getPageNum(); |
| 268 |
} else { |
| 269 |
const Ref ref = ld->getPageRef(); |
| 270 |
d->pageNum = data.doc->doc->findPage(ref); |
| 271 |
} |
| 272 |
double left = ld->getLeft(); |
| 273 |
double bottom = ld->getBottom(); |
| 274 |
double right = ld->getRight(); |
| 275 |
double top = ld->getTop(); |
| 276 |
d->zoom = ld->getZoom(); |
| 277 |
d->changeLeft = ld->getChangeLeft(); |
| 278 |
d->changeTop = ld->getChangeTop(); |
| 279 |
d->changeZoom = ld->getChangeZoom(); |
| 280 |
|
| 281 |
int leftAux = 0, topAux = 0, rightAux = 0, bottomAux = 0; |
| 282 |
|
| 283 |
if (!data.externalDest) { |
| 284 |
::Page *page; |
| 285 |
if (d->pageNum > 0 && d->pageNum <= data.doc->doc->getNumPages() && (page = data.doc->doc->getPage(d->pageNum))) { |
| 286 |
cvtUserToDev(page, left, top, &leftAux, &topAux); |
| 287 |
cvtUserToDev(page, right, bottom, &rightAux, &bottomAux); |
| 288 |
|
| 289 |
d->left = leftAux / (double)page->getCropWidth(); |
| 290 |
d->top = topAux / (double)page->getCropHeight(); |
| 291 |
d->right = rightAux / (double)page->getCropWidth(); |
| 292 |
d->bottom = bottomAux / (double)page->getCropHeight(); |
| 293 |
} else { |
| 294 |
d->pageNum = 0; |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
if (deleteDest) { |
| 299 |
delete ld; |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
LinkDestination::LinkDestination(const QString &description) : d(new LinkDestinationPrivate) |
| 304 |
{ |
| 305 |
const QStringList tokens = description.split(QChar::fromLatin1(';')); |
| 306 |
if (tokens.size() >= 10) { |
| 307 |
d->kind = static_cast<Kind>(tokens.at(0).toInt()); |
| 308 |
d->pageNum = tokens.at(1).toInt(); |
| 309 |
d->left = tokens.at(2).toDouble(); |
| 310 |
d->bottom = tokens.at(3).toDouble(); |
| 311 |
d->right = tokens.at(4).toDouble(); |
| 312 |
d->top = tokens.at(5).toDouble(); |
| 313 |
d->zoom = tokens.at(6).toDouble(); |
| 314 |
d->changeLeft = static_cast<bool>(tokens.at(7).toInt()); |
| 315 |
d->changeTop = static_cast<bool>(tokens.at(8).toInt()); |
| 316 |
d->changeZoom = static_cast<bool>(tokens.at(9).toInt()); |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
LinkDestination::LinkDestination(const LinkDestination &other) = default; |
| 321 |
|
| 322 |
LinkDestination::~LinkDestination() = default; |
| 323 |
|
| 324 |
LinkDestination::Kind LinkDestination::kind() const |
| 325 |
{ |
| 326 |
return d->kind; |
| 327 |
} |
| 328 |
|
| 329 |
int LinkDestination::pageNumber() const |
| 330 |
{ |
| 331 |
return d->pageNum; |
| 332 |
} |
| 333 |
|
| 334 |
double LinkDestination::left() const |
| 335 |
{ |
| 336 |
return d->left; |
| 337 |
} |
| 338 |
|
| 339 |
double LinkDestination::bottom() const |
| 340 |
{ |
| 341 |
return d->bottom; |
| 342 |
} |
| 343 |
|
| 344 |
double LinkDestination::right() const |
| 345 |
{ |
| 346 |
return d->right; |
| 347 |
} |
| 348 |
|
| 349 |
double LinkDestination::top() const |
| 350 |
{ |
| 351 |
return d->top; |
| 352 |
} |
| 353 |
|
| 354 |
double LinkDestination::zoom() const |
| 355 |
{ |
| 356 |
return d->zoom; |
| 357 |
} |
| 358 |
|
| 359 |
bool LinkDestination::isChangeLeft() const |
| 360 |
{ |
| 361 |
return d->changeLeft; |
| 362 |
} |
| 363 |
|
| 364 |
bool LinkDestination::isChangeTop() const |
| 365 |
{ |
| 366 |
return d->changeTop; |
| 367 |
} |
| 368 |
|
| 369 |
bool LinkDestination::isChangeZoom() const |
| 370 |
{ |
| 371 |
return d->changeZoom; |
| 372 |
} |
| 373 |
|
| 374 |
QString LinkDestination::toString() const |
| 375 |
{ |
| 376 |
const QChar semicolon = QChar::fromLatin1(';'); |
| 377 |
QString s = QString::number((qint8)d->kind); |
| 378 |
s += semicolon + QString::number(d->pageNum); |
| 379 |
s += semicolon + QString::number(d->left); |
| 380 |
s += semicolon + QString::number(d->bottom); |
| 381 |
s += semicolon + QString::number(d->right); |
| 382 |
s += semicolon + QString::number(d->top); |
| 383 |
s += semicolon + QString::number(d->zoom); |
| 384 |
s += semicolon + QString::number((qint8)d->changeLeft); |
| 385 |
s += semicolon + QString::number((qint8)d->changeTop); |
| 386 |
s += semicolon + QString::number((qint8)d->changeZoom); |
| 387 |
return s; |
| 388 |
} |
| 389 |
|
| 390 |
QString LinkDestination::destinationName() const |
| 391 |
{ |
| 392 |
return d->name; |
| 393 |
} |
| 394 |
|
| 395 |
LinkDestination &LinkDestination::operator=(const LinkDestination &other) |
| 396 |
{ |
| 397 |
if (this == &other) { |
| 398 |
return *this; |
| 399 |
} |
| 400 |
|
| 401 |
d = other.d; |
| 402 |
return *this; |
| 403 |
} |
| 404 |
|
| 405 |
// Link |
| 406 |
Link::~Link() |
| 407 |
{ |
| 408 |
delete d_ptr; |
| 409 |
} |
| 410 |
|
| 411 |
Link::Link(const QRectF &linkArea) : d_ptr(new LinkPrivate(linkArea)) { } |
| 412 |
|
| 413 |
Link::Link(LinkPrivate &dd) : d_ptr(&dd) { } |
| 414 |
|
| 415 |
Link::LinkType Link::linkType() const |
| 416 |
{ |
| 417 |
return None; |
| 418 |
} |
| 419 |
|
| 420 |
QRectF Link::linkArea() const |
| 421 |
{ |
| 422 |
Q_D(const Link); |
| 423 |
return d->linkArea; |
| 424 |
} |
| 425 |
|
| 426 |
QVector<Link *> Link::nextLinks() const |
| 427 |
{ |
| 428 |
QVector<Link *> links(d_ptr->nextLinks.size()); |
| 429 |
for (qsizetype i = 0; i < links.size(); i++) { |
| 430 |
links[i] = d_ptr->nextLinks[i].get(); |
| 431 |
} |
| 432 |
|
| 433 |
return links; |
| 434 |
} |
| 435 |
|
| 436 |
// LinkGoto |
| 437 |
LinkGoto::LinkGoto(const QRectF &linkArea, const QString &extFileName, const LinkDestination &destination) : Link(*new LinkGotoPrivate(linkArea, destination)) |
| 438 |
{ |
| 439 |
Q_D(LinkGoto); |
| 440 |
d->extFileName = extFileName; |
| 441 |
} |
| 442 |
|
| 443 |
LinkGoto::~LinkGoto() = default; |
| 444 |
|
| 445 |
bool LinkGoto::isExternal() const |
| 446 |
{ |
| 447 |
Q_D(const LinkGoto); |
| 448 |
return !d->extFileName.isEmpty(); |
| 449 |
} |
| 450 |
|
| 451 |
QString LinkGoto::fileName() const |
| 452 |
{ |
| 453 |
Q_D(const LinkGoto); |
| 454 |
return d->extFileName; |
| 455 |
} |
| 456 |
|
| 457 |
LinkDestination LinkGoto::destination() const |
| 458 |
{ |
| 459 |
Q_D(const LinkGoto); |
| 460 |
return d->destination; |
| 461 |
} |
| 462 |
|
| 463 |
Link::LinkType LinkGoto::linkType() const |
| 464 |
{ |
| 465 |
return Goto; |
| 466 |
} |
| 467 |
|
| 468 |
// LinkExecute |
| 469 |
LinkExecute::LinkExecute(const QRectF &linkArea, const QString &file, const QString ¶ms) : Link(*new LinkExecutePrivate(linkArea)) |
| 470 |
{ |
| 471 |
Q_D(LinkExecute); |
| 472 |
d->fileName = file; |
| 473 |
d->parameters = params; |
| 474 |
} |
| 475 |
|
| 476 |
LinkExecute::~LinkExecute() = default; |
| 477 |
|
| 478 |
QString LinkExecute::fileName() const |
| 479 |
{ |
| 480 |
Q_D(const LinkExecute); |
| 481 |
return d->fileName; |
| 482 |
} |
| 483 |
QString LinkExecute::parameters() const |
| 484 |
{ |
| 485 |
Q_D(const LinkExecute); |
| 486 |
return d->parameters; |
| 487 |
} |
| 488 |
|
| 489 |
Link::LinkType LinkExecute::linkType() const |
| 490 |
{ |
| 491 |
return Execute; |
| 492 |
} |
| 493 |
|
| 494 |
// LinkBrowse |
| 495 |
LinkBrowse::LinkBrowse(const QRectF &linkArea, const QString &url) : Link(*new LinkBrowsePrivate(linkArea)) |
| 496 |
{ |
| 497 |
Q_D(LinkBrowse); |
| 498 |
d->url = url; |
| 499 |
} |
| 500 |
|
| 501 |
LinkBrowse::~LinkBrowse() = default; |
| 502 |
|
| 503 |
QString LinkBrowse::url() const |
| 504 |
{ |
| 505 |
Q_D(const LinkBrowse); |
| 506 |
return d->url; |
| 507 |
} |
| 508 |
|
| 509 |
Link::LinkType LinkBrowse::linkType() const |
| 510 |
{ |
| 511 |
return Browse; |
| 512 |
} |
| 513 |
|
| 514 |
// LinkAction |
| 515 |
LinkAction::LinkAction(const QRectF &linkArea, ActionType actionType) : Link(*new LinkActionPrivate(linkArea)) |
| 516 |
{ |
| 517 |
Q_D(LinkAction); |
| 518 |
d->type = actionType; |
| 519 |
} |
| 520 |
|
| 521 |
LinkAction::~LinkAction() = default; |
| 522 |
|
| 523 |
LinkAction::ActionType LinkAction::actionType() const |
| 524 |
{ |
| 525 |
Q_D(const LinkAction); |
| 526 |
return d->type; |
| 527 |
} |
| 528 |
|
| 529 |
Link::LinkType LinkAction::linkType() const |
| 530 |
{ |
| 531 |
return Action; |
| 532 |
} |
| 533 |
|
| 534 |
// LinkSound |
| 535 |
LinkSound::LinkSound(const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound) : Link(*new LinkSoundPrivate(linkArea)) |
| 536 |
{ |
| 537 |
Q_D(LinkSound); |
| 538 |
d->volume = volume; |
| 539 |
d->sync = sync; |
| 540 |
d->repeat = repeat; |
| 541 |
d->mix = mix; |
| 542 |
d->sound = sound; |
| 543 |
} |
| 544 |
|
| 545 |
LinkSound::~LinkSound() = default; |
| 546 |
|
| 547 |
Link::LinkType LinkSound::linkType() const |
| 548 |
{ |
| 549 |
return Sound; |
| 550 |
} |
| 551 |
|
| 552 |
double LinkSound::volume() const |
| 553 |
{ |
| 554 |
Q_D(const LinkSound); |
| 555 |
return d->volume; |
| 556 |
} |
| 557 |
|
| 558 |
bool LinkSound::synchronous() const |
| 559 |
{ |
| 560 |
Q_D(const LinkSound); |
| 561 |
return d->sync; |
| 562 |
} |
| 563 |
|
| 564 |
bool LinkSound::repeat() const |
| 565 |
{ |
| 566 |
Q_D(const LinkSound); |
| 567 |
return d->repeat; |
| 568 |
} |
| 569 |
|
| 570 |
bool LinkSound::mix() const |
| 571 |
{ |
| 572 |
Q_D(const LinkSound); |
| 573 |
return d->mix; |
| 574 |
} |
| 575 |
|
| 576 |
SoundObject *LinkSound::sound() const |
| 577 |
{ |
| 578 |
Q_D(const LinkSound); |
| 579 |
return d->sound; |
| 580 |
} |
| 581 |
|
| 582 |
// LinkRendition |
| 583 |
LinkRendition::LinkRendition(const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref annotationReference) |
| 584 |
: LinkRendition(linkArea, std::unique_ptr<::MediaRendition>(rendition), operation, script, annotationReference) |
| 585 |
{ |
| 586 |
} |
| 587 |
|
| 588 |
LinkRendition::LinkRendition(const QRectF &linkArea, std::unique_ptr<::MediaRendition> &&rendition, int operation, const QString &script, const Ref annotationReference) |
| 589 |
: Link(*new LinkRenditionPrivate(linkArea, std::move(rendition), static_cast<enum ::LinkRendition::RenditionOperation>(operation), script, annotationReference)) |
| 590 |
{ |
| 591 |
} |
| 592 |
|
| 593 |
LinkRendition::~LinkRendition() = default; |
| 594 |
|
| 595 |
Link::LinkType LinkRendition::linkType() const |
| 596 |
{ |
| 597 |
return Rendition; |
| 598 |
} |
| 599 |
|
| 600 |
MediaRendition *LinkRendition::rendition() const |
| 601 |
{ |
| 602 |
Q_D(const LinkRendition); |
| 603 |
return d->rendition.get(); |
| 604 |
} |
| 605 |
|
| 606 |
LinkRendition::RenditionAction LinkRendition::action() const |
| 607 |
{ |
| 608 |
Q_D(const LinkRendition); |
| 609 |
return d->action; |
| 610 |
} |
| 611 |
|
| 612 |
QString LinkRendition::script() const |
| 613 |
{ |
| 614 |
Q_D(const LinkRendition); |
| 615 |
return d->script; |
| 616 |
} |
| 617 |
|
| 618 |
bool LinkRendition::isReferencedAnnotation(const ScreenAnnotation *annotation) const |
| 619 |
{ |
| 620 |
Q_D(const LinkRendition); |
| 621 |
if (d->annotationReference != Ref::INVALID() && d->annotationReference == annotation->d_ptr->pdfObjectReference()) { |
| 622 |
return true; |
| 623 |
} |
| 624 |
|
| 625 |
return false; |
| 626 |
} |
| 627 |
|
| 628 |
// LinkJavaScript |
| 629 |
LinkJavaScript::LinkJavaScript(const QRectF &linkArea, const QString &js) : Link(*new LinkJavaScriptPrivate(linkArea)) |
| 630 |
{ |
| 631 |
Q_D(LinkJavaScript); |
| 632 |
d->js = js; |
| 633 |
} |
| 634 |
|
| 635 |
LinkJavaScript::~LinkJavaScript() = default; |
| 636 |
|
| 637 |
Link::LinkType LinkJavaScript::linkType() const |
| 638 |
{ |
| 639 |
return JavaScript; |
| 640 |
} |
| 641 |
|
| 642 |
QString LinkJavaScript::script() const |
| 643 |
{ |
| 644 |
Q_D(const LinkJavaScript); |
| 645 |
return d->js; |
| 646 |
} |
| 647 |
|
| 648 |
// LinkMovie |
| 649 |
LinkMovie::LinkMovie(const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref annotationReference) : Link(*new LinkMoviePrivate(linkArea, operation, annotationTitle, annotationReference)) { } |
| 650 |
|
| 651 |
LinkMovie::~LinkMovie() = default; |
| 652 |
|
| 653 |
Link::LinkType LinkMovie::linkType() const |
| 654 |
{ |
| 655 |
return Movie; |
| 656 |
} |
| 657 |
|
| 658 |
LinkMovie::Operation LinkMovie::operation() const |
| 659 |
{ |
| 660 |
Q_D(const LinkMovie); |
| 661 |
return d->operation; |
| 662 |
} |
| 663 |
|
| 664 |
bool LinkMovie::isReferencedAnnotation(const MovieAnnotation *annotation) const |
| 665 |
{ |
| 666 |
Q_D(const LinkMovie); |
| 667 |
if (d->annotationReference != Ref::INVALID() && d->annotationReference == annotation->d_ptr->pdfObjectReference()) { |
| 668 |
return true; |
| 669 |
} else if (!d->annotationTitle.isNull()) { |
| 670 |
return (annotation->movieTitle() == d->annotationTitle); |
| 671 |
} |
| 672 |
|
| 673 |
return false; |
| 674 |
} |
| 675 |
|
| 676 |
LinkOCGState::LinkOCGState(LinkOCGStatePrivate *ocgp) : Link(*ocgp) { } |
| 677 |
|
| 678 |
LinkOCGState::~LinkOCGState() = default; |
| 679 |
|
| 680 |
Link::LinkType LinkOCGState::linkType() const |
| 681 |
{ |
| 682 |
return OCGState; |
| 683 |
} |
| 684 |
|
| 685 |
// LinkHide |
| 686 |
LinkHide::LinkHide(LinkHidePrivate *lhidep) : Link(*lhidep) { } |
| 687 |
|
| 688 |
LinkHide::~LinkHide() = default; |
| 689 |
|
| 690 |
Link::LinkType LinkHide::linkType() const |
| 691 |
{ |
| 692 |
return Hide; |
| 693 |
} |
| 694 |
|
| 695 |
QVector<QString> LinkHide::targets() const |
| 696 |
{ |
| 697 |
Q_D(const LinkHide); |
| 698 |
return QVector<QString>() << d->targetName; |
| 699 |
} |
| 700 |
|
| 701 |
bool LinkHide::isShowAction() const |
| 702 |
{ |
| 703 |
Q_D(const LinkHide); |
| 704 |
return d->isShow; |
| 705 |
} |
| 706 |
|
| 707 |
// LinkResetForm |
| 708 |
LinkResetForm::LinkResetForm(LinkResetFormPrivate *lrfp) : Link(*lrfp) { } |
| 709 |
|
| 710 |
LinkResetForm::~LinkResetForm() = default; |
| 711 |
|
| 712 |
Link::LinkType LinkResetForm::linkType() const |
| 713 |
{ |
| 714 |
return ResetForm; |
| 715 |
} |
| 716 |
|
| 717 |
// LinkSubmitForm |
| 718 |
// static assertions to ensure flags from Link.h match those from poppler-link.h |
| 719 |
static_assert(static_cast<int>(LinkSubmitForm::NoOpFlag) == static_cast<int>(::LinkSubmitForm::NoOpFlag), "NoOpFlag does not match"); |
| 720 |
static_assert(static_cast<int>(LinkSubmitForm::ExcludeFlag) == static_cast<int>(::LinkSubmitForm::ExcludeFlag), "ExcludeFlag does not match"); |
| 721 |
static_assert(static_cast<int>(LinkSubmitForm::IncludeNoValueFieldsFlag) == static_cast<int>(::LinkSubmitForm::IncludeNoValueFieldsFlag), "IncludeNoValueFieldsFlag does not match"); |
| 722 |
static_assert(static_cast<int>(LinkSubmitForm::ExportFormatFlag) == static_cast<int>(::LinkSubmitForm::ExportFormatFlag), "ExportFormatFlag does not match"); |
| 723 |
static_assert(static_cast<int>(LinkSubmitForm::GetMethodFlag) == static_cast<int>(::LinkSubmitForm::GetMethodFlag), "GetMethodFlag does not match"); |
| 724 |
static_assert(static_cast<int>(LinkSubmitForm::SubmitCoordinatesFlag) == static_cast<int>(::LinkSubmitForm::SubmitCoordinatesFlag), "SubmitCoordinatesFlag does not match"); |
| 725 |
static_assert(static_cast<int>(LinkSubmitForm::XFDFFlag) == static_cast<int>(::LinkSubmitForm::XFDFFlag), "XFDFFlag does not match"); |
| 726 |
static_assert(static_cast<int>(LinkSubmitForm::IncludeAppendSavesFlag) == static_cast<int>(::LinkSubmitForm::IncludeAppendSavesFlag), "IncludeAppendSavesFlag does not match"); |
| 727 |
static_assert(static_cast<int>(LinkSubmitForm::IncludeAnnotationsFlag) == static_cast<int>(::LinkSubmitForm::IncludeAnnotationsFlag), "IncludeAnnotationsFlag does not match"); |
| 728 |
static_assert(static_cast<int>(LinkSubmitForm::SubmitPDFFlag) == static_cast<int>(::LinkSubmitForm::SubmitPDFFlag), "SubmitPDFFlag does not match"); |
| 729 |
static_assert(static_cast<int>(LinkSubmitForm::CanonicalFormatFlag) == static_cast<int>(::LinkSubmitForm::CanonicalFormatFlag), "CanonicalFormatFlag does not match"); |
| 730 |
static_assert(static_cast<int>(LinkSubmitForm::ExclNonUserAnnotsFlag) == static_cast<int>(::LinkSubmitForm::ExclNonUserAnnotsFlag), "ExclNonUserAnnotsFlag does not match"); |
| 731 |
static_assert(static_cast<int>(LinkSubmitForm::ExclFKeyFlag) == static_cast<int>(::LinkSubmitForm::ExclFKeyFlag), "ExclFKeyFlag does not match"); |
| 732 |
static_assert(static_cast<int>(LinkSubmitForm::EmbedFormFlag) == static_cast<int>(::LinkSubmitForm::EmbedFormFlag), "EmbedFormFlag does not match"); |
| 733 |
|
| 734 |
LinkSubmitForm::LinkSubmitForm(LinkSubmitFormPrivate *lsfp) : Link(*lsfp) { } |
| 735 |
|
| 736 |
LinkSubmitForm::~LinkSubmitForm() = default; |
| 737 |
|
| 738 |
Link::LinkType LinkSubmitForm::linkType() const |
| 739 |
{ |
| 740 |
return SubmitForm; |
| 741 |
} |
| 742 |
|
| 743 |
QVector<int> LinkSubmitForm::getFieldIds() const |
| 744 |
{ |
| 745 |
Q_D(const LinkSubmitForm); |
| 746 |
return d->m_fieldIds; |
| 747 |
} |
| 748 |
|
| 749 |
QString LinkSubmitForm::getUrl() const |
| 750 |
{ |
| 751 |
Q_D(const LinkSubmitForm); |
| 752 |
return d->m_url; |
| 753 |
} |
| 754 |
|
| 755 |
LinkSubmitForm::SubmitFormFlags LinkSubmitForm::getFlags() const |
| 756 |
{ |
| 757 |
Q_D(const LinkSubmitForm); |
| 758 |
return d->m_flags; |
| 759 |
} |
| 760 |
} |