From 83e6d1fe6006ad8e3cf37d5ca412aedae5aab9a4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 1 Jan 2013 01:33:42 +0100 Subject: Add support for getting the paper names available for the printer Task-number: QTBUG-27714 Change-Id: I9bc6f1188f262e43f581add058d7895e1b5bd9e3 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/printsupport/kernel/qprintengine_win.cpp | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/printsupport/kernel/qprintengine_win.cpp') diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 97453f2e0e..f5690c12f3 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1596,6 +1596,38 @@ QList QWin32PrintEngine::supportedPaperSizes(const QPrinter return returnList; } +QList > QWin32PrintEngine::supportedSizesWithNames(const QPrinterInfo &printerInfo) +{ + QList > paperSizes; + if (printerInfo.isNull()) + return paperSizes; + DWORD size = DeviceCapabilities(reinterpret_cast(printerInfo.printerName().utf16()), + NULL, DC_PAPERNAMES, NULL, NULL); + if ((int)size != -1) { + wchar_t *papers = new wchar_t[size*64]; + size = DeviceCapabilities(reinterpret_cast(printerInfo.printerName().utf16()), + NULL, DC_PAPERNAMES, papers, NULL); + DWORD size2 = DeviceCapabilities(reinterpret_cast(printerInfo.printerName().utf16()), + NULL, DC_PAPERSIZE, NULL, NULL); + if ((int)size2 != -1) { + POINT *points = new POINT[size2*sizeof(POINT)]; + + size2 = DeviceCapabilities(reinterpret_cast(printerInfo.printerName().utf16()), + NULL, DC_PAPERSIZE, (wchar_t *)points, NULL); + wchar_t copyOfPaper[65]; + for (int i=0;i<(int)size;i++) { + wcscpy_s(copyOfPaper, 64, papers + (i * 64)); + copyOfPaper[64] = '\0'; + QString str = QString::fromWCharArray(copyOfPaper); + paperSizes << qMakePair(str, QSizeF(points[i].x / 10, points[i].y / 10)); + } + delete [] points; + } + delete [] papers; + } + return paperSizes; +} + void QWin32PrintEngine::queryDefaultPrinter(QString &name, QString &program, QString &port) { /* Read the default printer name, driver and port with the intuitive function -- cgit v1.2.3