summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2012-03-21 17:17:42 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-23 00:41:34 +0100
commitb188221fee0eaacec115b514185a0508ef655897 (patch)
tree167b09e47cc3b63dadf64527339a4248eda770b3 /src/printsupport/kernel
parent82c974f753e0081f8bedc356ea07a8cfa6fae583 (diff)
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 <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r--src/printsupport/kernel/qprintengine.h6
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp49
-rw-r--r--src/printsupport/kernel/qprintengine_win_p.h4
-rw-r--r--src/printsupport/kernel/qprinter.cpp42
-rw-r--r--src/printsupport/kernel/qprinter.h11
5 files changed, 36 insertions, 76 deletions
diff --git a/src/printsupport/kernel/qprintengine.h b/src/printsupport/kernel/qprintengine.h
index eb7797b5e0..563af895c1 100644
--- a/src/printsupport/kernel/qprintengine.h
+++ b/src/printsupport/kernel/qprintengine.h
@@ -101,12 +101,6 @@ public:
virtual int metric(QPaintDevice::PaintDeviceMetric) const = 0;
virtual QPrinter::PrinterState printerState() const = 0;
-
-#ifdef Q_WS_WIN
- virtual HDC getPrinterDC() const { return 0; }
- virtual void releasePrinterDC(HDC) const { }
-#endif
-
};
#endif // QT_NO_PRINTER
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<const wchar_t *>(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<QPrinter::PaperSize> 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<const wchar_t *>(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)
diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/kernel/qprintengine_win_p.h
index c267c1057f..8da6f32268 100644
--- a/src/printsupport/kernel/qprintengine_win_p.h
+++ b/src/printsupport/kernel/qprintengine_win_p.h
@@ -103,10 +103,8 @@ public:
HDC getDC() const;
void releaseDC(HDC) const;
- HDC getPrinterDC() const { return getDC(); }
- void releasePrinterDC(HDC dc) const { releaseDC(dc); }
-
static QList<QPrinter::PaperSize> supportedPaperSizes(const QPrinterInfo &printerInfo);
+ static void queryDefaultPrinter(QString &name, QString &program, QString &port);
private:
friend class QPrintDialog;
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 404f45d509..d713639dcc 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -56,10 +56,6 @@
#include <QtPrintSupport/QPlatformPrinterSupport>
#include <private/qpagedpaintdevice_p.h>
-#if defined (Q_WS_WIN)
-#include <private/qprintengine_win_p.h>
-#endif
-
#if defined(Q_WS_X11)
#include <private/qt_x11_p.h>
#endif
@@ -1722,7 +1718,7 @@ QPrintEngine *QPrinter::printEngine() const
return d->printEngine;
}
-#if defined (Q_WS_WIN)
+#if defined (Q_OS_WIN)
/*!
Sets the page size to be used by the printer under Windows to \a
pageSize.
@@ -1753,7 +1749,7 @@ int QPrinter::winPageSize() const
Q_D(const QPrinter);
return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt();
}
-#endif // Q_WS_WIN
+#endif // Q_OS_WIN
/*!
Returns a list of the resolutions (a list of dots-per-inch
@@ -1864,25 +1860,7 @@ QPrinter::PrinterState QPrinter::printerState() const
Use printerState() == QPrinter::Aborted instead.
*/
-#ifdef Q_WS_WIN
-/*!
- \internal
-*/
-HDC QPrinter::getDC() const
-{
- Q_D(const QPrinter);
- return d->printEngine->getPrinterDC();
-}
-
-/*!
- \internal
-*/
-void QPrinter::releaseDC(HDC hdc) const
-{
- Q_D(const QPrinter);
- d->printEngine->releasePrinterDC(hdc);
-}
-
+#ifdef Q_OS_WIN
/*!
Returns the supported paper sizes for this printer.
@@ -1907,7 +1885,7 @@ QList<QPrinter::PaperSource> QPrinter::supportedPaperSources() const
return int_list;
}
-#endif
+#endif // Q_OS_WIN
/*!
\fn QString QPrinter::printerSelectionOption() const
@@ -1941,7 +1919,7 @@ QList<QPrinter::PaperSource> QPrinter::supportedPaperSources() const
\sa printerSelectionOption()
*/
-#ifndef Q_WS_WIN
+#ifndef Q_OS_WIN
QString QPrinter::printerSelectionOption() const
{
Q_D(const QPrinter);
@@ -2207,16 +2185,6 @@ QPrinter::PrintRange QPrinter::printRange() const
Returns the current state of the printer being used by the print engine.
*/
-/*!
- \fn HDC QPrintEngine::getPrinterDC() const
- \internal
-*/
-
-/*!
- \fn void QPrintEngine::releasePrinterDC(HDC) const
- \internal
-*/
-
/*
Returns the dimensions for the given paper size, \a size, in millimeters.
*/
diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h
index 17b125bbf8..23c7ccc40c 100644
--- a/src/printsupport/kernel/qprinter.h
+++ b/src/printsupport/kernel/qprinter.h
@@ -200,7 +200,7 @@ public:
QList<int> supportedResolutions() const;
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
QList<PaperSource> supportedPaperSources() const;
#endif
@@ -210,7 +210,7 @@ public:
void setDoubleSidedPrinting(bool enable);
bool doubleSidedPrinting() const;
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
void setWinPageSize(int winPageSize);
int winPageSize() const;
#endif
@@ -220,7 +220,7 @@ public:
QRectF paperRect(Unit) const;
QRectF pageRect(Unit) const;
-#if !defined(Q_WS_WIN) || defined(qdoc)
+#if !defined(Q_OS_WIN) || defined(qdoc)
QString printerSelectionOption() const;
void setPrinterSelectionOption(const QString &);
#endif
@@ -233,11 +233,6 @@ public:
QPaintEngine *paintEngine() const;
QPrintEngine *printEngine() const;
-#ifdef Q_WS_WIN
- HDC getDC() const;
- void releaseDC(HDC hdc) const;
-#endif
-
void setFromTo(int fromPage, int toPage);
int fromPage() const;
int toPage() const;