| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qprintdevice.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2014 John Layt <jlayt@kde.org> | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtPrintSupport module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qprintdevice_p.h" | - | ||||||||||||
| 35 | #include "qplatformprintdevice.h" | - | ||||||||||||
| 36 | - | |||||||||||||
| 37 | #include <private/qdebug_p.h> | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 40 | - | |||||||||||||
| 41 | #ifndef QT_NO_PRINTER | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | QPrintDevice::QPrintDevice() | - | ||||||||||||
| 44 | : d(new QPlatformPrintDevice()) | - | ||||||||||||
| 45 | { | - | ||||||||||||
| 46 | } executed 144 times by 3 tests: end of blockExecuted by:
| 144 | ||||||||||||
| 47 | - | |||||||||||||
| 48 | QPrintDevice::QPrintDevice(const QString &id) | - | ||||||||||||
| 49 | : d(new QPlatformPrintDevice(id)) | - | ||||||||||||
| 50 | { | - | ||||||||||||
| 51 | } never executed: end of block | 0 | ||||||||||||
| 52 | - | |||||||||||||
| 53 | QPrintDevice::QPrintDevice(QPlatformPrintDevice *dd) | - | ||||||||||||
| 54 | : d(dd) | - | ||||||||||||
| 55 | { | - | ||||||||||||
| 56 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||
| 57 | - | |||||||||||||
| 58 | QPrintDevice::QPrintDevice(const QPrintDevice &other) | - | ||||||||||||
| 59 | : d(other.d) | - | ||||||||||||
| 60 | { | - | ||||||||||||
| 61 | } executed 136 times by 2 tests: end of blockExecuted by:
| 136 | ||||||||||||
| 62 | - | |||||||||||||
| 63 | QPrintDevice::~QPrintDevice() | - | ||||||||||||
| 64 | { | - | ||||||||||||
| 65 | } | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | QPrintDevice &QPrintDevice::operator=(const QPrintDevice &other) | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 | d = other.d; | - | ||||||||||||
| 70 | return *this; never executed: return *this; | 0 | ||||||||||||
| 71 | } | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | bool QPrintDevice::operator==(const QPrintDevice &other) const | - | ||||||||||||
| 74 | { | - | ||||||||||||
| 75 | if (d && other.d)
| 0 | ||||||||||||
| 76 | return d->id() == other.d->id(); never executed: return d->id() == other.d->id(); | 0 | ||||||||||||
| 77 | return d == other.d; never executed: return d == other.d; | 0 | ||||||||||||
| 78 | } | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | QString QPrintDevice::id() const | - | ||||||||||||
| 81 | { | - | ||||||||||||
| 82 | return isValid() ? d->id() : QString(); executed 6 times by 2 tests: return isValid() ? d->id() : QString();Executed by:
| 0-6 | ||||||||||||
| 83 | } | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | QString QPrintDevice::name() const | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 | return isValid() ? d->name() : QString(); never executed: return isValid() ? d->name() : QString();
| 0 | ||||||||||||
| 88 | } | - | ||||||||||||
| 89 | - | |||||||||||||
| 90 | QString QPrintDevice::location() const | - | ||||||||||||
| 91 | { | - | ||||||||||||
| 92 | return isValid() ? d->location() : QString(); executed 4 times by 1 test: return isValid() ? d->location() : QString();Executed by:
| 0-4 | ||||||||||||
| 93 | } | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | QString QPrintDevice::makeAndModel() const | - | ||||||||||||
| 96 | { | - | ||||||||||||
| 97 | return isValid() ? d->makeAndModel() : QString(); executed 4 times by 1 test: return isValid() ? d->makeAndModel() : QString();Executed by:
| 0-4 | ||||||||||||
| 98 | } | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | bool QPrintDevice::isValid() const | - | ||||||||||||
| 101 | { | - | ||||||||||||
| 102 | return d && d->isValid(); executed 285 times by 3 tests: return d && d->isValid();Executed by:
| 0-285 | ||||||||||||
| 103 | } | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | bool QPrintDevice::isDefault() const | - | ||||||||||||
| 106 | { | - | ||||||||||||
| 107 | return isValid() && d->isDefault(); never executed: return isValid() && d->isDefault();
| 0 | ||||||||||||
| 108 | } | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | bool QPrintDevice::isRemote() const | - | ||||||||||||
| 111 | { | - | ||||||||||||
| 112 | return isValid() && d->isRemote(); never executed: return isValid() && d->isRemote();
| 0 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | QPrint::DeviceState QPrintDevice::state() const | - | ||||||||||||
| 116 | { | - | ||||||||||||
| 117 | return isValid() ? d->state() : QPrint::Error; never executed: return isValid() ? d->state() : QPrint::Error;
| 0 | ||||||||||||
| 118 | } | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | bool QPrintDevice::isValidPageLayout(const QPageLayout &layout, int resolution) const | - | ||||||||||||
| 121 | { | - | ||||||||||||
| 122 | return isValid() && d->isValidPageLayout(layout, resolution); never executed: return isValid() && d->isValidPageLayout(layout, resolution);
| 0 | ||||||||||||
| 123 | } | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | bool QPrintDevice::supportsMultipleCopies() const | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | return isValid() && d->supportsMultipleCopies(); never executed: return isValid() && d->supportsMultipleCopies();
| 0 | ||||||||||||
| 128 | } | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | bool QPrintDevice::supportsCollateCopies() const | - | ||||||||||||
| 131 | { | - | ||||||||||||
| 132 | return isValid() && d->supportsCollateCopies(); never executed: return isValid() && d->supportsCollateCopies();
| 0 | ||||||||||||
| 133 | } | - | ||||||||||||
| 134 | - | |||||||||||||
| 135 | QPageSize QPrintDevice::defaultPageSize() const | - | ||||||||||||
| 136 | { | - | ||||||||||||
| 137 | return isValid() ? d->defaultPageSize() : QPageSize(); never executed: return isValid() ? d->defaultPageSize() : QPageSize();
| 0 | ||||||||||||
| 138 | } | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | QList<QPageSize> QPrintDevice::supportedPageSizes() const | - | ||||||||||||
| 141 | { | - | ||||||||||||
| 142 | return isValid() ? d->supportedPageSizes() : QList<QPageSize>(); executed 2 times by 1 test: return isValid() ? d->supportedPageSizes() : QList<QPageSize>();Executed by:
| 0-2 | ||||||||||||
| 143 | } | - | ||||||||||||
| 144 | - | |||||||||||||
| 145 | QPageSize QPrintDevice::supportedPageSize(const QPageSize &pageSize) const | - | ||||||||||||
| 146 | { | - | ||||||||||||
| 147 | return isValid() ? d->supportedPageSize(pageSize) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pageSize) : QPageSize();
| 0 | ||||||||||||
| 148 | } | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | QPageSize QPrintDevice::supportedPageSize(QPageSize::PageSizeId pageSizeId) const | - | ||||||||||||
| 151 | { | - | ||||||||||||
| 152 | return isValid() ? d->supportedPageSize(pageSizeId) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pageSizeId) : QPageSize();
| 0 | ||||||||||||
| 153 | } | - | ||||||||||||
| 154 | - | |||||||||||||
| 155 | QPageSize QPrintDevice::supportedPageSize(const QString &pageName) const | - | ||||||||||||
| 156 | { | - | ||||||||||||
| 157 | return isValid() ? d->supportedPageSize(pageName) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pageName) : QPageSize();
| 0 | ||||||||||||
| 158 | } | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | QPageSize QPrintDevice::supportedPageSize(const QSize &pointSize) const | - | ||||||||||||
| 161 | { | - | ||||||||||||
| 162 | return isValid() ? d->supportedPageSize(pointSize) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pointSize) : QPageSize();
| 0 | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | QPageSize QPrintDevice::supportedPageSize(const QSizeF &size, QPageSize::Unit units) const | - | ||||||||||||
| 166 | { | - | ||||||||||||
| 167 | return isValid() ? d->supportedPageSize(size, units) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(size, units) : QPageSize();
| 0 | ||||||||||||
| 168 | } | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 | bool QPrintDevice::supportsCustomPageSizes() const | - | ||||||||||||
| 171 | { | - | ||||||||||||
| 172 | return isValid() && d->supportsCustomPageSizes(); never executed: return isValid() && d->supportsCustomPageSizes();
| 0 | ||||||||||||
| 173 | } | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | QSize QPrintDevice::minimumPhysicalPageSize() const | - | ||||||||||||
| 176 | { | - | ||||||||||||
| 177 | return isValid() ? d->minimumPhysicalPageSize() : QSize(); never executed: return isValid() ? d->minimumPhysicalPageSize() : QSize();
| 0 | ||||||||||||
| 178 | } | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | QSize QPrintDevice::maximumPhysicalPageSize() const | - | ||||||||||||
| 181 | { | - | ||||||||||||
| 182 | return isValid() ? d->maximumPhysicalPageSize() : QSize(); never executed: return isValid() ? d->maximumPhysicalPageSize() : QSize();
| 0 | ||||||||||||
| 183 | } | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | QMarginsF QPrintDevice::printableMargins(const QPageSize &pageSize, | - | ||||||||||||
| 186 | QPageLayout::Orientation orientation, | - | ||||||||||||
| 187 | int resolution) const | - | ||||||||||||
| 188 | { | - | ||||||||||||
| 189 | return isValid() ? d->printableMargins(pageSize, orientation, resolution) : QMarginsF(); never executed: return isValid() ? d->printableMargins(pageSize, orientation, resolution) : QMarginsF();
| 0 | ||||||||||||
| 190 | } | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | int QPrintDevice::defaultResolution() const | - | ||||||||||||
| 193 | { | - | ||||||||||||
| 194 | return isValid() ? d->defaultResolution() : 0; never executed: return isValid() ? d->defaultResolution() : 0;
| 0 | ||||||||||||
| 195 | } | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | QList<int> QPrintDevice::supportedResolutions() const | - | ||||||||||||
| 198 | { | - | ||||||||||||
| 199 | return isValid() ? d->supportedResolutions() : QList<int>(); never executed: return isValid() ? d->supportedResolutions() : QList<int>();
| 0 | ||||||||||||
| 200 | } | - | ||||||||||||
| 201 | - | |||||||||||||
| 202 | QPrint::InputSlot QPrintDevice::defaultInputSlot() const | - | ||||||||||||
| 203 | { | - | ||||||||||||
| 204 | return isValid() ? d->defaultInputSlot() : QPrint::InputSlot(); never executed: return isValid() ? d->defaultInputSlot() : QPrint::InputSlot();
| 0 | ||||||||||||
| 205 | } | - | ||||||||||||
| 206 | - | |||||||||||||
| 207 | QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const | - | ||||||||||||
| 208 | { | - | ||||||||||||
| 209 | return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>(); never executed: return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>();
| 0 | ||||||||||||
| 210 | } | - | ||||||||||||
| 211 | - | |||||||||||||
| 212 | QPrint::OutputBin QPrintDevice::defaultOutputBin() const | - | ||||||||||||
| 213 | { | - | ||||||||||||
| 214 | return isValid() ? d->defaultOutputBin() : QPrint::OutputBin(); never executed: return isValid() ? d->defaultOutputBin() : QPrint::OutputBin();
| 0 | ||||||||||||
| 215 | } | - | ||||||||||||
| 216 | - | |||||||||||||
| 217 | QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const | - | ||||||||||||
| 218 | { | - | ||||||||||||
| 219 | return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>(); never executed: return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>();
| 0 | ||||||||||||
| 220 | } | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const | - | ||||||||||||
| 223 | { | - | ||||||||||||
| 224 | return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone; never executed: return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone;
| 0 | ||||||||||||
| 225 | } | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const | - | ||||||||||||
| 228 | { | - | ||||||||||||
| 229 | return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>(); never executed: return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>();
| 0 | ||||||||||||
| 230 | } | - | ||||||||||||
| 231 | - | |||||||||||||
| 232 | QPrint::ColorMode QPrintDevice::defaultColorMode() const | - | ||||||||||||
| 233 | { | - | ||||||||||||
| 234 | return isValid() ? d->defaultColorMode() : QPrint::GrayScale; never executed: return isValid() ? d->defaultColorMode() : QPrint::GrayScale;
| 0 | ||||||||||||
| 235 | } | - | ||||||||||||
| 236 | - | |||||||||||||
| 237 | QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const | - | ||||||||||||
| 238 | { | - | ||||||||||||
| 239 | return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>(); never executed: return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>();
| 0 | ||||||||||||
| 240 | } | - | ||||||||||||
| 241 | - | |||||||||||||
| 242 | #ifndef QT_NO_MIMETYPE | - | ||||||||||||
| 243 | QList<QMimeType> QPrintDevice::supportedMimeTypes() const | - | ||||||||||||
| 244 | { | - | ||||||||||||
| 245 | return isValid() ? d->supportedMimeTypes() : QList<QMimeType>(); never executed: return isValid() ? d->supportedMimeTypes() : QList<QMimeType>();
| 0 | ||||||||||||
| 246 | } | - | ||||||||||||
| 247 | #endif // QT_NO_MIMETYPE | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 | # ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 250 | void QPrintDevice::format(QDebug debug) const | - | ||||||||||||
| 251 | { | - | ||||||||||||
| 252 | QDebugStateSaver saver(debug); | - | ||||||||||||
| 253 | debug.noquote(); | - | ||||||||||||
| 254 | debug.nospace(); | - | ||||||||||||
| 255 | if (isValid()) {
| 0 | ||||||||||||
| 256 | const QString deviceId = id(); | - | ||||||||||||
| 257 | const QString deviceName = name(); | - | ||||||||||||
| 258 | debug << "id=\"" << deviceId << "\", state=" << state(); | - | ||||||||||||
| 259 | if (!deviceName.isEmpty() && deviceName != deviceId)
| 0 | ||||||||||||
| 260 | debug << ", name=\"" << deviceName << '"'; never executed: debug << ", name=\"" << deviceName << '"'; | 0 | ||||||||||||
| 261 | if (!location().isEmpty())
| 0 | ||||||||||||
| 262 | debug << ", location=\"" << location() << '"'; never executed: debug << ", location=\"" << location() << '"'; | 0 | ||||||||||||
| 263 | debug << ", makeAndModel=\"" << makeAndModel() << '"'; | - | ||||||||||||
| 264 | if (isDefault())
| 0 | ||||||||||||
| 265 | debug << ", default"; never executed: debug << ", default"; | 0 | ||||||||||||
| 266 | if (isRemote())
| 0 | ||||||||||||
| 267 | debug << ", remote"; never executed: debug << ", remote"; | 0 | ||||||||||||
| 268 | debug << ", defaultPageSize=" << defaultPageSize(); | - | ||||||||||||
| 269 | if (supportsCustomPageSizes())
| 0 | ||||||||||||
| 270 | debug << ", supportsCustomPageSizes"; never executed: debug << ", supportsCustomPageSizes"; | 0 | ||||||||||||
| 271 | debug << ", physicalPageSize=("; | - | ||||||||||||
| 272 | QtDebugUtils::formatQSize(debug, minimumPhysicalPageSize()); | - | ||||||||||||
| 273 | debug << ")..("; | - | ||||||||||||
| 274 | QtDebugUtils::formatQSize(debug, maximumPhysicalPageSize()); | - | ||||||||||||
| 275 | debug << "), defaultResolution=" << defaultResolution() | - | ||||||||||||
| 276 | << ", defaultDuplexMode=" << defaultDuplexMode() | - | ||||||||||||
| 277 | << ", defaultColorMode="<< defaultColorMode(); | - | ||||||||||||
| 278 | # ifndef QT_NO_MIMETYPE | - | ||||||||||||
| 279 | const QList<QMimeType> mimeTypes = supportedMimeTypes(); | - | ||||||||||||
| 280 | if (const int mimeTypeCount = mimeTypes.size()) {
| 0 | ||||||||||||
| 281 | debug << ", supportedMimeTypes=("; | - | ||||||||||||
| 282 | for (int i = 0; i < mimeTypeCount; ++i)
| 0 | ||||||||||||
| 283 | debug << " \"" << mimeTypes.at(i).name() << '"'; never executed: debug << " \"" << mimeTypes.at(i).name() << '"'; | 0 | ||||||||||||
| 284 | debug << ')'; | - | ||||||||||||
| 285 | } never executed: end of block | 0 | ||||||||||||
| 286 | # endif // !QT_NO_MIMETYPE | - | ||||||||||||
| 287 | } else { never executed: end of block | 0 | ||||||||||||
| 288 | debug << "null"; | - | ||||||||||||
| 289 | } never executed: end of block | 0 | ||||||||||||
| 290 | } | - | ||||||||||||
| 291 | - | |||||||||||||
| 292 | QDebug operator<<(QDebug debug, const QPrintDevice &p) | - | ||||||||||||
| 293 | { | - | ||||||||||||
| 294 | QDebugStateSaver saver(debug); | - | ||||||||||||
| 295 | debug.nospace(); | - | ||||||||||||
| 296 | debug << "QPrintDevice("; | - | ||||||||||||
| 297 | p.format(debug); | - | ||||||||||||
| 298 | debug << ')'; | - | ||||||||||||
| 299 | return debug; never executed: return debug; | 0 | ||||||||||||
| 300 | } | - | ||||||||||||
| 301 | # endif // QT_NO_DEBUG_STREAM | - | ||||||||||||
| 302 | #endif // QT_NO_PRINTER | - | ||||||||||||
| 303 | - | |||||||||||||
| 304 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |