| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qprintengine_pdf.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtGui 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 "qprintengine_pdf_p.h" | - | ||||||
| 35 | - | |||||||
| 36 | #ifndef QT_NO_PRINTER | - | ||||||
| 37 | - | |||||||
| 38 | #include <qiodevice.h> | - | ||||||
| 39 | #include <qfile.h> | - | ||||||
| 40 | #include <qdebug.h> | - | ||||||
| 41 | #include <qbuffer.h> | - | ||||||
| 42 | #include "qprinterinfo.h" | - | ||||||
| 43 | #include <QtGui/qpagelayout.h> | - | ||||||
| 44 | - | |||||||
| 45 | #ifdef Q_OS_UNIX | - | ||||||
| 46 | #include "private/qcore_unix_p.h" // overrides QT_OPEN | - | ||||||
| 47 | #endif | - | ||||||
| 48 | - | |||||||
| 49 | #ifdef Q_OS_WIN | - | ||||||
| 50 | #include <io.h> // _close. | - | ||||||
| 51 | #endif | - | ||||||
| 52 | - | |||||||
| 53 | QT_BEGIN_NAMESPACE | - | ||||||
| 54 | - | |||||||
| 55 | QPdfPrintEngine::QPdfPrintEngine(QPrinter::PrinterMode m) | - | ||||||
| 56 | : QPdfEngine(*new QPdfPrintEnginePrivate(m)) | - | ||||||
| 57 | { | - | ||||||
| 58 | state = QPrinter::Idle; | - | ||||||
| 59 | } executed 128 times by 2 tests: end of blockExecuted by:
| 128 | ||||||
| 60 | - | |||||||
| 61 | QPdfPrintEngine::QPdfPrintEngine(QPdfPrintEnginePrivate &p) | - | ||||||
| 62 | : QPdfEngine(p) | - | ||||||
| 63 | { | - | ||||||
| 64 | state = QPrinter::Idle; | - | ||||||
| 65 | } never executed: end of block | 0 | ||||||
| 66 | - | |||||||
| 67 | QPdfPrintEngine::~QPdfPrintEngine() | - | ||||||
| 68 | { | - | ||||||
| 69 | } | - | ||||||
| 70 | - | |||||||
| 71 | bool QPdfPrintEngine::begin(QPaintDevice *pdev) | - | ||||||
| 72 | { | - | ||||||
| 73 | Q_D(QPdfPrintEngine); | - | ||||||
| 74 | - | |||||||
| 75 | if (!d->openPrintDevice()) {
| 1-20 | ||||||
| 76 | state = QPrinter::Error; | - | ||||||
| 77 | return false; executed 1 time by 1 test: return false;Executed by:
| 1 | ||||||
| 78 | } | - | ||||||
| 79 | state = QPrinter::Active; | - | ||||||
| 80 | - | |||||||
| 81 | return QPdfEngine::begin(pdev); executed 20 times by 1 test: return QPdfEngine::begin(pdev);Executed by:
| 20 | ||||||
| 82 | } | - | ||||||
| 83 | - | |||||||
| 84 | bool QPdfPrintEngine::end() | - | ||||||
| 85 | { | - | ||||||
| 86 | Q_D(QPdfPrintEngine); | - | ||||||
| 87 | - | |||||||
| 88 | QPdfEngine::end(); | - | ||||||
| 89 | - | |||||||
| 90 | d->closePrintDevice(); | - | ||||||
| 91 | state = QPrinter::Idle; | - | ||||||
| 92 | - | |||||||
| 93 | return true; executed 20 times by 1 test: return true;Executed by:
| 20 | ||||||
| 94 | } | - | ||||||
| 95 | - | |||||||
| 96 | bool QPdfPrintEngine::newPage() | - | ||||||
| 97 | { | - | ||||||
| 98 | return QPdfEngine::newPage(); never executed: return QPdfEngine::newPage(); | 0 | ||||||
| 99 | } | - | ||||||
| 100 | - | |||||||
| 101 | int QPdfPrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const | - | ||||||
| 102 | { | - | ||||||
| 103 | return QPdfEngine::metric(m); executed 193 times by 1 test: return QPdfEngine::metric(m);Executed by:
| 193 | ||||||
| 104 | } | - | ||||||
| 105 | - | |||||||
| 106 | void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value) | - | ||||||
| 107 | { | - | ||||||
| 108 | Q_D(QPdfPrintEngine); | - | ||||||
| 109 | - | |||||||
| 110 | switch (int(key)) { | - | ||||||
| 111 | - | |||||||
| 112 | // The following keys are properties or derived values and so cannot be set | - | ||||||
| 113 | case PPK_PageRect: never executed: case PPK_PageRect: | 0 | ||||||
| 114 | break; never executed: break; | 0 | ||||||
| 115 | case PPK_PaperRect: never executed: case PPK_PaperRect: | 0 | ||||||
| 116 | break; never executed: break; | 0 | ||||||
| 117 | case PPK_PaperSources: never executed: case PPK_PaperSources: | 0 | ||||||
| 118 | break; never executed: break; | 0 | ||||||
| 119 | case PPK_SupportsMultipleCopies: never executed: case PPK_SupportsMultipleCopies: | 0 | ||||||
| 120 | break; never executed: break; | 0 | ||||||
| 121 | case PPK_SupportedResolutions: never executed: case PPK_SupportedResolutions: | 0 | ||||||
| 122 | break; never executed: break; | 0 | ||||||
| 123 | - | |||||||
| 124 | // The following keys are settings that are unsupported by the PDF PrintEngine | - | ||||||
| 125 | case PPK_CustomBase: never executed: case PPK_CustomBase: | 0 | ||||||
| 126 | break; never executed: break; | 0 | ||||||
| 127 | - | |||||||
| 128 | // The following keys are properties and settings that are supported by the PDF PrintEngine | - | ||||||
| 129 | case PPK_CollateCopies: executed 1 time by 1 test: case PPK_CollateCopies:Executed by:
| 1 | ||||||
| 130 | d->collate = value.toBool(); | - | ||||||
| 131 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 132 | case PPK_ColorMode: executed 1 time by 1 test: case PPK_ColorMode:Executed by:
| 1 | ||||||
| 133 | d->grayscale = (QPrinter::ColorMode(value.toInt()) == QPrinter::GrayScale); | - | ||||||
| 134 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 135 | case PPK_Creator: executed 1 time by 1 test: case PPK_Creator:Executed by:
| 1 | ||||||
| 136 | d->creator = value.toString(); | - | ||||||
| 137 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 138 | case PPK_DocumentName: executed 2 times by 1 test: case PPK_DocumentName:Executed by:
| 2 | ||||||
| 139 | d->title = value.toString(); | - | ||||||
| 140 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 141 | case PPK_FullPage: executed 19 times by 1 test: case PPK_FullPage:Executed by:
| 19 | ||||||
| 142 | if (value.toBool())
| 5-14 | ||||||
| 143 | d->m_pageLayout.setMode(QPageLayout::FullPageMode); executed 14 times by 1 test: d->m_pageLayout.setMode(QPageLayout::FullPageMode);Executed by:
| 14 | ||||||
| 144 | else | - | ||||||
| 145 | d->m_pageLayout.setMode(QPageLayout::StandardMode); executed 5 times by 1 test: d->m_pageLayout.setMode(QPageLayout::StandardMode);Executed by:
| 5 | ||||||
| 146 | break; executed 19 times by 1 test: break;Executed by:
| 19 | ||||||
| 147 | case PPK_CopyCount: // fallthrough executed 1 time by 1 test: case PPK_CopyCount:Executed by:
| 1 | ||||||
| 148 | case PPK_NumberOfCopies: executed 1 time by 1 test: case PPK_NumberOfCopies:Executed by:
| 1 | ||||||
| 149 | d->copies = value.toInt(); | - | ||||||
| 150 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 151 | case PPK_Orientation: executed 48 times by 1 test: case PPK_Orientation:Executed by:
| 48 | ||||||
| 152 | d->m_pageLayout.setOrientation(QPageLayout::Orientation(value.toInt())); | - | ||||||
| 153 | break; executed 48 times by 1 test: break;Executed by:
| 48 | ||||||
| 154 | case PPK_OutputFileName: executed 39 times by 1 test: case PPK_OutputFileName:Executed by:
| 39 | ||||||
| 155 | d->outputFileName = value.toString(); | - | ||||||
| 156 | break; executed 39 times by 1 test: break;Executed by:
| 39 | ||||||
| 157 | case PPK_PageOrder: executed 1 time by 1 test: case PPK_PageOrder:Executed by:
| 1 | ||||||
| 158 | d->pageOrder = QPrinter::PageOrder(value.toInt()); | - | ||||||
| 159 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 160 | case PPK_PageSize: { never executed: case PPK_PageSize: | 0 | ||||||
| 161 | QPageSize pageSize = QPageSize(QPageSize::PageSizeId(value.toInt())); | - | ||||||
| 162 | if (pageSize.isValid())
| 0 | ||||||
| 163 | d->m_pageLayout.setPageSize(pageSize); never executed: d->m_pageLayout.setPageSize(pageSize); | 0 | ||||||
| 164 | break; never executed: break; | 0 | ||||||
| 165 | } | - | ||||||
| 166 | case PPK_PaperName: { never executed: case PPK_PaperName: | 0 | ||||||
| 167 | QString name = value.toString(); | - | ||||||
| 168 | for (int i = 0; i <= QPageSize::LastPageSize; ++i) {
| 0 | ||||||
| 169 | QPageSize pageSize = QPageSize(QPageSize::PageSizeId(i)); | - | ||||||
| 170 | if (name == pageSize.name()) {
| 0 | ||||||
| 171 | d->m_pageLayout.setPageSize(pageSize); | - | ||||||
| 172 | break; never executed: break; | 0 | ||||||
| 173 | } | - | ||||||
| 174 | } never executed: end of block | 0 | ||||||
| 175 | break; never executed: break; | 0 | ||||||
| 176 | } | - | ||||||
| 177 | case PPK_WindowsPageSize: executed 1 time by 1 test: case PPK_WindowsPageSize:Executed by:
| 1 | ||||||
| 178 | d->m_pageLayout.setPageSize(QPageSize(QPageSize::id(value.toInt()))); | - | ||||||
| 179 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 180 | case PPK_PaperSource: executed 1 time by 1 test: case PPK_PaperSource:Executed by:
| 1 | ||||||
| 181 | d->paperSource = QPrinter::PaperSource(value.toInt()); | - | ||||||
| 182 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 183 | case PPK_PrinterName: executed 128 times by 2 tests: case PPK_PrinterName:Executed by:
| 128 | ||||||
| 184 | d->printerName = value.toString(); | - | ||||||
| 185 | break; executed 128 times by 2 tests: break;Executed by:
| 128 | ||||||
| 186 | case PPK_PrinterProgram: executed 1 time by 1 test: case PPK_PrinterProgram:Executed by:
| 1 | ||||||
| 187 | d->printProgram = value.toString(); | - | ||||||
| 188 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 189 | case PPK_Resolution: executed 27 times by 1 test: case PPK_Resolution:Executed by:
| 27 | ||||||
| 190 | d->resolution = value.toInt(); | - | ||||||
| 191 | break; executed 27 times by 1 test: break;Executed by:
| 27 | ||||||
| 192 | case PPK_SelectionOption: executed 1 time by 1 test: case PPK_SelectionOption:Executed by:
| 1 | ||||||
| 193 | d->selectionOption = value.toString(); | - | ||||||
| 194 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 195 | case PPK_FontEmbedding: executed 1 time by 1 test: case PPK_FontEmbedding:Executed by:
| 1 | ||||||
| 196 | d->embedFonts = value.toBool(); | - | ||||||
| 197 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 198 | case PPK_Duplex: executed 2 times by 1 test: case PPK_Duplex:Executed by:
| 2 | ||||||
| 199 | d->duplex = static_cast<QPrint::DuplexMode>(value.toInt()); | - | ||||||
| 200 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 201 | case PPK_CustomPaperSize: never executed: case PPK_CustomPaperSize: | 0 | ||||||
| 202 | d->m_pageLayout.setPageSize(QPageSize(value.toSizeF(), QPageSize::Point)); | - | ||||||
| 203 | break; never executed: break; | 0 | ||||||
| 204 | case PPK_PageMargins: { never executed: case PPK_PageMargins: | 0 | ||||||
| 205 | QList<QVariant> margins(value.toList()); | - | ||||||
| 206 | Q_ASSERT(margins.size() == 4); | - | ||||||
| 207 | d->m_pageLayout.setUnits(QPageLayout::Point); | - | ||||||
| 208 | d->m_pageLayout.setMargins(QMarginsF(margins.at(0).toReal(), margins.at(1).toReal(), | - | ||||||
| 209 | margins.at(2).toReal(), margins.at(3).toReal())); | - | ||||||
| 210 | break; never executed: break; | 0 | ||||||
| 211 | } | - | ||||||
| 212 | case PPK_QPageSize: { executed 47 times by 1 test: case PPK_QPageSize:Executed by:
| 47 | ||||||
| 213 | QPageSize pageSize = value.value<QPageSize>(); | - | ||||||
| 214 | if (pageSize.isValid())
| 0-47 | ||||||
| 215 | d->m_pageLayout.setPageSize(pageSize); executed 47 times by 1 test: d->m_pageLayout.setPageSize(pageSize);Executed by:
| 47 | ||||||
| 216 | break; executed 47 times by 1 test: break;Executed by:
| 47 | ||||||
| 217 | } | - | ||||||
| 218 | case PPK_QPageMargins: { executed 13 times by 1 test: case PPK_QPageMargins:Executed by:
| 13 | ||||||
| 219 | QPair<QMarginsF, QPageLayout::Unit> pair = value.value<QPair<QMarginsF, QPageLayout::Unit> >(); | - | ||||||
| 220 | d->m_pageLayout.setUnits(pair.second); | - | ||||||
| 221 | d->m_pageLayout.setMargins(pair.first); | - | ||||||
| 222 | break; executed 13 times by 1 test: break;Executed by:
| 13 | ||||||
| 223 | } | - | ||||||
| 224 | case PPK_QPageLayout: { never executed: case PPK_QPageLayout: | 0 | ||||||
| 225 | QPageLayout pageLayout = value.value<QPageLayout>(); | - | ||||||
| 226 | if (pageLayout.isValid())
| 0 | ||||||
| 227 | d->m_pageLayout = pageLayout; never executed: d->m_pageLayout = pageLayout; | 0 | ||||||
| 228 | break; never executed: break; | 0 | ||||||
| 229 | } | - | ||||||
| 230 | // No default so that compiler will complain if new keys added and not handled in this engine | - | ||||||
| 231 | } | - | ||||||
| 232 | } executed 336 times by 2 tests: end of blockExecuted by:
| 336 | ||||||
| 233 | - | |||||||
| 234 | QVariant QPdfPrintEngine::property(PrintEnginePropertyKey key) const | - | ||||||
| 235 | { | - | ||||||
| 236 | Q_D(const QPdfPrintEngine); | - | ||||||
| 237 | - | |||||||
| 238 | QVariant ret; | - | ||||||
| 239 | switch (int(key)) { | - | ||||||
| 240 | - | |||||||
| 241 | // The following keys are settings that are unsupported by the PDF PrintEngine | - | ||||||
| 242 | // Return sensible default values to ensure consistent behavior across platforms | - | ||||||
| 243 | case PPK_CustomBase: never executed: case PPK_CustomBase: | 0 | ||||||
| 244 | // Special case, leave null | - | ||||||
| 245 | break; never executed: break; | 0 | ||||||
| 246 | - | |||||||
| 247 | // The following keys are properties and settings that are supported by the PDF PrintEngine | - | ||||||
| 248 | case PPK_CollateCopies: executed 6 times by 1 test: case PPK_CollateCopies:Executed by:
| 6 | ||||||
| 249 | ret = d->collate; | - | ||||||
| 250 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||
| 251 | case PPK_ColorMode: executed 6 times by 1 test: case PPK_ColorMode:Executed by:
| 6 | ||||||
| 252 | ret = d->grayscale ? QPrinter::GrayScale : QPrinter::Color;
| 1-5 | ||||||
| 253 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||
| 254 | case PPK_Creator: executed 2 times by 1 test: case PPK_Creator:Executed by:
| 2 | ||||||
| 255 | ret = d->creator; | - | ||||||
| 256 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 257 | case PPK_DocumentName: executed 6 times by 1 test: case PPK_DocumentName:Executed by:
| 6 | ||||||
| 258 | ret = d->title; | - | ||||||
| 259 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||
| 260 | case PPK_FullPage: executed 3 times by 1 test: case PPK_FullPage:Executed by:
| 3 | ||||||
| 261 | ret = d->m_pageLayout.mode() == QPageLayout::FullPageMode; | - | ||||||
| 262 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||
| 263 | case PPK_CopyCount: executed 10 times by 1 test: case PPK_CopyCount:Executed by:
| 10 | ||||||
| 264 | ret = d->copies; | - | ||||||
| 265 | break; executed 10 times by 1 test: break;Executed by:
| 10 | ||||||
| 266 | case PPK_SupportsMultipleCopies: executed 1 time by 1 test: case PPK_SupportsMultipleCopies:Executed by:
| 1 | ||||||
| 267 | ret = false; | - | ||||||
| 268 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 269 | case PPK_NumberOfCopies: executed 3 times by 1 test: case PPK_NumberOfCopies:Executed by:
| 3 | ||||||
| 270 | ret = d->copies; | - | ||||||
| 271 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||
| 272 | case PPK_Orientation: never executed: case PPK_Orientation: | 0 | ||||||
| 273 | ret = d->m_pageLayout.orientation(); | - | ||||||
| 274 | break; never executed: break; | 0 | ||||||
| 275 | case PPK_OutputFileName: executed 5 times by 1 test: case PPK_OutputFileName:Executed by:
| 5 | ||||||
| 276 | ret = d->outputFileName; | - | ||||||
| 277 | break; executed 5 times by 1 test: break;Executed by:
| 5 | ||||||
| 278 | case PPK_PageOrder: executed 6 times by 1 test: case PPK_PageOrder:Executed by:
| 6 | ||||||
| 279 | ret = d->pageOrder; | - | ||||||
| 280 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||
| 281 | case PPK_PageSize: never executed: case PPK_PageSize: | 0 | ||||||
| 282 | ret = d->m_pageLayout.pageSize().id(); | - | ||||||
| 283 | break; never executed: break; | 0 | ||||||
| 284 | case PPK_PaperName: never executed: case PPK_PaperName: | 0 | ||||||
| 285 | ret = d->m_pageLayout.pageSize().name(); | - | ||||||
| 286 | break; never executed: break; | 0 | ||||||
| 287 | case PPK_WindowsPageSize: executed 2 times by 1 test: case PPK_WindowsPageSize:Executed by:
| 2 | ||||||
| 288 | ret = d->m_pageLayout.pageSize().windowsId(); | - | ||||||
| 289 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 290 | case PPK_PaperSource: executed 2 times by 1 test: case PPK_PaperSource:Executed by:
| 2 | ||||||
| 291 | ret = d->paperSource; | - | ||||||
| 292 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 293 | case PPK_PrinterName: executed 15 times by 1 test: case PPK_PrinterName:Executed by:
| 15 | ||||||
| 294 | ret = d->printerName; | - | ||||||
| 295 | break; executed 15 times by 1 test: break;Executed by:
| 15 | ||||||
| 296 | case PPK_PrinterProgram: executed 2 times by 1 test: case PPK_PrinterProgram:Executed by:
| 2 | ||||||
| 297 | ret = d->printProgram; | - | ||||||
| 298 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 299 | case PPK_Resolution: executed 110 times by 1 test: case PPK_Resolution:Executed by:
| 110 | ||||||
| 300 | ret = d->resolution; | - | ||||||
| 301 | break; executed 110 times by 1 test: break;Executed by:
| 110 | ||||||
| 302 | case PPK_SupportedResolutions: executed 1 time by 1 test: case PPK_SupportedResolutions:Executed by:
| 1 | ||||||
| 303 | ret = QList<QVariant>() << 72; | - | ||||||
| 304 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 305 | case PPK_PaperRect: executed 78 times by 1 test: case PPK_PaperRect:Executed by:
| 78 | ||||||
| 306 | ret = d->m_pageLayout.fullRectPixels(d->resolution); | - | ||||||
| 307 | break; executed 78 times by 1 test: break;Executed by:
| 78 | ||||||
| 308 | case PPK_PageRect: executed 24 times by 1 test: case PPK_PageRect:Executed by:
| 24 | ||||||
| 309 | ret = d->m_pageLayout.paintRectPixels(d->resolution); | - | ||||||
| 310 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||
| 311 | case PPK_SelectionOption: executed 2 times by 1 test: case PPK_SelectionOption:Executed by:
| 2 | ||||||
| 312 | ret = d->selectionOption; | - | ||||||
| 313 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 314 | case PPK_FontEmbedding: executed 2 times by 1 test: case PPK_FontEmbedding:Executed by:
| 2 | ||||||
| 315 | ret = d->embedFonts; | - | ||||||
| 316 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 317 | case PPK_Duplex: executed 8 times by 1 test: case PPK_Duplex:Executed by:
| 8 | ||||||
| 318 | ret = d->duplex; | - | ||||||
| 319 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||
| 320 | case PPK_CustomPaperSize: never executed: case PPK_CustomPaperSize: | 0 | ||||||
| 321 | ret = d->m_pageLayout.fullRectPoints().size(); | - | ||||||
| 322 | break; never executed: break; | 0 | ||||||
| 323 | case PPK_PageMargins: { never executed: case PPK_PageMargins: | 0 | ||||||
| 324 | QList<QVariant> list; | - | ||||||
| 325 | QMarginsF margins = d->m_pageLayout.margins(QPageLayout::Point); | - | ||||||
| 326 | list << margins.left() << margins.top() << margins.right() << margins.bottom(); | - | ||||||
| 327 | ret = list; | - | ||||||
| 328 | break; never executed: break; | 0 | ||||||
| 329 | } | - | ||||||
| 330 | case PPK_QPageSize: never executed: case PPK_QPageSize: | 0 | ||||||
| 331 | ret.setValue(d->m_pageLayout.pageSize()); | - | ||||||
| 332 | break; never executed: break; | 0 | ||||||
| 333 | case PPK_QPageMargins: { never executed: case PPK_QPageMargins: | 0 | ||||||
| 334 | QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(d->m_pageLayout.margins(), d->m_pageLayout.units()); | - | ||||||
| 335 | ret.setValue(pair); | - | ||||||
| 336 | break; never executed: break; | 0 | ||||||
| 337 | } | - | ||||||
| 338 | case PPK_QPageLayout: executed 462 times by 1 test: case PPK_QPageLayout:Executed by:
| 462 | ||||||
| 339 | ret.setValue(d->m_pageLayout); | - | ||||||
| 340 | break; executed 462 times by 1 test: break;Executed by:
| 462 | ||||||
| 341 | // No default so that compiler will complain if new keys added and not handled in this engine | - | ||||||
| 342 | } | - | ||||||
| 343 | return ret; executed 756 times by 1 test: return ret;Executed by:
| 756 | ||||||
| 344 | } | - | ||||||
| 345 | - | |||||||
| 346 | - | |||||||
| 347 | bool QPdfPrintEnginePrivate::openPrintDevice() | - | ||||||
| 348 | { | - | ||||||
| 349 | if (outDevice)
| 0-21 | ||||||
| 350 | return false; never executed: return false; | 0 | ||||||
| 351 | - | |||||||
| 352 | if (!outputFileName.isEmpty()) {
| 0-21 | ||||||
| 353 | QFile *file = new QFile(outputFileName); | - | ||||||
| 354 | if (! file->open(QFile::WriteOnly|QFile::Truncate)) {
| 1-20 | ||||||
| 355 | delete file; | - | ||||||
| 356 | return false; executed 1 time by 1 test: return false;Executed by:
| 1 | ||||||
| 357 | } | - | ||||||
| 358 | outDevice = file; | - | ||||||
| 359 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||
| 360 | - | |||||||
| 361 | return true; executed 20 times by 1 test: return true;Executed by:
| 20 | ||||||
| 362 | } | - | ||||||
| 363 | - | |||||||
| 364 | void QPdfPrintEnginePrivate::closePrintDevice() | - | ||||||
| 365 | { | - | ||||||
| 366 | if (outDevice) {
| 0-20 | ||||||
| 367 | outDevice->close(); | - | ||||||
| 368 | if (fd >= 0)
| 0-20 | ||||||
| 369 | #if defined(Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400 | - | ||||||
| 370 | ::_close(fd); | - | ||||||
| 371 | #else | - | ||||||
| 372 | ::close(fd); never executed: ::close(fd); | 0 | ||||||
| 373 | #endif | - | ||||||
| 374 | fd = -1; | - | ||||||
| 375 | delete outDevice; | - | ||||||
| 376 | outDevice = 0; | - | ||||||
| 377 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||
| 378 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||
| 379 | - | |||||||
| 380 | - | |||||||
| 381 | - | |||||||
| 382 | QPdfPrintEnginePrivate::QPdfPrintEnginePrivate(QPrinter::PrinterMode m) | - | ||||||
| 383 | : QPdfEnginePrivate(), | - | ||||||
| 384 | duplex(QPrint::DuplexNone), | - | ||||||
| 385 | collate(true), | - | ||||||
| 386 | copies(1), | - | ||||||
| 387 | pageOrder(QPrinter::FirstPageFirst), | - | ||||||
| 388 | paperSource(QPrinter::Auto), | - | ||||||
| 389 | fd(-1) | - | ||||||
| 390 | { | - | ||||||
| 391 | resolution = 72; | - | ||||||
| 392 | if (m == QPrinter::HighResolution)
| 32-96 | ||||||
| 393 | resolution = 1200; executed 32 times by 1 test: resolution = 1200;Executed by:
| 32 | ||||||
| 394 | else if (m == QPrinter::ScreenResolution)
| 4-92 | ||||||
| 395 | resolution = qt_defaultDpi(); executed 92 times by 2 tests: resolution = qt_defaultDpi();Executed by:
| 92 | ||||||
| 396 | } executed 128 times by 2 tests: end of blockExecuted by:
| 128 | ||||||
| 397 | - | |||||||
| 398 | QPdfPrintEnginePrivate::~QPdfPrintEnginePrivate() | - | ||||||
| 399 | { | - | ||||||
| 400 | } | - | ||||||
| 401 | - | |||||||
| 402 | QT_END_NAMESPACE | - | ||||||
| 403 | - | |||||||
| 404 | #endif // QT_NO_PRINTER | - | ||||||
| Source code | Switch to Preprocessed file |