Poppler Qt4 0.18.1
poppler-link.h
00001 /* poppler-link.h: qt interface to poppler
00002  * Copyright (C) 2006, Albert Astals Cid <aacid@kde.org>
00003  * Copyright (C) 2007-2008, 2010, Pino Toscano <pino@kde.org>
00004  * Copyright (C) 2010, Guillermo Amaral <gamaral@kdab.com>
00005  * Adapting code from
00006  *   Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef _POPPLER_LINK_H_
00024 #define _POPPLER_LINK_H_
00025 
00026 #include <QtCore/QString>
00027 #include <QtCore/QRectF>
00028 #include <QtCore/QSharedDataPointer>
00029 #include "poppler-export.h"
00030 
00031 namespace Poppler {
00032 
00033 class LinkPrivate;
00034 class LinkGotoPrivate;
00035 class LinkExecutePrivate;
00036 class LinkBrowsePrivate;
00037 class LinkActionPrivate;
00038 class LinkSoundPrivate;
00039 class LinkJavaScriptPrivate;
00040 class LinkMoviePrivate;
00041 class LinkDestinationData;
00042 class LinkDestinationPrivate;
00043 class SoundObject;
00044 
00054 class POPPLER_QT4_EXPORT LinkDestination
00055 {
00056         public:
00060                 enum Kind
00061                 {
00068                         destXYZ = 1,
00069                         destFit = 2,
00070                         destFitH = 3,
00071                         destFitV = 4,
00072                         destFitR = 5,
00073                         destFitB = 6,
00074                         destFitBH = 7,
00075                         destFitBV = 8
00076                 };
00077 
00079                 LinkDestination(const LinkDestinationData &data);
00080                 LinkDestination(const QString &description);
00082 
00085                 LinkDestination(const LinkDestination &other);
00089                 ~LinkDestination();
00090 
00091                 // Accessors.
00095                 Kind kind() const;
00102                 int pageNumber() const;
00107                 double left() const;
00108                 double bottom() const;
00109                 double right() const;
00114                 double top() const;
00115                 double zoom() const;
00122                 bool isChangeLeft() const;
00129                 bool isChangeTop() const;
00135                 bool isChangeZoom() const;
00136 
00140                 QString toString() const;
00141 
00147                 QString destinationName() const;
00148 
00152                 LinkDestination& operator=(const LinkDestination &other);
00153 
00154         private:
00155                 QSharedDataPointer< LinkDestinationPrivate > d;
00156 };
00157 
00165 class POPPLER_QT4_EXPORT Link
00166 {
00167         public:
00169                 Link( const QRectF &linkArea );
00171                 
00177                 enum LinkType
00178                 {
00179                     None,     
00180                     Goto,     
00181                     Execute,  
00182                     Browse,   
00183                     Action,   
00184                     Sound,    
00185                     Movie,    
00186                     JavaScript    
00187                 };
00188 
00192                 virtual LinkType linkType() const;
00193 
00197                 virtual ~Link();
00198                 
00205                 QRectF linkArea() const;
00206                 
00207         protected:
00209                 Link( LinkPrivate &dd );
00210                 Q_DECLARE_PRIVATE( Link )
00211                 LinkPrivate *d_ptr;
00213                 
00214         private:
00215                 Q_DISABLE_COPY( Link )
00216 };
00217 
00218 
00227 class POPPLER_QT4_EXPORT LinkGoto : public Link
00228 {
00229         public:
00237                 LinkGoto( const QRectF &linkArea, QString extFileName, const LinkDestination & destination );
00241                 ~LinkGoto();
00242 
00247                 bool isExternal() const;
00248                 // query for goto parameters
00253                 QString fileName() const;
00257                 LinkDestination destination() const;
00258                 LinkType linkType() const;
00259 
00260         private:
00261                 Q_DECLARE_PRIVATE( LinkGoto )
00262                 Q_DISABLE_COPY( LinkGoto )
00263 };
00264 
00273 class POPPLER_QT4_EXPORT LinkExecute : public Link
00274 {
00275         public:
00279                 QString fileName() const;
00283                 QString parameters() const;
00284 
00292                 LinkExecute( const QRectF &linkArea, const QString & file, const QString & params );
00296                 ~LinkExecute();
00297                 LinkType linkType() const;
00298 
00299         private:
00300                 Q_DECLARE_PRIVATE( LinkExecute )
00301                 Q_DISABLE_COPY( LinkExecute )
00302 };
00303 
00312 class POPPLER_QT4_EXPORT LinkBrowse : public Link
00313 {
00314         public:
00318                 QString url() const;
00319 
00326                 LinkBrowse( const QRectF &linkArea, const QString &url );
00330                 ~LinkBrowse();
00331                 LinkType linkType() const;
00332 
00333         private:
00334                 Q_DECLARE_PRIVATE( LinkBrowse )
00335                 Q_DISABLE_COPY( LinkBrowse )
00336 };      
00337 
00344 class POPPLER_QT4_EXPORT LinkAction : public Link
00345 {
00346         public:
00350                 enum ActionType { PageFirst = 1,
00351                                   PagePrev = 2,
00352                                   PageNext = 3,
00353                                   PageLast = 4,
00354                                   HistoryBack = 5,
00355                                   HistoryForward = 6,
00356                                   Quit = 7,
00357                                   Presentation = 8,
00358                                   EndPresentation = 9,
00359                                   Find = 10,
00360                                   GoToPage = 11,
00361                                   Close = 12,
00362                                   Print = 13    
00363                 };
00364 
00368                 ActionType actionType() const;
00369 
00377                 LinkAction( const QRectF &linkArea, ActionType actionType );
00381                 ~LinkAction();
00382                 LinkType linkType() const;
00383 
00384         private:
00385                 Q_DECLARE_PRIVATE( LinkAction )
00386                 Q_DISABLE_COPY( LinkAction )
00387 };
00388 
00394 class POPPLER_QT4_EXPORT LinkSound : public Link
00395 {
00396         public:
00397                 // create a Link_Sound
00398                 LinkSound( const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound );
00402                 virtual ~LinkSound();
00403 
00404                 LinkType linkType() const;
00405 
00413                 double volume() const;
00418                 bool synchronous() const;
00423                 bool repeat() const;
00431                 bool mix() const;
00435                 SoundObject *sound() const;
00436 
00437         private:
00438                 Q_DECLARE_PRIVATE( LinkSound )
00439                 Q_DISABLE_COPY( LinkSound )
00440 };
00441 
00447 class POPPLER_QT4_EXPORT LinkJavaScript : public Link
00448 {
00449         public:
00456                 LinkJavaScript( const QRectF &linkArea, const QString &js );
00460                 virtual ~LinkJavaScript();
00461 
00462                 LinkType linkType() const;
00463 
00467                 QString script() const;
00468 
00469         private:
00470                 Q_DECLARE_PRIVATE( LinkJavaScript )
00471                 Q_DISABLE_COPY( LinkJavaScript )
00472 };      
00473 
00474 #if 0
00475 
00476 class POPPLER_QT4_EXPORT LinkMovie : public Link
00477 // TODO this (Movie link)
00478 {
00479         public:
00480                 LinkMovie( const QRectF &linkArea );
00481                 ~LinkMovie();
00482                 LinkType linkType() const;
00483 
00484         private:
00485                 Q_DECLARE_PRIVATE( LinkMovie )
00486                 Q_DISABLE_COPY( LinkMovie )
00487 };
00488 #endif
00489 
00490 }
00491 
00492 #endif