From 5f35882f91ff5634b1694d1f6d62c057d278b1a6 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 12 Jan 2012 22:06:12 +0100 Subject: Fix using custom paper sizes on Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This solves the bug with using custom paper sizes on Mac, if a QSize was specified then with a Unit it would not respect this on Mac as it would not convert it correctly. Also paperSize() would return the wrong value. There is already a test for this in tst_QPrinter::testCustomPageSizes() Task-number: QTBUG-18723 Change-Id: I47c0cf2dd48ea3e0daa3b748f337ec38714aaf34 Reviewed-by: Samuel Rødal Reviewed-by: Jiang Jiang --- src/gui/painting/qprintengine_mac.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm index b103417..729c87b 100644 --- a/src/gui/painting/qprintengine_mac.mm +++ b/src/gui/painting/qprintengine_mac.mm @@ -179,6 +179,8 @@ void QMacPrintEnginePrivate::setPaperSize(QPrinter::PaperSize ps) QPrinter::PaperSize QMacPrintEnginePrivate::paperSize() const { + if (hasCustomPaperSize) + return QPrinter::Custom; PMRect paper; PMGetUnadjustedPaperRect(format, &paper); int wMM = int((paper.right - paper.left) / 72 * 25.4 + 0.5); @@ -854,11 +856,11 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const case PPK_PaperRect: { QRect r; PMRect macrect; + qreal hRatio = d->resolution.hRes / 72; + qreal vRatio = d->resolution.vRes / 72; if (d->hasCustomPaperSize) { - r = QRect(0, 0, qRound(d->customSize.width()), qRound(d->customSize.height())); + r = QRect(0, 0, qRound(d->customSize.width() * hRatio), qRound(d->customSize.height() * vRatio)); } else if (PMGetAdjustedPaperRect(d->format, ¯ect) == noErr) { - qreal hRatio = d->resolution.hRes / 72; - qreal vRatio = d->resolution.vRes / 72; r.setCoords(int(macrect.left * hRatio), int(macrect.top * vRatio), int(macrect.right * hRatio), int(macrect.bottom * vRatio)); r.translate(-r.x(), -r.y()); -- cgit v0.12