1
/* poppler-link.cc: qt interface to poppler
2
* Copyright (C) 2006, 2008 Albert Astals Cid
4
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
21
#include <poppler-qt.h>
22
#include <poppler-private.h>
24
#include <qstringlist.h>
30
LinkDestination::LinkDestination(const LinkDestinationData &data)
32
bool deleteDest = false;
33
LinkDest *ld = data.ld;
35
if ( data.namedDest && !ld )
38
ld = data.doc->doc.findDest( data.namedDest );
43
if (ld->getKind() == ::destXYZ) m_kind = destXYZ;
44
else if (ld->getKind() == ::destFit) m_kind = destFit;
45
else if (ld->getKind() == ::destFitH) m_kind = destFitH;
46
else if (ld->getKind() == ::destFitV) m_kind = destFitV;
47
else if (ld->getKind() == ::destFitR) m_kind = destFitR;
48
else if (ld->getKind() == ::destFitB) m_kind = destFitB;
49
else if (ld->getKind() == ::destFitBH) m_kind = destFitBH;
50
else if (ld->getKind() == ::destFitBV) m_kind = destFitBV;
52
if ( !ld->isPageRef() ) m_pageNum = ld->getPageNum();
55
Ref ref = ld->getPageRef();
56
m_pageNum = data.doc->doc.findPage( ref.num, ref.gen );
58
double left = ld->getLeft();
59
double bottom = ld->getBottom();
60
double right = ld->getRight();
61
double top = ld->getTop();
62
m_zoom = ld->getZoom();
63
m_changeLeft = ld->getChangeLeft();
64
m_changeTop = ld->getChangeTop();
65
m_changeZoom = ld->getChangeZoom();
67
int leftAux = 0, topAux = 0, rightAux = 0, bottomAux = 0;
69
#if defined(HAVE_SPLASH)
70
SplashOutputDev *sod = data.doc->getOutputDev();
71
sod->cvtUserToDev( left, top, &leftAux, &topAux );
72
sod->cvtUserToDev( right, bottom, &rightAux, &bottomAux );
80
if (deleteDest) delete ld;
83
LinkDestination::LinkDestination(const QString &description)
85
QStringList tokens = QStringList::split(';', description);
86
m_kind = static_cast<Kind>(tokens[0].toInt());
87
m_pageNum = tokens[1].toInt();
88
m_left = tokens[2].toDouble();
89
m_bottom = tokens[3].toDouble();
90
m_right = tokens[4].toDouble();
91
m_top = tokens[5].toDouble();
92
m_zoom = tokens[6].toDouble();
93
m_changeLeft = static_cast<bool>(tokens[7].toInt());
94
m_changeTop = static_cast<bool>(tokens[8].toInt());
95
m_changeZoom = static_cast<bool>(tokens[9].toInt());
98
LinkDestination::Kind LinkDestination::kind() const
103
int LinkDestination::pageNumber() const
108
double LinkDestination::left() const
113
double LinkDestination::bottom() const
118
double LinkDestination::right() const
123
double LinkDestination::top() const
128
double LinkDestination::zoom() const
133
bool LinkDestination::isChangeLeft() const
138
bool LinkDestination::isChangeTop() const
143
bool LinkDestination::isChangeZoom() const
148
QString LinkDestination::toString() const
150
QString s = QString::number( (Q_INT8)m_kind );
151
s += ";" + QString::number( m_pageNum );
152
s += ";" + QString::number( m_left );
153
s += ";" + QString::number( m_bottom );
154
s += ";" + QString::number( m_right );
155
s += ";" + QString::number( m_top );
156
s += ";" + QString::number( m_zoom );
157
s += ";" + QString::number( (Q_INT8)m_changeLeft );
158
s += ";" + QString::number( (Q_INT8)m_changeTop );
159
s += ";" + QString::number( (Q_INT8)m_changeZoom );
169
Link::Link(const QRect &linkArea) : m_linkArea(linkArea)
173
Link::LinkType Link::linkType() const
178
QRect Link::linkArea() const
184
LinkGoto::LinkGoto( const QRect &linkArea, QString extFileName, const LinkDestination & destination ) : Link(linkArea), m_extFileName(extFileName), m_destination(destination)
188
bool LinkGoto::isExternal() const
190
return !m_extFileName.isEmpty();
193
const QString &LinkGoto::fileName() const
195
return m_extFileName;
198
const LinkDestination &LinkGoto::destination() const
200
return m_destination;
203
Link::LinkType LinkGoto::linkType() const
209
LinkExecute::LinkExecute( const QRect &linkArea, const QString & file, const QString & params ) : Link(linkArea), m_fileName(file), m_parameters(params)
213
const QString & LinkExecute::fileName() const
217
const QString & LinkExecute::parameters() const
222
Link::LinkType LinkExecute::linkType() const
228
LinkBrowse::LinkBrowse( const QRect &linkArea, const QString &url ) : Link(linkArea), m_url(url)
232
const QString & LinkBrowse::url() const
237
Link::LinkType LinkBrowse::linkType() const
243
LinkAction::LinkAction( const QRect &linkArea, ActionType actionType ) : Link(linkArea), m_type(actionType)
247
LinkAction::ActionType LinkAction::actionType() const
252
Link::LinkType LinkAction::linkType() const
258
LinkMovie::LinkMovie( const QRect &linkArea ) : Link(linkArea)
262
Link::LinkType LinkMovie::linkType() const