| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qprinter.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | extern qreal qt_pixelMultiplier(int resolution); | - | ||||||||||||
| 11 | extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits); | - | ||||||||||||
| 12 | - | |||||||||||||
| 13 | - | |||||||||||||
| 14 | __attribute__((visibility("default"))) double qt_multiplierForUnit(QPrinter::Unit unit, int resolution) | - | ||||||||||||
| 15 | { | - | ||||||||||||
| 16 | switch(unit) { | - | ||||||||||||
| 17 | case QPrinter::Millimeter: | - | ||||||||||||
| 18 | return 2.83464566929; | - | ||||||||||||
| 19 | case QPrinter::Point: | - | ||||||||||||
| 20 | return 1.0; | - | ||||||||||||
| 21 | case QPrinter::Inch: | - | ||||||||||||
| 22 | return 72.0; | - | ||||||||||||
| 23 | case QPrinter::Pica: | - | ||||||||||||
| 24 | return 12; | - | ||||||||||||
| 25 | case QPrinter::Didot: | - | ||||||||||||
| 26 | return 1.065826771; | - | ||||||||||||
| 27 | case QPrinter::Cicero: | - | ||||||||||||
| 28 | return 12.789921252; | - | ||||||||||||
| 29 | case QPrinter::DevicePixel: | - | ||||||||||||
| 30 | return 72.0/resolution; | - | ||||||||||||
| 31 | } | - | ||||||||||||
| 32 | return 1.0; | - | ||||||||||||
| 33 | } | - | ||||||||||||
| 34 | - | |||||||||||||
| 35 | - | |||||||||||||
| 36 | __attribute__((visibility("default"))) QSizeF qt_printerPaperSize(QPrinter::Orientation orientation, | - | ||||||||||||
| 37 | QPrinter::PaperSize paperSize, | - | ||||||||||||
| 38 | QPrinter::Unit unit, | - | ||||||||||||
| 39 | int resolution) | - | ||||||||||||
| 40 | { | - | ||||||||||||
| 41 | QPageSize pageSize = QPageSize(QPageSize::PageSizeId(paperSize)); | - | ||||||||||||
| 42 | QSizeF sizef; | - | ||||||||||||
| 43 | if (unit == QPrinter::DevicePixel) | - | ||||||||||||
| 44 | sizef = pageSize.size(QPageSize::Point) * qt_multiplierForUnit(unit, resolution); | - | ||||||||||||
| 45 | else | - | ||||||||||||
| 46 | sizef = pageSize.size(QPageSize::Unit(unit)); | - | ||||||||||||
| 47 | return orientation == QPrinter::Landscape ? sizef.transposed() : sizef; | - | ||||||||||||
| 48 | } | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | QPrinterInfo QPrinterPrivate::findValidPrinter(const QPrinterInfo &printer) | - | ||||||||||||
| 51 | { | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | QPrinterInfo printerToUse = printer; | - | ||||||||||||
| 54 | if (printerToUse.isNull()) { | - | ||||||||||||
| 55 | printerToUse = QPrinterInfo::defaultPrinter(); | - | ||||||||||||
| 56 | if (printerToUse.isNull()) { | - | ||||||||||||
| 57 | QStringList availablePrinterNames = QPrinterInfo::availablePrinterNames(); | - | ||||||||||||
| 58 | if (!availablePrinterNames.isEmpty()) | - | ||||||||||||
| 59 | printerToUse = QPrinterInfo::printerInfo(availablePrinterNames.at(0)); | - | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | } | - | ||||||||||||
| 62 | return printerToUse; | - | ||||||||||||
| 63 | } | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | void QPrinterPrivate::initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer) | - | ||||||||||||
| 66 | { | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | outputFormat = QPrinter::PdfFormat; | - | ||||||||||||
| 69 | QPlatformPrinterSupport *ps = 0; | - | ||||||||||||
| 70 | QString printerName; | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | - | |||||||||||||
| 73 | if (format == QPrinter::NativeFormat) { | - | ||||||||||||
| 74 | ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||||||||
| 75 | QPrinterInfo printerToUse = findValidPrinter(printer); | - | ||||||||||||
| 76 | if (ps && !printerToUse.isNull()) { | - | ||||||||||||
| 77 | outputFormat = QPrinter::NativeFormat; | - | ||||||||||||
| 78 | printerName = printerToUse.printerName(); | - | ||||||||||||
| 79 | } | - | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | if (outputFormat == QPrinter::NativeFormat) { | - | ||||||||||||
| 83 | printEngine = ps->createNativePrintEngine(printerMode); | - | ||||||||||||
| 84 | paintEngine = ps->createPaintEngine(printEngine, printerMode); | - | ||||||||||||
| 85 | } else { | - | ||||||||||||
| 86 | QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode); | - | ||||||||||||
| 87 | paintEngine = pdfEngine; | - | ||||||||||||
| 88 | printEngine = pdfEngine; | - | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | use_default_engine = true; | - | ||||||||||||
| 92 | had_default_engines = true; | - | ||||||||||||
| 93 | setProperty(QPrintEngine::PPK_PrinterName, printerName); | - | ||||||||||||
| 94 | validPrinter = true; | - | ||||||||||||
| 95 | } | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | void QPrinterPrivate::changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer) | - | ||||||||||||
| 98 | { | - | ||||||||||||
| 99 | QPrintEngine *oldPrintEngine = printEngine; | - | ||||||||||||
| 100 | const bool def_engine = use_default_engine; | - | ||||||||||||
| 101 | - | |||||||||||||
| 102 | initEngines(format, printer); | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | if (oldPrintEngine
| 0 | ||||||||||||
| 105 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_properties)>::type> _container_((const auto properties = m_properties)); _container_.control && _container_.i != _container_.e; | - | ||||||||||||
| 106 | ++_container_.i, _container_.control ^= 1)for (QPrintEngine::PrintEnginePropertyKey key = *_container_.i; _container_.control; _container_.control = 0const auto &key : properties) { | - | ||||||||||||
| 107 | QVariant prop; | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | - | |||||||||||||
| 110 | - | |||||||||||||
| 111 | if (key == QPrintEngine::PPK_NumberOfCopies
| 0 | ||||||||||||
| 112 | prop = QVariant(q_ptr->copyCount()); never executed: prop = QVariant(q_ptr->copyCount()); | 0 | ||||||||||||
| 113 | else if (key != QPrintEngine::PPK_PrinterName
| 0 | ||||||||||||
| 114 | prop = oldPrintEngine->property(key); never executed: prop = oldPrintEngine->property(key); | 0 | ||||||||||||
| 115 | if (prop.isValid()
| 0 | ||||||||||||
| 116 | setProperty(key, prop); never executed: setProperty(key, prop); | 0 | ||||||||||||
| 117 | } never executed: end of block | 0 | ||||||||||||
| 118 | } never executed: end of block | 0 | ||||||||||||
| 119 | - | |||||||||||||
| 120 | if (def_engine
| 0 | ||||||||||||
| 121 | delete oldPrintEngine; never executed: delete oldPrintEngine; | 0 | ||||||||||||
| 122 | } never executed: end of block | 0 | ||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | QList<const QPicture *> QPrinterPrivate::previewPages() const | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | if (previewEngine) | - | ||||||||||||
| 128 | return previewEngine->pages(); | - | ||||||||||||
| 129 | return QList<const QPicture *>(); | - | ||||||||||||
| 130 | } | - | ||||||||||||
| 131 | - | |||||||||||||
| 132 | void QPrinterPrivate::setPreviewMode(bool enable) | - | ||||||||||||
| 133 | { | - | ||||||||||||
| 134 | QPrinter * const q = q_func(); | - | ||||||||||||
| 135 | if (enable) { | - | ||||||||||||
| 136 | if (!previewEngine) | - | ||||||||||||
| 137 | previewEngine = new QPreviewPaintEngine; | - | ||||||||||||
| 138 | had_default_engines = use_default_engine; | - | ||||||||||||
| 139 | use_default_engine = false; | - | ||||||||||||
| 140 | realPrintEngine = printEngine; | - | ||||||||||||
| 141 | realPaintEngine = paintEngine; | - | ||||||||||||
| 142 | q->setEngines(previewEngine, previewEngine); | - | ||||||||||||
| 143 | previewEngine->setProxyEngines(realPrintEngine, realPaintEngine); | - | ||||||||||||
| 144 | } else { | - | ||||||||||||
| 145 | q->setEngines(realPrintEngine, realPaintEngine); | - | ||||||||||||
| 146 | use_default_engine = had_default_engines; | - | ||||||||||||
| 147 | } | - | ||||||||||||
| 148 | } | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | - | |||||||||||||
| 151 | void QPrinterPrivate::setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value) | - | ||||||||||||
| 152 | { | - | ||||||||||||
| 153 | printEngine->setProperty(key, value); | - | ||||||||||||
| 154 | m_properties.insert(key); | - | ||||||||||||
| 155 | } | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | class QPrinterPagedPaintDevicePrivate : public QPagedPaintDevicePrivate | - | ||||||||||||
| 159 | { | - | ||||||||||||
| 160 | public: | - | ||||||||||||
| 161 | QPrinterPagedPaintDevicePrivate(QPrinterPrivate *d) | - | ||||||||||||
| 162 | : QPagedPaintDevicePrivate(), pd(d) | - | ||||||||||||
| 163 | {} | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | virtual ~QPrinterPagedPaintDevicePrivate() | - | ||||||||||||
| 166 | {} | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | bool setPageLayout(const QPageLayout &newPageLayout) override | - | ||||||||||||
| 169 | { | - | ||||||||||||
| 170 | if (pd->paintEngine->type() != QPaintEngine::Pdf | - | ||||||||||||
| 171 | && pd->printEngine->printerState() == QPrinter::Active) { | - | ||||||||||||
| 172 | QMessageLogger(__FILE__, 229236, __PRETTY_FUNCTION__).warning("QPrinter::setPageLayout: Cannot be changed while printer is active"); | - | ||||||||||||
| 173 | return false; | - | ||||||||||||
| 174 | } | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | - | |||||||||||||
| 177 | pd->setProperty(QPrintEngine::PPK_QPageLayout, QVariant::fromValue(newPageLayout)); | - | ||||||||||||
| 178 | - | |||||||||||||
| 179 | - | |||||||||||||
| 180 | m_pageLayout = pageLayout(); | - | ||||||||||||
| 181 | - | |||||||||||||
| 182 | return pageLayout().isEquivalentTo(newPageLayout); | - | ||||||||||||
| 183 | } | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | bool setPageSize(const QPageSize &pageSize) override | - | ||||||||||||
| 186 | { | - | ||||||||||||
| 187 | if (pd->paintEngine->type() != QPaintEngine::Pdf | - | ||||||||||||
| 188 | && pd->printEngine->printerState() == QPrinter::Active) { | - | ||||||||||||
| 189 | QMessageLogger(__FILE__, 246253, __PRETTY_FUNCTION__).warning("QPrinter::setPageLayout: Cannot be changed while printer is active"); | - | ||||||||||||
| 190 | return false; | - | ||||||||||||
| 191 | } | - | ||||||||||||
| 192 | - | |||||||||||||
| 193 | - | |||||||||||||
| 194 | - | |||||||||||||
| 195 | pd->setProperty(QPrintEngine::PPK_QPageSize, QVariant::fromValue(pageSize)); | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | - | |||||||||||||
| 198 | m_pageLayout = pageLayout(); | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | return pageLayout().pageSize().isEquivalentTo(pageSize); | - | ||||||||||||
| 201 | } | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | bool setPageOrientation(QPageLayout::Orientation orientation) override | - | ||||||||||||
| 204 | { | - | ||||||||||||
| 205 | - | |||||||||||||
| 206 | pd->setProperty(QPrintEngine::PPK_Orientation, orientation); | - | ||||||||||||
| 207 | - | |||||||||||||
| 208 | - | |||||||||||||
| 209 | m_pageLayout = pageLayout(); | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | return pageLayout().orientation() == orientation; | - | ||||||||||||
| 212 | } | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | bool setPageMargins(const QMarginsF &margins) override | - | ||||||||||||
| 215 | { | - | ||||||||||||
| 216 | return setPageMargins(margins, pageLayout().units()); | - | ||||||||||||
| 217 | } | - | ||||||||||||
| 218 | - | |||||||||||||
| 219 | bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override | - | ||||||||||||
| 220 | { | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units); | - | ||||||||||||
| 223 | pd->setProperty(QPrintEngine::PPK_QPageMargins, QVariant::fromValue(pair)); | - | ||||||||||||
| 224 | - | |||||||||||||
| 225 | - | |||||||||||||
| 226 | m_pageLayout = pageLayout(); | - | ||||||||||||
| 227 | - | |||||||||||||
| 228 | return pageLayout().margins() == margins && pageLayout().units() == units; | - | ||||||||||||
| 229 | } | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | QPageLayout pageLayout() const override | - | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>(); | - | ||||||||||||
| 234 | } | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | QPrinterPrivate *pd; | - | ||||||||||||
| 237 | }; | - | ||||||||||||
| 238 | QPrinter::QPrinter(PrinterMode mode) | - | ||||||||||||
| 239 | : QPagedPaintDevice(), | - | ||||||||||||
| 240 | d_ptr(new QPrinterPrivate(this)) | - | ||||||||||||
| 241 | { | - | ||||||||||||
| 242 | delete d; | - | ||||||||||||
| 243 | d = new QPrinterPagedPaintDevicePrivate(d_func()); | - | ||||||||||||
| 244 | d_ptr->init(QPrinterInfo(), mode); | - | ||||||||||||
| 245 | } | - | ||||||||||||
| 246 | - | |||||||||||||
| 247 | - | |||||||||||||
| 248 | - | |||||||||||||
| 249 | - | |||||||||||||
| 250 | - | |||||||||||||
| 251 | - | |||||||||||||
| 252 | QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode) | - | ||||||||||||
| 253 | : QPagedPaintDevice(), | - | ||||||||||||
| 254 | d_ptr(new QPrinterPrivate(this)) | - | ||||||||||||
| 255 | { | - | ||||||||||||
| 256 | delete d; | - | ||||||||||||
| 257 | d = new QPrinterPagedPaintDevicePrivate(d_func()); | - | ||||||||||||
| 258 | d_ptr->init(printer, mode); | - | ||||||||||||
| 259 | } | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | void QPrinterPrivate::init(const QPrinterInfo &printer, QPrinter::PrinterMode mode) | - | ||||||||||||
| 262 | { | - | ||||||||||||
| 263 | if (!(__builtin_expect(!!(!
| 0-128 | ||||||||||||
| 264 | QMessageLogger(__FILE__, 699706, __PRETTY_FUNCTION__).fatal("QPrinter: Must construct a QCoreApplication before a QPrinter"); | - | ||||||||||||
| 265 | return; never executed: return; | 0 | ||||||||||||
| 266 | } | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | printerMode = mode; | - | ||||||||||||
| 269 | - | |||||||||||||
| 270 | initEngines(QPrinter::NativeFormat, printer); | - | ||||||||||||
| 271 | } executed 128 times by 2 tests: end of blockExecuted by:
| 128 | ||||||||||||
| 272 | void QPrinter::setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine) | - | ||||||||||||
| 273 | { | - | ||||||||||||
| 274 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 275 | - | |||||||||||||
| 276 | if (d->use_default_engine) | - | ||||||||||||
| 277 | delete d->printEngine; | - | ||||||||||||
| 278 | - | |||||||||||||
| 279 | d->printEngine = printEngine; | - | ||||||||||||
| 280 | d->paintEngine = paintEngine; | - | ||||||||||||
| 281 | d->use_default_engine = false; | - | ||||||||||||
| 282 | } | - | ||||||||||||
| 283 | - | |||||||||||||
| 284 | - | |||||||||||||
| 285 | - | |||||||||||||
| 286 | - | |||||||||||||
| 287 | - | |||||||||||||
| 288 | - | |||||||||||||
| 289 | QPrinter::~QPrinter() | - | ||||||||||||
| 290 | { | - | ||||||||||||
| 291 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 292 | if (d->use_default_engine) | - | ||||||||||||
| 293 | delete d->printEngine; | - | ||||||||||||
| 294 | - | |||||||||||||
| 295 | delete d->previewEngine; | - | ||||||||||||
| 296 | - | |||||||||||||
| 297 | } | - | ||||||||||||
| 298 | void QPrinter::setOutputFormat(OutputFormat format) | - | ||||||||||||
| 299 | { | - | ||||||||||||
| 300 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 301 | - | |||||||||||||
| 302 | if (d->outputFormat == format) | - | ||||||||||||
| 303 | return; | - | ||||||||||||
| 304 | - | |||||||||||||
| 305 | if (format == QPrinter::NativeFormat) { | - | ||||||||||||
| 306 | QPrinterInfo printerToUse = d->findValidPrinter(); | - | ||||||||||||
| 307 | if (!printerToUse.isNull()) | - | ||||||||||||
| 308 | d->changeEngines(format, printerToUse); | - | ||||||||||||
| 309 | } else { | - | ||||||||||||
| 310 | d->changeEngines(format, QPrinterInfo()); | - | ||||||||||||
| 311 | } | - | ||||||||||||
| 312 | } | - | ||||||||||||
| 313 | - | |||||||||||||
| 314 | - | |||||||||||||
| 315 | - | |||||||||||||
| 316 | - | |||||||||||||
| 317 | - | |||||||||||||
| 318 | - | |||||||||||||
| 319 | QPrinter::OutputFormat QPrinter::outputFormat() const | - | ||||||||||||
| 320 | { | - | ||||||||||||
| 321 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 322 | return d->outputFormat; | - | ||||||||||||
| 323 | } | - | ||||||||||||
| 324 | - | |||||||||||||
| 325 | - | |||||||||||||
| 326 | - | |||||||||||||
| 327 | - | |||||||||||||
| 328 | - | |||||||||||||
| 329 | int QPrinter::devType() const | - | ||||||||||||
| 330 | { | - | ||||||||||||
| 331 | return QInternal::Printer; | - | ||||||||||||
| 332 | } | - | ||||||||||||
| 333 | - | |||||||||||||
| 334 | - | |||||||||||||
| 335 | - | |||||||||||||
| 336 | - | |||||||||||||
| 337 | - | |||||||||||||
| 338 | - | |||||||||||||
| 339 | - | |||||||||||||
| 340 | QString QPrinter::printerName() const | - | ||||||||||||
| 341 | { | - | ||||||||||||
| 342 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 343 | return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString(); | - | ||||||||||||
| 344 | } | - | ||||||||||||
| 345 | void QPrinter::setPrinterName(const QString &name) | - | ||||||||||||
| 346 | { | - | ||||||||||||
| 347 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 348 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 842849, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setPrinterName"); return; }; | - | ||||||||||||
| 349 | - | |||||||||||||
| 350 | if (printerName() == name) | - | ||||||||||||
| 351 | return; | - | ||||||||||||
| 352 | - | |||||||||||||
| 353 | if (name.isEmpty()) { | - | ||||||||||||
| 354 | setOutputFormat(QPrinter::PdfFormat); | - | ||||||||||||
| 355 | return; | - | ||||||||||||
| 356 | } | - | ||||||||||||
| 357 | - | |||||||||||||
| 358 | QPrinterInfo printerToUse = QPrinterInfo::printerInfo(name); | - | ||||||||||||
| 359 | if (printerToUse.isNull()) | - | ||||||||||||
| 360 | return; | - | ||||||||||||
| 361 | - | |||||||||||||
| 362 | if (outputFormat() == QPrinter::PdfFormat) { | - | ||||||||||||
| 363 | d->changeEngines(QPrinter::NativeFormat, printerToUse); | - | ||||||||||||
| 364 | } else { | - | ||||||||||||
| 365 | d->setProperty(QPrintEngine::PPK_PrinterName, name); | - | ||||||||||||
| 366 | } | - | ||||||||||||
| 367 | } | - | ||||||||||||
| 368 | bool QPrinter::isValid() const | - | ||||||||||||
| 369 | { | - | ||||||||||||
| 370 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 371 | if (!QCoreApplication::instance()) | - | ||||||||||||
| 372 | return false; | - | ||||||||||||
| 373 | return d->validPrinter; | - | ||||||||||||
| 374 | } | - | ||||||||||||
| 375 | QString QPrinter::outputFileName() const | - | ||||||||||||
| 376 | { | - | ||||||||||||
| 377 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 378 | return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString(); | - | ||||||||||||
| 379 | } | - | ||||||||||||
| 380 | void QPrinter::setOutputFileName(const QString &fileName) | - | ||||||||||||
| 381 | { | - | ||||||||||||
| 382 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 383 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 921928, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setOutputFileName"); return; }; | - | ||||||||||||
| 384 | - | |||||||||||||
| 385 | QFileInfo fi(fileName); | - | ||||||||||||
| 386 | if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive)) | - | ||||||||||||
| 387 | setOutputFormat(QPrinter::PdfFormat); | - | ||||||||||||
| 388 | else if (fileName.isEmpty()) | - | ||||||||||||
| 389 | setOutputFormat(QPrinter::NativeFormat); | - | ||||||||||||
| 390 | - | |||||||||||||
| 391 | d->setProperty(QPrintEngine::PPK_OutputFileName, fileName); | - | ||||||||||||
| 392 | } | - | ||||||||||||
| 393 | QString QPrinter::printProgram() const | - | ||||||||||||
| 394 | { | - | ||||||||||||
| 395 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 396 | return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString(); | - | ||||||||||||
| 397 | } | - | ||||||||||||
| 398 | void QPrinter::setPrintProgram(const QString &printProg) | - | ||||||||||||
| 399 | { | - | ||||||||||||
| 400 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 401 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 963970, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setPrintProgram"); return; }; | - | ||||||||||||
| 402 | d->setProperty(QPrintEngine::PPK_PrinterProgram, printProg); | - | ||||||||||||
| 403 | } | - | ||||||||||||
| 404 | - | |||||||||||||
| 405 | - | |||||||||||||
| 406 | - | |||||||||||||
| 407 | - | |||||||||||||
| 408 | - | |||||||||||||
| 409 | - | |||||||||||||
| 410 | - | |||||||||||||
| 411 | QString QPrinter::docName() const | - | ||||||||||||
| 412 | { | - | ||||||||||||
| 413 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 414 | return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString(); | - | ||||||||||||
| 415 | } | - | ||||||||||||
| 416 | void QPrinter::setDocName(const QString &name) | - | ||||||||||||
| 417 | { | - | ||||||||||||
| 418 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 419 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 9931000, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setDocName"); return; }; | - | ||||||||||||
| 420 | d->setProperty(QPrintEngine::PPK_DocumentName, name); | - | ||||||||||||
| 421 | } | - | ||||||||||||
| 422 | - | |||||||||||||
| 423 | - | |||||||||||||
| 424 | - | |||||||||||||
| 425 | - | |||||||||||||
| 426 | - | |||||||||||||
| 427 | - | |||||||||||||
| 428 | - | |||||||||||||
| 429 | QString QPrinter::creator() const | - | ||||||||||||
| 430 | { | - | ||||||||||||
| 431 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 432 | return d->printEngine->property(QPrintEngine::PPK_Creator).toString(); | - | ||||||||||||
| 433 | } | - | ||||||||||||
| 434 | void QPrinter::setCreator(const QString &creator) | - | ||||||||||||
| 435 | { | - | ||||||||||||
| 436 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 437 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 10231030, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setCreator"); return; }; | - | ||||||||||||
| 438 | d->setProperty(QPrintEngine::PPK_Creator, creator); | - | ||||||||||||
| 439 | } | - | ||||||||||||
| 440 | QPrinter::Orientation QPrinter::orientation() const | - | ||||||||||||
| 441 | { | - | ||||||||||||
| 442 | return QPrinter::Orientation(pageLayout().orientation()); | - | ||||||||||||
| 443 | } | - | ||||||||||||
| 444 | void QPrinter::setOrientation(Orientation orientation) | - | ||||||||||||
| 445 | { | - | ||||||||||||
| 446 | setPageOrientation(QPageLayout::Orientation(orientation)); | - | ||||||||||||
| 447 | } | - | ||||||||||||
| 448 | QPrinter::PaperSize QPrinter::paperSize() const | - | ||||||||||||
| 449 | { | - | ||||||||||||
| 450 | return pageSize(); | - | ||||||||||||
| 451 | } | - | ||||||||||||
| 452 | void QPrinter::setPaperSize(PaperSize newPaperSize) | - | ||||||||||||
| 453 | { | - | ||||||||||||
| 454 | setPageSize(QPageSize(QPageSize::PageSizeId(newPaperSize))); | - | ||||||||||||
| 455 | } | - | ||||||||||||
| 456 | QPrinter::PageSize QPrinter::pageSize() const | - | ||||||||||||
| 457 | { | - | ||||||||||||
| 458 | return QPrinter::PaperSize(pageLayout().pageSize().id()); | - | ||||||||||||
| 459 | } | - | ||||||||||||
| 460 | void QPrinter::setPageSize(PageSize newPageSize) | - | ||||||||||||
| 461 | { | - | ||||||||||||
| 462 | setPageSize(QPageSize(QPageSize::PageSizeId(newPageSize))); | - | ||||||||||||
| 463 | } | - | ||||||||||||
| 464 | void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit) | - | ||||||||||||
| 465 | { | - | ||||||||||||
| 466 | if (unit == QPrinter::DevicePixel) | - | ||||||||||||
| 467 | setPageSize(QPageSize(paperSize * qt_pixelMultiplier(resolution()), QPageSize::Point)); | - | ||||||||||||
| 468 | else | - | ||||||||||||
| 469 | setPageSize(QPageSize(paperSize, QPageSize::Unit(unit))); | - | ||||||||||||
| 470 | } | - | ||||||||||||
| 471 | void QPrinter::setPageSizeMM(const QSizeF &size) | - | ||||||||||||
| 472 | { | - | ||||||||||||
| 473 | setPageSize(QPageSize(size, QPageSize::Millimeter)); | - | ||||||||||||
| 474 | } | - | ||||||||||||
| 475 | QSizeF QPrinter::paperSize(Unit unit) const | - | ||||||||||||
| 476 | { | - | ||||||||||||
| 477 | if (unit == QPrinter::DevicePixel) | - | ||||||||||||
| 478 | return pageLayout().fullRectPixels(resolution()).size(); | - | ||||||||||||
| 479 | else | - | ||||||||||||
| 480 | return pageLayout().fullRect(QPageLayout::Unit(unit)).size(); | - | ||||||||||||
| 481 | } | - | ||||||||||||
| 482 | void QPrinter::setPaperName(const QString &paperName) | - | ||||||||||||
| 483 | { | - | ||||||||||||
| 484 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 485 | if (d->paintEngine->type() != QPaintEngine::Pdf) | - | ||||||||||||
| 486 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 12931300, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setPaperName"); return; }; | - | ||||||||||||
| 487 | d->setProperty(QPrintEngine::PPK_PaperName, paperName); | - | ||||||||||||
| 488 | } | - | ||||||||||||
| 489 | QString QPrinter::paperName() const | - | ||||||||||||
| 490 | { | - | ||||||||||||
| 491 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 492 | return d->printEngine->property(QPrintEngine::PPK_PaperName).toString(); | - | ||||||||||||
| 493 | } | - | ||||||||||||
| 494 | void QPrinter::setPageOrder(PageOrder pageOrder) | - | ||||||||||||
| 495 | { | - | ||||||||||||
| 496 | d->pageOrderAscending = (pageOrder == FirstPageFirst); | - | ||||||||||||
| 497 | - | |||||||||||||
| 498 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 499 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 13331340, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setPageOrder"); return; }; | - | ||||||||||||
| 500 | d->setProperty(QPrintEngine::PPK_PageOrder, pageOrder); | - | ||||||||||||
| 501 | } | - | ||||||||||||
| 502 | QPrinter::PageOrder QPrinter::pageOrder() const | - | ||||||||||||
| 503 | { | - | ||||||||||||
| 504 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 505 | return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt()); | - | ||||||||||||
| 506 | } | - | ||||||||||||
| 507 | void QPrinter::setColorMode(ColorMode newColorMode) | - | ||||||||||||
| 508 | { | - | ||||||||||||
| 509 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 510 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 13611368, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setColorMode"); return; }; | - | ||||||||||||
| 511 | d->setProperty(QPrintEngine::PPK_ColorMode, newColorMode); | - | ||||||||||||
| 512 | } | - | ||||||||||||
| 513 | - | |||||||||||||
| 514 | - | |||||||||||||
| 515 | - | |||||||||||||
| 516 | - | |||||||||||||
| 517 | - | |||||||||||||
| 518 | - | |||||||||||||
| 519 | - | |||||||||||||
| 520 | QPrinter::ColorMode QPrinter::colorMode() const | - | ||||||||||||
| 521 | { | - | ||||||||||||
| 522 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 523 | return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt()); | - | ||||||||||||
| 524 | } | - | ||||||||||||
| 525 | int QPrinter::numCopies() const | - | ||||||||||||
| 526 | { | - | ||||||||||||
| 527 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 528 | return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt(); | - | ||||||||||||
| 529 | } | - | ||||||||||||
| 530 | int QPrinter::actualNumCopies() const | - | ||||||||||||
| 531 | { | - | ||||||||||||
| 532 | return copyCount(); | - | ||||||||||||
| 533 | } | - | ||||||||||||
| 534 | void QPrinter::setNumCopies(int numCopies) | - | ||||||||||||
| 535 | { | - | ||||||||||||
| 536 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 537 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 14401447, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setNumCopies"); return; }; | - | ||||||||||||
| 538 | d->setProperty(QPrintEngine::PPK_NumberOfCopies, numCopies); | - | ||||||||||||
| 539 | } | - | ||||||||||||
| 540 | void QPrinter::setCopyCount(int count) | - | ||||||||||||
| 541 | { | - | ||||||||||||
| 542 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 543 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 14581465, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setCopyCount;"); return; }; | - | ||||||||||||
| 544 | d->setProperty(QPrintEngine::PPK_CopyCount, count); | - | ||||||||||||
| 545 | } | - | ||||||||||||
| 546 | int QPrinter::copyCount() const | - | ||||||||||||
| 547 | { | - | ||||||||||||
| 548 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 549 | return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt(); | - | ||||||||||||
| 550 | } | - | ||||||||||||
| 551 | bool QPrinter::supportsMultipleCopies() const | - | ||||||||||||
| 552 | { | - | ||||||||||||
| 553 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 554 | return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool(); | - | ||||||||||||
| 555 | } | - | ||||||||||||
| 556 | bool QPrinter::collateCopies() const | - | ||||||||||||
| 557 | { | - | ||||||||||||
| 558 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 559 | return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool(); | - | ||||||||||||
| 560 | } | - | ||||||||||||
| 561 | void QPrinter::setCollateCopies(bool collate) | - | ||||||||||||
| 562 | { | - | ||||||||||||
| 563 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 564 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 15271534, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setCollateCopies"); return; }; | - | ||||||||||||
| 565 | d->setProperty(QPrintEngine::PPK_CollateCopies, collate); | - | ||||||||||||
| 566 | } | - | ||||||||||||
| 567 | void QPrinter::setFullPage(bool fp) | - | ||||||||||||
| 568 | { | - | ||||||||||||
| 569 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 570 | - | |||||||||||||
| 571 | d->setProperty(QPrintEngine::PPK_FullPage, fp); | - | ||||||||||||
| 572 | - | |||||||||||||
| 573 | devicePageLayout() = pageLayout(); | - | ||||||||||||
| 574 | } | - | ||||||||||||
| 575 | bool QPrinter::fullPage() const | - | ||||||||||||
| 576 | { | - | ||||||||||||
| 577 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 578 | return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool(); | - | ||||||||||||
| 579 | } | - | ||||||||||||
| 580 | void QPrinter::setResolution(int dpi) | - | ||||||||||||
| 581 | { | - | ||||||||||||
| 582 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 583 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 15971604, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setResolution"); return; }; | - | ||||||||||||
| 584 | d->setProperty(QPrintEngine::PPK_Resolution, dpi); | - | ||||||||||||
| 585 | } | - | ||||||||||||
| 586 | int QPrinter::resolution() const | - | ||||||||||||
| 587 | { | - | ||||||||||||
| 588 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 589 | return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt(); | - | ||||||||||||
| 590 | } | - | ||||||||||||
| 591 | void QPrinter::setPaperSource(PaperSource source) | - | ||||||||||||
| 592 | { | - | ||||||||||||
| 593 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 594 | d->setProperty(QPrintEngine::PPK_PaperSource, source); | - | ||||||||||||
| 595 | } | - | ||||||||||||
| 596 | - | |||||||||||||
| 597 | - | |||||||||||||
| 598 | - | |||||||||||||
| 599 | - | |||||||||||||
| 600 | - | |||||||||||||
| 601 | QPrinter::PaperSource QPrinter::paperSource() const | - | ||||||||||||
| 602 | { | - | ||||||||||||
| 603 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 604 | return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt()); | - | ||||||||||||
| 605 | } | - | ||||||||||||
| 606 | void QPrinter::setFontEmbeddingEnabled(bool enable) | - | ||||||||||||
| 607 | { | - | ||||||||||||
| 608 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 609 | d->setProperty(QPrintEngine::PPK_FontEmbedding, enable); | - | ||||||||||||
| 610 | } | - | ||||||||||||
| 611 | bool QPrinter::fontEmbeddingEnabled() const | - | ||||||||||||
| 612 | { | - | ||||||||||||
| 613 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 614 | return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool(); | - | ||||||||||||
| 615 | } | - | ||||||||||||
| 616 | void QPrinter::setDoubleSidedPrinting(bool doubleSided) | - | ||||||||||||
| 617 | { | - | ||||||||||||
| 618 | setDuplex(doubleSided ? DuplexAuto : DuplexNone); | - | ||||||||||||
| 619 | } | - | ||||||||||||
| 620 | bool QPrinter::doubleSidedPrinting() const | - | ||||||||||||
| 621 | { | - | ||||||||||||
| 622 | return duplex() != DuplexNone; | - | ||||||||||||
| 623 | } | - | ||||||||||||
| 624 | void QPrinter::setDuplex(DuplexMode duplex) | - | ||||||||||||
| 625 | { | - | ||||||||||||
| 626 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 627 | d->setProperty(QPrintEngine::PPK_Duplex, duplex); | - | ||||||||||||
| 628 | } | - | ||||||||||||
| 629 | QPrinter::DuplexMode QPrinter::duplex() const | - | ||||||||||||
| 630 | { | - | ||||||||||||
| 631 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 632 | return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt()); | - | ||||||||||||
| 633 | } | - | ||||||||||||
| 634 | QRectF QPrinter::pageRect(Unit unit) const | - | ||||||||||||
| 635 | { | - | ||||||||||||
| 636 | if (unit == QPrinter::DevicePixel) | - | ||||||||||||
| 637 | return pageLayout().paintRectPixels(resolution()); | - | ||||||||||||
| 638 | else | - | ||||||||||||
| 639 | return pageLayout().paintRect(QPageLayout::Unit(unit)); | - | ||||||||||||
| 640 | } | - | ||||||||||||
| 641 | QRectF QPrinter::paperRect(Unit unit) const | - | ||||||||||||
| 642 | { | - | ||||||||||||
| 643 | if (unit == QPrinter::DevicePixel) | - | ||||||||||||
| 644 | return pageLayout().fullRectPixels(resolution()); | - | ||||||||||||
| 645 | else | - | ||||||||||||
| 646 | return pageLayout().fullRect(QPageLayout::Unit(unit)); | - | ||||||||||||
| 647 | } | - | ||||||||||||
| 648 | QRect QPrinter::pageRect() const | - | ||||||||||||
| 649 | { | - | ||||||||||||
| 650 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 651 | return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect(); | - | ||||||||||||
| 652 | } | - | ||||||||||||
| 653 | QRect QPrinter::paperRect() const | - | ||||||||||||
| 654 | { | - | ||||||||||||
| 655 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 656 | return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect(); | - | ||||||||||||
| 657 | } | - | ||||||||||||
| 658 | void QPrinter::setPageMargins(qreal left, qreal top, qreal right, qreal bottom, QPrinter::Unit unit) | - | ||||||||||||
| 659 | { | - | ||||||||||||
| 660 | if (unit == QPrinter::DevicePixel) { | - | ||||||||||||
| 661 | QMarginsF margins = QMarginsF(left, top, right, bottom); | - | ||||||||||||
| 662 | margins *= qt_pixelMultiplier(resolution()); | - | ||||||||||||
| 663 | margins = qt_convertMargins(margins, QPageLayout::Point, pageLayout().units()); | - | ||||||||||||
| 664 | setPageMargins(margins, pageLayout().units()); | - | ||||||||||||
| 665 | } else { | - | ||||||||||||
| 666 | setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Unit(unit)); | - | ||||||||||||
| 667 | } | - | ||||||||||||
| 668 | } | - | ||||||||||||
| 669 | void QPrinter::setMargins(const Margins &m) | - | ||||||||||||
| 670 | { | - | ||||||||||||
| 671 | setPageMargins(QMarginsF(m.left, m.top, m.right, m.bottom), QPageLayout::Millimeter); | - | ||||||||||||
| 672 | } | - | ||||||||||||
| 673 | void QPrinter::getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, QPrinter::Unit unit) const | - | ||||||||||||
| 674 | { | - | ||||||||||||
| 675 | QMarginsF margins; | - | ||||||||||||
| 676 | if (unit == QPrinter::DevicePixel) { | - | ||||||||||||
| 677 | QMargins tmp = pageLayout().marginsPixels(resolution()); | - | ||||||||||||
| 678 | margins = QMarginsF(tmp.left(), tmp.top(), tmp.right(), tmp.bottom()); | - | ||||||||||||
| 679 | } else { | - | ||||||||||||
| 680 | margins = pageLayout().margins(QPageLayout::Unit(unit)); | - | ||||||||||||
| 681 | } | - | ||||||||||||
| 682 | if (left) | - | ||||||||||||
| 683 | *left = margins.left(); | - | ||||||||||||
| 684 | if (right) | - | ||||||||||||
| 685 | *right = margins.right(); | - | ||||||||||||
| 686 | if (top) | - | ||||||||||||
| 687 | *top = margins.top(); | - | ||||||||||||
| 688 | if (bottom) | - | ||||||||||||
| 689 | *bottom = margins.bottom(); | - | ||||||||||||
| 690 | } | - | ||||||||||||
| 691 | - | |||||||||||||
| 692 | - | |||||||||||||
| 693 | - | |||||||||||||
| 694 | - | |||||||||||||
| 695 | - | |||||||||||||
| 696 | - | |||||||||||||
| 697 | int QPrinter::metric(PaintDeviceMetric id) const | - | ||||||||||||
| 698 | { | - | ||||||||||||
| 699 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 700 | return d->printEngine->metric(id); | - | ||||||||||||
| 701 | } | - | ||||||||||||
| 702 | - | |||||||||||||
| 703 | - | |||||||||||||
| 704 | - | |||||||||||||
| 705 | - | |||||||||||||
| 706 | QPaintEngine *QPrinter::paintEngine() const | - | ||||||||||||
| 707 | { | - | ||||||||||||
| 708 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 709 | return d->paintEngine; | - | ||||||||||||
| 710 | } | - | ||||||||||||
| 711 | - | |||||||||||||
| 712 | - | |||||||||||||
| 713 | - | |||||||||||||
| 714 | - | |||||||||||||
| 715 | - | |||||||||||||
| 716 | - | |||||||||||||
| 717 | QPrintEngine *QPrinter::printEngine() const | - | ||||||||||||
| 718 | { | - | ||||||||||||
| 719 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 720 | return d->printEngine; | - | ||||||||||||
| 721 | } | - | ||||||||||||
| 722 | void QPrinter::setWinPageSize(int pageSize) | - | ||||||||||||
| 723 | { | - | ||||||||||||
| 724 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 725 | if (d->printEngine->printerState() == QPrinter::Active) { QMessageLogger(__FILE__, 19141921, __PRETTY_FUNCTION__).warning("%s: Cannot be changed while printer is active", "QPrinter::setWinPageSize"); return; }; | - | ||||||||||||
| 726 | d->setProperty(QPrintEngine::PPK_WindowsPageSize, pageSize); | - | ||||||||||||
| 727 | } | - | ||||||||||||
| 728 | int QPrinter::winPageSize() const | - | ||||||||||||
| 729 | { | - | ||||||||||||
| 730 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 731 | return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt(); | - | ||||||||||||
| 732 | } | - | ||||||||||||
| 733 | QList<int> QPrinter::supportedResolutions() const | - | ||||||||||||
| 734 | { | - | ||||||||||||
| 735 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 736 | const QList<QVariant> varlist | - | ||||||||||||
| 737 | = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList(); | - | ||||||||||||
| 738 | QList<int> intlist; | - | ||||||||||||
| 739 | const int numSupportedResolutions = varlist.size();intlist.reserve(numSupportedResolutions);varlist.size()); | - | ||||||||||||
| 740 | for (int i = 0; i < numSupportedResolutions; ++iauto var : varlist) | - | ||||||||||||
| 741 | intlist << varlistvar.at(i).toInt(); executed 1 time by 1 test: intlist << var.toInt();Executed by:
| 1 | ||||||||||||
| 742 | return executed 1 time by 1 test: intlist;return intlist;Executed by:
executed 1 time by 1 test: return intlist;Executed by:
| 1 | ||||||||||||
| 743 | } | - | ||||||||||||
| 744 | bool QPrinter::newPage() | - | ||||||||||||
| 745 | { | - | ||||||||||||
| 746 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 747 | if (d->printEngine->printerState() != QPrinter::Active) | - | ||||||||||||
| 748 | return false; | - | ||||||||||||
| 749 | return d->printEngine->newPage(); | - | ||||||||||||
| 750 | } | - | ||||||||||||
| 751 | bool QPrinter::abort() | - | ||||||||||||
| 752 | { | - | ||||||||||||
| 753 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 754 | return d->printEngine->abort(); | - | ||||||||||||
| 755 | } | - | ||||||||||||
| 756 | - | |||||||||||||
| 757 | - | |||||||||||||
| 758 | - | |||||||||||||
| 759 | - | |||||||||||||
| 760 | - | |||||||||||||
| 761 | - | |||||||||||||
| 762 | QPrinter::PrinterState QPrinter::printerState() const | - | ||||||||||||
| 763 | { | - | ||||||||||||
| 764 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 765 | return d->printEngine->printerState(); | - | ||||||||||||
| 766 | } | - | ||||||||||||
| 767 | QString QPrinter::printerSelectionOption() const | - | ||||||||||||
| 768 | { | - | ||||||||||||
| 769 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 770 | return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString(); | - | ||||||||||||
| 771 | } | - | ||||||||||||
| 772 | void QPrinter::setPrinterSelectionOption(const QString &option) | - | ||||||||||||
| 773 | { | - | ||||||||||||
| 774 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 775 | d->setProperty(QPrintEngine::PPK_SelectionOption, option); | - | ||||||||||||
| 776 | } | - | ||||||||||||
| 777 | int QPrinter::fromPage() const | - | ||||||||||||
| 778 | { | - | ||||||||||||
| 779 | return d->fromPage; | - | ||||||||||||
| 780 | } | - | ||||||||||||
| 781 | int QPrinter::toPage() const | - | ||||||||||||
| 782 | { | - | ||||||||||||
| 783 | return d->toPage; | - | ||||||||||||
| 784 | } | - | ||||||||||||
| 785 | void QPrinter::setFromTo(int from, int to) | - | ||||||||||||
| 786 | { | - | ||||||||||||
| 787 | if (from > to
| 0-3 | ||||||||||||
| 788 | QMessageLogger(__FILE__, 21312138, __PRETTY_FUNCTION__).warning() << ("QPrinter::setFromTo: 'from' must be less than or equal to 'to'";); | - | ||||||||||||
| 789 | from = to; | - | ||||||||||||
| 790 | } never executed: end of block | 0 | ||||||||||||
| 791 | d->fromPage = from; | - | ||||||||||||
| 792 | d->toPage = to; | - | ||||||||||||
| 793 | } executed 3 times by 2 tests: end of blockExecuted by:
| 3 | ||||||||||||
| 794 | - | |||||||||||||
| 795 | - | |||||||||||||
| 796 | - | |||||||||||||
| 797 | - | |||||||||||||
| 798 | - | |||||||||||||
| 799 | - | |||||||||||||
| 800 | void QPrinter::setPrintRange( PrintRange range ) | - | ||||||||||||
| 801 | { | - | ||||||||||||
| 802 | d->printSelectionOnly = (range == Selection); | - | ||||||||||||
| 803 | - | |||||||||||||
| 804 | QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 805 | d->printRange = range; | - | ||||||||||||
| 806 | } | - | ||||||||||||
| 807 | QPrinter::PrintRange QPrinter::printRange() const | - | ||||||||||||
| 808 | { | - | ||||||||||||
| 809 | const QPrinterPrivate * const d = d_func(); | - | ||||||||||||
| 810 | return d->printRange; | - | ||||||||||||
| 811 | } | - | ||||||||||||
| 812 | - | |||||||||||||
| Switch to Source code | Preprocessed file |