summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel/qprintengine_win.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-01-19 10:44:43 +0100
committerAndy Shaw <andy.shaw@qt.io>2017-01-19 14:09:24 +0000
commitf46496602e855dccccb6052de0f7ccbc74db40cd (patch)
tree54f8fe301c5b7ced668fc3b489c7126f0a0f1e6b /src/printsupport/kernel/qprintengine_win.cpp
parentd2a589e1f0c9c7770bc1161296f7041046c3c369 (diff)
Windows: Support custom sizes entered via the print dialog
When going via the advanced settings for a printer in the print dialog it is possible to specify a custom page size directly. This needs to be picked up via the POSTSCRIPT_IDENTIFY ExtEscape identifier to see if it is supported at all and then queried to see if a custom size is set. Change-Id: Id5e94c1b25be1c6e28d9e26d8001cd1c96d8f5d9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/printsupport/kernel/qprintengine_win.cpp')
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 5a48e92a3a..f1ccbaa90a 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1659,9 +1659,33 @@ void QWin32PrintEnginePrivate::updatePageLayout()
m_pageLayout.setOrientation(devMode->dmOrientation == DMORIENT_LANDSCAPE ? QPageLayout::Landscape : QPageLayout::Portrait);
if (devMode->dmPaperSize >= DMPAPER_LAST) {
// Is a custom size
- QPageSize pageSize = QPageSize(QSizeF(devMode->dmPaperWidth / 10.0f, devMode->dmPaperLength / 10.0f),
- QPageSize::Millimeter);
- setPageSize(pageSize);
+ // Check if it is using the Postscript Custom Size first
+ bool hasCustom = false;
+ int feature = PSIDENT_GDICENTRIC;
+ if (ExtEscape(hdc, POSTSCRIPT_IDENTIFY,
+ sizeof(DWORD), reinterpret_cast<LPCSTR>(&feature), 0, 0) >= 0) {
+ PSFEATURE_CUSTPAPER custPaper;
+ feature = FEATURESETTING_CUSTPAPER;
+ if (ExtEscape(hdc, GET_PS_FEATURESETTING, sizeof(INT), reinterpret_cast<LPCSTR>(&feature),
+ sizeof(custPaper), reinterpret_cast<LPSTR>(&custPaper)) > 0) {
+ // If orientation is 1 and width/height is 0 then it's not really custom
+ if (!(custPaper.lOrientation == 1 && custPaper.lWidth == 0 && custPaper.lHeight == 0)) {
+ if (custPaper.lOrientation == 0 || custPaper.lOrientation == 2)
+ m_pageLayout.setOrientation(QPageLayout::Portrait);
+ else
+ m_pageLayout.setOrientation(QPageLayout::Landscape);
+ QPageSize pageSize = QPageSize(QSizeF(custPaper.lWidth, custPaper.lHeight),
+ QPageSize::Point);
+ setPageSize(pageSize);
+ hasCustom = true;
+ }
+ }
+ }
+ if (!hasCustom) {
+ QPageSize pageSize = QPageSize(QSizeF(devMode->dmPaperWidth / 10.0f, devMode->dmPaperLength / 10.0f),
+ QPageSize::Millimeter);
+ setPageSize(pageSize);
+ }
} else {
// Is a supported size
setPageSize(QPageSize(QPageSize::id(devMode->dmPaperSize)));