summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r--src/printsupport/kernel/kernel.pri42
-rw-r--r--src/printsupport/kernel/qcups.cpp110
-rw-r--r--src/printsupport/kernel/qcups_p.h58
-rw-r--r--src/printsupport/kernel/qpaintengine_alpha.cpp62
-rw-r--r--src/printsupport/kernel/qpaintengine_alpha_p.h44
-rw-r--r--src/printsupport/kernel/qpaintengine_preview.cpp40
-rw-r--r--src/printsupport/kernel/qpaintengine_preview_p.h40
-rw-r--r--src/printsupport/kernel/qplatformprintdevice.cpp94
-rw-r--r--src/printsupport/kernel/qplatformprintdevice.h60
-rw-r--r--src/printsupport/kernel/qplatformprintersupport.cpp48
-rw-r--r--src/printsupport/kernel/qplatformprintersupport.h40
-rw-r--r--src/printsupport/kernel/qplatformprintplugin.cpp52
-rw-r--r--src/printsupport/kernel/qplatformprintplugin.h42
-rw-r--r--src/printsupport/kernel/qprint.cpp159
-rw-r--r--src/printsupport/kernel/qprint_p.h191
-rw-r--r--src/printsupport/kernel/qprintdevice.cpp56
-rw-r--r--src/printsupport/kernel/qprintdevice_p.h50
-rw-r--r--src/printsupport/kernel/qprintengine.h41
-rw-r--r--src/printsupport/kernel/qprintengine_pdf.cpp78
-rw-r--r--src/printsupport/kernel/qprintengine_pdf_p.h46
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp1815
-rw-r--r--src/printsupport/kernel/qprintengine_win_p.h248
-rw-r--r--src/printsupport/kernel/qprinter.cpp685
-rw-r--r--src/printsupport/kernel/qprinter.h97
-rw-r--r--src/printsupport/kernel/qprinter_p.h51
-rw-r--r--src/printsupport/kernel/qprinterinfo.cpp118
-rw-r--r--src/printsupport/kernel/qprinterinfo.h49
-rw-r--r--src/printsupport/kernel/qprinterinfo_p.h40
-rw-r--r--src/printsupport/kernel/qtprintsupportglobal.h55
-rw-r--r--src/printsupport/kernel/qtprintsupportglobal_p.h40
30 files changed, 463 insertions, 4088 deletions
diff --git a/src/printsupport/kernel/kernel.pri b/src/printsupport/kernel/kernel.pri
deleted file mode 100644
index ea7b4b9780..0000000000
--- a/src/printsupport/kernel/kernel.pri
+++ /dev/null
@@ -1,42 +0,0 @@
-HEADERS += \
- $$PWD/qpaintengine_alpha_p.h \
- $$PWD/qprint_p.h \
- $$PWD/qprintdevice_p.h \
- $$PWD/qprintengine.h \
- $$PWD/qprinter.h \
- $$PWD/qprinter_p.h \
- $$PWD/qprinterinfo.h \
- $$PWD/qprinterinfo_p.h \
- $$PWD/qplatformprintdevice.h \
- $$PWD/qplatformprintplugin.h \
- $$PWD/qplatformprintersupport.h \
- $$PWD/qtprintsupportglobal_p.h \
- $$PWD/qtprintsupportglobal.h
-
-SOURCES += \
- $$PWD/qpaintengine_alpha.cpp \
- $$PWD/qprintdevice.cpp \
- $$PWD/qprintengine_pdf.cpp \
- $$PWD/qprinter.cpp \
- $$PWD/qprinterinfo.cpp \
- $$PWD/qplatformprintdevice.cpp \
- $$PWD/qplatformprintplugin.cpp \
- $$PWD/qplatformprintersupport.cpp
-
-qtConfig(printpreviewwidget) {
- HEADERS += $$PWD/qpaintengine_preview_p.h
- SOURCES += $$PWD/qpaintengine_preview.cpp
-}
-
-win32 {
- HEADERS += \
- $$PWD/qprintengine_win_p.h
- SOURCES += \
- $$PWD/qprintengine_win.cpp
- !winrt: LIBS_PRIVATE += -lwinspool -lcomdlg32 -lgdi32 -luser32
-}
-
-unix:!darwin:qtConfig(cups) {
- SOURCES += $$PWD/qcups.cpp
- HEADERS += $$PWD/qcups_p.h
-}
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 8505e8356c..231b816499 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qcups_p.h"
@@ -44,12 +8,24 @@
QT_BEGIN_NAMESPACE
-static QStringList cupsOptionsList(QPrinter *printer) Q_DECL_NOTHROW
+using namespace Qt::StringLiterals;
+
+QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil,
+ QCUPSSupport__JobHoldUntil)
+QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage,
+ QCUPSSupport__BannerPage)
+QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet)
+QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout,
+ QCUPSSupport__PagesPerSheetLayout)
+QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet,
+ QCUPSSupport__PagesPerSheet)
+
+static QStringList cupsOptionsList(QPrinter *printer) noexcept
{
return printer->printEngine()->property(PPK_CupsOptions).toStringList();
}
-void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions) Q_DECL_NOTHROW
+void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions) noexcept
{
printer->printEngine()->setProperty(PPK_CupsOptions, QVariant(cupsOptions));
}
@@ -83,7 +59,7 @@ void QCUPSSupport::clearCupsOptions(QPrinter *printer)
setCupsOptions(printer, QStringList());
}
-static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, const QTime holdUntilTime)
+static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, QTime holdUntilTime)
{
switch (jobHold) {
case QCUPSSupport::Indefinite:
@@ -106,37 +82,36 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold,
if (holdUntilTime < localDateTime.time())
localDateTime = localDateTime.addDays(1);
localDateTime.setTime(holdUntilTime);
- return localDateTime.toUTC().time().toString(QStringViewLiteral("HH:mm"));
+ return localDateTime.toUTC().time().toString(u"HH:mm");
}
// else fall through:
Q_FALLTHROUGH();
case QCUPSSupport::NoHold:
return QString();
}
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString &jobHoldUntil)
{
- if (jobHoldUntil == QLatin1String("indefinite")) {
+ if (jobHoldUntil == "indefinite"_L1) {
return { QCUPSSupport::Indefinite, QTime() };
- } else if (jobHoldUntil == QLatin1String("day-time")) {
+ } else if (jobHoldUntil == "day-time"_L1) {
return { QCUPSSupport::DayTime, QTime() };
- } else if (jobHoldUntil == QLatin1String("night")) {
+ } else if (jobHoldUntil == "night"_L1) {
return { QCUPSSupport::Night, QTime() };
- } else if (jobHoldUntil == QLatin1String("second-shift")) {
+ } else if (jobHoldUntil == "second-shift"_L1) {
return { QCUPSSupport::SecondShift, QTime() };
- } else if (jobHoldUntil == QLatin1String("third-shift")) {
+ } else if (jobHoldUntil == "third-shift"_L1) {
return { QCUPSSupport::ThirdShift, QTime() };
- } else if (jobHoldUntil == QLatin1String("weekend")) {
+ } else if (jobHoldUntil == "weekend"_L1) {
return { QCUPSSupport::Weekend, QTime() };
}
- QTime parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m:s"));
+ QTime parsedTime = QTime::fromString(jobHoldUntil, u"h:m:s");
if (!parsedTime.isValid())
- parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m"));
+ parsedTime = QTime::fromString(jobHoldUntil, u"h:m");
if (parsedTime.isValid()) {
// CUPS time is in UTC, user expects local time, so get the equivalent
QDateTime dateTimeUtc = QDateTime::currentDateTimeUtc();
@@ -149,7 +124,7 @@ QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString
ppd_option_t *QCUPSSupport::findPpdOption(const char *optionName, QPrintDevice *printDevice)
{
- ppd_file_t *ppd = printDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
+ ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(printDevice->property(PDPK_PpdFile));
if (ppd) {
for (int i = 0; i < ppd->num_groups; ++i) {
@@ -167,7 +142,7 @@ ppd_option_t *QCUPSSupport::findPpdOption(const char *optionName, QPrintDevice *
return nullptr;
}
-void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime)
+void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, QTime holdUntilTime)
{
const QString jobHoldUntilArgument = jobHoldToString(jobHold, holdUntilTime);
if (!jobHoldUntilArgument.isEmpty()) {
@@ -200,19 +175,18 @@ static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPa
case QCUPSSupport::Secret: return QStringLiteral("secret");
case QCUPSSupport::TopSecret: return QStringLiteral("topsecret");
}
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
static inline QCUPSSupport::BannerPage stringToBannerPage(const QString &bannerPage)
{
- if (bannerPage == QLatin1String("none")) return QCUPSSupport::NoBanner;
- else if (bannerPage == QLatin1String("standard")) return QCUPSSupport::Standard;
- else if (bannerPage == QLatin1String("unclassified")) return QCUPSSupport::Unclassified;
- else if (bannerPage == QLatin1String("confidential")) return QCUPSSupport::Confidential;
- else if (bannerPage == QLatin1String("classified")) return QCUPSSupport::Classified;
- else if (bannerPage == QLatin1String("secret")) return QCUPSSupport::Secret;
- else if (bannerPage == QLatin1String("topsecret")) return QCUPSSupport::TopSecret;
+ if (bannerPage == "none"_L1) return QCUPSSupport::NoBanner;
+ else if (bannerPage == "standard"_L1) return QCUPSSupport::Standard;
+ else if (bannerPage == "unclassified"_L1) return QCUPSSupport::Unclassified;
+ else if (bannerPage == "confidential"_L1) return QCUPSSupport::Confidential;
+ else if (bannerPage == "classified"_L1) return QCUPSSupport::Classified;
+ else if (bannerPage == "secret"_L1) return QCUPSSupport::Secret;
+ else if (bannerPage == "topsecret"_L1) return QCUPSSupport::TopSecret;
return QCUPSSupport::NoBanner;
}
@@ -221,8 +195,8 @@ QCUPSSupport::JobSheets QCUPSSupport::parseJobSheets(const QString &jobSheets)
{
JobSheets result;
- const QStringList parts = jobSheets.split(QLatin1Char(','));
- if (parts.count() == 2) {
+ const QStringList parts = jobSheets.split(u',');
+ if (parts.size() == 2) {
result.startBannerPage = stringToBannerPage(parts[0]);
result.endBannerPage = stringToBannerPage(parts[1]);
}
@@ -235,7 +209,7 @@ void QCUPSSupport::setBannerPages(QPrinter *printer, const BannerPage startBanne
const QString startBanner = bannerPageToString(startBannerPage);
const QString endBanner = bannerPageToString(endBannerPage);
- setCupsOption(printer, QStringLiteral("job-sheets"), startBanner + QLatin1Char(',') + endBanner);
+ setCupsOption(printer, QStringLiteral("job-sheets"), startBanner + u',' + endBanner);
}
void QCUPSSupport::setPageSet(QPrinter *printer, const PageSet pageSet)
@@ -265,8 +239,8 @@ void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerShee
// WARNING: and it is the last one (before the "\0")!
static const char pagesPerSheetData[][2] = { "1", "2", "4", "6", "9", {'1', '6'}, "\0" };
static const char pageLayoutData[][5] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl"};
- setCupsOption(printer, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet]));
- setCupsOption(printer, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout]));
+ setCupsOption(printer, QStringLiteral("number-up"), QLatin1StringView(pagesPerSheetData[pagesPerSheet]));
+ setCupsOption(printer, QStringLiteral("number-up-layout"), QLatin1StringView(pageLayoutData[pagesPerSheetLayout]));
}
void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo)
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index 57ec281383..4570935ba1 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QCUPS_P_H
#define QCUPS_P_H
@@ -137,7 +101,7 @@ public:
static void clearCupsOption(QPrinter *printer, const QString &option);
static void clearCupsOptions(QPrinter *printer);
- static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime());
+ static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, QTime holdUntilTime = QTime());
static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
static void setJobPriority(QPrinter *printer, int priority = 50);
static void setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage);
@@ -159,7 +123,7 @@ public:
struct JobHoldUntilWithTime
{
- JobHoldUntilWithTime(JobHoldUntil jh = NoHold, const QTime &t = QTime())
+ JobHoldUntilWithTime(JobHoldUntil jh = NoHold, QTime t = QTime())
: jobHold(jh), time(t) {}
JobHoldUntil jobHold;
@@ -177,10 +141,14 @@ Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheet, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QCUPSSupport::JobHoldUntil)
-Q_DECLARE_METATYPE(QCUPSSupport::BannerPage)
-Q_DECLARE_METATYPE(QCUPSSupport::PageSet)
-Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheetLayout)
-Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheet)
+QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil,
+ QCUPSSupport__JobHoldUntil, Q_PRINTSUPPORT_EXPORT)
+QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage,
+ QCUPSSupport__BannerPage, Q_PRINTSUPPORT_EXPORT)
+QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet, Q_PRINTSUPPORT_EXPORT)
+QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout,
+ QCUPSSupport__PagesPerSheetLayout, Q_PRINTSUPPORT_EXPORT)
+QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet,
+ QCUPSSupport__PagesPerSheet, Q_PRINTSUPPORT_EXPORT)
#endif
diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp
index 410051df2a..4c34457570 100644
--- a/src/printsupport/kernel/qpaintengine_alpha.cpp
+++ b/src/printsupport/kernel/qpaintengine_alpha.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <qtprintsupportglobal.h>
@@ -377,16 +341,16 @@ void QAlphaPaintEngine::cleanUp()
delete d->m_picpainter;
delete d->m_pic;
- d->m_picpainter = 0;
- d->m_pic = 0;
- d->m_picengine = 0;
+ d->m_picpainter = nullptr;
+ d->m_pic = nullptr;
+ d->m_picengine = nullptr;
}
QAlphaPaintEnginePrivate::QAlphaPaintEnginePrivate()
: m_pass(0),
- m_pic(0),
- m_picengine(0),
- m_picpainter(0),
+ m_pic(nullptr),
+ m_picengine(nullptr),
+ m_picpainter(nullptr),
m_numberOfCachedRects(0),
m_hasalpha(false),
m_alphaPen(false),
@@ -407,13 +371,11 @@ QAlphaPaintEnginePrivate::~QAlphaPaintEnginePrivate()
QRectF QAlphaPaintEnginePrivate::addPenWidth(const QPainterPath &path)
{
- Q_Q(QAlphaPaintEngine);
-
QPainterPath tmp = path;
if (m_pen.style() == Qt::NoPen)
return (path.controlPointRect() * m_transform).boundingRect();
- bool cosmetic = qt_pen_is_cosmetic(m_pen, q->state->renderHints());
+ bool cosmetic = m_pen.isCosmetic();
if (cosmetic)
tmp = path * m_transform;
@@ -439,9 +401,9 @@ void QAlphaPaintEnginePrivate::addAlphaRect(const QRectF &rect)
bool QAlphaPaintEnginePrivate::canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const
{
if (somethingInRectHasAlpha) {
- if (m_dirtyRects.count() != m_numberOfCachedRects) {
- m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.count());
- m_numberOfCachedRects = m_dirtyRects.count();
+ if (m_dirtyRects.size() != m_numberOfCachedRects) {
+ m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.size());
+ m_numberOfCachedRects = m_dirtyRects.size();
}
return m_cachedDirtyRgn.intersects(rect.toAlignedRect());
}
diff --git a/src/printsupport/kernel/qpaintengine_alpha_p.h b/src/printsupport/kernel/qpaintengine_alpha_p.h
index efae442690..221194d4ad 100644
--- a/src/printsupport/kernel/qpaintengine_alpha_p.h
+++ b/src/printsupport/kernel/qpaintengine_alpha_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPAINTENGINE_ALPHA_P_H
#define QPAINTENGINE_ALPHA_P_H
@@ -81,7 +45,7 @@ public:
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override;
protected:
- QAlphaPaintEngine(QAlphaPaintEnginePrivate &data, PaintEngineFeatures devcaps = 0);
+ QAlphaPaintEngine(QAlphaPaintEnginePrivate &data, PaintEngineFeatures devcaps = { });
QRegion alphaClipping() const;
bool continueCall() const;
void flushAndInit(bool init = true);
@@ -107,7 +71,7 @@ public:
QRegion m_cliprgn;
mutable QRegion m_cachedDirtyRgn;
mutable int m_numberOfCachedRects;
- QVector<QRect> m_dirtyRects;
+ QList<QRect> m_dirtyRects;
bool m_hasalpha;
bool m_alphaPen;
diff --git a/src/printsupport/kernel/qpaintengine_preview.cpp b/src/printsupport/kernel/qpaintengine_preview.cpp
index 7179249677..7e3a9f8c60 100644
--- a/src/printsupport/kernel/qpaintengine_preview.cpp
+++ b/src/printsupport/kernel/qpaintengine_preview.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <private/qpaintengine_preview_p.h>
#include <private/qpainter_p.h>
diff --git a/src/printsupport/kernel/qpaintengine_preview_p.h b/src/printsupport/kernel/qpaintengine_preview_p.h
index 9203e40235..87692a0b92 100644
--- a/src/printsupport/kernel/qpaintengine_preview_p.h
+++ b/src/printsupport/kernel/qpaintengine_preview_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPAINTENGINE_PREVIEW_P_H
#define QPAINTENGINE_PREVIEW_P_H
diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp
index 69d984cb0c..a2ee51f887 100644
--- a/src/printsupport/kernel/qplatformprintdevice.cpp
+++ b/src/printsupport/kernel/qplatformprintdevice.cpp
@@ -1,49 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPrintSupport module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformprintdevice.h"
#include "qprintdevice_p.h"
-#if QT_CONFIG(printdialog)
-#include "qprintdialog.h"
-#endif
+#include <QtCore/qcoreapplication.h>
#include <QtGui/qpagelayout.h>
QT_BEGIN_NAMESPACE
@@ -113,6 +75,10 @@ bool QPlatformPrintDevice::isValidPageLayout(const QPageLayout &layout, int reso
if (!supportedPageSize(layout.pageSize()).isValid())
return false;
+ // In fullpage mode, margins outside the printable area are valid
+ if (layout.mode() == QPageLayout::FullPageMode)
+ return true;
+
// Check the margins are valid
QMarginsF pointMargins = layout.margins(QPageLayout::Point);
QMarginsF printMargins = printableMargins(layout.pageSize(), layout.orientation(), resolution);
@@ -165,7 +131,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(const QPageSize &pageSize) con
// e.g. Windows defines DMPAPER_11X17 and DMPAPER_TABLOID with names "11x17" and "Tabloid", but both
// map to QPageSize::Tabloid / PPD Key "Tabloid" / ANSI B Tabloid
if (pageSize.id() != QPageSize::Custom) {
- for (const QPageSize &ps : m_pageSizes) {
+ for (const QPageSize &ps : std::as_const(m_pageSizes)) {
if (ps.id() == pageSize.id() && ps.name() == pageSize.name())
return ps;
}
@@ -173,7 +139,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(const QPageSize &pageSize) con
// Next try match on id only if not custom
if (pageSize.id() != QPageSize::Custom) {
- for (const QPageSize &ps : m_pageSizes) {
+ for (const QPageSize &ps : std::as_const(m_pageSizes)) {
if (ps.id() == pageSize.id())
return ps;
}
@@ -188,7 +154,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(QPageSize::PageSizeId pageSize
if (!m_havePageSizes)
loadPageSizes();
- for (const QPageSize &ps : m_pageSizes) {
+ for (const QPageSize &ps : std::as_const(m_pageSizes)) {
if (ps.id() == pageSizeId)
return ps;
}
@@ -202,7 +168,7 @@ QPageSize QPlatformPrintDevice::supportedPageSize(const QString &pageName) const
if (!m_havePageSizes)
loadPageSizes();
- for (const QPageSize &ps : m_pageSizes) {
+ for (const QPageSize &ps : std::as_const(m_pageSizes)) {
if (ps.name() == pageName)
return ps;
}
@@ -235,7 +201,7 @@ QPageSize QPlatformPrintDevice::supportedPageSizeMatch(const QPageSize &pageSize
return pageSize;
// Try to find a supported page size based on point size
- for (const QPageSize &ps : m_pageSizes) {
+ for (const QPageSize &ps : std::as_const(m_pageSizes)) {
if (ps.sizePoints() == pageSize.sizePoints())
return ps;
}
@@ -261,9 +227,9 @@ QMarginsF QPlatformPrintDevice::printableMargins(const QPageSize &pageSize,
QPageLayout::Orientation orientation,
int resolution) const
{
- Q_UNUSED(pageSize)
- Q_UNUSED(orientation)
- Q_UNUSED(resolution)
+ Q_UNUSED(pageSize);
+ Q_UNUSED(orientation);
+ Q_UNUSED(resolution);
return QMarginsF(0, 0, 0, 0);
}
@@ -291,16 +257,12 @@ QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const
{
QPrint::InputSlot input;
input.key = QByteArrayLiteral("Auto");
-#if QT_CONFIG(printdialog)
- input.name = QPrintDialog::tr("Automatic");
-#else
- input.name = QString::fromLatin1("Automatic");
-#endif
+ input.name = QCoreApplication::translate("Print Device Input Slot", "Automatic");
input.id = QPrint::Auto;
return input;
}
-QVector<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const
+QList<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const
{
if (!m_haveInputSlots)
loadInputSlots();
@@ -315,16 +277,12 @@ QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const
{
QPrint::OutputBin output;
output.key = QByteArrayLiteral("Auto");
-#if QT_CONFIG(printdialog)
- output.name = QPrintDialog::tr("Automatic");
-#else
- output.name = QString::fromLatin1("Automatic");
-#endif
+ output.name = QCoreApplication::translate("Print Device Output Bin", "Automatic");
output.id = QPrint::AutoOutputBin;
return output;
}
-QVector<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const
+QList<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const
{
if (!m_haveOutputBins)
loadOutputBins();
@@ -340,7 +298,7 @@ QPrint::DuplexMode QPlatformPrintDevice::defaultDuplexMode() const
return QPrint::DuplexNone;
}
-QVector<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const
+QList<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const
{
if (!m_haveDuplexModes)
loadDuplexModes();
@@ -356,7 +314,7 @@ QPrint::ColorMode QPlatformPrintDevice::defaultColorMode() const
return QPrint::GrayScale;
}
-QVector<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const
+QList<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const
{
if (!m_haveColorModes)
loadColorModes();
@@ -371,23 +329,23 @@ void QPlatformPrintDevice::loadMimeTypes() const
QVariant QPlatformPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) const
{
- Q_UNUSED(key)
+ Q_UNUSED(key);
return QVariant();
}
bool QPlatformPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value)
{
- Q_UNUSED(key)
- Q_UNUSED(value)
+ Q_UNUSED(key);
+ Q_UNUSED(value);
return false;
}
bool QPlatformPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const
{
- Q_UNUSED(key)
- Q_UNUSED(params)
+ Q_UNUSED(key);
+ Q_UNUSED(params);
return false;
}
diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h
index 64723db92e..a8d9c10f7f 100644
--- a/src/printsupport/kernel/qplatformprintdevice.h
+++ b/src/printsupport/kernel/qplatformprintdevice.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPrintSupport module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPLATFORMPRINTDEVICE_H
#define QPLATFORMPRINTDEVICE_H
@@ -56,8 +20,8 @@
#include <private/qprint_p.h>
#include <private/qprintdevice_p.h>
+#include <QtCore/qlist.h>
#include <QtCore/qvariant.h>
-#include <QtCore/qvector.h>
#if QT_CONFIG(mimetype)
#include <QtCore/qmimetype.h>
#endif
@@ -112,16 +76,16 @@ public:
virtual QList<int> supportedResolutions() const;
virtual QPrint::InputSlot defaultInputSlot() const;
- virtual QVector<QPrint::InputSlot> supportedInputSlots() const;
+ virtual QList<QPrint::InputSlot> supportedInputSlots() const;
virtual QPrint::OutputBin defaultOutputBin() const;
- virtual QVector<QPrint::OutputBin> supportedOutputBins() const;
+ virtual QList<QPrint::OutputBin> supportedOutputBins() const;
virtual QPrint::DuplexMode defaultDuplexMode() const;
- virtual QVector<QPrint::DuplexMode> supportedDuplexModes() const;
+ virtual QList<QPrint::DuplexMode> supportedDuplexModes() const;
virtual QPrint::ColorMode defaultColorMode() const;
- virtual QVector<QPrint::ColorMode> supportedColorModes() const;
+ virtual QList<QPrint::ColorMode> supportedColorModes() const;
virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const;
virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value);
@@ -169,16 +133,16 @@ protected:
mutable QList<int> m_resolutions;
mutable bool m_haveInputSlots;
- mutable QVector<QPrint::InputSlot> m_inputSlots;
+ mutable QList<QPrint::InputSlot> m_inputSlots;
mutable bool m_haveOutputBins;
- mutable QVector<QPrint::OutputBin> m_outputBins;
+ mutable QList<QPrint::OutputBin> m_outputBins;
mutable bool m_haveDuplexModes;
- mutable QVector<QPrint::DuplexMode> m_duplexModes;
+ mutable QList<QPrint::DuplexMode> m_duplexModes;
mutable bool m_haveColorModes;
- mutable QVector<QPrint::ColorMode> m_colorModes;
+ mutable QList<QPrint::ColorMode> m_colorModes;
#if QT_CONFIG(mimetype)
mutable bool m_haveMimeTypes;
diff --git a/src/printsupport/kernel/qplatformprintersupport.cpp b/src/printsupport/kernel/qplatformprintersupport.cpp
index a25dc6d45c..f900de62c4 100644
--- a/src/printsupport/kernel/qplatformprintersupport.cpp
+++ b/src/printsupport/kernel/qplatformprintersupport.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformprintersupport.h"
#include "qplatformprintdevice.h"
@@ -85,7 +49,7 @@ QPrintDevice QPlatformPrinterSupport::createPrintDevice(QPlatformPrintDevice *de
QPrintDevice QPlatformPrinterSupport::createPrintDevice(const QString &id)
{
- Q_UNUSED(id)
+ Q_UNUSED(id);
return QPrintDevice();
}
@@ -101,9 +65,9 @@ QString QPlatformPrinterSupport::defaultPrintDeviceId() const
QPageSize QPlatformPrinterSupport::createPageSize(const QString &id, QSize size, const QString &localizedName)
{
- Q_UNUSED(id)
- Q_UNUSED(size)
- Q_UNUSED(localizedName)
+ Q_UNUSED(id);
+ Q_UNUSED(size);
+ Q_UNUSED(localizedName);
return QPageSize();
}
diff --git a/src/printsupport/kernel/qplatformprintersupport.h b/src/printsupport/kernel/qplatformprintersupport.h
index 413c1067c2..0aba2eab59 100644
--- a/src/printsupport/kernel/qplatformprintersupport.h
+++ b/src/printsupport/kernel/qplatformprintersupport.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPLATFORMPRINTERSUPPORT_H
#define QPLATFORMPRINTERSUPPORT_H
diff --git a/src/printsupport/kernel/qplatformprintplugin.cpp b/src/printsupport/kernel/qplatformprintplugin.cpp
index 9a7656f7d6..c48e5f65bf 100644
--- a/src/printsupport/kernel/qplatformprintplugin.cpp
+++ b/src/printsupport/kernel/qplatformprintplugin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformprintplugin.h"
#include "qplatformprintersupport.h"
@@ -46,10 +10,18 @@
#ifndef QT_NO_PRINTER
+#if defined(Q_OS_MACOS)
+Q_IMPORT_PLUGIN(QCocoaPrinterSupportPlugin)
+#elif defined(Q_OS_WIN)
+Q_IMPORT_PLUGIN(QWindowsPrinterSupportPlugin)
+#endif
+
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QPlatformPrinterSupportFactoryInterface_iid, QLatin1String("/printsupport"), Qt::CaseInsensitive))
+ (QPlatformPrinterSupportFactoryInterface_iid, "/printsupport"_L1, Qt::CaseInsensitive))
QPlatformPrinterSupportPlugin::QPlatformPrinterSupportPlugin(QObject *parent)
: QObject(parent)
@@ -99,4 +71,6 @@ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
QT_END_NAMESPACE
+#include "moc_qplatformprintplugin.cpp"
+
#endif
diff --git a/src/printsupport/kernel/qplatformprintplugin.h b/src/printsupport/kernel/qplatformprintplugin.h
index 30e8f7938a..0e7ec9cd9f 100644
--- a/src/printsupport/kernel/qplatformprintplugin.h
+++ b/src/printsupport/kernel/qplatformprintplugin.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPLATFORMPRINTPLUGIN_H
#define QPLATFORMPRINTPLUGIN_H
@@ -66,7 +30,7 @@ class Q_PRINTSUPPORT_EXPORT QPlatformPrinterSupportPlugin : public QObject
{
Q_OBJECT
public:
- explicit QPlatformPrinterSupportPlugin(QObject *parent = 0);
+ explicit QPlatformPrinterSupportPlugin(QObject *parent = nullptr);
~QPlatformPrinterSupportPlugin();
virtual QPlatformPrinterSupport *create(const QString &key) = 0;
diff --git a/src/printsupport/kernel/qprint.cpp b/src/printsupport/kernel/qprint.cpp
new file mode 100644
index 0000000000..755da40a08
--- /dev/null
+++ b/src/printsupport/kernel/qprint.cpp
@@ -0,0 +1,159 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qprint_p.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_PRINTER
+
+// Note: PPD standard does not define a standard set of InputSlot keywords,
+// it is a free form text field left to the PPD writer to decide,
+// but it does suggest some names for consistency with the Windows enum.
+static const InputSlotMap inputSlotMap[] = {
+ { QPrint::Upper, DMBIN_UPPER, "Upper" },
+ { QPrint::Lower, DMBIN_LOWER, "Lower" },
+ { QPrint::Middle, DMBIN_MIDDLE, "Middle" },
+ { QPrint::Manual, DMBIN_MANUAL, "Manual" },
+ { QPrint::Envelope, DMBIN_ENVELOPE, "Envelope" },
+ { QPrint::EnvelopeManual, DMBIN_ENVMANUAL, "EnvelopeManual" },
+ { QPrint::Auto, DMBIN_AUTO, "Auto" },
+ { QPrint::Tractor, DMBIN_TRACTOR, "Tractor" },
+ { QPrint::SmallFormat, DMBIN_SMALLFMT, "AnySmallFormat" },
+ { QPrint::LargeFormat, DMBIN_LARGEFMT, "AnyLargeFormat" },
+ { QPrint::LargeCapacity, DMBIN_LARGECAPACITY, "LargeCapacity" },
+ { QPrint::Cassette, DMBIN_CASSETTE, "Cassette" },
+ { QPrint::FormSource, DMBIN_FORMSOURCE, "FormSource" },
+ { QPrint::Manual, DMBIN_MANUAL, "ManualFeed" },
+ { QPrint::OnlyOne, DMBIN_ONLYONE, "OnlyOne" }, // = QPrint::Upper
+ { QPrint::CustomInputSlot, DMBIN_USER, "" } // Must always be last row
+};
+
+static const OutputBinMap outputBinMap[] = {
+ { QPrint::AutoOutputBin, "" }, // Not a PPD defined value, internal use only
+ { QPrint::UpperBin, "Upper" },
+ { QPrint::LowerBin, "Lower" },
+ { QPrint::RearBin, "Rear" },
+ { QPrint::CustomOutputBin, "" } // Must always be last row
+};
+
+namespace QPrintUtils {
+
+QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key)
+{
+ for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) {
+ if (inputSlotMap[i].key == key)
+ return inputSlotMap[i].id;
+ }
+ return QPrint::CustomInputSlot;
+}
+
+QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id)
+{
+ for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) {
+ if (inputSlotMap[i].id == id)
+ return QByteArray(inputSlotMap[i].key);
+ }
+ return QByteArray();
+}
+
+int inputSlotIdToWindowsId(QPrint::InputSlotId id)
+{
+ for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) {
+ if (inputSlotMap[i].id == id)
+ return inputSlotMap[i].windowsId;
+ }
+ return 0;
+}
+
+QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key)
+{
+ for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) {
+ if (outputBinMap[i].key == key)
+ return outputBinMap[i].id;
+ }
+ return QPrint::CustomOutputBin;
+}
+
+QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id)
+{
+ for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) {
+ if (outputBinMap[i].id == id)
+ return QByteArray(outputBinMap[i].key);
+ }
+ return QByteArray();
+}
+
+QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name)
+{
+ QPrint::InputSlot slot;
+ slot.name = name;
+ int i;
+ for (i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) {
+ if (inputSlotMap[i].windowsId == windowsId) {
+ slot.key = inputSlotMap[i].key;
+ slot.id = inputSlotMap[i].id;
+ slot.windowsId = inputSlotMap[i].windowsId;
+ return slot;
+ }
+ }
+ slot.key = inputSlotMap[i].key;
+ slot.id = inputSlotMap[i].id;
+ slot.windowsId = windowsId;
+ return slot;
+}
+
+#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups))
+
+// PPD utilities shared by CUPS and Mac plugins requiring CUPS headers
+// May turn into a proper internal QPpd class if enough shared between Mac and CUPS,
+// but where would it live? Not in base module as don't want to link to CUPS.
+// May have to have two copies in plugins to keep in sync.
+
+QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice)
+{
+ QPrint::InputSlot input;
+ input.key = choice.choice;
+ input.name = QString::fromUtf8(choice.text);
+ input.id = inputSlotKeyToInputSlotId(input.key);
+ input.windowsId = inputSlotMap[input.id].windowsId;
+ return input;
+}
+
+QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice)
+{
+ QPrint::OutputBin output;
+ output.key = choice.choice;
+ output.name = QString::fromUtf8(choice.text);
+ output.id = outputBinKeyToOutputBinId(output.key);
+ return output;
+}
+
+int parsePpdResolution(const QByteArray &value)
+{
+ if (value.isEmpty())
+ return -1;
+ // value can be in form 600dpi or 600x600dpi
+ QByteArray result = value.split('x').at(0);
+ if (result.endsWith("dpi"))
+ result.chop(3);
+ return result.toInt();
+}
+
+QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice)
+{
+ if (choice == "DuplexTumble")
+ return QPrint::DuplexShortSide;
+ else if (choice == "DuplexNoTumble")
+ return QPrint::DuplexLongSide;
+ else // None or SimplexTumble or SimplexNoTumble
+ return QPrint::DuplexNone;
+}
+
+#endif // Mac and CUPS PPD Utilities
+
+}
+
+#endif // QT_NO_PRINTER
+
+QT_END_NAMESPACE
diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h
index 4956775461..0a94aa8db3 100644
--- a/src/printsupport/kernel/qprint_p.h
+++ b/src/printsupport/kernel/qprint_p.h
@@ -1,41 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPrintSupport module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINT_P_H
#define QPRINT_P_H
@@ -59,6 +24,7 @@
#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups))
#include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module
+// ### QT_DECL_METATYPE_EXTERN_TAGGED once there's a qprint.cpp TU
Q_DECLARE_METATYPE(ppd_file_t *)
#endif
@@ -102,6 +68,7 @@ namespace QPrint {
DuplexShortSide
};
+ // Note: Keep in sync with QPrinter::ColorMode
enum ColorMode {
GrayScale,
Color
@@ -159,142 +126,32 @@ struct InputSlotMap {
const char *key;
};
-// Note: PPD standard does not define a standard set of InputSlot keywords,
-// it is a free form text field left to the PPD writer to decide,
-// but it does suggest some names for consistency with the Windows enum.
-static const InputSlotMap inputSlotMap[] = {
- { QPrint::Upper, DMBIN_UPPER, "Upper" },
- { QPrint::Lower, DMBIN_LOWER, "Lower" },
- { QPrint::Middle, DMBIN_MIDDLE, "Middle" },
- { QPrint::Manual, DMBIN_MANUAL, "Manual" },
- { QPrint::Envelope, DMBIN_ENVELOPE, "Envelope" },
- { QPrint::EnvelopeManual, DMBIN_ENVMANUAL, "EnvelopeManual" },
- { QPrint::Auto, DMBIN_AUTO, "Auto" },
- { QPrint::Tractor, DMBIN_TRACTOR, "Tractor" },
- { QPrint::SmallFormat, DMBIN_SMALLFMT, "AnySmallFormat" },
- { QPrint::LargeFormat, DMBIN_LARGEFMT, "AnyLargeFormat" },
- { QPrint::LargeCapacity, DMBIN_LARGECAPACITY, "LargeCapacity" },
- { QPrint::Cassette, DMBIN_CASSETTE, "Cassette" },
- { QPrint::FormSource, DMBIN_FORMSOURCE, "FormSource" },
- { QPrint::Manual, DMBIN_MANUAL, "ManualFeed" },
- { QPrint::OnlyOne, DMBIN_ONLYONE, "OnlyOne" }, // = QPrint::Upper
- { QPrint::CustomInputSlot, DMBIN_USER, "" } // Must always be last row
-};
-
struct OutputBinMap {
QPrint::OutputBinId id;
const char *key;
};
-static const OutputBinMap outputBinMap[] = {
- { QPrint::AutoOutputBin, "" }, // Not a PPD defined value, internal use only
- { QPrint::UpperBin, "Upper" },
- { QPrint::LowerBin, "Lower" },
- { QPrint::RearBin, "Rear" },
- { QPrint::CustomOutputBin, "" } // Must always be last row
-};
-
// Print utilities shared by print plugins
-class QPrintUtils
-{
-
-public:
-
- static QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key)
- {
- for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) {
- if (inputSlotMap[i].key == key)
- return inputSlotMap[i].id;
- }
- return QPrint::CustomInputSlot;
- }
-
- static QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id)
- {
- for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) {
- if (inputSlotMap[i].id == id)
- return QByteArray(inputSlotMap[i].key);
- }
- return QByteArray();
- }
-
- static int inputSlotIdToWindowsId(QPrint::InputSlotId id)
- {
- for (int i = 0; inputSlotMap[i].id != QPrint::CustomInputSlot; ++i) {
- if (inputSlotMap[i].id == id)
- return inputSlotMap[i].windowsId;
- }
- return 0;
- }
-
- static QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key)
- {
- for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) {
- if (outputBinMap[i].key == key)
- return outputBinMap[i].id;
- }
- return QPrint::CustomOutputBin;
- }
-
- static QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id)
- {
- for (int i = 0; outputBinMap[i].id != QPrint::CustomOutputBin; ++i) {
- if (outputBinMap[i].id == id)
- return QByteArray(outputBinMap[i].key);
- }
- return QByteArray();
- }
-
-#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups))
-
- // PPD utilities shared by CUPS and Mac plugins requiring CUPS headers
- // May turn into a proper internal QPpd class if enough shared between Mac and CUPS,
- // but where would it live? Not in base module as don't want to link to CUPS.
- // May have to have two copies in plugins to keep in sync.
-
- static QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice)
- {
- QPrint::InputSlot input;
- input.key = choice.choice;
- input.name = QString::fromUtf8(choice.text);
- input.id = inputSlotKeyToInputSlotId(input.key);
- input.windowsId = inputSlotMap[input.id].windowsId;
- return input;
- }
-
- static QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice)
- {
- QPrint::OutputBin output;
- output.key = choice.choice;
- output.name = QString::fromUtf8(choice.text);
- output.id = outputBinKeyToOutputBinId(output.key);
- return output;
- }
-
- static int parsePpdResolution(const QByteArray &value)
- {
- if (value.isEmpty())
- return -1;
- // value can be in form 600dpi or 600x600dpi
- QByteArray result = value.split('x').at(0);
- if (result.endsWith("dpi"))
- result.chop(3);
- return result.toInt();
- }
-
- static QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice)
- {
- if (choice == "DuplexTumble")
- return QPrint::DuplexShortSide;
- else if (choice == "DuplexNoTumble")
- return QPrint::DuplexLongSide;
- else // None or SimplexTumble or SimplexNoTumble
- return QPrint::DuplexNone;
- }
-
-#endif // Mac and CUPS PPD Utilities
-
+namespace QPrintUtils {
+
+Q_PRINTSUPPORT_EXPORT QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key);
+Q_PRINTSUPPORT_EXPORT QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id);
+Q_PRINTSUPPORT_EXPORT int inputSlotIdToWindowsId(QPrint::InputSlotId id);
+Q_PRINTSUPPORT_EXPORT QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key);
+Q_PRINTSUPPORT_EXPORT QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id);
+Q_PRINTSUPPORT_EXPORT QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name);
+
+# if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups))
+// PPD utilities shared by CUPS and Mac plugins requiring CUPS headers
+// May turn into a proper internal QPpd class if enough shared between Mac and CUPS,
+// but where would it live? Not in base module as don't want to link to CUPS.
+// May have to have two copies in plugins to keep in sync.
+Q_PRINTSUPPORT_EXPORT QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice);
+Q_PRINTSUPPORT_EXPORT QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice);
+Q_PRINTSUPPORT_EXPORT int parsePpdResolution(const QByteArray &value);
+Q_PRINTSUPPORT_EXPORT QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice);
+# endif // Mac and CUPS PPD Utilities
};
#endif // QT_NO_PRINTER
diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp
index 7fca3e45bf..acf6d0f329 100644
--- a/src/printsupport/kernel/qprintdevice.cpp
+++ b/src/printsupport/kernel/qprintdevice.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPrintSupport module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qprintdevice_p.h"
#include "qplatformprintdevice.h"
@@ -210,9 +174,9 @@ QPrint::InputSlot QPrintDevice::defaultInputSlot() const
return isValid() ? d->defaultInputSlot() : QPrint::InputSlot();
}
-QVector<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const
+QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const
{
- return isValid() ? d->supportedInputSlots() : QVector<QPrint::InputSlot>{};
+ return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>{};
}
QPrint::OutputBin QPrintDevice::defaultOutputBin() const
@@ -220,9 +184,9 @@ QPrint::OutputBin QPrintDevice::defaultOutputBin() const
return isValid() ? d->defaultOutputBin() : QPrint::OutputBin();
}
-QVector<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const
+QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const
{
- return isValid() ? d->supportedOutputBins() : QVector<QPrint::OutputBin>{};
+ return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>{};
}
QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const
@@ -230,9 +194,9 @@ QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const
return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone;
}
-QVector<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const
+QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const
{
- return isValid() ? d->supportedDuplexModes() : QVector<QPrint::DuplexMode>{};
+ return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>{};
}
QPrint::ColorMode QPrintDevice::defaultColorMode() const
@@ -240,9 +204,9 @@ QPrint::ColorMode QPrintDevice::defaultColorMode() const
return isValid() ? d->defaultColorMode() : QPrint::GrayScale;
}
-QVector<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
+QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
{
- return isValid() ? d->supportedColorModes() : QVector<QPrint::ColorMode>{};
+ return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>{};
}
QVariant QPrintDevice::property(PrintDevicePropertyKey key) const
diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h
index a2b18f08cf..ec4b9c59fc 100644
--- a/src/printsupport/kernel/qprintdevice_p.h
+++ b/src/printsupport/kernel/qprintdevice_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPrintSupport module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTDEVICE_H
#define QPRINTDEVICE_H
@@ -76,9 +40,7 @@ public:
~QPrintDevice();
QPrintDevice &operator=(const QPrintDevice &other);
- #ifdef Q_COMPILER_RVALUE_REFS
QPrintDevice &operator=(QPrintDevice &&other) { swap(other); return *this; }
-#endif
void swap(QPrintDevice &other) { d.swap(other.d); }
@@ -120,16 +82,16 @@ public:
QList<int> supportedResolutions() const;
QPrint::InputSlot defaultInputSlot() const;
- QVector<QPrint::InputSlot> supportedInputSlots() const;
+ QList<QPrint::InputSlot> supportedInputSlots() const;
QPrint::OutputBin defaultOutputBin() const;
- QVector<QPrint::OutputBin> supportedOutputBins() const;
+ QList<QPrint::OutputBin> supportedOutputBins() const;
QPrint::DuplexMode defaultDuplexMode() const;
- QVector<QPrint::DuplexMode> supportedDuplexModes() const;
+ QList<QPrint::DuplexMode> supportedDuplexModes() const;
QPrint::ColorMode defaultColorMode() const;
- QVector<QPrint::ColorMode> supportedColorModes() const;
+ QList<QPrint::ColorMode> supportedColorModes() const;
enum PrintDevicePropertyKey {
PDPK_CustomBase = 0xff00
diff --git a/src/printsupport/kernel/qprintengine.h b/src/printsupport/kernel/qprintengine.h
index 698f7548cf..65d9ed9a06 100644
--- a/src/printsupport/kernel/qprintengine.h
+++ b/src/printsupport/kernel/qprintengine.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTENGINE_H
#define QPRINTENGINE_H
@@ -44,6 +8,7 @@
#include <QtCore/qvariant.h>
#include <QtPrintSupport/qprinter.h>
+// ### move to qmargins.h
Q_DECLARE_METATYPE(QMarginsF)
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp
index 3c24e5ac69..3e50247186 100644
--- a/src/printsupport/kernel/qprintengine_pdf.cpp
+++ b/src/printsupport/kernel/qprintengine_pdf.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qprintengine_pdf_p.h"
@@ -140,7 +104,14 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
d->collate = value.toBool();
break;
case PPK_ColorMode:
- d->grayscale = (QPrinter::ColorMode(value.toInt()) == QPrinter::GrayScale);
+ switch (QPrinter::ColorMode(value.toInt())) {
+ case QPrinter::GrayScale:
+ d->colorModel = QPdfEngine::ColorModel::Grayscale;
+ break;
+ case QPrinter::Color:
+ d->colorModel = QPdfEngine::ColorModel::Auto;
+ break;
+ }
break;
case PPK_Creator:
d->creator = value.toString();
@@ -213,23 +184,24 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
Q_ASSERT(margins.size() == 4);
d->m_pageLayout.setUnits(QPageLayout::Point);
d->m_pageLayout.setMargins(QMarginsF(margins.at(0).toReal(), margins.at(1).toReal(),
- margins.at(2).toReal(), margins.at(3).toReal()));
+ margins.at(2).toReal(), margins.at(3).toReal()),
+ QPageLayout::OutOfBoundsPolicy::Clamp);
break;
}
case PPK_QPageSize: {
- QPageSize pageSize = value.value<QPageSize>();
+ QPageSize pageSize = qvariant_cast<QPageSize>(value);
if (pageSize.isValid())
d->m_pageLayout.setPageSize(pageSize);
break;
}
case PPK_QPageMargins: {
- QPair<QMarginsF, QPageLayout::Unit> pair = value.value<QPair<QMarginsF, QPageLayout::Unit> >();
+ QPair<QMarginsF, QPageLayout::Unit> pair = qvariant_cast<QPair<QMarginsF, QPageLayout::Unit> >(value);
d->m_pageLayout.setUnits(pair.second);
- d->m_pageLayout.setMargins(pair.first);
+ d->m_pageLayout.setMargins(pair.first, QPageLayout::OutOfBoundsPolicy::Clamp);
break;
}
case PPK_QPageLayout: {
- QPageLayout pageLayout = value.value<QPageLayout>();
+ QPageLayout pageLayout = qvariant_cast<QPageLayout>(value);
if (pageLayout.isValid())
d->m_pageLayout = pageLayout;
break;
@@ -257,7 +229,7 @@ QVariant QPdfPrintEngine::property(PrintEnginePropertyKey key) const
ret = d->collate;
break;
case PPK_ColorMode:
- ret = d->grayscale ? QPrinter::GrayScale : QPrinter::Color;
+ ret = d->printerColorMode();
break;
case PPK_Creator:
ret = d->creator;
@@ -403,6 +375,22 @@ QPdfPrintEnginePrivate::~QPdfPrintEnginePrivate()
{
}
+QPrinter::ColorMode QPdfPrintEnginePrivate::printerColorMode() const
+{
+ switch (colorModel) {
+ case QPdfEngine::ColorModel::RGB:
+ case QPdfEngine::ColorModel::CMYK:
+ case QPdfEngine::ColorModel::Auto:
+ return QPrinter::Color;
+ case QPdfEngine::ColorModel::Grayscale:
+ return QPrinter::GrayScale;
+ }
+
+ Q_UNREACHABLE();
+ return QPrinter::Color;
+}
+
+
QT_END_NAMESPACE
#endif // QT_NO_PRINTER
diff --git a/src/printsupport/kernel/qprintengine_pdf_p.h b/src/printsupport/kernel/qprintengine_pdf_p.h
index e7ae21f260..dbf50080a4 100644
--- a/src/printsupport/kernel/qprintengine_pdf_p.h
+++ b/src/printsupport/kernel/qprintengine_pdf_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTENGINE_PDF_P_H
#define QPRINTENGINE_PDF_P_H
@@ -54,13 +18,11 @@
#include "QtPrintSupport/qprintengine.h"
#ifndef QT_NO_PRINTER
+#include "QtCore/qdatastream.h"
#include "QtCore/qmap.h"
-#include "QtGui/qmatrix.h"
#include "QtCore/qstring.h"
-#include "QtCore/qvector.h"
#include "QtGui/qpaintengine.h"
#include "QtGui/qpainterpath.h"
-#include "QtCore/qdatastream.h"
#include "private/qfontengine_p.h"
#include "private/qpdf_p.h"
@@ -117,6 +79,8 @@ public:
QPdfPrintEnginePrivate(QPrinter::PrinterMode m);
~QPdfPrintEnginePrivate();
+ QPrinter::ColorMode printerColorMode() const;
+
virtual bool openPrintDevice();
virtual void closePrintDevice();
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
deleted file mode 100644
index add57e9d95..0000000000
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ /dev/null
@@ -1,1815 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtPrintSupport/qtprintsupportglobal.h>
-
-#ifndef QT_NO_PRINTER
-
-#include "qprintengine_win_p.h"
-
-#include <limits.h>
-
-#include <private/qprinter_p.h>
-#include <private/qfont_p.h>
-#include <private/qfontengine_p.h>
-#include <private/qpainter_p.h>
-
-#include <qpa/qplatformprintplugin.h>
-#include <qpa/qplatformprintersupport.h>
-
-#include <qbitmap.h>
-#include <qdebug.h>
-#include <qvector.h>
-#include <qpicture.h>
-#include <qpa/qplatformpixmap.h>
-#include <private/qpicture_p.h>
-#include <private/qpixmap_raster_p.h>
-#include <QtCore/QMetaType>
-#include <QtCore/qt_windows.h>
-#include <QtGui/qpagelayout.h>
-
-Q_DECLARE_METATYPE(HFONT)
-Q_DECLARE_METATYPE(LOGFONT)
-
-QT_BEGIN_NAMESPACE
-
-Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
-extern QPainterPath qt_regionToPath(const QRegion &region);
-extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
-
-// #define QT_DEBUG_DRAW
-// #define QT_DEBUG_METRICS
-
-static void draw_text_item_win(const QPointF &_pos, const QTextItemInt &ti, HDC hdc,
- const QTransform &xform, const QPointF &topLeft);
-
-QWin32PrintEngine::QWin32PrintEngine(QPrinter::PrinterMode mode, const QString &deviceId)
- : QAlphaPaintEngine(*(new QWin32PrintEnginePrivate),
- PaintEngineFeatures(PrimitiveTransform
- | PixmapTransform
- | PerspectiveTransform
- | PainterPaths
- | Antialiasing
- | PaintOutsidePaintEvent))
-{
- Q_D(QWin32PrintEngine);
- d->mode = mode;
- QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
- if (ps)
- d->m_printDevice = ps->createPrintDevice(deviceId.isEmpty() ? ps->defaultPrintDeviceId() : deviceId);
- d->m_pageLayout.setPageSize(d->m_printDevice.defaultPageSize());
- d->initialize();
-}
-
-static QByteArray msgBeginFailed(const char *function, const DOCINFO &d)
-{
- QString result;
- QTextStream str(&result);
- str << "QWin32PrintEngine::begin: " << function << " failed";
- if (d.lpszDocName && d.lpszDocName[0])
- str << ", document \"" << QString::fromWCharArray(d.lpszDocName) << '"';
- if (d.lpszOutput && d.lpszOutput[0])
- str << ", file \"" << QString::fromWCharArray(d.lpszOutput) << '"';
- return std::move(result).toLocal8Bit();
-}
-
-bool QWin32PrintEngine::begin(QPaintDevice *pdev)
-{
- Q_D(QWin32PrintEngine);
-
- QAlphaPaintEngine::begin(pdev);
- if (!continueCall())
- return true;
-
- if (d->reinit) {
- d->resetDC();
- d->reinit = false;
- }
-
- // ### set default colors and stuff...
-
- bool ok = d->state == QPrinter::Idle;
-
- if (!d->hdc)
- return false;
-
- d->devMode->dmCopies = d->num_copies;
-
- DOCINFO di;
- memset(&di, 0, sizeof(DOCINFO));
- di.cbSize = sizeof(DOCINFO);
- 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 (d->printToFile)
- di.lpszOutput = d->fileName.isEmpty() ? L"FILE:" : reinterpret_cast<const wchar_t *>(d->fileName.utf16());
- if (ok && StartDoc(d->hdc, &di) == SP_ERROR) {
- qErrnoWarning(msgBeginFailed("StartDoc", di));
- ok = false;
- }
-
- if (StartPage(d->hdc) <= 0) {
- qErrnoWarning(msgBeginFailed("StartPage", di));
- ok = false;
- }
-
- if (!ok) {
- d->state = QPrinter::Idle;
- } else {
- d->state = QPrinter::Active;
- }
-
- d->matrix = QTransform();
- d->has_pen = true;
- d->pen = QColor(Qt::black);
- d->has_brush = false;
-
- d->complex_xform = false;
-
- updateMatrix(d->matrix);
-
- if (!ok)
- cleanUp();
-
-#ifdef QT_DEBUG_METRICS
- qDebug("QWin32PrintEngine::begin()");
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
-
- return ok;
-}
-
-bool QWin32PrintEngine::end()
-{
- Q_D(QWin32PrintEngine);
-
- if (d->hdc) {
- if (d->state == QPrinter::Aborted) {
- cleanUp();
- AbortDoc(d->hdc);
- return true;
- }
- }
-
- QAlphaPaintEngine::end();
- if (!continueCall())
- return true;
-
- if (d->hdc) {
- if (EndPage(d->hdc) <= 0) // end; printing done
- qErrnoWarning("QWin32PrintEngine::end: EndPage failed (%p)", d->hdc);
- if (EndDoc(d->hdc) <= 0)
- qErrnoWarning("QWin32PrintEngine::end: EndDoc failed");
- }
-
- d->state = QPrinter::Idle;
- d->reinit = true;
- return true;
-}
-
-bool QWin32PrintEngine::newPage()
-{
- Q_D(QWin32PrintEngine);
- Q_ASSERT(isActive());
-
- Q_ASSERT(d->hdc);
-
- flushAndInit();
-
- bool transparent = GetBkMode(d->hdc) == TRANSPARENT;
-
- if (EndPage(d->hdc) <= 0) {
- qErrnoWarning("QWin32PrintEngine::newPage: EndPage failed");
- return false;
- }
-
- if (d->reinit) {
- if (!d->resetDC())
- return false;
- d->reinit = false;
- }
-
- if (StartPage(d->hdc) <= 0) {
- qErrnoWarning("Win32PrintEngine::newPage: StartPage failed");
- return false;
- }
-
- SetTextAlign(d->hdc, TA_BASELINE);
- if (transparent)
- SetBkMode(d->hdc, TRANSPARENT);
-
-#ifdef QT_DEBUG_METRICS
- qDebug("QWin32PrintEngine::newPage()");
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
-
- // ###
- return true;
-
- bool success = false;
- if (d->hdc && d->state == QPrinter::Active) {
- if (EndPage(d->hdc) > 0) {
- // reinitialize the DC before StartPage if needed,
- // because resetdc is disabled between calls to the StartPage and EndPage functions
- // (see StartPage documentation in the Platform SDK:Windows GDI)
-// state = PST_ACTIVEDOC;
-// reinit();
-// state = PST_ACTIVE;
- // start the new page now
- if (d->reinit) {
- if (!d->resetDC())
- qErrnoWarning("QWin32PrintEngine::newPage(), ResetDC failed (2)");
- d->reinit = false;
- }
- success = (StartPage(d->hdc) > 0);
- if (!success)
- qErrnoWarning("Win32PrintEngine::newPage: StartPage failed (2)");
- }
- if (!success) {
- d->state = QPrinter::Aborted;
- return false;
- }
- }
- return true;
-}
-
-bool QWin32PrintEngine::abort()
-{
- // do nothing loop.
- return false;
-}
-
-void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
-{
- Q_D(const QWin32PrintEngine);
-
- QAlphaPaintEngine::drawTextItem(p, textItem);
- if (!continueCall())
- return;
-
- const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
- QRgb brushColor = state->pen().brush().color().rgb();
- bool fallBack = state->pen().brush().style() != Qt::SolidPattern
- || qAlpha(brushColor) != 0xff
- || d->txop >= QTransform::TxProject
- || ti.fontEngine->type() != QFontEngine::Win
- || !d->embed_fonts;
-
- if (!fallBack) {
- const QVariantMap userData = ti.fontEngine->userData().toMap();
- const QVariant hFontV = userData.value(QStringLiteral("hFont"));
- const QVariant logFontV = userData.value(QStringLiteral("logFont"));
- if (hFontV.canConvert<HFONT>() && logFontV.canConvert<LOGFONT>()) {
- const HFONT hfont = hFontV.value<HFONT>();
- const LOGFONT logFont = logFontV.value<LOGFONT>();
- // Try selecting the font to see if we get a substitution font
- SelectObject(d->hdc, hfont);
- if (GetDeviceCaps(d->hdc, TECHNOLOGY) != DT_CHARSTREAM) {
- wchar_t n[64];
- GetTextFace(d->hdc, 64, n);
- fallBack = QString::fromWCharArray(n)
- != QString::fromWCharArray(logFont.lfFaceName);
- }
- }
- }
-
-
- if (fallBack) {
- QPaintEngine::drawTextItem(p, textItem);
- return ;
- }
-
- COLORREF cf = RGB(qRed(brushColor), qGreen(brushColor), qBlue(brushColor));
- SelectObject(d->hdc, CreateSolidBrush(cf));
- SelectObject(d->hdc, CreatePen(PS_SOLID, 1, cf));
- SetTextColor(d->hdc, cf);
-
- draw_text_item_win(p, ti, d->hdc, d->matrix, QPointF(0.0, 0.0));
- DeleteObject(SelectObject(d->hdc,GetStockObject(HOLLOW_BRUSH)));
- DeleteObject(SelectObject(d->hdc,GetStockObject(BLACK_PEN)));
-}
-
-int QWin32PrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const
-{
- Q_D(const QWin32PrintEngine);
-
- if (!d->hdc)
- return 0;
-
- int val;
- int res = d->resolution;
-
- switch (m) {
- case QPaintDevice::PdmWidth:
- val = d->m_paintRectPixels.width();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::metric(PdmWidth) = " << val;
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- case QPaintDevice::PdmHeight:
- val = d->m_paintRectPixels.height();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::metric(PdmHeight) = " << val;
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- case QPaintDevice::PdmDpiX:
- val = res;
- break;
- case QPaintDevice::PdmDpiY:
- val = res;
- break;
- case QPaintDevice::PdmPhysicalDpiX:
- val = GetDeviceCaps(d->hdc, LOGPIXELSX);
- break;
- case QPaintDevice::PdmPhysicalDpiY:
- val = GetDeviceCaps(d->hdc, LOGPIXELSY);
- break;
- case QPaintDevice::PdmWidthMM:
- val = d->m_paintSizeMM.width();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::metric(PdmWidthMM) = " << val;
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- case QPaintDevice::PdmHeightMM:
- val = d->m_paintSizeMM.height();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::metric(PdmHeightMM) = " << val;
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- case QPaintDevice::PdmNumColors:
- {
- int bpp = GetDeviceCaps(d->hdc, BITSPIXEL);
- if(bpp==32)
- val = INT_MAX;
- else if(bpp<=8)
- val = GetDeviceCaps(d->hdc, NUMCOLORS);
- else
- val = 1 << (bpp * GetDeviceCaps(d->hdc, PLANES));
- }
- break;
- case QPaintDevice::PdmDepth:
- val = GetDeviceCaps(d->hdc, PLANES);
- break;
- case QPaintDevice::PdmDevicePixelRatio:
- val = 1;
- break;
- case QPaintDevice::PdmDevicePixelRatioScaled:
- val = 1 * QPaintDevice::devicePixelRatioFScale();
- break;
- default:
- qWarning("QPrinter::metric: Invalid metric command");
- return 0;
- }
- return val;
-}
-
-void QWin32PrintEngine::updateState(const QPaintEngineState &state)
-{
- Q_D(QWin32PrintEngine);
-
- QAlphaPaintEngine::updateState(state);
- if (!continueCall())
- return;
-
- if (state.state() & DirtyTransform) {
- updateMatrix(state.transform());
- }
-
- if (state.state() & DirtyPen) {
- d->pen = state.pen();
- d->has_pen = d->pen.style() != Qt::NoPen && d->pen.isSolid();
- }
-
- if (state.state() & DirtyBrush) {
- QBrush brush = state.brush();
- d->has_brush = brush.style() == Qt::SolidPattern;
- d->brush_color = brush.color();
- }
-
- if (state.state() & DirtyClipEnabled) {
- if (state.isClipEnabled())
- updateClipPath(painter()->clipPath(), Qt::ReplaceClip);
- else
- updateClipPath(QPainterPath(), Qt::NoClip);
- }
-
- if (state.state() & DirtyClipPath) {
- updateClipPath(state.clipPath(), state.clipOperation());
- }
-
- if (state.state() & DirtyClipRegion) {
- QRegion clipRegion = state.clipRegion();
- QPainterPath clipPath = qt_regionToPath(clipRegion);
- updateClipPath(clipPath, state.clipOperation());
- }
-}
-
-void QWin32PrintEngine::updateClipPath(const QPainterPath &clipPath, Qt::ClipOperation op)
-{
- Q_D(QWin32PrintEngine);
-
- bool doclip = true;
- if (op == Qt::NoClip) {
- SelectClipRgn(d->hdc, 0);
- doclip = false;
- }
-
- if (doclip) {
- QPainterPath xformed = clipPath * d->matrix;
-
- if (xformed.isEmpty()) {
-// QRegion empty(-0x1000000, -0x1000000, 1, 1);
- HRGN empty = CreateRectRgn(-0x1000000, -0x1000000, -0x0fffffff, -0x0ffffff);
- SelectClipRgn(d->hdc, empty);
- DeleteObject(empty);
- } else {
- d->composeGdiPath(xformed);
- const int ops[] = {
- -1, // Qt::NoClip, covered above
- RGN_COPY, // Qt::ReplaceClip
- RGN_AND, // Qt::IntersectClip
- RGN_OR // Qt::UniteClip
- };
- Q_ASSERT(op > 0 && unsigned(op) <= sizeof(ops) / sizeof(int));
- SelectClipPath(d->hdc, ops[op]);
- }
- }
-
- QPainterPath aclip = qt_regionToPath(alphaClipping());
- if (!aclip.isEmpty()) {
- QTransform tx(d->stretch_x, 0, 0, d->stretch_y, d->origin_x, d->origin_y);
- d->composeGdiPath(tx.map(aclip));
- SelectClipPath(d->hdc, RGN_DIFF);
- }
-}
-
-void QWin32PrintEngine::updateMatrix(const QTransform &m)
-{
- Q_D(QWin32PrintEngine);
-
- QTransform stretch(d->stretch_x, 0, 0, d->stretch_y, d->origin_x, d->origin_y);
- d->painterMatrix = m;
- d->matrix = d->painterMatrix * stretch;
- d->txop = d->matrix.type();
- d->complex_xform = (d->txop > QTransform::TxScale);
-}
-
-enum HBitmapFormat
-{
- HBitmapNoAlpha,
- HBitmapPremultipliedAlpha,
- HBitmapAlpha
-};
-
-void QWin32PrintEngine::drawPixmap(const QRectF &targetRect,
- const QPixmap &originalPixmap,
- const QRectF &sourceRect)
-{
- Q_D(QWin32PrintEngine);
-
- QAlphaPaintEngine::drawPixmap(targetRect, originalPixmap, sourceRect);
- if (!continueCall())
- return;
-
- const int tileSize = 2048;
-
- QRectF r = targetRect;
- QRectF sr = sourceRect;
-
- QPixmap pixmap = originalPixmap;
- if (sr.size() != pixmap.size()) {
- pixmap = pixmap.copy(sr.toRect());
- }
-
- qreal scaleX = 1.0f;
- qreal scaleY = 1.0f;
-
- QTransform scaleMatrix = QTransform::fromScale(r.width() / pixmap.width(), r.height() / pixmap.height());
- QTransform adapted = QPixmap::trueMatrix(d->painterMatrix * scaleMatrix,
- pixmap.width(), pixmap.height());
-
- qreal xform_offset_x = adapted.dx();
- qreal xform_offset_y = adapted.dy();
-
- if (d->complex_xform) {
- pixmap = pixmap.transformed(adapted);
- scaleX = d->stretch_x;
- scaleY = d->stretch_y;
- } else {
- scaleX = d->stretch_x * (r.width() / pixmap.width()) * d->painterMatrix.m11();
- scaleY = d->stretch_y * (r.height() / pixmap.height()) * d->painterMatrix.m22();
- }
-
- QPointF topLeft = r.topLeft() * d->painterMatrix;
- int tx = int(topLeft.x() * d->stretch_x + d->origin_x);
- int ty = int(topLeft.y() * d->stretch_y + d->origin_y);
- int tw = qAbs(int(pixmap.width() * scaleX));
- int th = qAbs(int(pixmap.height() * scaleY));
-
- xform_offset_x *= d->stretch_x;
- xform_offset_y *= d->stretch_y;
-
- int dc_state = SaveDC(d->hdc);
-
- int tilesw = pixmap.width() / tileSize;
- int tilesh = pixmap.height() / tileSize;
- ++tilesw;
- ++tilesh;
-
- int txinc = tileSize*scaleX;
- int tyinc = tileSize*scaleY;
-
- for (int y = 0; y < tilesh; ++y) {
- int tposy = ty + (y * tyinc);
- int imgh = tileSize;
- int height = tyinc;
- if (y == (tilesh - 1)) {
- imgh = pixmap.height() - (y * tileSize);
- height = (th - (y * tyinc));
- }
- for (int x = 0; x < tilesw; ++x) {
- int tposx = tx + (x * txinc);
- int imgw = tileSize;
- int width = txinc;
- if (x == (tilesw - 1)) {
- imgw = pixmap.width() - (x * tileSize);
- width = (tw - (x * txinc));
- }
-
-
- QImage img(QSize(imgw, imgh), QImage::Format_RGB32);
- img.fill(Qt::white);
- QPainter painter(&img);
- painter.drawPixmap(0,0, pixmap, tileSize * x, tileSize * y, imgw, imgh);
- QPixmap p = QPixmap::fromImage(img);
-
- HBITMAP hbitmap = qt_pixmapToWinHBITMAP(p, HBitmapNoAlpha);
- HDC hbitmap_hdc = CreateCompatibleDC(d->hdc);
- HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap);
-
- if (!StretchBlt(d->hdc, qRound(tposx - xform_offset_x), qRound(tposy - xform_offset_y), width, height,
- hbitmap_hdc, 0, 0, p.width(), p.height(), SRCCOPY))
- qErrnoWarning("QWin32PrintEngine::drawPixmap, StretchBlt failed");
-
- SelectObject(hbitmap_hdc, null_bitmap);
- DeleteObject(hbitmap);
- DeleteDC(hbitmap_hdc);
- }
- }
-
- RestoreDC(d->hdc, dc_state);
-}
-
-
-void QWin32PrintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &pos)
-{
- Q_D(QWin32PrintEngine);
-
- QAlphaPaintEngine::drawTiledPixmap(r, pm, pos);
- if (!continueCall())
- return;
-
- if (d->complex_xform || !pos.isNull()) {
- QPaintEngine::drawTiledPixmap(r, pm, pos);
- } else {
- int dc_state = SaveDC(d->hdc);
-
- HBITMAP hbitmap = qt_pixmapToWinHBITMAP(pm, HBitmapNoAlpha);
- HDC hbitmap_hdc = CreateCompatibleDC(d->hdc);
- HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap);
-
- QRectF trect = d->painterMatrix.mapRect(r);
- int tx = int(trect.left() * d->stretch_x + d->origin_x);
- int ty = int(trect.top() * d->stretch_y + d->origin_y);
-
- int xtiles = int(trect.width() / pm.width()) + 1;
- int ytiles = int(trect.height() / pm.height()) + 1;
- int xinc = int(pm.width() * d->stretch_x);
- int yinc = int(pm.height() * d->stretch_y);
-
- for (int y = 0; y < ytiles; ++y) {
- int ity = ty + (yinc * y);
- int ith = pm.height();
- if (y == (ytiles - 1)) {
- ith = int(trect.height() - (pm.height() * y));
- }
-
- for (int x = 0; x < xtiles; ++x) {
- int itx = tx + (xinc * x);
- int itw = pm.width();
- if (x == (xtiles - 1)) {
- itw = int(trect.width() - (pm.width() * x));
- }
-
- if (!StretchBlt(d->hdc, itx, ity, int(itw * d->stretch_x), int(ith * d->stretch_y),
- hbitmap_hdc, 0, 0, itw, ith, SRCCOPY))
- qErrnoWarning("QWin32PrintEngine::drawPixmap, StretchBlt failed");
-
- }
- }
-
- SelectObject(hbitmap_hdc, null_bitmap);
- DeleteObject(hbitmap);
- DeleteDC(hbitmap_hdc);
-
- RestoreDC(d->hdc, dc_state);
- }
-}
-
-
-void QWin32PrintEnginePrivate::composeGdiPath(const QPainterPath &path)
-{
- if (!BeginPath(hdc))
- qErrnoWarning("QWin32PrintEnginePrivate::drawPath: BeginPath failed");
-
- // Drawing the subpaths
- int start = -1;
- for (int i=0; i<path.elementCount(); ++i) {
- const QPainterPath::Element &elm = path.elementAt(i);
- switch (elm.type) {
- case QPainterPath::MoveToElement:
- if (start >= 0
- && path.elementAt(start).x == path.elementAt(i-1).x
- && path.elementAt(start).y == path.elementAt(i-1).y)
- CloseFigure(hdc);
- start = i;
- MoveToEx(hdc, qRound(elm.x), qRound(elm.y), 0);
- break;
- case QPainterPath::LineToElement:
- LineTo(hdc, qRound(elm.x), qRound(elm.y));
- break;
- case QPainterPath::CurveToElement: {
- POINT pts[3] = {
- { qRound(elm.x), qRound(elm.y) },
- { qRound(path.elementAt(i+1).x), qRound(path.elementAt(i+1).y) },
- { qRound(path.elementAt(i+2).x), qRound(path.elementAt(i+2).y) }
- };
- i+=2;
- PolyBezierTo(hdc, pts, 3);
- break;
- }
- default:
- qFatal("QWin32PaintEngine::drawPath: Unhandled type: %d", elm.type);
- }
- }
-
- if (start >= 0
- && path.elementAt(start).x == path.elementAt(path.elementCount()-1).x
- && path.elementAt(start).y == path.elementAt(path.elementCount()-1).y)
- CloseFigure(hdc);
-
- if (!EndPath(hdc))
- qErrnoWarning("QWin32PaintEngine::drawPath: EndPath failed");
-
- SetPolyFillMode(hdc, path.fillRule() == Qt::WindingFill ? WINDING : ALTERNATE);
-}
-
-
-void QWin32PrintEnginePrivate::fillPath_dev(const QPainterPath &path, const QColor &color)
-{
-#ifdef QT_DEBUG_DRAW
- qDebug() << " --- QWin32PrintEnginePrivate::fillPath() bound:" << path.boundingRect() << color;
-#endif
-
- composeGdiPath(path);
-
- HBRUSH brush = CreateSolidBrush(RGB(color.red(), color.green(), color.blue()));
- HGDIOBJ old_brush = SelectObject(hdc, brush);
- FillPath(hdc);
- DeleteObject(SelectObject(hdc, old_brush));
-}
-
-void QWin32PrintEnginePrivate::strokePath_dev(const QPainterPath &path, const QColor &color, qreal penWidth)
-{
- composeGdiPath(path);
- LOGBRUSH brush;
- brush.lbStyle = BS_SOLID;
- brush.lbColor = RGB(color.red(), color.green(), color.blue());
- DWORD capStyle = PS_ENDCAP_SQUARE;
- DWORD joinStyle = PS_JOIN_BEVEL;
- if (pen.capStyle() == Qt::FlatCap)
- capStyle = PS_ENDCAP_FLAT;
- else if (pen.capStyle() == Qt::RoundCap)
- capStyle = PS_ENDCAP_ROUND;
-
- if (pen.joinStyle() == Qt::MiterJoin)
- joinStyle = PS_JOIN_MITER;
- else if (pen.joinStyle() == Qt::RoundJoin)
- joinStyle = PS_JOIN_ROUND;
-
- HPEN pen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | capStyle | joinStyle,
- (penWidth == 0) ? 1 : penWidth, &brush, 0, 0);
-
- HGDIOBJ old_pen = SelectObject(hdc, pen);
- StrokePath(hdc);
- DeleteObject(SelectObject(hdc, old_pen));
-}
-
-
-void QWin32PrintEnginePrivate::fillPath(const QPainterPath &path, const QColor &color)
-{
- fillPath_dev(path * matrix, color);
-}
-
-void QWin32PrintEnginePrivate::strokePath(const QPainterPath &path, const QColor &color)
-{
- Q_Q(QWin32PrintEngine);
-
- QPainterPathStroker stroker;
- if (pen.style() == Qt::CustomDashLine) {
- stroker.setDashPattern(pen.dashPattern());
- stroker.setDashOffset(pen.dashOffset());
- } else {
- stroker.setDashPattern(pen.style());
- }
- stroker.setCapStyle(pen.capStyle());
- stroker.setJoinStyle(pen.joinStyle());
- stroker.setMiterLimit(pen.miterLimit());
-
- QPainterPath stroke;
- qreal width = pen.widthF();
- bool cosmetic = qt_pen_is_cosmetic(pen, q->state->renderHints());
- if (pen.style() == Qt::SolidLine && (cosmetic || matrix.type() < QTransform::TxScale)) {
- strokePath_dev(path * matrix, color, width);
- } else {
- stroker.setWidth(width);
- if (cosmetic) {
- stroke = stroker.createStroke(path * matrix);
- } else {
- stroke = stroker.createStroke(path) * painterMatrix;
- QTransform stretch(stretch_x, 0, 0, stretch_y, origin_x, origin_y);
- stroke = stroke * stretch;
- }
-
- if (stroke.isEmpty())
- return;
-
- fillPath_dev(stroke, color);
- }
-}
-
-
-void QWin32PrintEngine::drawPath(const QPainterPath &path)
-{
-#ifdef QT_DEBUG_DRAW
- qDebug() << " - QWin32PrintEngine::drawPath(), bounds: " << path.boundingRect();
-#endif
-
- Q_D(QWin32PrintEngine);
-
- QAlphaPaintEngine::drawPath(path);
- if (!continueCall())
- return;
-
- if (d->has_brush)
- d->fillPath(path, d->brush_color);
-
- if (d->has_pen)
- d->strokePath(path, d->pen.color());
-}
-
-
-void QWin32PrintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
-{
-#ifdef QT_DEBUG_DRAW
- qDebug() << " - QWin32PrintEngine::drawPolygon(), pointCount: " << pointCount;
-#endif
-
- QAlphaPaintEngine::drawPolygon(points, pointCount, mode);
- if (!continueCall())
- return;
-
- Q_ASSERT(pointCount > 1);
-
- QPainterPath path(points[0]);
-
- for (int i=1; i<pointCount; ++i) {
- path.lineTo(points[i]);
- }
-
- Q_D(QWin32PrintEngine);
-
- bool has_brush = d->has_brush;
-
- if (mode == PolylineMode)
- d->has_brush = false; // No brush for polylines
- else
- path.closeSubpath(); // polygons are should always be closed.
-
- drawPath(path);
- d->has_brush = has_brush;
-}
-
-QWin32PrintEnginePrivate::~QWin32PrintEnginePrivate()
-{
- release();
-}
-
-void QWin32PrintEnginePrivate::initialize()
-{
- release();
-
- Q_ASSERT(!hPrinter);
- Q_ASSERT(!hdc);
- Q_ASSERT(!devMode);
- Q_ASSERT(!pInfo);
-
- if (!m_printDevice.isValid())
- return;
-
- txop = QTransform::TxNone;
-
- QString printerName = m_printDevice.id();
- bool ok = OpenPrinter((LPWSTR)printerName.utf16(), (LPHANDLE)&hPrinter, 0);
- if (!ok) {
- qErrnoWarning("QWin32PrintEngine::initialize: OpenPrinter failed");
- return;
- }
-
- // Fetch the PRINTER_INFO_2 with DEVMODE data containing the
- // printer settings.
- DWORD infoSize, numBytes;
- GetPrinter(hPrinter, 2, NULL, 0, &infoSize);
- hMem = GlobalAlloc(GHND, infoSize);
- pInfo = (PRINTER_INFO_2*) GlobalLock(hMem);
- ok = GetPrinter(hPrinter, 2, (LPBYTE)pInfo, infoSize, &numBytes);
-
- if (!ok) {
- qErrnoWarning("QWin32PrintEngine::initialize: GetPrinter failed");
- release();
- return;
- }
-
- devMode = pInfo->pDevMode;
-
- if (!devMode) {
- // pInfo->pDevMode == NULL for some printers and passing NULL
- // into CreateDC leads to the printer doing nothing. In addition,
- // the framework assumes that devMode isn't NULL, such as in
- // QWin32PrintEngine::begin() and QPageSetupDialog::exec()
- // Attempt to get the DEVMODE a different way.
-
- // Allocate the required buffer
- LONG result = DocumentProperties(NULL, hPrinter, (LPWSTR)printerName.utf16(),
- NULL, NULL, 0);
- devMode = (DEVMODE *) malloc(result);
- ownsDevMode = true;
-
- // Get the default DevMode
- result = DocumentProperties(NULL, hPrinter, (LPWSTR)printerName.utf16(),
- devMode, NULL, DM_OUT_BUFFER);
- if (result != IDOK) {
- qErrnoWarning("QWin32PrintEngine::initialize: Failed to obtain devMode");
- free(devMode);
- devMode = NULL;
- ownsDevMode = false;
- }
- }
-
- hdc = CreateDC(NULL, (LPCWSTR)printerName.utf16(), 0, devMode);
-
- if (!hdc) {
- qErrnoWarning("QWin32PrintEngine::initialize: CreateDC failed");
- release();
- return;
- }
-
- Q_ASSERT(hPrinter);
- Q_ASSERT(pInfo);
-
- initHDC();
-
- if (devMode) {
- num_copies = devMode->dmCopies;
- devMode->dmCollate = DMCOLLATE_TRUE;
- updatePageLayout();
- }
-
-#if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS
- qDebug("QWin32PrintEngine::initialize()");
- debugMetrics();
-#endif // QT_DEBUG_DRAW || QT_DEBUG_METRICS
-}
-
-void QWin32PrintEnginePrivate::initHDC()
-{
- Q_ASSERT(hdc);
-
- HDC display_dc = GetDC(0);
- dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
- dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
- dpi_display = GetDeviceCaps(display_dc, LOGPIXELSY);
- ReleaseDC(0, display_dc);
- if (dpi_display == 0) {
- qWarning("QWin32PrintEngine::metric: GetDeviceCaps() failed, "
- "might be a driver problem");
- dpi_display = 96; // Reasonable default
- }
-
- switch(mode) {
- case QPrinter::ScreenResolution:
- resolution = dpi_display;
- stretch_x = dpi_x / double(dpi_display);
- stretch_y = dpi_y / double(dpi_display);
- break;
- case QPrinter::PrinterResolution:
- case QPrinter::HighResolution:
- resolution = dpi_y;
- stretch_x = 1;
- stretch_y = 1;
- break;
- default:
- break;
- }
-
- updateMetrics();
-}
-
-void QWin32PrintEnginePrivate::release()
-{
- if (globalDevMode) { // Devmode comes from print dialog
- GlobalUnlock(globalDevMode);
- } else if (hMem) {
- GlobalUnlock(hMem);
- GlobalFree(hMem);
- }
- if (hPrinter)
- ClosePrinter(hPrinter);
- if (hdc)
- DeleteDC(hdc);
-
- // Check if devMode was allocated separately from pInfo / hMem.
- if (ownsDevMode)
- free(devMode);
-
- hdc = 0;
- hPrinter = 0;
- pInfo = 0;
- hMem = 0;
- devMode = 0;
- ownsDevMode = false;
-}
-
-void QWin32PrintEnginePrivate::doReinit()
-{
- if (state == QPrinter::Active) {
- reinit = true;
- } else {
- resetDC();
- reinit = false;
- }
-}
-
-bool QWin32PrintEnginePrivate::resetDC()
-{
- if (!hdc) {
- qWarning("ResetDC() called with null hdc.");
- return false;
- }
- const HDC oldHdc = hdc;
- const HDC hdc = ResetDC(oldHdc, devMode);
- if (!hdc) {
- const int lastError = GetLastError();
- qErrnoWarning(lastError, "ResetDC() on %p failed (%d)", oldHdc, lastError);
- }
- return hdc != 0;
-}
-
-static int indexOfId(const QVector<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id)
-{
- for (int i = 0; i < inputSlots.size(); ++i) {
- if (inputSlots.at(i).id == id)
- return i;
- }
- return -1;
-}
-
-static int indexOfWindowsId(const QVector<QPrint::InputSlot> &inputSlots, int windowsId)
-{
- for (int i = 0; i < inputSlots.size(); ++i) {
- if (inputSlots.at(i).windowsId == windowsId)
- return i;
- }
- return -1;
-}
-
-void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
-{
- Q_D(QWin32PrintEngine);
- switch (key) {
-
- // The following keys are properties or derived values and so cannot be set
- case PPK_PageRect:
- break;
- case PPK_PaperRect:
- break;
- case PPK_PaperSources:
- break;
- case PPK_SupportsMultipleCopies:
- break;
- case PPK_SupportedResolutions:
- break;
-
- // The following keys are settings that are unsupported by the Windows PrintEngine
- case PPK_CustomBase:
- break;
- case PPK_PageOrder:
- break;
- case PPK_PrinterProgram:
- break;
- case PPK_SelectionOption:
- break;
-
- // The following keys are properties and settings that are supported by the Windows PrintEngine
- case PPK_FontEmbedding:
- d->embed_fonts = value.toBool();
- break;
-
- case PPK_CollateCopies:
- {
- if (!d->devMode)
- break;
- d->devMode->dmCollate = value.toBool() ? DMCOLLATE_TRUE : DMCOLLATE_FALSE;
- d->doReinit();
- }
- break;
-
- case PPK_ColorMode:
- {
- if (!d->devMode)
- break;
- d->devMode->dmColor = (value.toInt() == QPrinter::Color) ? DMCOLOR_COLOR : DMCOLOR_MONOCHROME;
- d->doReinit();
- }
- 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");
- return;
- }
- d->docName = value.toString();
- break;
-
- case PPK_Duplex: {
- if (!d->devMode)
- break;
- QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
- if (mode == property(PPK_Duplex).toInt() || !d->m_printDevice.supportedDuplexModes().contains(mode))
- break;
- switch (mode) {
- case QPrint::DuplexNone:
- d->devMode->dmDuplex = DMDUP_SIMPLEX;
- break;
- case QPrint::DuplexAuto:
- d->devMode->dmDuplex = d->m_pageLayout.orientation() == QPageLayout::Landscape ? DMDUP_HORIZONTAL : DMDUP_VERTICAL;
- break;
- case QPrint::DuplexLongSide:
- d->devMode->dmDuplex = DMDUP_VERTICAL;
- break;
- case QPrint::DuplexShortSide:
- d->devMode->dmDuplex = DMDUP_HORIZONTAL;
- break;
- default:
- // Don't change
- break;
- }
- d->doReinit();
- break;
- }
-
- case PPK_FullPage:
- if (value.toBool())
- d->m_pageLayout.setMode(QPageLayout::FullPageMode);
- else
- d->m_pageLayout.setMode(QPageLayout::StandardMode);
- d->updateMetrics();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_FullPage," << value.toBool() << + ")";
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
-
- case PPK_CopyCount:
- case PPK_NumberOfCopies:
- if (!d->devMode)
- break;
- d->num_copies = value.toInt();
- d->devMode->dmCopies = d->num_copies;
- d->doReinit();
- break;
-
- case PPK_Orientation: {
- if (!d->devMode)
- break;
- QPageLayout::Orientation orientation = QPageLayout::Orientation(value.toInt());
- d->devMode->dmOrientation = orientation == QPageLayout::Landscape ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;
- d->m_pageLayout.setOrientation(orientation);
- d->updateMetrics();
- d->doReinit();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_Orientation," << orientation << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- }
-
- case PPK_OutputFileName:
- if (isActive()) {
- qWarning("QWin32PrintEngine: Cannot change filename while printing");
- } else {
- d->fileName = value.toString();
- d->printToFile = !value.toString().isEmpty();
- }
- break;
-
- case PPK_PageSize: {
- if (!d->devMode)
- break;
- const QPageSize pageSize = QPageSize(QPageSize::PageSizeId(value.toInt()));
- if (pageSize.isValid()) {
- d->setPageSize(pageSize);
- d->doReinit();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_PageSize," << value.toInt() << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- }
- break;
- }
-
- case PPK_PaperName: {
- if (!d->devMode)
- break;
- // Get the named page size from the printer if supported
- const QPageSize pageSize = d->m_printDevice.supportedPageSize(value.toString());
- if (pageSize.isValid()) {
- d->setPageSize(pageSize);
- d->doReinit();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_PaperName," << value.toString() << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- }
- break;
- }
-
- case PPK_PaperSource: {
- if (!d->devMode)
- break;
- const auto inputSlots = d->m_printDevice.supportedInputSlots();
- const int paperSource = value.toInt();
- const int index = paperSource >= DMBIN_USER ?
- indexOfWindowsId(inputSlots, paperSource) : indexOfId(inputSlots, QPrint::InputSlotId(paperSource));
- d->devMode->dmDefaultSource = index >= 0 ? inputSlots.at(index).windowsId : DMBIN_AUTO;
- d->doReinit();
- break;
- }
-
- case PPK_PrinterName: {
- QString id = value.toString();
- QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
- if (!ps)
- return;
-
- QVariant pageSize = QVariant::fromValue(d->m_pageLayout.pageSize());
- const bool isFullPage = (d->m_pageLayout.mode() == QPageLayout::FullPageMode);
- QVariant orientation = QVariant::fromValue(d->m_pageLayout.orientation());
- QVariant margins = QVariant::fromValue(
- QPair<QMarginsF, QPageLayout::Unit>(d->m_pageLayout.margins(), d->m_pageLayout.units()));
- QPrintDevice printDevice = ps->createPrintDevice(id.isEmpty() ? ps->defaultPrintDeviceId() : id);
- if (printDevice.isValid()) {
- d->m_printDevice = printDevice;
- d->initialize();
- if (d->m_printDevice.supportedPageSize(pageSize.value<QPageSize>()).isValid())
- setProperty(PPK_QPageSize, pageSize);
- else
- setProperty(PPK_CustomPaperSize, pageSize.value<QPageSize>().size(QPageSize::Point));
- setProperty(PPK_FullPage, QVariant(isFullPage));
- setProperty(PPK_Orientation, orientation);
- setProperty(PPK_QPageMargins, margins);
- }
- break;
- }
-
- case PPK_Resolution: {
- d->resolution = value.toInt();
- d->stretch_x = d->dpi_x / double(d->resolution);
- d->stretch_y = d->dpi_y / double(d->resolution);
- d->updateMetrics();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_Resolution," << value.toInt() << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- }
-
- case PPK_WindowsPageSize: {
- if (!d->devMode)
- break;
- const QPageSize pageSize = QPageSize(QPageSize::id(value.toInt()));
- if (pageSize.isValid()) {
- d->setPageSize(pageSize);
- d->doReinit();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_WindowsPageSize," << value.toInt() << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- }
- break;
- }
-
- case PPK_CustomPaperSize: {
- if (!d->devMode)
- break;
- const QPageSize pageSize = QPageSize(value.toSizeF(), QPageSize::Point);
- if (pageSize.isValid()) {
- d->setPageSize(pageSize);
- d->doReinit();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_CustomPaperSize," << value.toSizeF() << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- }
- break;
- }
-
- case PPK_PageMargins: {
- QList<QVariant> margins(value.toList());
- Q_ASSERT(margins.size() == 4);
- d->m_pageLayout.setUnits(QPageLayout::Point);
- d->m_pageLayout.setMargins(QMarginsF(margins.at(0).toReal(), margins.at(1).toReal(),
- margins.at(2).toReal(), margins.at(3).toReal()));
- d->updateMetrics();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_PageMargins," << margins << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- }
-
- case PPK_QPageSize: {
- if (!d->devMode)
- break;
- // Get the page size from the printer if supported
- const QPageSize pageSize = value.value<QPageSize>();
- if (pageSize.isValid()) {
- d->setPageSize(pageSize);
- d->doReinit();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageSize," << pageSize << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- }
- break;
- }
-
- case PPK_QPageMargins: {
- QPair<QMarginsF, QPageLayout::Unit> pair = value.value<QPair<QMarginsF, QPageLayout::Unit> >();
- d->m_pageLayout.setUnits(pair.second);
- d->m_pageLayout.setMargins(pair.first);
- d->updateMetrics();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageMargins," << pair.first << pair.second << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- break;
- }
-
- case PPK_QPageLayout: {
- QPageLayout pageLayout = value.value<QPageLayout>();
- if (pageLayout.isValid() && d->m_printDevice.isValidPageLayout(pageLayout, d->resolution)) {
- setProperty(PPK_QPageSize, QVariant::fromValue(pageLayout.pageSize()));
- setProperty(PPK_FullPage, pageLayout.mode() == QPageLayout::FullPageMode);
- setProperty(PPK_Orientation, QVariant::fromValue(pageLayout.orientation()));
- d->m_pageLayout.setUnits(pageLayout.units());
- d->m_pageLayout.setMargins(pageLayout.margins());
- d->updateMetrics();
-#ifdef QT_DEBUG_METRICS
- qDebug() << "QWin32PrintEngine::setProperty(PPK_QPageLayout," << pageLayout << ')';
- d->debugMetrics();
-#endif // QT_DEBUG_METRICS
- }
- break;
- }
-
- // No default so that compiler will complain if new keys added and not handled in this engine
- }
-}
-
-QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
-{
- Q_D(const QWin32PrintEngine);
- QVariant value;
- switch (key) {
-
- // The following keys are settings that are unsupported by the Windows PrintEngine
- // Return sensible default values to ensure consistent behavior across platforms
- case PPK_PageOrder:
- value = QPrinter::FirstPageFirst;
- break;
- case PPK_PrinterProgram:
- value = QString();
- break;
- case PPK_SelectionOption:
- value = QString();
- break;
-
- // The following keys are properties and settings that are supported by the Windows PrintEngine
- case PPK_FontEmbedding:
- value = d->embed_fonts;
- break;
-
- case PPK_CollateCopies:
- if (!d->devMode)
- value = false;
- else
- value = d->devMode->dmCollate == DMCOLLATE_TRUE;
- break;
-
- case PPK_ColorMode:
- {
- if (!d->devMode) {
- value = QPrinter::Color;
- } else {
- value = (d->devMode->dmColor == DMCOLOR_COLOR) ? QPrinter::Color : QPrinter::GrayScale;
- }
- }
- break;
-
- case PPK_Creator:
- value = d->m_creator;
- break;
-
- case PPK_DocumentName:
- value = d->docName;
- break;
-
- case PPK_Duplex: {
- if (!d->devMode) {
- value = QPrinter::DuplexNone;
- } else {
- switch (d->devMode->dmDuplex) {
- case DMDUP_VERTICAL:
- value = QPrinter::DuplexLongSide;
- break;
- case DMDUP_HORIZONTAL:
- value = QPrinter::DuplexShortSide;
- break;
- case DMDUP_SIMPLEX:
- default:
- value = QPrinter::DuplexNone;
- break;
- }
- }
- break;
- }
-
- case PPK_FullPage:
- value = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
- break;
-
- case PPK_CopyCount:
- value = d->num_copies;
- break;
-
- case PPK_SupportsMultipleCopies:
- value = true;
- break;
-
- case PPK_NumberOfCopies:
- value = 1;
- break;
-
- case PPK_Orientation:
- value = d->m_pageLayout.orientation();
- break;
-
- case PPK_OutputFileName:
- value = d->fileName;
- break;
-
- case PPK_PageRect:
- // PageRect is returned in device pixels
- value = d->m_pageLayout.paintRectPixels(d->resolution);
- break;
-
- case PPK_PageSize:
- value = d->m_pageLayout.pageSize().id();
- break;
-
- case PPK_PaperRect:
- // PaperRect is returned in device pixels
- value = d->m_pageLayout.fullRectPixels(d->resolution);
- break;
-
- case PPK_PaperName:
- value = d->m_pageLayout.pageSize().name();
- break;
-
- case PPK_PaperSource:
- if (!d->devMode) {
- value = d->m_printDevice.defaultInputSlot().id;
- } else {
- if (d->devMode->dmDefaultSource >= DMBIN_USER) {
- value = int(d->devMode->dmDefaultSource);
- } else {
- const auto inputSlots = d->m_printDevice.supportedInputSlots();
- const int index = indexOfWindowsId(inputSlots, d->devMode->dmDefaultSource);
- value = index >= 0 ? inputSlots.at(index).id : QPrint::Auto;
- }
- }
- break;
-
- case PPK_PrinterName:
- value = d->m_printDevice.id();
- break;
-
- case PPK_Resolution:
- if (d->resolution || d->m_printDevice.isValid())
- value = d->resolution;
- break;
-
- case PPK_SupportedResolutions: {
- QList<QVariant> list;
- const auto resolutions = d->m_printDevice.supportedResolutions();
- list.reserve(resolutions.size());
- for (int resolution : resolutions)
- list << resolution;
- value = list;
- break;
- }
-
- case PPK_WindowsPageSize:
- value = d->m_pageLayout.pageSize().windowsId();
- break;
-
- case PPK_PaperSources: {
- QList<QVariant> out;
- const auto inputSlots = d->m_printDevice.supportedInputSlots();
- out.reserve(inputSlots.size());
- for (const QPrint::InputSlot &inputSlot : inputSlots)
- out << QVariant(inputSlot.id == QPrint::CustomInputSlot ? inputSlot.windowsId : int(inputSlot.id));
- value = out;
- break;
- }
-
- case PPK_CustomPaperSize:
- value = d->m_pageLayout.fullRectPoints().size();
- break;
-
- case PPK_PageMargins: {
- QList<QVariant> list;
- QMarginsF margins = d->m_pageLayout.margins(QPageLayout::Point);
- list << margins.left() << margins.top() << margins.right() << margins.bottom();
- value = list;
- break;
- }
-
- case PPK_QPageSize:
- value.setValue(d->m_pageLayout.pageSize());
- break;
-
- case PPK_QPageMargins: {
- QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(d->m_pageLayout.margins(), d->m_pageLayout.units());
- value.setValue(pair);
- break;
- }
-
- case PPK_QPageLayout:
- value.setValue(d->m_pageLayout);
- break;
-
- case PPK_CustomBase:
- break;
-
- // No default so that compiler will complain if new keys added and not handled in this engine
- }
- return value;
-}
-
-QPrinter::PrinterState QWin32PrintEngine::printerState() const
-{
- return d_func()->state;
-}
-
-HDC QWin32PrintEngine::getDC() const
-{
- return d_func()->hdc;
-}
-
-void QWin32PrintEngine::releaseDC(HDC) const
-{
-
-}
-
-HGLOBAL *QWin32PrintEngine::createGlobalDevNames()
-{
- Q_D(QWin32PrintEngine);
-
- int size = sizeof(DEVNAMES) + d->m_printDevice.id().length() * 2 + 2;
- auto hGlobal = reinterpret_cast<HGLOBAL *>(GlobalAlloc(GMEM_MOVEABLE, size));
- auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(hGlobal));
-
- dn->wDriverOffset = 0;
- dn->wDeviceOffset = sizeof(DEVNAMES) / sizeof(wchar_t);
- dn->wOutputOffset = 0;
-
- memcpy(reinterpret_cast<ushort*>(dn) + dn->wDeviceOffset,
- d->m_printDevice.id().utf16(), d->m_printDevice.id().length() * 2 + 2);
- dn->wDefault = 0;
-
- GlobalUnlock(hGlobal);
- return hGlobal;
-}
-
-void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalDevMode)
-{
- Q_D(QWin32PrintEngine);
- if (globalDevNames) {
- auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(globalDevNames));
- const QString id =
- QString::fromWCharArray(reinterpret_cast<const wchar_t*>(dn) + dn->wDeviceOffset);
- QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
- if (ps)
- d->m_printDevice = ps->createPrintDevice(id.isEmpty() ? ps->defaultPrintDeviceId() : id);
- GlobalUnlock(globalDevNames);
- }
-
- if (globalDevMode) {
- auto dm = reinterpret_cast<DEVMODE*>(GlobalLock(globalDevMode));
- d->release();
- d->globalDevMode = globalDevMode;
- if (d->ownsDevMode) {
- free(d->devMode);
- d->ownsDevMode = false;
- }
- d->devMode = dm;
- d->hdc = CreateDC(NULL, reinterpret_cast<const wchar_t *>(d->m_printDevice.id().utf16()), 0, dm);
-
- d->num_copies = d->devMode->dmCopies;
- d->updatePageLayout();
-
- if (!OpenPrinter((wchar_t*)d->m_printDevice.id().utf16(), &d->hPrinter, 0))
- qWarning("QPrinter: OpenPrinter() failed after reading DEVMODE.");
- }
-
- if (d->hdc)
- d->initHDC();
-
-#if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS
- qDebug("QWin32PrintEngine::setGlobalDevMode()");
- debugMetrics();
-#endif // QT_DEBUG_DRAW || QT_DEBUG_METRICS
-}
-
-HGLOBAL QWin32PrintEngine::globalDevMode()
-{
- Q_D(QWin32PrintEngine);
- return d->globalDevMode;
-}
-
-void QWin32PrintEnginePrivate::setPageSize(const QPageSize &pageSize)
-{
- if (!pageSize.isValid())
- return;
-
- Q_ASSERT(devMode);
-
- // Use the printer page size if supported
- const QPageSize printerPageSize = m_printDevice.supportedPageSize(pageSize);
- const QPageSize usePageSize = printerPageSize.isValid() ? printerPageSize : pageSize;
-
- const QMarginsF printable = m_printDevice.printableMargins(usePageSize, m_pageLayout.orientation(), resolution);
- m_pageLayout.setPageSize(usePageSize, qt_convertMargins(printable, QPageLayout::Point, m_pageLayout.units()));
-
- // Setup if Windows custom size, i.e. not a known Windows ID
- if (printerPageSize.isValid()) {
- has_custom_paper_size = false;
- devMode->dmPaperSize = m_pageLayout.pageSize().windowsId();
- devMode->dmFields &= ~(DM_PAPERLENGTH | DM_PAPERWIDTH);
- devMode->dmPaperWidth = 0;
- devMode->dmPaperLength = 0;
- } else {
- devMode->dmPaperSize = DMPAPER_USER;
- devMode->dmFields |= DM_PAPERLENGTH | DM_PAPERWIDTH;
- // Size in tenths of a millimeter
- const QSizeF sizeMM = m_pageLayout.pageSize().size(QPageSize::Millimeter);
- devMode->dmPaperWidth = qRound(sizeMM.width() * 10.0);
- devMode->dmPaperLength = qRound(sizeMM.height() * 10.0);
- }
- updateMetrics();
-}
-
-// Update the page layout after any changes made to devMode
-void QWin32PrintEnginePrivate::updatePageLayout()
-{
- Q_ASSERT(devMode);
-
- // Update orientation first as is needed to obtain printable margins when changing page size
- m_pageLayout.setOrientation(devMode->dmOrientation == DMORIENT_LANDSCAPE ? QPageLayout::Landscape : QPageLayout::Portrait);
- if (devMode->dmPaperSize >= DMPAPER_LAST) {
- // Is a custom size
- // Check if it is using the Postscript Custom Size first
- bool hasCustom = false;
- int feature = PSIDENT_GDICENTRIC;
- if (ExtEscape(hdc, POSTSCRIPT_IDENTIFY,
- sizeof(DWORD), reinterpret_cast<LPCSTR>(&feature), 0, 0) >= 0) {
- PSFEATURE_CUSTPAPER custPaper;
- feature = FEATURESETTING_CUSTPAPER;
- if (ExtEscape(hdc, GET_PS_FEATURESETTING, sizeof(INT), reinterpret_cast<LPCSTR>(&feature),
- sizeof(custPaper), reinterpret_cast<LPSTR>(&custPaper)) > 0) {
- // If orientation is 1 and width/height is 0 then it's not really custom
- if (!(custPaper.lOrientation == 1 && custPaper.lWidth == 0 && custPaper.lHeight == 0)) {
- if (custPaper.lOrientation == 0 || custPaper.lOrientation == 2)
- m_pageLayout.setOrientation(QPageLayout::Portrait);
- else
- m_pageLayout.setOrientation(QPageLayout::Landscape);
- QPageSize pageSize = QPageSize(QSizeF(custPaper.lWidth, custPaper.lHeight),
- QPageSize::Point);
- setPageSize(pageSize);
- hasCustom = true;
- }
- }
- }
- if (!hasCustom) {
- QPageSize pageSize = QPageSize(QSizeF(devMode->dmPaperWidth / 10.0f, devMode->dmPaperLength / 10.0f),
- QPageSize::Millimeter);
- setPageSize(pageSize);
- }
- } else {
- // Is a supported size
- setPageSize(QPageSize(QPageSize::id(devMode->dmPaperSize)));
- }
- updateMetrics();
-}
-
-// Update the cached page paint metrics whenever page layout is changed
-void QWin32PrintEnginePrivate::updateMetrics()
-{
- m_paintRectPixels = m_pageLayout.paintRectPixels(resolution);
- QSizeF sizeMM = m_pageLayout.paintRect(QPageLayout::Millimeter).size();
- m_paintSizeMM = QSize(qRound(sizeMM.width()), qRound(sizeMM.height()));
- // Calculate the origin using the physical device pixels, not our paint pixels
- // Origin is defined as User Margins - Device Margins
- QMarginsF margins = m_pageLayout.margins(QPageLayout::Millimeter) / 25.4;
- origin_x = qRound(margins.left() * dpi_x) - GetDeviceCaps(hdc, PHYSICALOFFSETX);
- origin_y = qRound(margins.top() * dpi_y) - GetDeviceCaps(hdc, PHYSICALOFFSETY);
-}
-
-void QWin32PrintEnginePrivate::debugMetrics() const
-{
- qDebug() << " " << "m_pageLayout = " << m_pageLayout;
- qDebug() << " " << "m_paintRectPixels = " << m_paintRectPixels;
- qDebug() << " " << "m_paintSizeMM = " << m_paintSizeMM;
- qDebug() << " " << "resolution = " << resolution;
- qDebug() << " " << "stretch = " << stretch_x << stretch_y;
- qDebug() << " " << "origin = " << origin_x << origin_y;
- qDebug() << " " << "dpi = " << dpi_x << dpi_y;
- qDebug() << "";
-}
-
-static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC hdc,
- const QTransform &xform, const QPointF &topLeft)
-{
- QPointF baseline_pos = xform.inverted().map(xform.map(pos) - topLeft);
-
- SetTextAlign(hdc, TA_BASELINE);
- SetBkMode(hdc, TRANSPARENT);
-
- const bool has_kerning = ti.f && ti.f->kerning();
-
- HFONT hfont = 0;
-
- if (ti.fontEngine->type() == QFontEngine::Win) {
- const QVariantMap userData = ti.fontEngine->userData().toMap();
- const QVariant hfontV = userData.value(QStringLiteral("hFont"));
- const QVariant ttfV = userData.value(QStringLiteral("trueType"));
- if (ttfV.toBool() && hfontV.canConvert<HFONT>())
- hfont = hfontV.value<HFONT>();
- }
-
- if (!hfont)
- hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
-
- HGDIOBJ old_font = SelectObject(hdc, hfont);
- unsigned int options = ETO_GLYPH_INDEX;
- QGlyphLayout glyphs = ti.glyphs;
-
- bool fast = !has_kerning && !(ti.flags & QTextItem::RightToLeft);
- for (int i = 0; fast && i < glyphs.numGlyphs; i++) {
- if (glyphs.offsets[i].x != 0 || glyphs.offsets[i].y != 0 || glyphs.justifications[i].space_18d6 != 0
- || glyphs.attributes[i].dontPrint) {
- fast = false;
- break;
- }
- }
-
- // Scale, rotate and translate here.
- XFORM win_xform;
- win_xform.eM11 = xform.m11();
- win_xform.eM12 = xform.m12();
- win_xform.eM21 = xform.m21();
- win_xform.eM22 = xform.m22();
- win_xform.eDx = xform.dx();
- win_xform.eDy = xform.dy();
-
- SetGraphicsMode(hdc, GM_ADVANCED);
- SetWorldTransform(hdc, &win_xform);
-
- if (fast) {
- // fast path
- QVarLengthArray<wchar_t> g(glyphs.numGlyphs);
- for (int i = 0; i < glyphs.numGlyphs; ++i)
- g[i] = glyphs.glyphs[i];
- ExtTextOut(hdc,
- qRound(baseline_pos.x() + glyphs.offsets[0].x.toReal()),
- qRound(baseline_pos.y() + glyphs.offsets[0].y.toReal()),
- options, 0, g.constData(), glyphs.numGlyphs, 0);
- } else {
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> _glyphs;
-
- QTransform matrix = QTransform::fromTranslate(baseline_pos.x(), baseline_pos.y());
- ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags,
- _glyphs, positions);
- if (_glyphs.isEmpty()) {
- SelectObject(hdc, old_font);
- return;
- }
-
- options |= ETO_PDY;
- QVarLengthArray<INT> glyphDistances(_glyphs.size() * 2);
- QVarLengthArray<wchar_t> g(_glyphs.size());
- const int lastGlyph = _glyphs.size() - 1;
- for (int i = 0; i < lastGlyph; ++i) {
- glyphDistances[i * 2] = qRound(positions[i + 1].x) - qRound(positions[i].x);
- glyphDistances[i * 2 + 1] = qRound(positions[i + 1].y) - qRound(positions[i].y);
- g[i] = _glyphs[i];
- }
- glyphDistances[lastGlyph * 2] = 0;
- glyphDistances[lastGlyph * 2 + 1] = 0;
- g[lastGlyph] = _glyphs[lastGlyph];
- ExtTextOut(hdc, qRound(positions[0].x), qRound(positions[0].y), options, nullptr,
- g.constData(), _glyphs.size(),
- glyphDistances.data());
- }
-
- win_xform.eM11 = win_xform.eM22 = 1.0;
- win_xform.eM12 = win_xform.eM21 = win_xform.eDx = win_xform.eDy = 0.0;
- SetWorldTransform(hdc, &win_xform);
-
- SelectObject(hdc, old_font);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/kernel/qprintengine_win_p.h
deleted file mode 100644
index 876155a3a5..0000000000
--- a/src/printsupport/kernel/qprintengine_win_p.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPRINTENGINE_WIN_P_H
-#define QPRINTENGINE_WIN_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
-
-#ifndef QT_NO_PRINTER
-
-#include <QtGui/qpaintengine.h>
-#include <QtGui/qpagelayout.h>
-#include <QtPrintSupport/QPrintEngine>
-#include <QtPrintSupport/QPrinter>
-#include <private/qpaintengine_alpha_p.h>
-#include <private/qprintdevice_p.h>
-#include <QtCore/qt_windows.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWin32PrintEnginePrivate;
-class QPrinterPrivate;
-class QPainterState;
-
-class Q_PRINTSUPPORT_EXPORT QWin32PrintEngine : public QAlphaPaintEngine, public QPrintEngine
-{
- Q_DECLARE_PRIVATE(QWin32PrintEngine)
-public:
- QWin32PrintEngine(QPrinter::PrinterMode mode, const QString &deviceId);
-
- // override QWin32PaintEngine
- bool begin(QPaintDevice *dev);
- bool end();
-
- void updateState(const QPaintEngineState &state);
-
- void updateMatrix(const QTransform &matrix);
- void updateClipPath(const QPainterPath &clip, Qt::ClipOperation op);
-
- void drawPath(const QPainterPath &path);
- void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
- void drawTextItem(const QPointF &p, const QTextItem &textItem);
-
- void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &p);
- void setProperty(PrintEnginePropertyKey key, const QVariant &value);
- QVariant property(PrintEnginePropertyKey key) const;
-
- bool newPage();
- bool abort();
- int metric(QPaintDevice::PaintDeviceMetric) const;
-
- QPrinter::PrinterState printerState() const;
-
- QPaintEngine::Type type() const { return Windows; }
-
- HDC getDC() const;
- void releaseDC(HDC) const;
-
- /* Used by print/page setup dialogs */
- void setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalDevMode);
- HGLOBAL *createGlobalDevNames();
- HGLOBAL globalDevMode();
-
-private:
- friend class QPrintDialog;
- friend class QPageSetupDialog;
-};
-
-class QWin32PrintEnginePrivate : public QAlphaPaintEnginePrivate
-{
- Q_DECLARE_PUBLIC(QWin32PrintEngine)
-public:
- QWin32PrintEnginePrivate() :
- hPrinter(0),
- globalDevMode(0),
- devMode(0),
- pInfo(0),
- hMem(0),
- hdc(0),
- ownsDevMode(false),
- mode(QPrinter::ScreenResolution),
- state(QPrinter::Idle),
- resolution(0),
- m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))),
- stretch_x(1), stretch_y(1), origin_x(0), origin_y(0),
- dpi_x(96), dpi_y(96), dpi_display(96),
- num_copies(1),
- printToFile(false),
- reinit(false),
- complex_xform(false), has_pen(false), has_brush(false), has_custom_paper_size(false),
- embed_fonts(true),
- txop(0 /* QTransform::TxNone */)
- {
- }
-
- ~QWin32PrintEnginePrivate();
-
-
- /* Initializes the printer data based on the current printer name. This
- function creates a DEVMODE struct, HDC and a printer handle. If these
- structures are already in use, they are freed using release
- */
- void initialize();
-
- /* Initializes data in the print engine whenever the HDC has been renewed
- */
- void initHDC();
-
- /* Releases all the handles the printer currently holds, HDC, DEVMODE,
- etc and resets the corresponding members to 0. */
- void release();
-
- /* Resets the DC with changes in devmode. If the printer is active
- this function only sets the reinit variable to true so it
- is handled in the next begin or newpage. */
- void doReinit();
-
- bool resetDC();
-
- void strokePath(const QPainterPath &path, const QColor &color);
- void fillPath(const QPainterPath &path, const QColor &color);
-
- void composeGdiPath(const QPainterPath &path);
- void fillPath_dev(const QPainterPath &path, const QColor &color);
- void strokePath_dev(const QPainterPath &path, const QColor &color, qreal width);
-
- void setPageSize(const QPageSize &pageSize);
- void updatePageLayout();
- void updateMetrics();
- void debugMetrics() const;
-
- // Windows GDI printer references.
- HANDLE hPrinter;
-
- HGLOBAL globalDevMode;
- DEVMODE *devMode;
- PRINTER_INFO_2 *pInfo;
- HGLOBAL hMem;
-
- HDC hdc;
-
- // True if devMode was allocated separately from pInfo.
- bool ownsDevMode;
-
- QPrinter::PrinterMode mode;
-
- // Print Device
- QPrintDevice m_printDevice;
-
- // Document info
- QString docName;
- QString m_creator;
- QString fileName;
-
- QPrinter::PrinterState state;
- int resolution;
-
- // Page Layout
- QPageLayout m_pageLayout;
-
- // Page metrics cache
- QRect m_paintRectPixels;
- QSize m_paintSizeMM;
-
- // Windows painting
- qreal stretch_x;
- qreal stretch_y;
- int origin_x;
- int origin_y;
-
- int dpi_x;
- int dpi_y;
- int dpi_display;
- int num_copies;
-
- uint printToFile : 1;
- uint reinit : 1;
-
- uint complex_xform : 1;
- uint has_pen : 1;
- uint has_brush : 1;
- uint has_custom_paper_size : 1;
- uint embed_fonts : 1;
-
- uint txop;
-
- QColor brush_color;
- QPen pen;
- QColor pen_color;
- QSizeF paper_size; // In points
-
- QTransform painterMatrix;
- QTransform matrix;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
-
-#endif // QPRINTENGINE_WIN_P_H
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 829a13863b..10c4c681ba 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qprinter.h"
#include "qprinter_p.h"
@@ -61,6 +25,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#define ABORT_IF_ACTIVE(location) \
if (d->printEngine->printerState() == QPrinter::Active) { \
qWarning("%s: Cannot be changed while printer is active", location); \
@@ -76,43 +42,6 @@ QT_BEGIN_NAMESPACE
extern qreal qt_pixelMultiplier(int resolution);
extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
-/// return the multiplier of converting from the unit value to postscript-points.
-Q_PRINTSUPPORT_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
-{
- switch(unit) {
- case QPrinter::Millimeter:
- return 2.83464566929;
- case QPrinter::Point:
- return 1.0;
- case QPrinter::Inch:
- return 72.0;
- case QPrinter::Pica:
- return 12;
- case QPrinter::Didot:
- return 1.065826771;
- case QPrinter::Cicero:
- return 12.789921252;
- case QPrinter::DevicePixel:
- return 72.0/resolution;
- }
- return 1.0;
-}
-
-// not static: it's needed in qpagesetupdialog_unix.cpp
-Q_PRINTSUPPORT_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
- QPrinter::PaperSize paperSize,
- QPrinter::Unit unit,
- int resolution)
-{
- QPageSize pageSize = QPageSize(QPageSize::PageSizeId(paperSize));
- QSizeF sizef;
- if (unit == QPrinter::DevicePixel)
- sizef = pageSize.size(QPageSize::Point) * qt_multiplierForUnit(unit, resolution);
- else
- sizef = pageSize.size(QPageSize::Unit(unit));
- return orientation == QPrinter::Landscape ? sizef.transposed() : sizef;
-}
-
QPrinterInfo QPrinterPrivate::findValidPrinter(const QPrinterInfo &printer)
{
// Try find a valid printer to use, either the one given, the default or the first available
@@ -200,6 +129,11 @@ QList<const QPicture *> QPrinterPrivate::previewPages() const
return QList<const QPicture *>();
}
+bool QPrinterPrivate::previewMode() const
+{
+ return (previewEngine != nullptr) && (previewEngine == printEngine);
+}
+
void QPrinterPrivate::setPreviewMode(bool enable)
{
Q_Q(QPrinter);
@@ -294,7 +228,7 @@ public:
{
QPrinterPrivate *pd = QPrinterPrivate::get(m_printer);
- return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
+ return qvariant_cast<QPageLayout>(pd->printEngine->property(QPrintEngine::PPK_QPageLayout));
}
QPrinter *m_printer;
@@ -335,9 +269,8 @@ public:
The most important parameters are:
\list
- \li setOrientation() tells QPrinter which page orientation to use.
- \li setPaperSize() tells QPrinter what paper size to expect from the
- printer.
+ \li setPageLayout() tells QPrinter which page orientation to use, and
+ what size to expect from the printer.
\li setResolution() tells QPrinter what resolution you wish the
printer to provide, in dots per inch (DPI).
\li setFullPage() tells QPrinter whether you want to deal with the
@@ -420,22 +353,6 @@ public:
*/
/*!
- \enum QPrinter::Orientation
-
- This enum type (not to be confused with \c Orientation) is used
- to specify each page's orientation.
-
- \value Portrait the page's height is greater than its width.
-
- \value Landscape the page's width is greater than its height.
-
- This type interacts with \l QPrinter::PaperSize and
- QPrinter::setFullPage() to determine the final size of the page
- available to the application.
-*/
-
-
-/*!
\enum QPrinter::PrintRange
Used to specify the print range selection option.
@@ -449,31 +366,6 @@ public:
*/
/*!
- \typedef QPrinter::PaperSize
- \since 4.4
-
- typdef for the enum QPagedPaintDevice::PageSize.
-
- This enum type specifies what paper size QPrinter should use.
- QPrinter does not check that the paper size is available; it just
- uses this information, together with QPrinter::Orientation and
- QPrinter::setFullPage(), to determine the printable area.
-
- The defined sizes (with setFullPage(true)) are found in QPagedPaintDevice.
-
- With setFullPage(false) (the default), the metrics will be a bit
- smaller; how much depends on the printer in use.
-
- Due to historic reasons QPageSize::Executive is not the same as the standard
- Postscript and Windows Executive size, use QPageSize::ExecutiveStandard instead.
-
- The Postscript standard size QPageSize::Folio is different to the Windows
- DMPAPER_FOLIO size, use the Postscript standard size QPageSize::FanFoldGermanLegal
- if needed.
-*/
-
-
-/*!
\enum QPrinter::PageOrder
This enum type is used by QPrinter to tell the application program
@@ -544,7 +436,7 @@ public:
Note the difference between Point and DevicePixel. The Point unit is
defined to be 1/72th of an inch, while the DevicePixel unit is
- resolution dependant and is based on the actual pixels, or dots, on
+ resolution dependent and is based on the actual pixels, or dots, on
the printer.
*/
@@ -828,7 +720,7 @@ void QPrinter::setOutputFileName(const QString &fileName)
ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
QFileInfo fi(fileName);
- if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
+ if (!fi.suffix().compare("pdf"_L1, Qt::CaseInsensitive))
setOutputFormat(QPrinter::PdfFormat);
else if (fileName.isEmpty())
setOutputFormat(QPrinter::NativeFormat);
@@ -931,294 +823,6 @@ void QPrinter::setCreator(const QString &creator)
d->setProperty(QPrintEngine::PPK_Creator, creator);
}
-// Defined in QPagedPaintDevice but non-virtual, add QPrinter specific doc here
-#ifdef Q_CLANG_QDOC
-/*!
- \fn bool QPrinter::setPageLayout(const QPageLayout &newLayout)
- \since 5.3
-
- Sets the page layout to \a newLayout.
-
- If the \a newLayout is not valid for the current printer then the page
- layout will not be changed. For example, if the page size is not supported
- by the printer, or if the margins fall outside the printable area.
-
- Returns true if the page layout was successfully set to \a newLayout.
-
- \sa pageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
-*/
-
-/*!
- \fn bool QPrinter::setPageSize(const QPageSize &pageSize)
- \since 5.3
-
- Sets the page size to \a pageSize.
-
- If the \a pageSize is not valid for the current printer then the page
- size will not be changed.
-
- Changing the page size may affect the current page margins if they fall
- outside the printable margins for the new page size on the current printer.
-
- To obtain the current QPageSize use pageLayout().pageSize().
-
- Returns true if the page size was successfully set to \a pageSize.
-
- \sa pageLayout(), setPageLayout()
-*/
-
-/*!
- \fn bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
- \since 5.3
-
- Sets the page \a orientation to QPageLayout::Portrait or QPageLayout::Landscape.
-
- The printer driver reads this setting and prints the page using the
- specified orientation.
-
- On Windows and Mac, this option can be changed while printing and will
- take effect from the next call to newPage().
-
- To obtain the current QPageLayout::Orientation use pageLayout().pageOrientation().
-
- Returns true if the page orientation was successfully set to \a orientation.
-
- \sa pageLayout(), setPageLayout()
-*/
-
-/*!
- \fn bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
- \since 5.3
-
- Set the page margins to \a margins in the given \a units. If \a units are
- not provided then the current units are used.
-
- If in Full Page mode then no check is performed on the \a margins set,
- otherwise the \a margins must fall within the printable area for the page
- size on the current printer.
-
- To obtain the current page margins use pageLayout().pageMargins().
-
- Returns \c true if the page margins was successfully set to \a margins.
-
- \sa pageLayout(), setPageLayout()
-*/
-
-/*!
- \fn bool QPrinter::setPageMargins(const QMarginsF &margins)
-
- Set the page margins to \a margins using the current units.
- Returns \c true if the page margins were set successfully.
-
- \sa pageLayout(), setPageLayout()
-*/
-/*!
- \fn QPageLayout QPrinter::pageLayout() const
- \since 5.3
-
- Returns the current page layout. Use this method to access the current
- QPageSize, QPageLayout::Orientation, QMarginsF, fullPageRect() and paintRect().
-
- Note that you cannot use the setters on the returned object, you must either
- call the QPrinter methods or setPageLayout().
-
- \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
-*/
-#endif
-
-/*!
- \obsolete Use pageLayout().pageOrientation() instead.
-
- Returns the orientation setting. This is driver-dependent, but is usually
- QPrinter::Portrait.
-
- \sa pageLayout()
-*/
-QPrinter::Orientation QPrinter::orientation() const
-{
- return QPrinter::Orientation(pageLayout().orientation());
-}
-
-
-/*!
- \obsolete Use setPageOrientation() instead.
-
- Sets the print orientation to \a orientation.
-
- The orientation can be either QPrinter::Portrait or
- QPrinter::Landscape.
-
- The printer driver reads this setting and prints using the
- specified orientation.
-
- On Windows and Mac, this option can be changed while printing and will
- take effect from the next call to newPage().
-
- \sa setPageOrientation()
-*/
-
-void QPrinter::setOrientation(Orientation orientation)
-{
- setPageOrientation(QPageLayout::Orientation(orientation));
-}
-
-/*!
- \since 4.4
-
- \obsolete Use pageLayout().pageSize().id() instead.
-
- Returns the printer paper size. The default value is driver-dependent.
-
- \sa pageLayout()
-*/
-
-QPrinter::PaperSize QPrinter::paperSize() const
-{
- return pageSize();
-}
-
-/*!
- \since 4.4
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the printer paper size to \a newPaperSize if that size is
- supported. The result is undefined if \a newPaperSize is not
- supported.
-
- The default paper size is driver-dependent.
-
- This function is useful mostly for setting a default value that
- the user can override in the print dialog.
-
- \sa setPageSize()
-*/
-void QPrinter::setPaperSize(PaperSize newPaperSize)
-{
- setPageSize(QPageSize(QPageSize::PageSizeId(newPaperSize)));
-}
-
-/*!
- \obsolete Use pageLayout().pageSize().id() instead.
-
- Returns the printer page size. The default value is driver-dependent.
-
- \sa pageLayout()
-*/
-QPrinter::PageSize QPrinter::pageSize() const
-{
- return QPrinter::PaperSize(pageLayout().pageSize().id());
-}
-
-
-/*!
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the printer page size based on \a newPageSize.
-
- \sa setPageSize()
-*/
-
-void QPrinter::setPageSize(PageSize newPageSize)
-{
- setPageSize(QPageSize(QPageSize::PageSizeId(newPageSize)));
-}
-
-/*!
- \since 4.4
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the paper size based on \a paperSize in \a unit.
-
- Note that the paper size is defined in a portrait layout, regardless of
- what the current printer orientation is set to.
-
- \sa setPageSize()
-*/
-
-void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit)
-{
- if (unit == QPrinter::DevicePixel)
- setPageSize(QPageSize(paperSize * qt_pixelMultiplier(resolution()), QPageSize::Point));
- else
- setPageSize(QPageSize(paperSize, QPageSize::Unit(unit)));
-}
-
-/*!
- \reimp
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Use setPageSize(QPageSize) instead.
-
- Note that the page size is defined in a portrait layout, regardless of
- what the current printer orientation is set to.
-
- \sa setPageSize()
-*/
-void QPrinter::setPageSizeMM(const QSizeF &size)
-{
- setPageSize(QPageSize(size, QPageSize::Millimeter));
-}
-
-/*!
- \since 4.4
-
- \obsolete Use pageLayout().pageSize().size() or
- pageLayout().fullPageSize() instead.
-
- Returns the paper size in \a unit.
-
- Note that the returned size reflects the current paper orientation.
-
- \sa pageLayout()
-*/
-
-QSizeF QPrinter::paperSize(Unit unit) const
-{
- if (unit == QPrinter::DevicePixel)
- return pageLayout().fullRectPixels(resolution()).size();
- else
- return pageLayout().fullRect(QPageLayout::Unit(unit)).size();
-}
-
-/*!
- \since 5.1
-
- \obsolete Use setPageSize(QPageSize) instead.
-
- Sets the paper used by the printer to \a paperName.
-
- \sa setPageSize()
-*/
-
-void QPrinter::setPaperName(const QString &paperName)
-{
- Q_D(QPrinter);
- if (d->paintEngine->type() != QPaintEngine::Pdf)
- ABORT_IF_ACTIVE("QPrinter::setPaperName");
- d->setProperty(QPrintEngine::PPK_PaperName, paperName);
-}
-
-/*!
- \since 5.1
-
- \obsolete Use pageLayout().pageSize().name() instead.
-
- Returns the paper name of the paper set on the printer.
-
- The default value for this is driver-dependent.
-
- \sa pageLayout()
-*/
-
-QString QPrinter::paperName() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_PaperName).toString();
-}
-
/*!
Sets the page order to \a pageOrder.
@@ -1281,73 +885,6 @@ QPrinter::ColorMode QPrinter::colorMode() const
return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
}
-
-/*!
- \obsolete
- Returns the number of copies to be printed. The default value is 1.
-
- On Windows, \macos and X11 systems that support CUPS, this will always
- return 1 as these operating systems can internally handle the number
- of copies.
-
- On X11, this value will return the number of times the application is
- required to print in order to match the number specified in the printer setup
- dialog. This has been done since some printer drivers are not capable of
- buffering up the copies and in those cases the application must make an
- explicit call to the print code for each copy.
-
- Use copyCount() in conjunction with supportsMultipleCopies() instead.
-
- \sa setNumCopies(), actualNumCopies()
-*/
-
-int QPrinter::numCopies() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();
-}
-
-
-/*!
- \obsolete
- \since 4.6
-
- Returns the number of copies that will be printed. The default
- value is 1.
-
- This function always returns the actual value specified in the print
- dialog or using setNumCopies().
-
- Use copyCount() instead.
-
- \sa setNumCopies(), numCopies()
-*/
-int QPrinter::actualNumCopies() const
-{
- return copyCount();
-}
-
-
-
-/*!
- \obsolete
- Sets the number of copies to be printed to \a numCopies.
-
- The printer driver reads this setting and prints the specified
- number of copies.
-
- Use setCopyCount() instead.
-
- \sa numCopies()
-*/
-
-void QPrinter::setNumCopies(int numCopies)
-{
- Q_D(QPrinter);
- ABORT_IF_ACTIVE("QPrinter::setNumCopies");
- d->setProperty(QPrintEngine::PPK_NumberOfCopies, numCopies);
-}
-
/*!
\since 4.7
@@ -1450,12 +987,12 @@ void QPrinter::setCollateCopies(bool collate)
coordinate system coincides with the top-left corner of the paper
itself. In this case, the
\l{QPaintDevice::PaintDeviceMetric}{device metrics} will report
- the exact same dimensions as indicated by \l{PaperSize}. It may not
+ the exact same dimensions as indicated by \{QPageSize}. It may not
be possible to print on the entire physical page because of the
printer's margins, so the application must account for the margins
itself.
- \sa fullPage(), pageLayout(), setPageSize(), width(), height()
+ \sa fullPage(), QPagedPaintDevice::pageLayout(), QPagedPaintDevice::setPageSize()
*/
void QPrinter::setFullPage(bool fp)
@@ -1473,7 +1010,7 @@ void QPrinter::setFullPage(bool fp)
See setFullPage() for details and caveats.
- \sa setFullPage(), pageLayout()
+ \sa setFullPage(), QPagedPaintDevice::pageLayout()
*/
bool QPrinter::fullPage() const
@@ -1493,7 +1030,7 @@ bool QPrinter::fullPage() const
This function must be called before QPainter::begin() to have an effect on
all platforms.
- \sa resolution(), setPaperSize()
+ \sa resolution(), QPagedPaintDevice::setPageSize()
*/
void QPrinter::setResolution(int dpi)
@@ -1588,35 +1125,6 @@ bool QPrinter::fontEmbeddingEnabled() const
*/
/*!
- \since 4.2
-
- \obsolete Use setDuplex() instead.
-
- Enables double sided printing if \a doubleSided is true; otherwise disables it.
-
- \sa setDuplex()
-*/
-void QPrinter::setDoubleSidedPrinting(bool doubleSided)
-{
- setDuplex(doubleSided ? DuplexAuto : DuplexNone);
-}
-
-
-/*!
- \since 4.2
-
- \obsolete Use duplex() instead.
-
- Returns \c true if double side printing is enabled.
-
- \sa duplex()
-*/
-bool QPrinter::doubleSidedPrinting() const
-{
- return duplex() != DuplexNone;
-}
-
-/*!
\since 4.4
Enables double sided printing based on the \a duplex mode.
@@ -1649,7 +1157,7 @@ QPrinter::DuplexMode QPrinter::duplex() const
than the paperRect() since the page normally has margins between
its borders and the paper.
- \sa paperSize()
+ \sa QPagedPaintDevice::pageLayout()
*/
QRectF QPrinter::pageRect(Unit unit) const
{
@@ -1677,104 +1185,6 @@ QRectF QPrinter::paperRect(Unit unit) const
}
/*!
- \obsolete Use pageLayout().paintRectPixels(resolution()) instead.
-
- Returns the page's rectangle; this is usually smaller than the
- paperRect() since the page normally has margins between its
- borders and the paper.
-
- The unit of the returned rectangle is DevicePixel.
-
- \sa pageLayout()
-*/
-QRect QPrinter::pageRect() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect();
-}
-
-/*!
- \obsolete Use pageLayout().fullRectPixels(resolution()) instead.
-
- Returns the paper's rectangle; this is usually larger than the
- pageRect().
-
- The unit of the returned rectangle is DevicePixel.
-
- \sa pageLayout()
-*/
-QRect QPrinter::paperRect() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect();
-}
-
-/*!
- \since 4.4
-
- \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.
-
- This function sets the \a left, \a top, \a right and \a bottom
- page margins for this printer. The unit of the margins are
- specified with the \a unit parameter.
-
- \sa setPageMargins()
-*/
-void QPrinter::setPageMargins(qreal left, qreal top, qreal right, qreal bottom, QPrinter::Unit unit)
-{
- if (unit == QPrinter::DevicePixel) {
- QMarginsF margins = QMarginsF(left, top, right, bottom);
- margins *= qt_pixelMultiplier(resolution());
- margins = qt_convertMargins(margins, QPageLayout::Point, pageLayout().units());
- setPageMargins(margins, pageLayout().units());
- } else {
- setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Unit(unit));
- }
-}
-
-/*!
- \reimp
-
- \obsolete Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.
-
- \sa setPageMargins()
- */
-void QPrinter::setMargins(const Margins &m)
-{
- setPageMargins(QMarginsF(m.left, m.top, m.right, m.bottom), QPageLayout::Millimeter);
-}
-
-/*!
- \since 4.4
-
- \obsolete Use pageLayout().pageMargins() instead.
-
- Returns the page margins for this printer in \a left, \a top, \a
- right, \a bottom. The unit of the returned margins are specified
- with the \a unit parameter.
-
- \sa pageLayout(), setPageMargins()
-*/
-void QPrinter::getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, QPrinter::Unit unit) const
-{
- QMarginsF margins;
- if (unit == QPrinter::DevicePixel) {
- QMargins tmp = pageLayout().marginsPixels(resolution());
- margins = QMarginsF(tmp.left(), tmp.top(), tmp.right(), tmp.bottom());
- } else {
- margins = pageLayout().margins(QPageLayout::Unit(unit));
- }
- if (left)
- *left = margins.left();
- if (right)
- *right = margins.right();
- if (top)
- *top = margins.top();
- if (bottom)
- *bottom = margins.bottom();
-}
-
-/*!
\internal
Returns the metric for the given \a id.
@@ -1806,34 +1216,6 @@ QPrintEngine *QPrinter::printEngine() const
}
/*!
- \obsolete Use QPageSize::id(windowsId) and setPageLayout(QPageSize) instead.
-
- Sets the page size to be used by the printer under Windows to \a
- pageSize.
-
- \sa pageLayout()
-*/
-void QPrinter::setWinPageSize(int pageSize)
-{
- Q_D(QPrinter);
- ABORT_IF_ACTIVE("QPrinter::setWinPageSize");
- d->setProperty(QPrintEngine::PPK_WindowsPageSize, pageSize);
-}
-
-/*!
- \obsolete Use pageLayout.pageSize().windowsId() instead.
-
- Returns the page size used by the printer under Windows.
-
- \sa pageLayout()
-*/
-int QPrinter::winPageSize() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt();
-}
-
-/*!
Returns a list of the resolutions (a list of dots-per-inch
integers) that the printer says it supports.
@@ -1848,7 +1230,7 @@ QList<int> QPrinter::supportedResolutions() const
= d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
QList<int> intlist;
intlist.reserve(varlist.size());
- for (auto var : varlist)
+ for (const auto &var : varlist)
intlist << var.toInt();
return intlist;
}
@@ -1895,7 +1277,7 @@ QPrinter::PrinterState QPrinter::printerState() const
return d->printEngine->printerState();
}
-#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_WIN) || defined(Q_QDOC)
/*!
Returns the supported paper sizes for this printer.
@@ -1981,12 +1363,12 @@ void QPrinter::setPrinterSelectionOption(const QString &option)
\note If fromPage() and toPage() both return 0, this indicates that
\e{the whole document will be printed}.
- \sa setFromTo(), toPage()
+ \sa setFromTo(), toPage(), pageRanges()
*/
int QPrinter::fromPage() const
{
- return d->fromPage;
+ return d->pageRanges.firstPage();
}
/*!
@@ -2005,12 +1387,12 @@ int QPrinter::fromPage() const
The programmer is responsible for reading this setting and
printing accordingly.
- \sa setFromTo(), fromPage()
+ \sa setFromTo(), fromPage(), pageRanges()
*/
int QPrinter::toPage() const
{
- return d->toPage;
+ return d->pageRanges.lastPage();
}
/*!
@@ -2027,17 +1409,14 @@ int QPrinter::toPage() const
This function is mostly used to set a default value that the user can
override in the print dialog when you call setup().
- \sa fromPage(), toPage()
+ \sa fromPage(), toPage(), pageRanges()
*/
void QPrinter::setFromTo(int from, int to)
{
- if (from > to) {
- qWarning("QPrinter::setFromTo: 'from' must be less than or equal to 'to'");
- from = to;
- }
- d->fromPage = from;
- d->toPage = to;
+ d->pageRanges.clear();
+ if (from && to)
+ d->pageRanges.addRange(from, to);
}
/*!
@@ -2117,7 +1496,7 @@ QPrinter::PrintRange QPrinter::printRange() const
\value PPK_NumberOfCopies Obsolete. An integer specifying the number of
copies. Use PPK_CopyCount instead.
- \value PPK_Orientation Specifies a QPrinter::Orientation value.
+ \value PPK_Orientation Specifies a QPageLayout::Orientation value.
\value PPK_OutputFileName The output file name as a string. An
empty file name indicates that the printer should not print to a file.
@@ -2224,8 +1603,4 @@ QPrinter::PrintRange QPrinter::printRange() const
QT_END_NAMESPACE
-#elif defined(Q_OS_WINRT)
-QT_BEGIN_NAMESPACE
-bool Q_PRINTSUPPORT_EXPORT qt_winrt_export_lib_creation_variable;
-QT_END_NAMESPACE
#endif // QT_NO_PRINTER
diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h
index 28dca78a63..c60f0eea1f 100644
--- a/src/printsupport/kernel/qprinter.h
+++ b/src/printsupport/kernel/qprinter.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTER_H
#define QPRINTER_H
@@ -44,7 +8,6 @@
#include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
#include <QtGui/qpagedpaintdevice.h>
-#include <QtGui/qpagelayout.h>
QT_BEGIN_NAMESPACE
@@ -60,7 +23,6 @@ class QPaintEngine;
class QPrintEngine;
class QPrinterInfo;
class QPageSize;
-class QPageMargins;
class Q_PRINTSUPPORT_EXPORT QPrinter : public QPagedPaintDevice
{
@@ -74,11 +36,6 @@ public:
int devType() const override;
- enum Orientation { Portrait, Landscape };
-
- // ### Qt6 Remove in favor of QPage::PageSize
- typedef PageSize PaperSize;
-
enum PageOrder { FirstPageFirst,
LastPageFirst };
@@ -154,36 +111,6 @@ public:
void setCreator(const QString &);
QString creator() const;
-#ifdef Q_CLANG_QDOC
- // ### Qt6 Remove when these are made virtual in QPagedPaintDevice
- bool setPageLayout(const QPageLayout &pageLayout);
- bool setPageSize(const QPageSize &pageSize);
- bool setPageOrientation(QPageLayout::Orientation orientation);
- bool setPageMargins(const QMarginsF &margins);
- bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
- QPageLayout pageLayout() const;
-#else
- using QPagedPaintDevice::setPageSize;
- using QPagedPaintDevice::setPageMargins;
-#endif
-
- void setOrientation(Orientation);
- Orientation orientation() const;
-
- void setPageSize(PageSize) override;
- PageSize pageSize() const;
-
- void setPageSizeMM(const QSizeF &size) override;
-
- void setPaperSize(PaperSize);
- PaperSize paperSize() const;
-
- void setPaperSize(const QSizeF &paperSize, Unit unit);
- QSizeF paperSize(Unit unit) const;
-
- void setPaperName(const QString &paperName);
- QString paperName() const;
-
void setPageOrder(PageOrder);
PageOrder pageOrder() const;
@@ -199,11 +126,6 @@ public:
void setFullPage(bool);
bool fullPage() const;
- void setNumCopies(int);
- int numCopies() const;
-
- int actualNumCopies() const;
-
void setCopyCount(int);
int copyCount() const;
bool supportsMultipleCopies() const;
@@ -216,21 +138,13 @@ public:
QList<int> supportedResolutions() const;
-#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_WIN) || defined(Q_QDOC)
QList<PaperSource> supportedPaperSources() const;
#endif
void setFontEmbeddingEnabled(bool enable);
bool fontEmbeddingEnabled() const;
- void setDoubleSidedPrinting(bool enable);
- bool doubleSidedPrinting() const;
-
- void setWinPageSize(int winPageSize);
- int winPageSize() const;
-
- QRect paperRect() const;
- QRect pageRect() const;
QRectF paperRect(Unit) const;
QRectF pageRect(Unit) const;
@@ -252,11 +166,6 @@ public:
void setPrintRange(PrintRange range);
PrintRange printRange() const;
- void setMargins(const Margins &m) override;
-
- void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit);
- void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const;
-
protected:
int metric(PaintDeviceMetric) const override;
void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
diff --git a/src/printsupport/kernel/qprinter_p.h b/src/printsupport/kernel/qprinter_p.h
index 37c9702c17..77dd5fb4bc 100644
--- a/src/printsupport/kernel/qprinter_p.h
+++ b/src/printsupport/kernel/qprinter_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTER_P_H
#define QPRINTER_P_H
@@ -76,12 +40,12 @@ class Q_PRINTSUPPORT_EXPORT QPrinterPrivate
public:
QPrinterPrivate(QPrinter *printer)
: pdfVersion(QPrinter::PdfVersion_1_4),
- printEngine(0),
- paintEngine(0),
- realPrintEngine(0),
- realPaintEngine(0),
+ printEngine(nullptr),
+ paintEngine(nullptr),
+ realPrintEngine(nullptr),
+ realPaintEngine(nullptr),
#if QT_CONFIG(printpreviewwidget)
- previewEngine(0),
+ previewEngine(nullptr),
#endif
q_ptr(printer),
printRange(QPrinter::AllPages),
@@ -106,6 +70,7 @@ public:
#if QT_CONFIG(printpreviewwidget)
QList<const QPicture *> previewPages() const;
void setPreviewMode(bool);
+ bool previewMode() const;
#endif
void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value);
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index 4b092dee64..59078b4df4 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qprinterinfo.h"
#include "qprinterinfo_p.h"
@@ -57,7 +21,7 @@ class QPrinterInfoPrivateDeleter
public:
static inline void cleanup(QPrinterInfoPrivate *d)
{
- if (d != shared_null)
+ if (d != &*shared_null)
delete d;
}
};
@@ -106,7 +70,7 @@ QPrinterInfo::QPrinterInfo()
Constructs a copy of \a other.
*/
QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
- : d_ptr((other.d_ptr.data() == shared_null) ? shared_null : new QPrinterInfoPrivate(*other.d_ptr))
+ : d_ptr((other.d_ptr.data() == shared_null) ? &*shared_null : new QPrinterInfoPrivate(*other.d_ptr))
{
}
@@ -313,51 +277,6 @@ QPageSize QPrinterInfo::maximumPhysicalPageSize() const
return QPageSize(d->m_printDevice.maximumPhysicalPageSize(), QString(), QPageSize::ExactMatch);
}
-#if QT_DEPRECATED_SINCE(5,3)
-/*!
- \obsolete Use supportedPageSizes() instead.
-
- Returns a list of supported paper sizes by the printer.
-
- Not all printer drivers support this query, so the list may be empty.
-
- \since 4.4
-*/
-
-QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
-{
- Q_D(const QPrinterInfo);
- QList<QPrinter::PaperSize> list;
- const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
- list.reserve(supportedPageSizes.size());
- for (const QPageSize &pageSize : supportedPageSizes)
- list.append(QPrinter::PaperSize(pageSize.id()));
- return list;
-}
-
-/*!
- \obsolete Use supportedPageSizes() instead.
-
- Returns a list of all the paper names supported by the driver with the
- corresponding size in millimeters.
-
- Not all printer drivers support this query, so the list may be empty.
-
- \since 5.1
-*/
-
-QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const
-{
- Q_D(const QPrinterInfo);
- QList<QPair<QString, QSizeF> > list;
- const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
- list.reserve(supportedPageSizes.size());
- for (const QPageSize &pageSize : supportedPageSizes)
- list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter)));
- return list;
-}
-#endif // QT_DEPRECATED_SINCE(5,3)
-
/*!
Returns a list of resolutions supported by this printer.
@@ -400,6 +319,35 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
}
/*!
+ Returns the default color mode of this printer.
+
+ \since 5.13
+*/
+
+QPrinter::ColorMode QPrinterInfo::defaultColorMode() const
+{
+ Q_D(const QPrinterInfo);
+ return QPrinter::ColorMode(d->m_printDevice.defaultColorMode());
+}
+
+/*!
+ Returns the supported color modes of this printer.
+
+ \since 5.13
+*/
+
+QList<QPrinter::ColorMode> QPrinterInfo::supportedColorModes() const
+{
+ Q_D(const QPrinterInfo);
+ QList<QPrinter::ColorMode> list;
+ const auto supportedColorModes = d->m_printDevice.supportedColorModes();
+ list.reserve(supportedColorModes.size());
+ for (QPrint::ColorMode mode : supportedColorModes)
+ list << QPrinter::ColorMode(mode);
+ return list;
+}
+
+/*!
Returns a list of all the available Printer Names on this system.
It is recommended to use this instead of availablePrinters() as
diff --git a/src/printsupport/kernel/qprinterinfo.h b/src/printsupport/kernel/qprinterinfo.h
index 8bac395ab3..f1b16e7ccb 100644
--- a/src/printsupport/kernel/qprinterinfo.h
+++ b/src/printsupport/kernel/qprinterinfo.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTERINFO_H
#define QPRINTERINFO_H
@@ -44,7 +8,6 @@
#include <QtPrintSupport/qprinter.h>
#include <QtCore/QList>
-#include <QtCore/QPair>
#include <QtGui/qpagesize.h>
QT_BEGIN_NAMESPACE
@@ -83,16 +46,14 @@ public:
QPageSize minimumPhysicalPageSize() const;
QPageSize maximumPhysicalPageSize() const;
-#if QT_DEPRECATED_SINCE(5,3)
- QT_DEPRECATED QList<QPrinter::PaperSize> supportedPaperSizes() const;
- QT_DEPRECATED QList<QPair<QString, QSizeF> > supportedSizesWithNames() const;
-#endif // QT_DEPRECATED_SINCE(5,3)
-
QList<int> supportedResolutions() const;
QPrinter::DuplexMode defaultDuplexMode() const;
QList<QPrinter::DuplexMode> supportedDuplexModes() const;
+ QPrinter::ColorMode defaultColorMode() const;
+ QList<QPrinter::ColorMode> supportedColorModes() const;
+
static QStringList availablePrinterNames();
static QList<QPrinterInfo> availablePrinters();
diff --git a/src/printsupport/kernel/qprinterinfo_p.h b/src/printsupport/kernel/qprinterinfo_p.h
index 727457a959..ef6a814468 100644
--- a/src/printsupport/kernel/qprinterinfo_p.h
+++ b/src/printsupport/kernel/qprinterinfo_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTERINFO_P_H
#define QPRINTERINFO_P_H
diff --git a/src/printsupport/kernel/qtprintsupportglobal.h b/src/printsupport/kernel/qtprintsupportglobal.h
index 67779af5a2..95f52d18f5 100644
--- a/src/printsupport/kernel/qtprintsupportglobal.h
+++ b/src/printsupport/kernel/qtprintsupportglobal.h
@@ -1,60 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTPRINTSUPPORTGLOBAL_H
#define QTPRINTSUPPORTGLOBAL_H
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtPrintSupport/qtprintsupport-config.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_STATIC
-# if defined(QT_BUILD_PRINTSUPPORT_LIB)
-# define Q_PRINTSUPPORT_EXPORT Q_DECL_EXPORT
-# else
-# define Q_PRINTSUPPORT_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define Q_PRINTSUPPORT_EXPORT
-#endif
-
-QT_END_NAMESPACE
+#include <QtPrintSupport/qtprintsupportexports.h>
#endif // QTPRINTSUPPORTGLOBAL_H
diff --git a/src/printsupport/kernel/qtprintsupportglobal_p.h b/src/printsupport/kernel/qtprintsupportglobal_p.h
index 0623a08f1c..53afe86e56 100644
--- a/src/printsupport/kernel/qtprintsupportglobal_p.h
+++ b/src/printsupport/kernel/qtprintsupportglobal_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPrintSupport module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTPRINTSUPPORTGLOBAL_P_H
#define QTPRINTSUPPORTGLOBAL_P_H