From 8486d8dd941e56aaffeab179ef84c4a1b8992e6b Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 25 Jan 2019 01:47:34 +0300 Subject: [PATCH 1/2] Attempt to ignore printer rectangle if page size is equal to printer page size --- limereport/lrreportengine.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index ab09828..0cd8628 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -323,14 +323,14 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer) renderPage.pageItem()->rightMargin(), renderPage.pageItem()->bottomMargin(), QPrinter::Millimeter); - printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation()); + printer.setOrientation(static_cast(renderPage.pageItem()->pageOrientation())); QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)? QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()): renderPage.pageItem()->sizeMM(); printer.setPaperSize(pageSize,QPrinter::Millimeter); } else { printer.setFullPage(renderPage.pageItem()->fullPage()); - printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation()); + printer.setOrientation(static_cast(renderPage.pageItem()->pageOrientation())); if (renderPage.pageItem()->pageSize()==PageItemDesignIntf::Custom){ QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)? QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()): @@ -339,7 +339,7 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer) printer.setPaperSize(pageSize,QPrinter::Millimeter); } else { if (page->getSetPageSizeToPrinter() || printer.outputFormat() == QPrinter::PdfFormat) - printer.setPaperSize((QPrinter::PageSize)renderPage.pageItem()->pageSize()); + printer.setPaperSize(static_cast(renderPage.pageItem()->pageSize())); } } @@ -354,7 +354,9 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer) printerPageRect = QRectF(0,0,(printerPageRect.size().width() + rightMargin + leftMargin) * Const::mmFACTOR, (printerPageRect.size().height() + bottomMargin +topMargin) * Const::mmFACTOR); - if (printerPageRect.width() < page->geometry().width()){ + if (printer.pageSize() != static_cast(page->pageSize()) && + printerPageRect.width() < page->geometry().width()) + { qreal pageWidth = page->geometry().width(); QRectF currentPrintingRect = printerPageRect; while (pageWidth>0){ From 14c1b56c83583a08eb26a942b8ce2422f0c97ae9 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 1 Feb 2019 21:59:37 +0300 Subject: [PATCH 2/2] Checking painter before render the report has been added --- limereport/lrreportengine.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 0cd8628..b45fcdd 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -348,6 +348,10 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer) } else { isFirst=false; painter = new QPainter(&printer); + if (!painter->isActive()){ + delete painter; + return; + } } QRectF printerPageRect = printer.pageRect(QPrinter::Millimeter);