diff options
author | Antonin Stefanutti <antonin@stefanutti.fr> | 2015-05-21 22:20:21 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-08-31 08:00:44 +0000 |
commit | 62dd2add32c7c4d5d409d457c818ac88c952e7f6 (patch) | |
tree | 652b062280f4eb8a3e3854e7a119e96f536ce009 | |
parent | a7592da5461b695f2182f14d5d03ef97e2177965 (diff) | |
download | qtwebkit-62dd2add32c7c4d5d409d457c818ac88c952e7f6.tar.gz |
Render anchors as clickable links in PDF documents
Implements the GraphicsContext::setURLForRect method using the new
QPdfEngine::drawHyperlink method added in version 5.6.0 so that
anchors are rendered as clickable links in PDF documents.
Task-number: QTBUG-44563
Change-Id: Ic45399ba2d97be28816e54f6bd169e90de236e91
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
-rw-r--r-- | Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index d183dd8ee..65b93535a 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -49,6 +49,7 @@ #include "Font.h" #include "ImageBuffer.h" #include "NotImplemented.h" +#include "KURL.h" #include "Path.h" #include "Pattern.h" #include "ShadowBlur.h" @@ -65,9 +66,12 @@ #include <QPixmap> #include <QPolygonF> #include <QStack> +#include <QUrl> #include <QVector> #include <wtf/MathExtras.h> +#include <private/qpdf_p.h> + #if OS(WINDOWS) QT_BEGIN_NAMESPACE Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP, int hbitmapFormat = 0); @@ -1558,9 +1562,18 @@ void GraphicsContext::set3DTransform(const TransformationMatrix& transform) } #endif -void GraphicsContext::setURLForRect(const KURL&, const IntRect&) +void GraphicsContext::setURLForRect(const KURL& url, const IntRect& rect) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + if (paintingDisabled()) + return; + + QPainter* p = m_data->p(); + if (p->paintEngine()->type() == QPaintEngine::Pdf) + static_cast<QPdfEngine *>(p->paintEngine())->drawHyperlink(p->worldTransform().mapRect(QRectF(rect.x(), rect.y(), rect.width(), rect.height())), QUrl(url.string())); +#else notImplemented(); +#endif } void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace colorSpace) |