Skip to content

Commit

Permalink
Render anchors as clickable links in PDF documents
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
astefanutti authored and vitallium committed Dec 12, 2015
1 parent 5765f14 commit ef91a25
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ef91a25

Please sign in to comment.