QPrintEngne - Fix PPK_Creator
Add support to the Mac and Windows print engines to preserve the creator name when switching between native and pdf format. Change-Id: Ie036af3140f24d8e34aa886f091384f93aa0157b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
0ee72b09fd
commit
27c33a8f7a
@ -607,9 +607,6 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
|
||||
// The following keys are settings that are unsupported by the Mac PrintEngine
|
||||
case PPK_ColorMode:
|
||||
break;
|
||||
case PPK_Creator:
|
||||
// TODO Add value preservation support by using local variable
|
||||
break;
|
||||
case PPK_CustomBase:
|
||||
break;
|
||||
case PPK_Duplex:
|
||||
@ -662,6 +659,9 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
|
||||
case PPK_CollateCopies:
|
||||
PMSetCollate(d->settings(), value.toBool());
|
||||
break;
|
||||
case PPK_Creator:
|
||||
d->m_creator = value.toString();
|
||||
break;
|
||||
case PPK_DocumentName:
|
||||
PMPrintSettingsSetJobName(d->settings(), QCFString(value.toString()));
|
||||
break;
|
||||
@ -759,9 +759,6 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
case PPK_ColorMode:
|
||||
ret = QPrinter::Color;
|
||||
break;
|
||||
case PPK_Creator:
|
||||
ret = QString();
|
||||
break;
|
||||
case PPK_CustomBase:
|
||||
// Special case, leave null
|
||||
break;
|
||||
@ -804,6 +801,9 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
ret = bool(status);
|
||||
break;
|
||||
}
|
||||
case PPK_Creator:
|
||||
ret = d->m_creator;
|
||||
break;
|
||||
case PPK_DocumentName: {
|
||||
CFStringRef name;
|
||||
PMPrintSettingsGetJobName(d->settings(), &name);
|
||||
|
@ -125,6 +125,7 @@ public:
|
||||
NSPrintInfo *printInfo;
|
||||
PMResolution resolution;
|
||||
QString outputFilename;
|
||||
QString m_creator;
|
||||
bool fullPage;
|
||||
QPaintEngine *paintEngine;
|
||||
bool hasCustomPaperSize;
|
||||
|
@ -1290,9 +1290,6 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||||
break;
|
||||
|
||||
// The following keys are settings that are unsupported by the Windows PrintEngine
|
||||
case PPK_Creator:
|
||||
// TODO Add value preservation support by using local variable
|
||||
break;
|
||||
case PPK_CustomBase:
|
||||
break;
|
||||
case PPK_Duplex:
|
||||
@ -1326,6 +1323,10 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||||
}
|
||||
break;
|
||||
|
||||
case PPK_Creator:
|
||||
d->m_creator = value.toString();
|
||||
break;
|
||||
|
||||
case PPK_DocumentName:
|
||||
if (isActive()) {
|
||||
qWarning("QWin32PrintEngine: Cannot change document name while printing is active");
|
||||
@ -1505,9 +1506,6 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
||||
|
||||
// The following keys are settings that are unsupported by the Windows PrintEngine
|
||||
// Return sensible default values to ensure consistent behavior across platforms
|
||||
case PPK_Creator:
|
||||
value = QString();
|
||||
break;
|
||||
case PPK_Duplex:
|
||||
// TODO Add support using DEVMODE.dmDuplex
|
||||
value = QPrinter::DuplexNone;
|
||||
@ -1540,6 +1538,10 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
||||
}
|
||||
break;
|
||||
|
||||
case PPK_Creator:
|
||||
value = d->m_creator;
|
||||
break;
|
||||
|
||||
case PPK_DocumentName:
|
||||
value = d->docName;
|
||||
break;
|
||||
|
@ -210,6 +210,7 @@ public:
|
||||
|
||||
// Document info
|
||||
QString docName;
|
||||
QString m_creator;
|
||||
QString fileName;
|
||||
|
||||
QPrinter::PrinterState state;
|
||||
|
@ -1067,8 +1067,8 @@ void tst_QPrinter::creator()
|
||||
// creator() / setCreator() / PPK_Creator
|
||||
// PdfFormat: Supported, default QString()
|
||||
// NativeFormat, Cups: Supported, default QString()
|
||||
// NativeFormat, Win: Unsupported, always QString()
|
||||
// NativeFormat, Mac: Unsupported, always QString()
|
||||
// NativeFormat, Win: Supported, default QString()
|
||||
// NativeFormat, Mac: Supported, default QString()
|
||||
|
||||
QPrinter pdf;
|
||||
pdf.setOutputFormat(QPrinter::PdfFormat);
|
||||
@ -1084,9 +1084,6 @@ void tst_QPrinter::creator()
|
||||
// Test set/get
|
||||
QString expected = QStringLiteral("Test Creator");
|
||||
native.setCreator(expected);
|
||||
#if defined Q_OS_MAC || defined Q_OS_WIN
|
||||
expected.clear();
|
||||
#endif // Q_OS_MAC || Q_OS_WIN
|
||||
QCOMPARE(native.creator(), expected);
|
||||
|
||||
// Test value preservation
|
||||
|
Loading…
Reference in New Issue
Block a user