From b188221fee0eaacec115b514185a0508ef655897 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 21 Mar 2012 17:17:42 +0200 Subject: Fix QPrinter test in Windows Fixed Q_WS_WIN flagging to Q_OS_WIN in QPrinter API and related implementation to make API match the documentation and Qt 4.8. Also Removed the unused internal HDC related functions from the API, that were previously behind Q_WS_WIN flag. Some of the properties tested are documented to be valid for native print engine only in X11 environment, so skipped testing those in non-xcb environments. Copy collation is also apparently not supported in Windows native print engine, though this seems to be undocumented, so skipped that only in Windows. At least one of the test blocks in tst_QPrinter::valuePreservation() failed due to default printer not getting set properly, so fixed that, too. Task-number: QTBUG-24191 Task-number: QTBUG-22927 Change-Id: I44a5e3d647a1279fcc7f1e99de6881f9be330246 Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprintengine_win.cpp | 49 +++++++++++++++------------- 1 file changed, 27 insertions(+), 22 deletions(-) (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 171ebbce17..37d2b27d15 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -966,28 +966,7 @@ void QWin32PrintEngine::drawPolygon(const QPointF *points, int pointCount, Polyg void QWin32PrintEnginePrivate::queryDefault() { - /* Read the default printer name, driver and port with the intuitive function - * Strings "windows" and "device" are specified in the MSDN under EnumPrinters() - */ - QString noPrinters(QLatin1String("qt_no_printers")); - wchar_t buffer[256]; - GetProfileString(L"windows", L"device", - reinterpret_cast(noPrinters.utf16()), - buffer, 256); - QString output = QString::fromWCharArray(buffer); - if (output.isEmpty() || output == noPrinters) // no printers - return; - - QStringList info = output.split(QLatin1Char(',')); - int infoSize = info.size(); - if (infoSize > 0) { - if (name.isEmpty()) - name = info.at(0); - if (program.isEmpty() && infoSize > 1) - program = info.at(1); - if (port.isEmpty() && infoSize > 2) - port = info.at(2); - } + QWin32PrintEngine::queryDefaultPrinter(name, program, port); } QWin32PrintEnginePrivate::~QWin32PrintEnginePrivate() @@ -1601,6 +1580,32 @@ QList QWin32PrintEngine::supportedPaperSizes(const QPrinter return returnList; } +void QWin32PrintEngine::queryDefaultPrinter(QString &name, QString &program, QString &port) +{ + /* Read the default printer name, driver and port with the intuitive function + * Strings "windows" and "device" are specified in the MSDN under EnumPrinters() + */ + QString noPrinters(QLatin1String("qt_no_printers")); + wchar_t buffer[256]; + GetProfileString(L"windows", L"device", + reinterpret_cast(noPrinters.utf16()), + buffer, 256); + QString output = QString::fromWCharArray(buffer); + if (output.isEmpty() || output == noPrinters) // no printers + return; + + QStringList info = output.split(QLatin1Char(',')); + int infoSize = info.size(); + if (infoSize > 0) { + if (name.isEmpty()) + name = info.at(0); + if (program.isEmpty() && infoSize > 1) + program = info.at(1); + if (port.isEmpty() && infoSize > 2) + port = info.at(2); + } +} + HGLOBAL *QWin32PrintEnginePrivate::createDevNames() { int size = sizeof(DEVNAMES) -- cgit v1.2.3