summaryrefslogtreecommitdiff
path: root/qt
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2006-06-25 16:19:32 +0000
committerAlbert Astals Cid <aacid@kde.org>2006-06-25 16:19:32 +0000
commit4995d09c91173d34a435112828aff21a63b147e9 (patch)
tree11ccb32d223697d5a6db687fd9eb2badb13ca3bb /qt
parent087921b134c2646e6d41960f471a1819c7c8790a (diff)
rename poppler-link.h to poppler-link-qt3.h to not get conflicts on install
Diffstat (limited to 'qt')
-rw-r--r--qt/Makefile.am2
-rw-r--r--qt/poppler-link-qt3.h188
-rw-r--r--qt/poppler-link.cc258
-rw-r--r--qt/poppler-qt.h4
4 files changed, 449 insertions, 3 deletions
diff --git a/qt/Makefile.am b/qt/Makefile.am
index c1911ca2..41cd64b9 100644
--- a/qt/Makefile.am
+++ b/qt/Makefile.am
@@ -11,7 +11,7 @@ poppler_includedir = $(includedir)/poppler
poppler_include_HEADERS = \
poppler-qt.h \
poppler-page-transition.h \
- poppler-link.h
+ poppler-link-qt3.h
lib_LTLIBRARIES = libpoppler-qt.la
libpoppler_qt_la_SOURCES = \
diff --git a/qt/poppler-link-qt3.h b/qt/poppler-link-qt3.h
new file mode 100644
index 00000000..a5637129
--- /dev/null
+++ b/qt/poppler-link-qt3.h
@@ -0,0 +1,188 @@
+/* poppler-link.h: qt interface to poppler
+ * Copyright (C) 2006, Albert Astals Cid <aacid@kde.org>
+ * Adapting code from
+ * Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _POPPLER_LINK_H_
+#define _POPPLER_LINK_H_
+
+#include <qstring.h>
+#include <qrect.h>
+
+namespace Poppler {
+
+class LinkDestinationData;
+
+class LinkDestination
+{
+ public:
+ enum Kind
+ {
+ destXYZ = 1,
+ destFit = 2,
+ destFitH = 3,
+ destFitV = 4,
+ destFitR = 5,
+ destFitB = 6,
+ destFitBH = 7,
+ destFitBV = 8
+ };
+
+ LinkDestination(const LinkDestinationData &data);
+ LinkDestination(const QString &description);
+
+ // Accessors.
+ Kind kind() const;
+ int pageNumber() const;
+ double left() const;
+ double bottom() const;
+ double right() const;
+ double top() const;
+ double zoom() const;
+ bool isChangeLeft() const;
+ bool isChangeTop() const;
+ bool isChangeZoom() const;
+
+ QString toString() const;
+
+ private:
+ Kind m_kind; // destination type
+ int m_pageNum; // page number
+ double m_left, m_bottom; // position
+ double m_right, m_top;
+ double m_zoom; // zoom factor
+ bool m_changeLeft, m_changeTop; // for destXYZ links, which position
+ bool m_changeZoom; // components to change
+};
+
+/**
+ * @short Encapsulates data that describes a link.
+ *
+ * This is the base class for links. It makes mandatory for inherited
+ * widgets to reimplement the 'linkType' method and return the type of
+ * the link described by the reimplemented class.
+ */
+class Link
+{
+ public:
+ Link( const QRect &linkArea );
+
+ // get link type (inherited classes mustreturn an unique identifier)
+ enum LinkType { None, Goto, Execute, Browse, Action, Movie };
+ virtual LinkType linkType() const;
+
+ // virtual destructor
+ virtual ~Link();
+
+ QRect linkArea() const;
+
+ private:
+ QRect m_linkArea;
+};
+
+
+/** Goto: a viewport and maybe a reference to an external filename **/
+class LinkGoto : public Link
+{
+ public:
+ LinkGoto( const QRect &linkArea, QString extFileName, const LinkDestination & destination );
+
+ // query for goto parameters
+ bool isExternal() const;
+ const QString & fileName() const;
+ const LinkDestination & destination() const;
+ LinkType linkType() const;
+
+ private:
+ QString m_extFileName;
+ LinkDestination m_destination;
+};
+
+/** Execute: filename and parameters to execute **/
+class LinkExecute : public Link
+{
+ public:
+ // query for filename / parameters
+ const QString & fileName() const;
+ const QString & parameters() const;
+
+ // create a Link_Execute
+ LinkExecute( const QRect &linkArea, const QString & file, const QString & params );
+ LinkType linkType() const;
+
+ private:
+ QString m_fileName;
+ QString m_parameters;
+};
+
+/** Browse: an URL to open, ranging from 'http://' to 'mailto:' etc.. **/
+class LinkBrowse : public Link
+{
+ public:
+ // query for URL
+ const QString & url() const;
+
+ // create a Link_Browse
+ LinkBrowse( const QRect &linkArea, const QString &url );
+ LinkType linkType() const;
+
+ private:
+ QString m_url;
+};
+
+/** Action: contains an action to perform on document / viewer **/
+class LinkAction : public Link
+{
+ public:
+ // define types of actions
+ enum ActionType { PageFirst = 1,
+ PagePrev = 2,
+ PageNext = 3,
+ PageLast = 4,
+ HistoryBack = 5,
+ HistoryForward = 6,
+ Quit = 7,
+ Presentation = 8,
+ EndPresentation = 9,
+ Find = 10,
+ GoToPage = 11,
+ Close = 12 };
+
+ // query for action type
+ ActionType actionType() const;
+
+ // create a Link_Action
+ LinkAction( const QRect &linkArea, ActionType actionType );
+ LinkType linkType() const;
+
+ private:
+ ActionType m_type;
+};
+
+/** Movie: Not yet defined -> think renaming to 'Media' link **/
+class LinkMovie : public Link
+// TODO this (Movie link)
+{
+ public:
+ LinkMovie( const QRect &linkArea );
+ LinkType linkType() const;
+};
+
+}
+
+#endif
diff --git a/qt/poppler-link.cc b/qt/poppler-link.cc
new file mode 100644
index 00000000..64a745c1
--- /dev/null
+++ b/qt/poppler-link.cc
@@ -0,0 +1,258 @@
+/* poppler-link.cc: qt interface to poppler
+ * Copyright (C) 2006, Albert Astals Cid
+ * Adapting code from
+ * Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <poppler-qt.h>
+#include <poppler-private.h>
+
+#include <qstringlist.h>
+
+#include <Link.h>
+
+namespace Poppler {
+
+ LinkDestination::LinkDestination(const LinkDestinationData &data)
+ {
+ LinkDest *ld = data.ld;
+
+ if ( data.namedDest && !ld )
+ ld = data.doc->doc.findDest( data.namedDest );
+
+ if (!ld) return;
+
+ if (ld->getKind() == ::destXYZ) m_kind = destXYZ;
+ else if (ld->getKind() == ::destFit) m_kind = destFit;
+ else if (ld->getKind() == ::destFitH) m_kind = destFitH;
+ else if (ld->getKind() == ::destFitV) m_kind = destFitV;
+ else if (ld->getKind() == ::destFitR) m_kind = destFitR;
+ else if (ld->getKind() == ::destFitB) m_kind = destFitB;
+ else if (ld->getKind() == ::destFitBH) m_kind = destFitBH;
+ else if (ld->getKind() == ::destFitBV) m_kind = destFitBV;
+
+ if ( !ld->isPageRef() ) m_pageNum = ld->getPageNum();
+ else
+ {
+ Ref ref = ld->getPageRef();
+ m_pageNum = data.doc->doc.findPage( ref.num, ref.gen );
+ }
+ double left = ld->getLeft();
+ double bottom = ld->getBottom();
+ double right = ld->getRight();
+ double top = ld->getTop();
+ m_zoom = ld->getZoom();
+ m_changeLeft = ld->getChangeLeft();
+ m_changeTop = ld->getChangeTop();
+ m_changeZoom = ld->getChangeZoom();
+
+ int leftAux, topAux, rightAux, bottomAux;
+
+ SplashOutputDev *sod = data.doc->getOutputDev();
+ sod->cvtUserToDev( left, top, &leftAux, &topAux );
+ sod->cvtUserToDev( right, bottom, &rightAux, &bottomAux );
+
+ m_left = leftAux;
+ m_top = topAux;
+ m_right = rightAux;
+ m_bottom = bottomAux;
+ }
+
+ LinkDestination::LinkDestination(const QString &description)
+ {
+ QStringList tokens = QStringList::split(';', description);
+ m_kind = static_cast<Kind>(tokens[0].toInt());
+ m_pageNum = tokens[1].toInt();
+ m_left = tokens[2].toDouble();
+ m_bottom = tokens[3].toDouble();
+ m_top = tokens[4].toDouble();
+ m_zoom = tokens[5].toDouble();
+ m_changeLeft = static_cast<bool>(tokens[6].toInt());
+ m_changeTop = static_cast<bool>(tokens[7].toInt());
+ m_changeZoom = static_cast<bool>(tokens[8].toInt());
+ }
+
+ LinkDestination::Kind LinkDestination::kind() const
+ {
+ return m_kind;
+ }
+
+ int LinkDestination::pageNumber() const
+ {
+ return m_pageNum;
+ }
+
+ double LinkDestination::left() const
+ {
+ return m_left;
+ }
+
+ double LinkDestination::bottom() const
+ {
+ return m_bottom;
+ }
+
+ double LinkDestination::right() const
+ {
+ return m_right;
+ }
+
+ double LinkDestination::top() const
+ {
+ return m_top;
+ }
+
+ double LinkDestination::zoom() const
+ {
+ return m_zoom;
+ }
+
+ bool LinkDestination::isChangeLeft() const
+ {
+ return m_changeLeft;
+ }
+
+ bool LinkDestination::isChangeTop() const
+ {
+ return m_changeTop;
+ }
+
+ bool LinkDestination::isChangeZoom() const
+ {
+ return m_changeZoom;
+ }
+
+ QString LinkDestination::toString() const
+ {
+ QString s = QString::number( (Q_INT8)m_kind );
+ s += ";" + QString::number( m_pageNum );
+ s += ";" + QString::number( m_left );
+ s += ";" + QString::number( m_bottom );
+ s += ";" + QString::number( m_right );
+ s += ";" + QString::number( m_top );
+ s += ";" + QString::number( m_zoom );
+ s += ";" + QString::number( (Q_INT8)m_changeLeft );
+ s += ";" + QString::number( (Q_INT8)m_changeTop );
+ s += ";" + QString::number( (Q_INT8)m_changeZoom );
+ return s;
+ }
+
+
+ // Link
+ Link::~Link()
+ {
+ }
+
+ Link::Link(const QRect &linkArea) : m_linkArea(linkArea)
+ {
+ }
+
+ Link::LinkType Link::linkType() const
+ {
+ return None;
+ }
+
+ QRect Link::linkArea() const
+ {
+ return m_linkArea;
+ }
+
+ // LinkGoto
+ LinkGoto::LinkGoto( const QRect &linkArea, QString extFileName, const LinkDestination & destination ) : Link(linkArea), m_extFileName(extFileName), m_destination(destination)
+ {
+ }
+
+ bool LinkGoto::isExternal() const
+ {
+ return !m_extFileName.isEmpty();
+ }
+
+ const QString &LinkGoto::fileName() const
+ {
+ return m_extFileName;
+ }
+
+ const LinkDestination &LinkGoto::destination() const
+ {
+ return m_destination;
+ }
+
+ Link::LinkType LinkGoto::linkType() const
+ {
+ return Goto;
+ }
+
+ // LinkExecute
+ LinkExecute::LinkExecute( const QRect &linkArea, const QString & file, const QString & params ) : Link(linkArea), m_fileName(file), m_parameters(params)
+ {
+ }
+
+ const QString & LinkExecute::fileName() const
+ {
+ return m_fileName;
+ }
+ const QString & LinkExecute::parameters() const
+ {
+ return m_parameters;
+ }
+
+ Link::LinkType LinkExecute::linkType() const
+ {
+ return Execute;
+ }
+
+ // LinkBrowse
+ LinkBrowse::LinkBrowse( const QRect &linkArea, const QString &url ) : Link(linkArea), m_url(url)
+ {
+ }
+
+ const QString & LinkBrowse::url() const
+ {
+ return m_url;
+ }
+
+ Link::LinkType LinkBrowse::linkType() const
+ {
+ return Browse;
+ }
+
+ // LinkAction
+ LinkAction::LinkAction( const QRect &linkArea, ActionType actionType ) : Link(linkArea), m_type(actionType)
+ {
+ }
+
+ LinkAction::ActionType LinkAction::actionType() const
+ {
+ return m_type;
+ }
+
+ Link::LinkType LinkAction::linkType() const
+ {
+ return Action;
+ }
+
+ // LinkMovie
+ LinkMovie::LinkMovie( const QRect &linkArea ) : Link(linkArea)
+ {
+ }
+
+ Link::LinkType LinkMovie::linkType() const
+ {
+ return Movie;
+ }
+
+}
diff --git a/qt/poppler-qt.h b/qt/poppler-qt.h
index baf929dd..451e062c 100644
--- a/qt/poppler-qt.h
+++ b/qt/poppler-qt.h
@@ -24,7 +24,7 @@
#include <qdatetime.h>
#include <qpixmap.h>
-#include <poppler-link.h>
+#include <poppler-link-qt3.h>
#include <poppler-page-transition.h>
namespace Poppler {
@@ -231,7 +231,7 @@ public:
bool okToAddNotes() const;
double getPDFVersion() const;
- bool print(const QString &fileName, QValueList<int> pageList, double hDPI, double vDPI, int rotate);
+ bool print(const QString &fileName, QValueList<int> pageList, double hDPI, double vDPI, int rotate, int paperWidth = -1, int paperHeight = -1);
/**
The fonts within the PDF document.