1 /* 2 <one line to give the program's name and a brief idea of what it does.> 3 Copyright (C) 2012 <copyright holder> <email> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License along 16 with this program; if not, write to the Free Software Foundation, Inc., 17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 21 #ifndef ADJUSTEDLINK_H 22 #define ADJUSTEDLINK_H 23 #include "renderingidentifier.h" 24 #include <QSharedPointer> 25 #include "poppler-qt.h" 26 27 #include <stdexcept> 28 29 /** Link that is adjusted to a rendered page. 30 * This includes failing to construct if it is completely outside the scope. 31 */ 32 class AdjustedLink 33 { 34 public: 35 /** Exception class */ 36 struct OutsidePage: public std::runtime_error { 37 OutsidePage(); 38 }; 39 40 /** Exception class */ 41 struct UnsupportedLinkType{}; 42 43 AdjustedLink(const RenderingIdentifier& renderIdent, QSharedPointer<Poppler::Link> link); 44 45 /** Returns the link area as floating point in the range 0..1 **/ 46 QRectF linkArea() const; 47 48 /** Returns the link area, but scaled to the given QRectangle **/ 49 QRect linkArea(const QRect& rect) const; 50 51 /** Target page number */ 52 uint targetPageNumber() const; 53 54 /** Returns a shared pointer to the Poppler link 55 */ 56 QSharedPointer<Poppler::Link> link() const; 57 58 /** Forwarding function for Poppler::Link::LinkType **/ 59 Poppler::Link::LinkType linkType() const; 60 61 private: 62 QSharedPointer<Poppler::Link> m_link; 63 RenderingIdentifier ri; 64 65 Poppler::LinkGoto const& lgt() const; 66 }; 67 68 69 #endif // ADJUSTEDLINK_H 70