Commit f301a85b authored by Gil Moskowitz's avatar Gil Moskowitz Committed by GitHub

Merge pull request #75 from davidbeauchamp/28914

Issue #28914: Correctly determine page size in OpenRPT renderer, and handle changes between Qt4 and Qt5
parents ea9c38ac b12d3ae2
/*
* OpenRPT report writer and rendering engine
* Copyright (C) 2001-2014 by OpenMFG, LLC
* Copyright (C) 2001-2016 by OpenMFG, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -62,21 +62,29 @@ bool ORPrintRender::setupPrinter(ORODocument * pDocument, QPrinter * pPrinter)
pPrinter->setPageOrder(QPrinter::FirstPageFirst);
PageSizeInfo psi = PageSizeInfo::getByName(pDocument->pageOptions().getPageSize());
if(psi.isNull())
{
pPrinter->setPaperSize(QSizeF(pDocument->pageOptions().getCustomWidth(), pDocument->pageOptions().getCustomHeight()), QPrinter::Inch);
}
else
QSizeF pagesize;
if (! psi.isNull())
pagesize = QSizeF(psi.width() / 100.0, psi.height() / 100.0);
else if (pDocument->pageOptions().getPageSize() == "Custom")
pagesize = QSizeF(pDocument->pageOptions().getCustomWidth(),
pDocument->pageOptions().getCustomHeight());
else
{
#if defined(Q_WS_MAC) && (QT_VERSION < 0x040801) // QTBUG-20882
pPrinter->setPageSize((QPrinter::PageSize)psi.qpValue());
#else
if (pDocument->pageOptions().getPageSize() == "Custom")
pPrinter->setPaperSize(QSizeF(psi.width() / 100.0,
psi.height() / 100.0), QPrinter::Inch);
#endif
#if QT_VERSION >= 0x050000
pagesize = QPageSize(QPageSize::Letter).size(QPageSize::Inch);
#else
pPrinter->setPaperSize(QPrinter::Letter);
pagesize = pPrinter->paperSize(QPrinter::Inch);
#endif
}
#if QT_VERSION >= 0x050000
pPrinter->setPageSize(QPageSize(pagesize, QPageSize::Inch));
#else
pPrinter->setPaperSize(pagesize, QPrinter::Inch);
#endif
return true;
}
......@@ -96,6 +104,17 @@ bool ORPrintRender::render(ORODocument * pDocument)
_printer->setFullPage(true);
#ifdef Q_OS_WIN
// Issue 28914 - Margin calculation wrong on windows
// Works around https://bugreports.qt.io/browse/QTBUG-5363
// page rectangle is wrong after calling setFullPage above,
// this resets it to the correct value
_printer->setPageMargins(QMarginsF(pDocument->pageOptions().getMarginLeft(),
pDocument->pageOptions().getMarginRight(),
pDocument->pageOptions().getMarginTop(),
pDocument->pageOptions().getMarginBottom()));
#endif
bool deleteWhenComplete = false;
bool endWhenComplete = false;
......
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