diff options
-rw-r--r-- | src/plugins/platforms/cocoa/qprintengine_mac.mm | 17 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 6 | ||||
-rw-r--r-- | tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp | 11 |
3 files changed, 15 insertions, 19 deletions
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index dd2bd718f6..170eccdd1b 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -615,9 +615,6 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va break; case PPK_CustomBase: break; - case PPK_DocumentName: - // TODO Add support using PMPrintSettingsSetJobName / PMPrintSettingsGetJobName - break; case PPK_Duplex: // TODO Add support using PMSetDuplex / PMGetDuplex break; @@ -665,7 +662,9 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va PMSessionValidatePageFormat(d->session(), d->format(), kPMDontWantBoolean); break; } - + case PPK_DocumentName: + PMPrintSettingsSetJobName(d->settings(), QCFString(value.toString())); + break; case PPK_FullPage: d->fullPage = value.toBool(); break; @@ -770,10 +769,6 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const case PPK_CustomBase: // Special case, leave null break; - case PPK_DocumentName: - // TODO Add support using PMPrintSettingsSetJobName / PMPrintSettingsGetJobName - ret = QString(); - break; case PPK_Duplex: // TODO Add support using PMSetDuplex / PMGetDuplex ret = QPrinter::DuplexNone; @@ -807,6 +802,12 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const break; // The following keys are properties and settings that are supported by the Mac PrintEngine + case PPK_DocumentName: { + CFStringRef name; + PMPrintSettingsGetJobName(d->settings(), &name); + ret = QCFString::toQString(name); + break; + } case PPK_FullPage: ret = d->fullPage; break; diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index d36b7b87c1..34f3106313 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -237,7 +237,6 @@ QWin32PrintEngine::QWin32PrintEngine(QPrinter::PrinterMode mode) | PaintOutsidePaintEvent)) { Q_D(QWin32PrintEngine); - d->docName = QLatin1String("document1"); d->mode = mode; d->queryDefault(); d->initialize(); @@ -272,7 +271,10 @@ bool QWin32PrintEngine::begin(QPaintDevice *pdev) DOCINFO di; memset(&di, 0, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); - di.lpszDocName = reinterpret_cast<const wchar_t *>(d->docName.utf16()); + if (d->docName.isEmpty()) + di.lpszDocName = L"document1"; + else + di.lpszDocName = reinterpret_cast<const wchar_t *>(d->docName.utf16()); if (d->printToFile && !d->fileName.isEmpty()) di.lpszOutput = reinterpret_cast<const wchar_t *>(d->fileName.utf16()); if (ok && StartDoc(d->hdc, &di) == SP_ERROR) { diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 37aa7b2a16..322254602d 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -1107,8 +1107,8 @@ void tst_QPrinter::docName() // docName() / setDocName() / PPK_DocumentName // PdfFormat: Supported, default QString() // NativeFormat, Cups: Supported, default QString() - // NativeFormat, Win: Supported, default "document1" - // NativeFormat, Mac: Unsupported, always QString() + // NativeFormat, Win: Supported, default QString() + // NativeFormat, Mac: Supported, default QString() QPrinter pdf; pdf.setOutputFormat(QPrinter::PdfFormat); @@ -1119,18 +1119,11 @@ void tst_QPrinter::docName() QPrinter native; if (native.outputFormat() == QPrinter::NativeFormat) { // Test default -#ifdef Q_OS_WIN - QCOMPARE(native.docName(), QString("document1")); -#else QCOMPARE(native.docName(), QString()); -#endif // Q_OS_WIN // Test set/get QString expected = QStringLiteral("Test Name"); native.setDocName(expected); -#ifdef Q_OS_MAC - expected.clear(); -#endif // Q_OS_MAC QCOMPARE(native.docName(), expected); // Test value preservation |