Commit 5f63304a authored by Adam Pigg's avatar Adam Pigg

Print report in HighDPI

REVIEW:121281
BUG:340598

Squashed commit of the following:

commit 505c65d9ba93d23535a0a0dee9d3da1aefc13237
Author: Adam Pigg <adam@piggz.co.uk>
Date:   Sun Nov 30 19:57:50 2014 +0000

    Addressed review comments

commit bc9a04024916309b6109fe6450fc01246218a269
Author: Adam Pigg <adam@piggz.co.uk>
Date:   Fri Nov 28 19:47:16 2014 +0000

    When printing reports use High DPI
parent 5fd95293
......@@ -20,6 +20,7 @@
#include "KoReportPrintRenderer.h"
#include "renderobjects.h"
#include <KoPageFormat.h>
#include <KoDpi.h>
#include <kdebug.h>
#include <QPainter>
......@@ -73,6 +74,9 @@ bool KoReportPrintRenderer::render(const KoReportRendererContext &context, ORODo
int toPage = context.printer->toPage();
if (toPage == 0 || toPage > document->pages())
toPage = document->pages();
qreal scale = context.printer->resolution() / qreal(KoDpi::dpiX());
for (int copy = 0; copy < context.printer->numCopies(); copy++) {
for (int page = fromPage; page < toPage; page++) {
if (page > fromPage)
......@@ -82,10 +86,13 @@ bool KoReportPrintRenderer::render(const KoReportRendererContext &context, ORODo
if (context.printer->pageOrder() == QPrinter::LastPageFirst)
p = document->page(toPage - 1 - page);
// Render Page Objects
for (int i = 0; i < p->primitives(); i++) {
OROPrimitive * prim = p->primitive(i);
prim->setPosition(prim->position() * scale);
prim->setSize(prim->size() * scale);
//kDebug() << "Rendering object" << i << "type" << prim->type();
if (prim->type() == OROTextBox::TextBox) {
//kDebug() << "Text Box";
......@@ -111,7 +118,7 @@ bool KoReportPrintRenderer::render(const KoReportRendererContext &context, ORODo
context.painter->drawText(rc, tb->flags(), tb->text());
//outer line
context.painter->setPen(QPen(tb->lineStyle().lineColor, tb->lineStyle().weight, tb->lineStyle().style));
context.painter->setPen(QPen(tb->lineStyle().lineColor, tb->lineStyle().weight * scale, tb->lineStyle().style));
context.painter->drawRect(rc);
//Reset back to defaults for next element
......@@ -121,9 +128,9 @@ bool KoReportPrintRenderer::render(const KoReportRendererContext &context, ORODo
//kDebug() << "Line";
OROLine * ln = (OROLine*) prim;
QPointF s = ln->startPoint();
QPointF e = ln->endPoint();
QPointF e = ln->endPoint() * scale;
//QPen pen ( _painter->pen() );
QPen pen(ln->lineStyle().lineColor, ln->lineStyle().weight, ln->lineStyle().style);
QPen pen(ln->lineStyle().lineColor, ln->lineStyle().weight * scale, ln->lineStyle().style);
context.painter->save();
context.painter->setRenderHint(QPainter::Antialiasing, true);
......@@ -191,7 +198,7 @@ bool KoReportPrintRenderer::render(const KoReportRendererContext &context, ORODo
if (chk->lineStyle().style == Qt::NoPen || chk->lineStyle().weight <= 0) {
context.painter->setPen(QPen(Qt::lightGray));
} else {
context.painter->setPen(QPen(chk->lineStyle().lineColor, chk->lineStyle().weight, chk->lineStyle().style));
context.painter->setPen(QPen(chk->lineStyle().lineColor, chk->lineStyle().weight * scale, chk->lineStyle().style));
}
qreal ox = sz.width() / 5;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment