summaryrefslogtreecommitdiffstats
path: root/src/printsupport
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2012-10-25 06:43:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-30 12:53:46 +0100
commit50ec06da2c8a1c680d48b84f8c1267fe78a86b6a (patch)
treec31c6015dd0ba3cad1fe194ee5e77a19e5798fc5 /src/printsupport
parentbf722c1ab387e8892242dcaacd8afd36d592ebb6 (diff)
Only use the user set page margins for custom paper
When the QPrinter is initalized then it will set up page margins based on the default paper size. If the paper size is changed to be a custom one then it should disregard the margins for the default paper size. If the page margins are set explicitly beforehand then it will use these page margins. Change-Id: Ic535c3a80b8b217dbd5eb5f4fb2cbc0ab1354563 Reviewed-by: Titta Heikkala <titta.heikkala@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/printsupport')
-rw-r--r--src/printsupport/kernel/qprintengine_pdf.cpp9
-rw-r--r--src/printsupport/kernel/qprintengine_pdf_p.h2
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp16
3 files changed, 18 insertions, 9 deletions
diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp
index 3e343176ba..c4bcb697f5 100644
--- a/src/printsupport/kernel/qprintengine_pdf.cpp
+++ b/src/printsupport/kernel/qprintengine_pdf.cpp
@@ -213,6 +213,7 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
d->topMargin = margins.at(1).toReal();
d->rightMargin = margins.at(2).toReal();
d->bottomMargin = margins.at(3).toReal();
+ d->pageMarginsSet = true;
break;
}
default:
@@ -298,8 +299,11 @@ QVariant QPdfPrintEngine::property(PrintEnginePropertyKey key) const
case PPK_PageMargins:
{
QList<QVariant> margins;
- margins << d->leftMargin << d->topMargin
- << d->rightMargin << d->bottomMargin;
+ if (d->printerPaperSize == QPrinter::Custom && !d->pageMarginsSet)
+ margins << 0 << 0 << 0 << 0;
+ else
+ margins << d->leftMargin << d->topMargin
+ << d->rightMargin << d->bottomMargin;
ret = margins;
break;
}
@@ -353,6 +357,7 @@ QPdfPrintEnginePrivate::QPdfPrintEnginePrivate(QPrinter::PrinterMode m)
pageOrder(QPrinter::FirstPageFirst),
paperSource(QPrinter::Auto),
printerPaperSize(QPrinter::A4),
+ pageMarginsSet(false),
fd(-1)
{
resolution = 72;
diff --git a/src/printsupport/kernel/qprintengine_pdf_p.h b/src/printsupport/kernel/qprintengine_pdf_p.h
index 36df233f72..2d70c4619e 100644
--- a/src/printsupport/kernel/qprintengine_pdf_p.h
+++ b/src/printsupport/kernel/qprintengine_pdf_p.h
@@ -151,7 +151,7 @@ private:
QPrinter::PaperSize printerPaperSize;
QSizeF customPaperSize; // in postscript points
-
+ bool pageMarginsSet;
int fd;
};
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 28e0363d6e..200b5fd102 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1540,13 +1540,17 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
case PPK_PageMargins:
{
QList<QVariant> margins;
- QRect pageMargins(d->getPageMargins());
+ if (d->has_custom_paper_size && !d->pageMarginsSet) {
+ margins << 0 << 0 << 0 << 0;
+ } else {
+ QRect pageMargins(d->getPageMargins());
- // specified in 1/100 mm
- margins << (mmToInches(pageMargins.left()/100.0) * 72)
- << (mmToInches(pageMargins.top()/100.0) * 72)
- << (mmToInches(pageMargins.width()/100.0) * 72)
- << (mmToInches(pageMargins.height()/100.0) * 72);
+ // specified in 1/100 mm
+ margins << (mmToInches(pageMargins.left()/100.0) * 72)
+ << (mmToInches(pageMargins.top()/100.0) * 72)
+ << (mmToInches(pageMargins.width()/100.0) * 72)
+ << (mmToInches(pageMargins.height()/100.0) * 72);
+ }
value = margins;
break;
}