kernel/qprinter.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qprinter.h" -
43#include "qprinter_p.h" -
44 -
45#ifndef QT_NO_PRINTER -
46 -
47#include <qpa/qplatformprintplugin.h> -
48#include <qpa/qplatformprintersupport.h> -
49 -
50#include "qprintengine.h" -
51#include "qprinterinfo.h" -
52#include "qlist.h" -
53#include <qcoreapplication.h> -
54#include <qfileinfo.h> -
55 -
56#include <private/qpagedpaintdevice_p.h> -
57 -
58 -
59#ifndef QT_NO_PDF -
60#include "qprintengine_pdf_p.h" -
61#endif -
62 -
63#include <qpicture.h> -
64#include <private/qpaintengine_preview_p.h> -
65 -
66QT_BEGIN_NAMESPACE -
67 -
68#define ABORT_IF_ACTIVE(location) \ -
69 if (d->printEngine->printerState() == QPrinter::Active) { \ -
70 qWarning("%s: Cannot be changed while printer is active", location); \ -
71 return; \ -
72 } -
73 -
74// NB! This table needs to be in sync with QPrinter::PaperSize -
75static const float qt_paperSizes[][2] = { -
76 {210, 297}, // A4 -
77 {176, 250}, // B5 -
78 {215.9f, 279.4f}, // Letter -
79 {215.9f, 355.6f}, // Legal -
80 {190.5f, 254}, // Executive -
81 {841, 1189}, // A0 -
82 {594, 841}, // A1 -
83 {420, 594}, // A2 -
84 {297, 420}, // A3 -
85 {148, 210}, // A5 -
86 {105, 148}, // A6 -
87 {74, 105}, // A7 -
88 {52, 74}, // A8 -
89 {37, 52}, // A8 -
90 {1000, 1414}, // B0 -
91 {707, 1000}, // B1 -
92 {31, 44}, // B10 -
93 {500, 707}, // B2 -
94 {353, 500}, // B3 -
95 {250, 353}, // B4 -
96 {125, 176}, // B6 -
97 {88, 125}, // B7 -
98 {62, 88}, // B8 -
99 {33, 62}, // B9 -
100 {163, 229}, // C5E -
101 {105, 241}, // US Common -
102 {110, 220}, // DLE -
103 {210, 330}, // Folio -
104 {431.8f, 279.4f}, // Ledger -
105 {279.4f, 431.8f} // Tabloid -
106}; -
107 -
108/// return the multiplier of converting from the unit value to postscript-points. -
109Q_PRINTSUPPORT_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resolution) -
110{ -
111 switch(unit) { -
112 case QPrinter::Millimeter: -
113 return 2.83464566929;
executed: return 2.83464566929;
Execution Count:23
23
114 case QPrinter::Point: -
115 return 1.0;
executed: return 1.0;
Execution Count:8
8
116 case QPrinter::Inch: -
117 return 72.0;
executed: return 72.0;
Execution Count:11
11
118 case QPrinter::Pica: -
119 return 12;
executed: return 12;
Execution Count:7
7
120 case QPrinter::Didot: -
121 return 1.065826771;
executed: return 1.065826771;
Execution Count:7
7
122 case QPrinter::Cicero: -
123 return 12.789921252;
executed: return 12.789921252;
Execution Count:7
7
124 case QPrinter::DevicePixel: -
125 return 72.0/resolution;
never executed: return 72.0/resolution;
0
126 } -
127 return 1.0;
never executed: return 1.0;
0
128} -
129 -
130// not static: it's needed in qpagesetupdialog_unix.cpp -
131Q_PRINTSUPPORT_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation, -
132 QPrinter::PaperSize paperSize, -
133 QPrinter::Unit unit, -
134 int resolution) -
135{ -
136 int width_index = 0;
never executed (the execution status of this line is deduced): int width_index = 0;
-
137 int height_index = 1;
never executed (the execution status of this line is deduced): int height_index = 1;
-
138 if (orientation == QPrinter::Landscape) {
never evaluated: orientation == QPrinter::Landscape
0
139 width_index = 1;
never executed (the execution status of this line is deduced): width_index = 1;
-
140 height_index = 0;
never executed (the execution status of this line is deduced): height_index = 0;
-
141 }
never executed: }
0
142 const qreal multiplier = qt_multiplierForUnit(unit, resolution);
never executed (the execution status of this line is deduced): const qreal multiplier = qt_multiplierForUnit(unit, resolution);
-
143 return QSizeF((qt_paperSizes[paperSize][width_index] * 72 / 25.4) / multiplier,
never executed: return QSizeF((qt_paperSizes[paperSize][width_index] * 72 / 25.4) / multiplier, (qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier);
0
144 (qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier);
never executed: return QSizeF((qt_paperSizes[paperSize][width_index] * 72 / 25.4) / multiplier, (qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier);
0
145} -
146 -
147void QPrinterPrivate::createDefaultEngines() -
148{ -
149 QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
executed (the execution status of this line is deduced): QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
-
150 if (outputFormat == QPrinter::NativeFormat && ps) {
evaluated: outputFormat == QPrinter::NativeFormat
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:117
partially evaluated: ps
TRUEFALSE
yes
Evaluation Count:117
no
Evaluation Count:0
0-117
151 printEngine = ps->createNativePrintEngine(printerMode);
executed (the execution status of this line is deduced): printEngine = ps->createNativePrintEngine(printerMode);
-
152 paintEngine = ps->createPaintEngine(printEngine, printerMode);
executed (the execution status of this line is deduced): paintEngine = ps->createPaintEngine(printEngine, printerMode);
-
153 } else {
executed: }
Execution Count:117
117
154 QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode);
executed (the execution status of this line is deduced): QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode);
-
155 paintEngine = pdfEngine;
executed (the execution status of this line is deduced): paintEngine = pdfEngine;
-
156 printEngine = pdfEngine;
executed (the execution status of this line is deduced): printEngine = pdfEngine;
-
157 }
executed: }
Execution Count:117
117
158 use_default_engine = true;
executed (the execution status of this line is deduced): use_default_engine = true;
-
159 had_default_engines = true;
executed (the execution status of this line is deduced): had_default_engines = true;
-
160}
executed: }
Execution Count:234
234
161 -
162#ifndef QT_NO_PRINTPREVIEWWIDGET -
163QList<const QPicture *> QPrinterPrivate::previewPages() const -
164{ -
165 if (previewEngine)
never evaluated: previewEngine
0
166 return previewEngine->pages();
never executed: return previewEngine->pages();
0
167 return QList<const QPicture *>();
never executed: return QList<const QPicture *>();
0
168} -
169 -
170void QPrinterPrivate::setPreviewMode(bool enable) -
171{ -
172 Q_Q(QPrinter);
never executed (the execution status of this line is deduced): QPrinter * const q = q_func();
-
173 if (enable) {
never evaluated: enable
0
174 if (!previewEngine)
never evaluated: !previewEngine
0
175 previewEngine = new QPreviewPaintEngine;
never executed: previewEngine = new QPreviewPaintEngine;
0
176 had_default_engines = use_default_engine;
never executed (the execution status of this line is deduced): had_default_engines = use_default_engine;
-
177 use_default_engine = false;
never executed (the execution status of this line is deduced): use_default_engine = false;
-
178 realPrintEngine = printEngine;
never executed (the execution status of this line is deduced): realPrintEngine = printEngine;
-
179 realPaintEngine = paintEngine;
never executed (the execution status of this line is deduced): realPaintEngine = paintEngine;
-
180 q->setEngines(previewEngine, previewEngine);
never executed (the execution status of this line is deduced): q->setEngines(previewEngine, previewEngine);
-
181 previewEngine->setProxyEngines(realPrintEngine, realPaintEngine);
never executed (the execution status of this line is deduced): previewEngine->setProxyEngines(realPrintEngine, realPaintEngine);
-
182 } else {
never executed: }
0
183 q->setEngines(realPrintEngine, realPaintEngine);
never executed (the execution status of this line is deduced): q->setEngines(realPrintEngine, realPaintEngine);
-
184 use_default_engine = had_default_engines;
never executed (the execution status of this line is deduced): use_default_engine = had_default_engines;
-
185 }
never executed: }
0
186} -
187#endif // QT_NO_PRINTPREVIEWWIDGET -
188 -
189void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey key) -
190{ -
191 for (int c = 0; c < manualSetList.size(); ++c) {
evaluated: c < manualSetList.size()
TRUEFALSE
yes
Evaluation Count:363
yes
Evaluation Count:188
188-363
192 if (manualSetList[c] == key) return;
executed: return;
Execution Count:22
evaluated: manualSetList[c] == key
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:341
22-341
193 }
executed: }
Execution Count:341
341
194 manualSetList.append(key);
executed (the execution status of this line is deduced): manualSetList.append(key);
-
195}
executed: }
Execution Count:188
188
196 -
197 -
198/*! -
199 \class QPrinter -
200 \reentrant -
201 -
202 \brief The QPrinter class is a paint device that paints on a printer. -
203 -
204 \ingroup printing -
205 \inmodule QtPrintSupport -
206 -
207 -
208 This device represents a series of pages of printed output, and is -
209 used in almost exactly the same way as other paint devices such as -
210 QWidget and QPixmap. -
211 A set of additional functions are provided to manage device-specific -
212 features, such as orientation and resolution, and to step through -
213 the pages in a document as it is generated. -
214 -
215 When printing directly to a printer on Windows or Mac OS X, QPrinter uses -
216 the built-in printer drivers. On X11, QPrinter uses the -
217 \l{Common Unix Printing System (CUPS)} -
218 to send PDF output to the printer. As an alternative, -
219 the printProgram() function can be used to specify the command or utility -
220 to use instead of the system default. -
221 -
222 Note that setting parameters like paper size and resolution on an -
223 invalid printer is undefined. You can use QPrinter::isValid() to -
224 verify this before changing any parameters. -
225 -
226 QPrinter supports a number of parameters, most of which can be -
227 changed by the end user through a \l{QPrintDialog}{print dialog}. In -
228 general, QPrinter passes these functions onto the underlying QPrintEngine. -
229 -
230 The most important parameters are: -
231 \list -
232 \li setOrientation() tells QPrinter which page orientation to use. -
233 \li setPaperSize() tells QPrinter what paper size to expect from the -
234 printer. -
235 \li setResolution() tells QPrinter what resolution you wish the -
236 printer to provide, in dots per inch (DPI). -
237 \li setFullPage() tells QPrinter whether you want to deal with the -
238 full page or just with the part the printer can draw on. -
239 \li setCopyCount() tells QPrinter how many copies of the document -
240 it should print. -
241 \endlist -
242 -
243 Many of these functions can only be called before the actual printing -
244 begins (i.e., before QPainter::begin() is called). This usually makes -
245 sense because, for example, it's not possible to change the number of -
246 copies when you are halfway through printing. There are also some -
247 settings that the user sets (through the printer dialog) and that -
248 applications are expected to obey. See QAbstractPrintDialog's -
249 documentation for more details. -
250 -
251 When QPainter::begin() is called, the QPrinter it operates on is prepared for -
252 a new page, enabling the QPainter to be used immediately to paint the first -
253 page in a document. Once the first page has been painted, newPage() can be -
254 called to request a new blank page to paint on, or QPainter::end() can be -
255 called to finish printing. The second page and all following pages are -
256 prepared using a call to newPage() before they are painted. -
257 -
258 The first page in a document does not need to be preceded by a call to -
259 newPage(). You only need to calling newPage() after QPainter::begin() if you -
260 need to insert a blank page at the beginning of a printed document. -
261 Similarly, calling newPage() after the last page in a document is painted will -
262 result in a trailing blank page appended to the end of the printed document. -
263 -
264 If you want to abort the print job, abort() will try its best to -
265 stop printing. It may cancel the entire job or just part of it. -
266 -
267 Since QPrinter can print to any QPrintEngine subclass, it is possible to -
268 extend printing support to cover new types of printing subsystem by -
269 subclassing QPrintEngine and reimplementing its interface. -
270 -
271 \sa QPrintDialog, {Qt Print Support} -
272*/ -
273 -
274/*! -
275 \enum QPrinter::PrinterState -
276 -
277 \value Idle -
278 \value Active -
279 \value Aborted -
280 \value Error -
281*/ -
282 -
283/*! -
284 \enum QPrinter::PrinterMode -
285 -
286 This enum describes the mode the printer should work in. It -
287 basically presets a certain resolution and working mode. -
288 -
289 \value ScreenResolution Sets the resolution of the print device to -
290 the screen resolution. This has the big advantage that the results -
291 obtained when painting on the printer will match more or less -
292 exactly the visible output on the screen. It is the easiest to -
293 use, as font metrics on the screen and on the printer are the -
294 same. This is the default value. ScreenResolution will produce a -
295 lower quality output than HighResolution and should only be used -
296 for drafts. -
297 -
298 \value PrinterResolution This value is deprecated. Is is -
299 equivalent to ScreenResolution on Unix and HighResolution on -
300 Windows and Mac. Due do the difference between ScreenResolution -
301 and HighResolution, use of this value may lead to non-portable -
302 printer code. -
303 -
304 \value HighResolution On Windows, sets the printer resolution to that -
305 defined for the printer in use. For PDF printing, sets the -
306 resolution of the PDF driver to 1200 dpi. -
307 -
308 \note When rendering text on a QPrinter device, it is important -
309 to realize that the size of text, when specified in points, is -
310 independent of the resolution specified for the device itself. -
311 Therefore, it may be useful to specify the font size in pixels -
312 when combining text with graphics to ensure that their relative -
313 sizes are what you expect. -
314*/ -
315 -
316/*! -
317 \enum QPrinter::Orientation -
318 -
319 This enum type (not to be confused with \c Orientation) is used -
320 to specify each page's orientation. -
321 -
322 \value Portrait the page's height is greater than its width. -
323 -
324 \value Landscape the page's width is greater than its height. -
325 -
326 This type interacts with \l QPrinter::PaperSize and -
327 QPrinter::setFullPage() to determine the final size of the page -
328 available to the application. -
329*/ -
330 -
331 -
332/*! -
333 \enum QPrinter::PrintRange -
334 -
335 Used to specify the print range selection option. -
336 -
337 \value AllPages All pages should be printed. -
338 \value Selection Only the selection should be printed. -
339 \value PageRange The specified page range should be printed. -
340 \value CurrentPage Only the current page should be printed. -
341 -
342 \sa QAbstractPrintDialog::PrintRange -
343*/ -
344 -
345/*! -
346 \enum QPrinter::PaperSize -
347 \since 4.4 -
348 -
349 This enum type specifies what paper size QPrinter should use. -
350 QPrinter does not check that the paper size is available; it just -
351 uses this information, together with QPrinter::Orientation and -
352 QPrinter::setFullPage(), to determine the printable area. -
353 -
354 The defined sizes (with setFullPage(true)) are: -
355 -
356 \value A0 841 x 1189 mm -
357 \value A1 594 x 841 mm -
358 \value A2 420 x 594 mm -
359 \value A3 297 x 420 mm -
360 \value A4 210 x 297 mm, 8.26 x 11.69 inches -
361 \value A5 148 x 210 mm -
362 \value A6 105 x 148 mm -
363 \value A7 74 x 105 mm -
364 \value A8 52 x 74 mm -
365 \value A9 37 x 52 mm -
366 \value B0 1000 x 1414 mm -
367 \value B1 707 x 1000 mm -
368 \value B2 500 x 707 mm -
369 \value B3 353 x 500 mm -
370 \value B4 250 x 353 mm -
371 \value B5 176 x 250 mm, 6.93 x 9.84 inches -
372 \value B6 125 x 176 mm -
373 \value B7 88 x 125 mm -
374 \value B8 62 x 88 mm -
375 \value B9 33 x 62 mm -
376 \value B10 31 x 44 mm -
377 \value C5E 163 x 229 mm -
378 \value Comm10E 105 x 241 mm, U.S. Common 10 Envelope -
379 \value DLE 110 x 220 mm -
380 \value Executive 7.5 x 10 inches, 190.5 x 254 mm -
381 \value Folio 210 x 330 mm -
382 \value Ledger 431.8 x 279.4 mm -
383 \value Legal 8.5 x 14 inches, 215.9 x 355.6 mm -
384 \value Letter 8.5 x 11 inches, 215.9 x 279.4 mm -
385 \value Tabloid 279.4 x 431.8 mm -
386 \value Custom Unknown, or a user defined size. -
387 -
388 With setFullPage(false) (the default), the metrics will be a bit -
389 smaller; how much depends on the printer in use. -
390 -
391 \omitvalue NPageSize -
392 \omitvalue NPaperSize -
393*/ -
394 -
395 -
396/*! -
397 \enum QPrinter::PageOrder -
398 -
399 This enum type is used by QPrinter to tell the application program -
400 how to print. -
401 -
402 \value FirstPageFirst the lowest-numbered page should be printed -
403 first. -
404 -
405 \value LastPageFirst the highest-numbered page should be printed -
406 first. -
407*/ -
408 -
409/*! -
410 \enum QPrinter::ColorMode -
411 -
412 This enum type is used to indicate whether QPrinter should print -
413 in color or not. -
414 -
415 \value Color print in color if available, otherwise in grayscale. -
416 -
417 \value GrayScale print in grayscale, even on color printers. -
418*/ -
419 -
420/*! -
421 \enum QPrinter::PaperSource -
422 -
423 This enum type specifies what paper source QPrinter is to use. -
424 QPrinter does not check that the paper source is available; it -
425 just uses this information to try and set the paper source. -
426 Whether it will set the paper source depends on whether the -
427 printer has that particular source. -
428 -
429 \warning This is currently only implemented for Windows. -
430 -
431 \value Auto -
432 \value Cassette -
433 \value Envelope -
434 \value EnvelopeManual -
435 \value FormSource -
436 \value LargeCapacity -
437 \value LargeFormat -
438 \value Lower -
439 \value MaxPageSource -
440 \value Middle -
441 \value Manual -
442 \value OnlyOne -
443 \value Tractor -
444 \value SmallFormat -
445*/ -
446 -
447/*! -
448 \enum QPrinter::Unit -
449 \since 4.4 -
450 -
451 This enum type is used to specify the measurement unit for page and -
452 paper sizes. -
453 -
454 \value Millimeter -
455 \value Point -
456 \value Inch -
457 \value Pica -
458 \value Didot -
459 \value Cicero -
460 \value DevicePixel -
461 -
462 Note the difference between Point and DevicePixel. The Point unit is -
463 defined to be 1/72th of an inch, while the DevicePixel unit is -
464 resolution dependant and is based on the actual pixels, or dots, on -
465 the printer. -
466*/ -
467 -
468 -
469/* -
470 \enum QPrinter::PrintRange -
471 -
472 This enum is used to specify which print range the application -
473 should use to print. -
474 -
475 \value AllPages All the pages should be printed. -
476 \value Selection Only the selection should be printed. -
477 \value PageRange Print according to the from page and to page options. -
478 \value CurrentPage Only the current page should be printed. -
479 -
480 \sa setPrintRange(), printRange() -
481*/ -
482 -
483/*! -
484 Creates a new printer object with the given \a mode. -
485*/ -
486QPrinter::QPrinter(PrinterMode mode) -
487 : QPagedPaintDevice(), -
488 d_ptr(new QPrinterPrivate(this)) -
489{ -
490 d_ptr->init(mode);
executed (the execution status of this line is deduced): d_ptr->init(mode);
-
491 QPrinterInfo defPrn(QPrinterInfo::defaultPrinter());
executed (the execution status of this line is deduced): QPrinterInfo defPrn(QPrinterInfo::defaultPrinter());
-
492 if (!defPrn.isNull()) {
partially evaluated: !defPrn.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:83
0-83
493 setPrinterName(defPrn.printerName());
never executed (the execution status of this line is deduced): setPrinterName(defPrn.printerName());
-
494 } else if (QPrinterInfo::availablePrinters().isEmpty()) {
never executed: }
partially evaluated: QPrinterInfo::availablePrinters().isEmpty()
TRUEFALSE
yes
Evaluation Count:83
no
Evaluation Count:0
0-83
495 setOutputFormat(QPrinter::PdfFormat);
executed (the execution status of this line is deduced): setOutputFormat(QPrinter::PdfFormat);
-
496 }
executed: }
Execution Count:83
83
497} -
498 -
499/*! -
500 \since 4.4 -
501 -
502 Creates a new printer object with the given \a printer and \a mode. -
503*/ -
504QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode) -
505 : QPagedPaintDevice(), -
506 d_ptr(new QPrinterPrivate(this)) -
507{ -
508 d_ptr->init(mode);
never executed (the execution status of this line is deduced): d_ptr->init(mode);
-
509 setPrinterName(printer.printerName());
never executed (the execution status of this line is deduced): setPrinterName(printer.printerName());
-
510}
never executed: }
0
511 -
512void QPrinterPrivate::init(QPrinter::PrinterMode mode) -
513{ -
514 if (!QCoreApplication::instance()) {
partially evaluated: !QCoreApplication::instance()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:83
0-83
515 qFatal("QPrinter: Must construct a QApplication before a QPaintDevice");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qprinter.cpp", 515, __PRETTY_FUNCTION__).fatal("QPrinter: Must construct a QApplication before a QPaintDevice");
-
516 return;
never executed: return;
0
517 } -
518 -
519 printerMode = mode;
executed (the execution status of this line is deduced): printerMode = mode;
-
520 outputFormat = QPrinter::NativeFormat;
executed (the execution status of this line is deduced): outputFormat = QPrinter::NativeFormat;
-
521 createDefaultEngines();
executed (the execution status of this line is deduced): createDefaultEngines();
-
522 -
523#ifndef QT_NO_PRINTPREVIEWWIDGET -
524 previewEngine = 0;
executed (the execution status of this line is deduced): previewEngine = 0;
-
525#endif -
526 realPrintEngine = 0;
executed (the execution status of this line is deduced): realPrintEngine = 0;
-
527 realPaintEngine = 0;
executed (the execution status of this line is deduced): realPaintEngine = 0;
-
528}
executed: }
Execution Count:83
83
529 -
530/*! -
531 This function is used by subclasses of QPrinter to specify custom -
532 print and paint engines (\a printEngine and \a paintEngine, -
533 respectively). -
534 -
535 QPrinter does not take ownership of the engines, so you need to -
536 manage these engine instances yourself. -
537 -
538 Note that changing the engines will reset the printer state and -
539 all its properties. -
540 -
541 \sa printEngine(), paintEngine(), setOutputFormat() -
542 -
543 \since 4.1 -
544*/ -
545void QPrinter::setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine) -
546{ -
547 Q_D(QPrinter);
never executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
548 -
549 if (d->use_default_engine)
never evaluated: d->use_default_engine
0
550 delete d->printEngine;
never executed: delete d->printEngine;
0
551 -
552 d->printEngine = printEngine;
never executed (the execution status of this line is deduced): d->printEngine = printEngine;
-
553 d->paintEngine = paintEngine;
never executed (the execution status of this line is deduced): d->paintEngine = paintEngine;
-
554 d->use_default_engine = false;
never executed (the execution status of this line is deduced): d->use_default_engine = false;
-
555}
never executed: }
0
556 -
557/*! -
558 Destroys the printer object and frees any allocated resources. If -
559 the printer is destroyed while a print job is in progress this may -
560 or may not affect the print job. -
561*/ -
562QPrinter::~QPrinter() -
563{ -
564 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
565 if (d->use_default_engine)
partially evaluated: d->use_default_engine
TRUEFALSE
yes
Evaluation Count:83
no
Evaluation Count:0
0-83
566 delete d->printEngine;
executed: delete d->printEngine;
Execution Count:83
83
567#ifndef QT_NO_PRINTPREVIEWWIDGET -
568 delete d->previewEngine;
executed (the execution status of this line is deduced): delete d->previewEngine;
-
569#endif -
570}
executed: }
Execution Count:83
83
571 -
572/*! -
573 \enum QPrinter::OutputFormat -
574 -
575 The OutputFormat enum is used to describe the format QPrinter should -
576 use for printing. -
577 -
578 \value NativeFormat QPrinter will print output using a method defined -
579 by the platform it is running on. This mode is the default when printing -
580 directly to a printer. -
581 -
582 \value PdfFormat QPrinter will generate its output as a searchable PDF file. -
583 This mode is the default when printing to a file. -
584 -
585 \sa outputFormat(), setOutputFormat(), setOutputFileName() -
586*/ -
587 -
588/*! -
589 \since 4.1 -
590 -
591 Sets the output format for this printer to \a format. -
592*/ -
593void QPrinter::setOutputFormat(OutputFormat format) -
594{ -
595 -
596#ifndef QT_NO_PDF -
597 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
598 if (d->validPrinter && d->outputFormat == format)
evaluated: d->validPrinter
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:85
evaluated: d->outputFormat == format
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:66
28-94
599 return;
executed: return;
Execution Count:28
28
600 d->outputFormat = format;
executed (the execution status of this line is deduced): d->outputFormat = format;
-
601 -
602 QPrintEngine *oldPrintEngine = d->printEngine;
executed (the execution status of this line is deduced): QPrintEngine *oldPrintEngine = d->printEngine;
-
603 const bool def_engine = d->use_default_engine;
executed (the execution status of this line is deduced): const bool def_engine = d->use_default_engine;
-
604 d->printEngine = 0;
executed (the execution status of this line is deduced): d->printEngine = 0;
-
605 -
606 d->createDefaultEngines();
executed (the execution status of this line is deduced): d->createDefaultEngines();
-
607 -
608 if (oldPrintEngine) {
partially evaluated: oldPrintEngine
TRUEFALSE
yes
Evaluation Count:151
no
Evaluation Count:0
0-151
609 for (int i = 0; i < d->manualSetList.size(); ++i) {
evaluated: i < d->manualSetList.size()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:151
32-151
610 QPrintEngine::PrintEnginePropertyKey key = d->manualSetList[i];
executed (the execution status of this line is deduced): QPrintEngine::PrintEnginePropertyKey key = d->manualSetList[i];
-
611 QVariant prop;
executed (the execution status of this line is deduced): QVariant prop;
-
612 // PPK_NumberOfCopies need special treatmeant since it in most cases -
613 // will return 1, disregarding the actual value that was set -
614 if (key == QPrintEngine::PPK_NumberOfCopies)
partially evaluated: key == QPrintEngine::PPK_NumberOfCopies
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
615 prop = QVariant(copyCount());
never executed: prop = QVariant(copyCount());
0
616 else -
617 prop = oldPrintEngine->property(key);
executed: prop = oldPrintEngine->property(key);
Execution Count:32
32
618 if (prop.isValid())
partially evaluated: prop.isValid()
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
619 d->printEngine->setProperty(key, prop);
executed: d->printEngine->setProperty(key, prop);
Execution Count:32
32
620 }
executed: }
Execution Count:32
32
621 }
executed: }
Execution Count:151
151
622 -
623 if (def_engine)
partially evaluated: def_engine
TRUEFALSE
yes
Evaluation Count:151
no
Evaluation Count:0
0-151
624 delete oldPrintEngine;
executed: delete oldPrintEngine;
Execution Count:151
151
625 -
626 if (d->outputFormat == QPrinter::PdfFormat)
evaluated: d->outputFormat == QPrinter::PdfFormat
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:34
34-117
627 d->validPrinter = true;
executed: d->validPrinter = true;
Execution Count:117
117
628#else -
629 Q_UNUSED(format); -
630#endif -
631}
executed: }
Execution Count:151
151
632 -
633/*! -
634 \since 4.1 -
635 -
636 Returns the output format for this printer. -
637*/ -
638QPrinter::OutputFormat QPrinter::outputFormat() const -
639{ -
640 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
641 return d->outputFormat;
executed: return d->outputFormat;
Execution Count:4
4
642} -
643 -
644 -
645 -
646/*! \internal -
647*/ -
648int QPrinter::devType() const -
649{ -
650 return QInternal::Printer;
executed: return QInternal::Printer;
Execution Count:83
83
651} -
652 -
653/*! -
654 Returns the printer name. This value is initially set to the name -
655 of the default printer. -
656 -
657 \sa setPrinterName() -
658*/ -
659QString QPrinter::printerName() const -
660{ -
661 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
662 return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();
executed: return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();
Execution Count:12
12
663} -
664 -
665/*! -
666 Sets the printer name to \a name. -
667 -
668 \sa printerName(), isValid() -
669*/ -
670void QPrinter::setPrinterName(const QString &name) -
671{ -
672 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
673 ABORT_IF_ACTIVE("QPrinter::setPrinterName");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
674 -
675 QList<QPrinterInfo> prnList = QPrinterInfo::availablePrinters();
executed (the execution status of this line is deduced): QList<QPrinterInfo> prnList = QPrinterInfo::availablePrinters();
-
676 if (name.isEmpty()) {
evaluated: name.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
677 d->validPrinter = d->outputFormat == QPrinter::PdfFormat;
executed (the execution status of this line is deduced): d->validPrinter = d->outputFormat == QPrinter::PdfFormat;
-
678 } else {
executed: }
Execution Count:3
3
679 d->validPrinter = false;
executed (the execution status of this line is deduced): d->validPrinter = false;
-
680 for (int i = 0; i < prnList.size(); ++i) {
partially evaluated: i < prnList.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
681 if (prnList[i].printerName() == name) {
never evaluated: prnList[i].printerName() == name
0
682 d->validPrinter = true;
never executed (the execution status of this line is deduced): d->validPrinter = true;
-
683 break;
never executed: break;
0
684 } -
685 }
never executed: }
0
686 }
executed: }
Execution Count:3
3
687 -
688 d->printEngine->setProperty(QPrintEngine::PPK_PrinterName, name);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_PrinterName, name);
-
689 d->addToManualSetList(QPrintEngine::PPK_PrinterName);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_PrinterName);
-
690}
executed: }
Execution Count:6
6
691 -
692 -
693/*! -
694 \since 4.4 -
695 -
696 Returns true if the printer currently selected is a valid printer -
697 in the system, or a pure PDF printer; otherwise returns false. -
698 -
699 To detect other failures check the output of QPainter::begin() or QPrinter::newPage(). -
700 -
701 \snippet printing-qprinter/errors.cpp 0 -
702 -
703 \sa setPrinterName() -
704*/ -
705bool QPrinter::isValid() const -
706{ -
707 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
708 if (!qApp)
partially evaluated: !QCoreApplication::instance()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
709 return false;
never executed: return false;
0
710 return d->validPrinter;
executed: return d->validPrinter;
Execution Count:2
2
711} -
712 -
713/*! -
714 \fn QString QPrinter::outputFileName() const -
715 -
716 Returns the name of the output file. By default, this is an empty string -
717 (indicating that the printer shouldn't print to file). -
718 -
719 \sa QPrintEngine::PrintEnginePropertyKey -
720 -
721*/ -
722 -
723QString QPrinter::outputFileName() const -
724{ -
725 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
726 return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();
executed: return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();
Execution Count:8
8
727} -
728 -
729/*! -
730 Sets the name of the output file to \a fileName. -
731 -
732 Setting a null or empty name (0 or "") disables printing to a file. -
733 Setting a non-empty name enables printing to a file. -
734 -
735 This can change the value of outputFormat(). -
736 If the file name has the ".pdf" suffix PDF is generated. If the file name -
737 has a suffix other than ".pdf", the output format used is the -
738 one set with setOutputFormat(). -
739 -
740 QPrinter uses Qt's cross-platform PDF print engines -
741 respectively. If you can produce this format natively, for example -
742 Mac OS X can generate PDF's from its print engine, set the output format -
743 back to NativeFormat. -
744 -
745 \sa outputFileName(), setOutputFormat() -
746*/ -
747 -
748void QPrinter::setOutputFileName(const QString &fileName) -
749{ -
750 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
751 ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
752 -
753 QFileInfo fi(fileName);
executed (the execution status of this line is deduced): QFileInfo fi(fileName);
-
754 if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
evaluated: !fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:34
6-34
755 setOutputFormat(QPrinter::PdfFormat);
executed: setOutputFormat(QPrinter::PdfFormat);
Execution Count:6
6
756 else if (fileName.isEmpty())
partially evaluated: fileName.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
757 setOutputFormat(QPrinter::NativeFormat);
never executed: setOutputFormat(QPrinter::NativeFormat);
0
758 -
759 d->printEngine->setProperty(QPrintEngine::PPK_OutputFileName, fileName);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_OutputFileName, fileName);
-
760 d->addToManualSetList(QPrintEngine::PPK_OutputFileName);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_OutputFileName);
-
761}
executed: }
Execution Count:40
40
762 -
763 -
764/*! -
765 Returns the name of the program that sends the print output to the -
766 printer. -
767 -
768 The default is to return an empty string; meaning that QPrinter will try to -
769 be smart in a system-dependent way. On X11 only, you can set it to something -
770 different to use a specific print program. On the other platforms, this -
771 returns an empty string. -
772 -
773 \sa setPrintProgram(), setPrinterSelectionOption() -
774*/ -
775QString QPrinter::printProgram() const -
776{ -
777 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
778 return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();
executed: return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();
Execution Count:5
5
779} -
780 -
781 -
782/*! -
783 Sets the name of the program that should do the print job to \a -
784 printProg. -
785 -
786 On X11, this function sets the program to call with the PDF -
787 output. On other platforms, it has no effect. -
788 -
789 \sa printProgram() -
790*/ -
791void QPrinter::setPrintProgram(const QString &printProg) -
792{ -
793 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
794 ABORT_IF_ACTIVE("QPrinter::setPrintProgram");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
795 d->printEngine->setProperty(QPrintEngine::PPK_PrinterProgram, printProg);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_PrinterProgram, printProg);
-
796 d->addToManualSetList(QPrintEngine::PPK_PrinterProgram);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_PrinterProgram);
-
797}
executed: }
Execution Count:2
2
798 -
799 -
800/*! -
801 Returns the document name. -
802 -
803 \sa setDocName(), QPrintEngine::PrintEnginePropertyKey -
804*/ -
805QString QPrinter::docName() const -
806{ -
807 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
808 return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();
executed: return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();
Execution Count:8
8
809} -
810 -
811 -
812/*! -
813 Sets the document name to \a name. -
814 -
815 On X11, the document name is for example used as the default -
816 output filename in QPrintDialog. Note that the document name does -
817 not affect the file name if the printer is printing to a file. -
818 Use the setOutputFile() function for this. -
819 -
820 \sa docName(), QPrintEngine::PrintEnginePropertyKey -
821*/ -
822void QPrinter::setDocName(const QString &name) -
823{ -
824 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
825 ABORT_IF_ACTIVE("QPrinter::setDocName");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
826 d->printEngine->setProperty(QPrintEngine::PPK_DocumentName, name);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_DocumentName, name);
-
827 d->addToManualSetList(QPrintEngine::PPK_DocumentName);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_DocumentName);
-
828}
executed: }
Execution Count:3
3
829 -
830 -
831/*! -
832 Returns the name of the application that created the document. -
833 -
834 \sa setCreator() -
835*/ -
836QString QPrinter::creator() const -
837{ -
838 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
839 return d->printEngine->property(QPrintEngine::PPK_Creator).toString();
executed: return d->printEngine->property(QPrintEngine::PPK_Creator).toString();
Execution Count:5
5
840} -
841 -
842 -
843/*! -
844 Sets the name of the application that created the document to \a -
845 creator. -
846 -
847 This function is only applicable to the X11 version of Qt. If no -
848 creator name is specified, the creator will be set to "Qt" -
849 followed by some version number. -
850 -
851 \sa creator() -
852*/ -
853void QPrinter::setCreator(const QString &creator) -
854{ -
855 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
856 ABORT_IF_ACTIVE("QPrinter::setCreator");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
857 d->printEngine->setProperty(QPrintEngine::PPK_Creator, creator);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_Creator, creator);
-
858 d->addToManualSetList(QPrintEngine::PPK_Creator);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_Creator);
-
859}
executed: }
Execution Count:2
2
860 -
861 -
862/*! -
863 Returns the orientation setting. This is driver-dependent, but is usually -
864 QPrinter::Portrait. -
865 -
866 \sa setOrientation() -
867*/ -
868QPrinter::Orientation QPrinter::orientation() const -
869{ -
870 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
871 return QPrinter::Orientation(d->printEngine->property(QPrintEngine::PPK_Orientation).toInt());
executed: return QPrinter::Orientation(d->printEngine->property(QPrintEngine::PPK_Orientation).toInt());
Execution Count:54
54
872} -
873 -
874 -
875/*! -
876 Sets the print orientation to \a orientation. -
877 -
878 The orientation can be either QPrinter::Portrait or -
879 QPrinter::Landscape. -
880 -
881 The printer driver reads this setting and prints using the -
882 specified orientation. -
883 -
884 On Windows, this option can be changed while printing and will -
885 take effect from the next call to newPage(). -
886 -
887 On Mac OS X, changing the orientation during a print job has no effect. -
888 -
889 \sa orientation() -
890*/ -
891 -
892void QPrinter::setOrientation(Orientation orientation) -
893{ -
894 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
895 d->printEngine->setProperty(QPrintEngine::PPK_Orientation, orientation);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_Orientation, orientation);
-
896 d->addToManualSetList(QPrintEngine::PPK_Orientation);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_Orientation);
-
897}
executed: }
Execution Count:44
44
898 -
899 -
900/*! -
901 \since 4.4 -
902 Returns the printer paper size. The default value is driver-dependent. -
903 -
904 \sa setPaperSize(), pageRect(), paperRect() -
905*/ -
906 -
907QPrinter::PaperSize QPrinter::paperSize() const -
908{ -
909 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
910 return QPrinter::PaperSize(d->printEngine->property(QPrintEngine::PPK_PaperSize).toInt());
executed: return QPrinter::PaperSize(d->printEngine->property(QPrintEngine::PPK_PaperSize).toInt());
Execution Count:20
20
911} -
912 -
913/*! -
914 \since 4.4 -
915 -
916 Sets the printer paper size to \a newPaperSize if that size is -
917 supported. The result is undefined if \a newPaperSize is not -
918 supported. -
919 -
920 The default paper size is driver-dependent. -
921 -
922 This function is useful mostly for setting a default value that -
923 the user can override in the print dialog. -
924 -
925 \sa paperSize(), PaperSize, setFullPage(), setResolution(), pageRect(), paperRect() -
926*/ -
927void QPrinter::setPaperSize(PaperSize newPaperSize) -
928{ -
929 setPageSize(newPaperSize);
never executed (the execution status of this line is deduced): setPageSize(newPaperSize);
-
930}
never executed: }
0
931 -
932/*! -
933 \obsolete -
934 -
935 Returns the printer page size. The default value is driver-dependent. -
936 -
937 Use paperSize() instead. -
938*/ -
939QPrinter::PageSize QPrinter::pageSize() const -
940{ -
941 return paperSize();
executed: return paperSize();
Execution Count:16
16
942} -
943 -
944 -
945/*! -
946 \obsolete -
947 -
948 Sets the printer page size based on \a newPageSize. -
949 -
950 Use setPaperSize() instead. -
951*/ -
952 -
953void QPrinter::setPageSize(PageSize newPageSize) -
954{ -
955 QPagedPaintDevice::setPageSize(newPageSize);
never executed (the execution status of this line is deduced): QPagedPaintDevice::setPageSize(newPageSize);
-
956 -
957 Q_D(QPrinter);
never executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
958 if (d->paintEngine->type() != QPaintEngine::Pdf)
partially evaluated: d->paintEngine->type() != QPaintEngine::Pdf
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
959 ABORT_IF_ACTIVE("QPrinter::setPaperSize");
never executed: return;
never evaluated: d->printEngine->printerState() == QPrinter::Active
0
960 if (newPageSize < 0 || newPageSize >= NPageSize) {
partially evaluated: newPageSize < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
partially evaluated: newPageSize >= NPageSize
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
961 qWarning("QPrinter::setPaperSize: Illegal paper size %d", newPageSize);
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qprinter.cpp", 961, __PRETTY_FUNCTION__).warning("QPrinter::setPaperSize: Illegal paper size %d", newPageSize);
-
962 return;
never executed: return;
0
963 } -
964 d->printEngine->setProperty(QPrintEngine::PPK_PaperSize, newPageSize);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_PaperSize, newPageSize);
-
965 d->addToManualSetList(QPrintEngine::PPK_PaperSize);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_PaperSize);
-
966 d->hasUserSetPageSize = true;
executed (the execution status of this line is deduced): d->hasUserSetPageSize = true;
-
967}
executed: }
Execution Count:30
30
968 -
969/*! -
970 \since 4.4 -
971 -
972 Sets the paper size based on \a paperSize in \a unit. -
973 -
974 \sa paperSize() -
975*/ -
976 -
977void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit) -
978{ -
979 Q_D(QPrinter);
never executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
980 if (d->paintEngine->type() != QPaintEngine::Pdf)
partially evaluated: d->paintEngine->type() != QPaintEngine::Pdf
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
981 ABORT_IF_ACTIVE("QPrinter::setPaperSize");
never executed: return;
never evaluated: d->printEngine->printerState() == QPrinter::Active
0
982 const qreal multiplier = qt_multiplierForUnit(unit, resolution());
executed (the execution status of this line is deduced): const qreal multiplier = qt_multiplierForUnit(unit, resolution());
-
983 QSizeF size(paperSize.width() * multiplier * 25.4/72., paperSize.height() * multiplier * 25.4/72.);
executed (the execution status of this line is deduced): QSizeF size(paperSize.width() * multiplier * 25.4/72., paperSize.height() * multiplier * 25.4/72.);
-
984 setPageSizeMM(size);
executed (the execution status of this line is deduced): setPageSizeMM(size);
-
985}
executed: }
Execution Count:7
7
986 -
987/*! -
988 \reimp -
989 */ -
990void QPrinter::setPageSizeMM(const QSizeF &size) -
991{ -
992 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
993 -
994 QPagedPaintDevice::setPageSizeMM(size);
executed (the execution status of this line is deduced): QPagedPaintDevice::setPageSizeMM(size);
-
995 -
996 QSizeF s = size * 72./25.4;
executed (the execution status of this line is deduced): QSizeF s = size * 72./25.4;
-
997 d->printEngine->setProperty(QPrintEngine::PPK_CustomPaperSize, s);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_CustomPaperSize, s);
-
998 d->addToManualSetList(QPrintEngine::PPK_CustomPaperSize);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_CustomPaperSize);
-
999 d->hasUserSetPageSize = true;
executed (the execution status of this line is deduced): d->hasUserSetPageSize = true;
-
1000}
executed: }
Execution Count:7
7
1001 -
1002/*! -
1003 \since 4.4 -
1004 -
1005 Returns the paper size in \a unit. -
1006 -
1007 \sa setPaperSize() -
1008*/ -
1009 -
1010QSizeF QPrinter::paperSize(Unit unit) const -
1011{ -
1012 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1013 int res = resolution();
executed (the execution status of this line is deduced): int res = resolution();
-
1014 const qreal multiplier = qt_multiplierForUnit(unit, res);
executed (the execution status of this line is deduced): const qreal multiplier = qt_multiplierForUnit(unit, res);
-
1015 PaperSize paperType = paperSize();
executed (the execution status of this line is deduced): PaperSize paperType = paperSize();
-
1016 if (paperType == Custom) {
partially evaluated: paperType == Custom
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1017 QSizeF size = d->printEngine->property(QPrintEngine::PPK_CustomPaperSize).toSizeF();
executed (the execution status of this line is deduced): QSizeF size = d->printEngine->property(QPrintEngine::PPK_CustomPaperSize).toSizeF();
-
1018 return QSizeF(size.width() / multiplier, size.height() / multiplier);
executed: return QSizeF(size.width() / multiplier, size.height() / multiplier);
Execution Count:4
4
1019 } -
1020 else { -
1021 return qt_printerPaperSize(orientation(), paperType, unit, res);
never executed: return qt_printerPaperSize(orientation(), paperType, unit, res);
0
1022 } -
1023} -
1024 -
1025/*! -
1026 Sets the page order to \a pageOrder. -
1027 -
1028 The page order can be QPrinter::FirstPageFirst or -
1029 QPrinter::LastPageFirst. The application is responsible for -
1030 reading the page order and printing accordingly. -
1031 -
1032 This function is mostly useful for setting a default value that -
1033 the user can override in the print dialog. -
1034 -
1035 This function is only supported under X11. -
1036*/ -
1037 -
1038void QPrinter::setPageOrder(PageOrder pageOrder) -
1039{ -
1040 d->pageOrderAscending = (pageOrder == FirstPageFirst);
executed (the execution status of this line is deduced): d->pageOrderAscending = (pageOrder == FirstPageFirst);
-
1041 -
1042 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1043 ABORT_IF_ACTIVE("QPrinter::setPageOrder");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1044 d->printEngine->setProperty(QPrintEngine::PPK_PageOrder, pageOrder);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_PageOrder, pageOrder);
-
1045 d->addToManualSetList(QPrintEngine::PPK_PageOrder);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_PageOrder);
-
1046}
executed: }
Execution Count:3
3
1047 -
1048 -
1049/*! -
1050 Returns the current page order. -
1051 -
1052 The default page order is \c FirstPageFirst. -
1053*/ -
1054 -
1055QPrinter::PageOrder QPrinter::pageOrder() const -
1056{ -
1057 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1058 return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());
executed: return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());
Execution Count:10
10
1059} -
1060 -
1061 -
1062/*! -
1063 Sets the printer's color mode to \a newColorMode, which can be -
1064 either \c Color or \c GrayScale. -
1065 -
1066 \sa colorMode() -
1067*/ -
1068 -
1069void QPrinter::setColorMode(ColorMode newColorMode) -
1070{ -
1071 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1072 ABORT_IF_ACTIVE("QPrinter::setColorMode");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1073 d->printEngine->setProperty(QPrintEngine::PPK_ColorMode, newColorMode);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_ColorMode, newColorMode);
-
1074 d->addToManualSetList(QPrintEngine::PPK_ColorMode);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_ColorMode);
-
1075}
executed: }
Execution Count:3
3
1076 -
1077 -
1078/*! -
1079 Returns the current color mode. -
1080 -
1081 \sa setColorMode() -
1082*/ -
1083QPrinter::ColorMode QPrinter::colorMode() const -
1084{ -
1085 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1086 return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
executed: return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());
Execution Count:10
10
1087} -
1088 -
1089 -
1090/*! -
1091 \obsolete -
1092 Returns the number of copies to be printed. The default value is 1. -
1093 -
1094 On Windows, Mac OS X and X11 systems that support CUPS, this will always -
1095 return 1 as these operating systems can internally handle the number -
1096 of copies. -
1097 -
1098 On X11, this value will return the number of times the application is -
1099 required to print in order to match the number specified in the printer setup -
1100 dialog. This has been done since some printer drivers are not capable of -
1101 buffering up the copies and in those cases the application must make an -
1102 explicit call to the print code for each copy. -
1103 -
1104 Use copyCount() in conjunction with supportsMultipleCopies() instead. -
1105 -
1106 \sa setNumCopies(), actualNumCopies() -
1107*/ -
1108 -
1109int QPrinter::numCopies() const -
1110{ -
1111 Q_D(const QPrinter);
never executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1112 return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();
never executed: return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();
0
1113} -
1114 -
1115 -
1116/*! -
1117 \obsolete -
1118 \since 4.6 -
1119 -
1120 Returns the number of copies that will be printed. The default -
1121 value is 1. -
1122 -
1123 This function always returns the actual value specified in the print -
1124 dialog or using setNumCopies(). -
1125 -
1126 Use copyCount() instead. -
1127 -
1128 \sa setNumCopies(), numCopies() -
1129*/ -
1130int QPrinter::actualNumCopies() const -
1131{ -
1132 return copyCount();
never executed: return copyCount();
0
1133} -
1134 -
1135 -
1136 -
1137/*! -
1138 \obsolete -
1139 Sets the number of copies to be printed to \a numCopies. -
1140 -
1141 The printer driver reads this setting and prints the specified -
1142 number of copies. -
1143 -
1144 Use setCopyCount() instead. -
1145 -
1146 \sa numCopies() -
1147*/ -
1148 -
1149void QPrinter::setNumCopies(int numCopies) -
1150{ -
1151 Q_D(QPrinter);
never executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1152 ABORT_IF_ACTIVE("QPrinter::setNumCopies");
never executed: return;
never evaluated: d->printEngine->printerState() == QPrinter::Active
0
1153 d->printEngine->setProperty(QPrintEngine::PPK_NumberOfCopies, numCopies);
never executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_NumberOfCopies, numCopies);
-
1154 d->addToManualSetList(QPrintEngine::PPK_NumberOfCopies);
never executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_NumberOfCopies);
-
1155}
never executed: }
0
1156 -
1157/*! -
1158 \since 4.7 -
1159 -
1160 Sets the number of copies to be printed to \a count. -
1161 -
1162 The printer driver reads this setting and prints the specified number of -
1163 copies. -
1164 -
1165 \sa copyCount(), supportsMultipleCopies() -
1166*/ -
1167 -
1168void QPrinter::setCopyCount(int count) -
1169{ -
1170 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1171 ABORT_IF_ACTIVE("QPrinter::setCopyCount;");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1172 d->printEngine->setProperty(QPrintEngine::PPK_CopyCount, count);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_CopyCount, count);
-
1173 d->addToManualSetList(QPrintEngine::PPK_CopyCount);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_CopyCount);
-
1174}
executed: }
Execution Count:1
1
1175 -
1176/*! -
1177 \since 4.7 -
1178 -
1179 Returns the number of copies that will be printed. The default value is 1. -
1180 -
1181 \sa setCopyCount(), supportsMultipleCopies() -
1182*/ -
1183 -
1184int QPrinter::copyCount() const -
1185{ -
1186 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1187 return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
executed: return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
Execution Count:5
5
1188} -
1189 -
1190/*! -
1191 \since 4.7 -
1192 -
1193 Returns true if the printer supports printing multiple copies of the same -
1194 document in one job; otherwise false is returned. -
1195 -
1196 On most systems this function will return true. However, on X11 systems -
1197 that do not support CUPS, this function will return false. That means the -
1198 application has to handle the number of copies by printing the same -
1199 document the required number of times. -
1200 -
1201 \sa setCopyCount(), copyCount() -
1202*/ -
1203 -
1204bool QPrinter::supportsMultipleCopies() const -
1205{ -
1206 Q_D(const QPrinter);
never executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1207 return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
never executed: return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
0
1208} -
1209 -
1210/*! -
1211 \since 4.1 -
1212 -
1213 Returns true if collation is turned on when multiple copies is selected. -
1214 Returns false if it is turned off when multiple copies is selected. -
1215 When collating is turned off the printing of each individual page will be repeated -
1216 the numCopies() amount before the next page is started. With collating turned on -
1217 all pages are printed before the next copy of those pages is started. -
1218 -
1219 \sa setCollateCopies() -
1220*/ -
1221bool QPrinter::collateCopies() const -
1222{ -
1223 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1224 return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool();
executed: return d->printEngine->property(QPrintEngine::PPK_CollateCopies).toBool();
Execution Count:10
10
1225} -
1226 -
1227 -
1228/*! -
1229 \since 4.1 -
1230 -
1231 Sets the default value for collation checkbox when the print -
1232 dialog appears. If \a collate is true, it will enable -
1233 setCollateCopiesEnabled(). The default value is false. This value -
1234 will be changed by what the user presses in the print dialog. -
1235 -
1236 \sa collateCopies() -
1237*/ -
1238void QPrinter::setCollateCopies(bool collate) -
1239{ -
1240 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1241 ABORT_IF_ACTIVE("QPrinter::setCollateCopies");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1242 d->printEngine->setProperty(QPrintEngine::PPK_CollateCopies, collate);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_CollateCopies, collate);
-
1243 d->addToManualSetList(QPrintEngine::PPK_CollateCopies);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_CollateCopies);
-
1244}
executed: }
Execution Count:3
3
1245 -
1246 -
1247 -
1248/*! -
1249 If \a fp is true, enables support for painting over the entire page; -
1250 otherwise restricts painting to the printable area reported by the -
1251 device. -
1252 -
1253 By default, full page printing is disabled. In this case, the origin -
1254 of the QPrinter's coordinate system coincides with the top-left -
1255 corner of the printable area. -
1256 -
1257 If full page printing is enabled, the origin of the QPrinter's -
1258 coordinate system coincides with the top-left corner of the paper -
1259 itself. In this case, the -
1260 \l{QPaintDevice::PaintDeviceMetric}{device metrics} will report -
1261 the exact same dimensions as indicated by \l{PaperSize}. It may not -
1262 be possible to print on the entire physical page because of the -
1263 printer's margins, so the application must account for the margins -
1264 itself. -
1265 -
1266 \sa fullPage(), setPaperSize(), width(), height() -
1267*/ -
1268 -
1269void QPrinter::setFullPage(bool fp) -
1270{ -
1271 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1272 d->printEngine->setProperty(QPrintEngine::PPK_FullPage, fp);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_FullPage, fp);
-
1273 d->addToManualSetList(QPrintEngine::PPK_FullPage);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_FullPage);
-
1274}
executed: }
Execution Count:20
20
1275 -
1276 -
1277/*! -
1278 Returns true if the origin of the printer's coordinate system is -
1279 at the corner of the page and false if it is at the edge of the -
1280 printable area. -
1281 -
1282 See setFullPage() for details and caveats. -
1283 -
1284 \sa setFullPage(), PaperSize -
1285*/ -
1286 -
1287bool QPrinter::fullPage() const -
1288{ -
1289 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1290 return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool();
executed: return d->printEngine->property(QPrintEngine::PPK_FullPage).toBool();
Execution Count:6
6
1291} -
1292 -
1293 -
1294/*! -
1295 Requests that the printer prints at \a dpi or as near to \a dpi as -
1296 possible. -
1297 -
1298 This setting affects the coordinate system as returned by, for -
1299 example QPainter::viewport(). -
1300 -
1301 This function must be called before QPainter::begin() to have an effect on -
1302 all platforms. -
1303 -
1304 \sa resolution(), setPaperSize() -
1305*/ -
1306 -
1307void QPrinter::setResolution(int dpi) -
1308{ -
1309 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1310 ABORT_IF_ACTIVE("QPrinter::setResolution");
never executed: return;
partially evaluated: d->printEngine->printerState() == QPrinter::Active
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1311 d->printEngine->setProperty(QPrintEngine::PPK_Resolution, dpi);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_Resolution, dpi);
-
1312 d->addToManualSetList(QPrintEngine::PPK_Resolution);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_Resolution);
-
1313}
executed: }
Execution Count:25
25
1314 -
1315 -
1316/*! -
1317 Returns the current assumed resolution of the printer, as set by -
1318 setResolution() or by the printer driver. -
1319 -
1320 \sa setResolution() -
1321*/ -
1322 -
1323int QPrinter::resolution() const -
1324{ -
1325 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1326 return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt();
executed: return d->printEngine->property(QPrintEngine::PPK_Resolution).toInt();
Execution Count:163
163
1327} -
1328 -
1329/*! -
1330 Sets the paper source setting to \a source. -
1331 -
1332 Windows only: This option can be changed while printing and will -
1333 take effect from the next call to newPage() -
1334 -
1335 \sa paperSource() -
1336*/ -
1337 -
1338void QPrinter::setPaperSource(PaperSource source) -
1339{ -
1340 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1341 d->printEngine->setProperty(QPrintEngine::PPK_PaperSource, source);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_PaperSource, source);
-
1342 d->addToManualSetList(QPrintEngine::PPK_PaperSource);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_PaperSource);
-
1343}
executed: }
Execution Count:3
3
1344 -
1345/*! -
1346 Returns the printer's paper source. This is \c Manual or a printer -
1347 tray or paper cassette. -
1348*/ -
1349QPrinter::PaperSource QPrinter::paperSource() const -
1350{ -
1351 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1352 return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt());
executed: return QPrinter::PaperSource(d->printEngine->property(QPrintEngine::PPK_PaperSource).toInt());
Execution Count:6
6
1353} -
1354 -
1355 -
1356/*! -
1357 \since 4.1 -
1358 -
1359 Enabled or disables font embedding depending on \a enable. -
1360 -
1361 Currently this option is only supported on X11. -
1362 -
1363 \sa fontEmbeddingEnabled() -
1364*/ -
1365void QPrinter::setFontEmbeddingEnabled(bool enable) -
1366{ -
1367 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1368 d->printEngine->setProperty(QPrintEngine::PPK_FontEmbedding, enable);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_FontEmbedding, enable);
-
1369 d->addToManualSetList(QPrintEngine::PPK_FontEmbedding);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_FontEmbedding);
-
1370}
executed: }
Execution Count:3
3
1371 -
1372/*! -
1373 \since 4.1 -
1374 -
1375 Returns true if font embedding is enabled. -
1376 -
1377 Currently this option is only supported on X11. -
1378 -
1379 \sa setFontEmbeddingEnabled() -
1380*/ -
1381bool QPrinter::fontEmbeddingEnabled() const -
1382{ -
1383 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1384 return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool();
executed: return d->printEngine->property(QPrintEngine::PPK_FontEmbedding).toBool();
Execution Count:6
6
1385} -
1386 -
1387/*! -
1388 \enum QPrinter::DuplexMode -
1389 \since 4.4 -
1390 -
1391 This enum is used to indicate whether printing will occur on one or both sides -
1392 of each sheet of paper (simplex or duplex printing). -
1393 -
1394 \value DuplexNone Single sided (simplex) printing only. -
1395 \value DuplexAuto The printer's default setting is used to determine whether -
1396 duplex printing is used. -
1397 \value DuplexLongSide Both sides of each sheet of paper are used for printing. -
1398 The paper is turned over its longest edge before the second -
1399 side is printed -
1400 \value DuplexShortSide Both sides of each sheet of paper are used for printing. -
1401 The paper is turned over its shortest edge before the second -
1402 side is printed -
1403*/ -
1404 -
1405/*! -
1406 \since 4.2 -
1407 -
1408 Enables double sided printing if \a doubleSided is true; otherwise disables it. -
1409 -
1410 Currently this option is only supported on X11. -
1411*/ -
1412void QPrinter::setDoubleSidedPrinting(bool doubleSided) -
1413{ -
1414 setDuplex(doubleSided ? DuplexAuto : DuplexNone);
executed (the execution status of this line is deduced): setDuplex(doubleSided ? DuplexAuto : DuplexNone);
-
1415}
executed: }
Execution Count:3
3
1416 -
1417 -
1418/*! -
1419 \since 4.2 -
1420 -
1421 Returns true if double side printing is enabled. -
1422 -
1423 Currently this option is only supported on X11. -
1424*/ -
1425bool QPrinter::doubleSidedPrinting() const -
1426{ -
1427 return duplex() != DuplexNone;
executed: return duplex() != DuplexNone;
Execution Count:6
6
1428} -
1429 -
1430/*! -
1431 \since 4.4 -
1432 -
1433 Enables double sided printing based on the \a duplex mode. -
1434 -
1435 Currently this option is only supported on X11. -
1436*/ -
1437void QPrinter::setDuplex(DuplexMode duplex) -
1438{ -
1439 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1440 d->printEngine->setProperty(QPrintEngine::PPK_Duplex, duplex);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_Duplex, duplex);
-
1441 d->addToManualSetList(QPrintEngine::PPK_Duplex);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_Duplex);
-
1442}
executed: }
Execution Count:3
3
1443 -
1444/*! -
1445 \since 4.4 -
1446 -
1447 Returns the current duplex mode. -
1448 -
1449 Currently this option is only supported on X11. -
1450*/ -
1451QPrinter::DuplexMode QPrinter::duplex() const -
1452{ -
1453 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1454 return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt());
executed: return static_cast <DuplexMode> (d->printEngine->property(QPrintEngine::PPK_Duplex).toInt());
Execution Count:10
10
1455} -
1456 -
1457/*! -
1458 \since 4.4 -
1459 -
1460 Returns the page's rectangle in \a unit; this is usually smaller -
1461 than the paperRect() since the page normally has margins between -
1462 its borders and the paper. -
1463 -
1464 \sa paperSize() -
1465*/ -
1466QRectF QPrinter::pageRect(Unit unit) const -
1467{ -
1468 Q_D(const QPrinter);
never executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1469 int res = resolution();
never executed (the execution status of this line is deduced): int res = resolution();
-
1470 const qreal multiplier = qt_multiplierForUnit(unit, res);
never executed (the execution status of this line is deduced): const qreal multiplier = qt_multiplierForUnit(unit, res);
-
1471 // the page rect is in device pixels -
1472 QRect devRect(d->printEngine->property(QPrintEngine::PPK_PageRect).toRect());
never executed (the execution status of this line is deduced): QRect devRect(d->printEngine->property(QPrintEngine::PPK_PageRect).toRect());
-
1473 if (unit == DevicePixel)
never evaluated: unit == DevicePixel
0
1474 return devRect;
never executed: return devRect;
0
1475 QRectF diRect(devRect.x()*72.0/res,
never executed (the execution status of this line is deduced): QRectF diRect(devRect.x()*72.0/res,
-
1476 devRect.y()*72.0/res,
never executed (the execution status of this line is deduced): devRect.y()*72.0/res,
-
1477 devRect.width()*72.0/res,
never executed (the execution status of this line is deduced): devRect.width()*72.0/res,
-
1478 devRect.height()*72.0/res);
never executed (the execution status of this line is deduced): devRect.height()*72.0/res);
-
1479 return QRectF(diRect.x()/multiplier, diRect.y()/multiplier,
never executed: return QRectF(diRect.x()/multiplier, diRect.y()/multiplier, diRect.width()/multiplier, diRect.height()/multiplier);
0
1480 diRect.width()/multiplier, diRect.height()/multiplier);
never executed: return QRectF(diRect.x()/multiplier, diRect.y()/multiplier, diRect.width()/multiplier, diRect.height()/multiplier);
0
1481} -
1482 -
1483 -
1484/*! -
1485 \since 4.4 -
1486 -
1487 Returns the paper's rectangle in \a unit; this is usually larger -
1488 than the pageRect(). -
1489 -
1490 \sa pageRect() -
1491*/ -
1492QRectF QPrinter::paperRect(Unit unit) const -
1493{ -
1494 Q_D(const QPrinter);
never executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1495 int res = resolution();
never executed (the execution status of this line is deduced): int res = resolution();
-
1496 const qreal multiplier = qt_multiplierForUnit(unit, resolution());
never executed (the execution status of this line is deduced): const qreal multiplier = qt_multiplierForUnit(unit, resolution());
-
1497 // the page rect is in device pixels -
1498 QRect devRect(d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect());
never executed (the execution status of this line is deduced): QRect devRect(d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect());
-
1499 if (unit == DevicePixel)
never evaluated: unit == DevicePixel
0
1500 return devRect;
never executed: return devRect;
0
1501 QRectF diRect(devRect.x()*72.0/res,
never executed (the execution status of this line is deduced): QRectF diRect(devRect.x()*72.0/res,
-
1502 devRect.y()*72.0/res,
never executed (the execution status of this line is deduced): devRect.y()*72.0/res,
-
1503 devRect.width()*72.0/res,
never executed (the execution status of this line is deduced): devRect.width()*72.0/res,
-
1504 devRect.height()*72.0/res);
never executed (the execution status of this line is deduced): devRect.height()*72.0/res);
-
1505 return QRectF(diRect.x()/multiplier, diRect.y()/multiplier,
never executed: return QRectF(diRect.x()/multiplier, diRect.y()/multiplier, diRect.width()/multiplier, diRect.height()/multiplier);
0
1506 diRect.width()/multiplier, diRect.height()/multiplier);
never executed: return QRectF(diRect.x()/multiplier, diRect.y()/multiplier, diRect.width()/multiplier, diRect.height()/multiplier);
0
1507} -
1508 -
1509/*! -
1510 Returns the page's rectangle; this is usually smaller than the -
1511 paperRect() since the page normally has margins between its -
1512 borders and the paper. -
1513 -
1514 The unit of the returned rectangle is DevicePixel. -
1515 -
1516 \sa paperSize() -
1517*/ -
1518QRect QPrinter::pageRect() const -
1519{ -
1520 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1521 return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect();
executed: return d->printEngine->property(QPrintEngine::PPK_PageRect).toRect();
Execution Count:24
24
1522} -
1523 -
1524/*! -
1525 Returns the paper's rectangle; this is usually larger than the -
1526 pageRect(). -
1527 -
1528 The unit of the returned rectangle is DevicePixel. -
1529 -
1530 \sa pageRect() -
1531*/ -
1532QRect QPrinter::paperRect() const -
1533{ -
1534 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1535 return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect();
executed: return d->printEngine->property(QPrintEngine::PPK_PaperRect).toRect();
Execution Count:78
78
1536} -
1537 -
1538 -
1539/*! -
1540 \since 4.4 -
1541 -
1542 This function sets the \a left, \a top, \a right and \a bottom -
1543 page margins for this printer. The unit of the margins are -
1544 specified with the \a unit parameter. -
1545 -
1546 \sa getPageMargins() -
1547*/ -
1548void QPrinter::setPageMargins(qreal left, qreal top, qreal right, qreal bottom, QPrinter::Unit unit) -
1549{ -
1550 const qreal multiplier = qt_multiplierForUnit(unit, resolution()) * 25.4/72.;
executed (the execution status of this line is deduced): const qreal multiplier = qt_multiplierForUnit(unit, resolution()) * 25.4/72.;
-
1551 Margins m = { left*multiplier, right*multiplier, top*multiplier, bottom*multiplier };
executed (the execution status of this line is deduced): Margins m = { left*multiplier, right*multiplier, top*multiplier, bottom*multiplier };
-
1552 setMargins(m);
executed (the execution status of this line is deduced): setMargins(m);
-
1553}
executed: }
Execution Count:10
10
1554 -
1555/*! -
1556 \reimp -
1557 */ -
1558void QPrinter::setMargins(const Margins &m) -
1559{ -
1560 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1561 -
1562 // set margins also to super class -
1563 QPagedPaintDevice::setMargins(m);
executed (the execution status of this line is deduced): QPagedPaintDevice::setMargins(m);
-
1564 -
1565 const qreal multiplier = 72./25.4;
executed (the execution status of this line is deduced): const qreal multiplier = 72./25.4;
-
1566 QList<QVariant> margins;
executed (the execution status of this line is deduced): QList<QVariant> margins;
-
1567 margins << (m.left * multiplier) << (m.top * multiplier)
executed (the execution status of this line is deduced): margins << (m.left * multiplier) << (m.top * multiplier)
-
1568 << (m.right * multiplier) << (m.bottom * multiplier);
executed (the execution status of this line is deduced): << (m.right * multiplier) << (m.bottom * multiplier);
-
1569 d->printEngine->setProperty(QPrintEngine::PPK_PageMargins, margins);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_PageMargins, margins);
-
1570 d->addToManualSetList(QPrintEngine::PPK_PageMargins);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_PageMargins);
-
1571 d->hasCustomPageMargins = true;
executed (the execution status of this line is deduced): d->hasCustomPageMargins = true;
-
1572}
executed: }
Execution Count:10
10
1573 -
1574 -
1575/*! -
1576 \since 4.4 -
1577 -
1578 Returns the page margins for this printer in \a left, \a top, \a -
1579 right, \a bottom. The unit of the returned margins are specified -
1580 with the \a unit parameter. -
1581 -
1582 \sa setPageMargins() -
1583*/ -
1584void QPrinter::getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, QPrinter::Unit unit) const -
1585{ -
1586 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1587 Q_ASSERT(left && top && right && bottom);
executed (the execution status of this line is deduced): qt_noop();
-
1588 const qreal multiplier = qt_multiplierForUnit(unit, resolution());
executed (the execution status of this line is deduced): const qreal multiplier = qt_multiplierForUnit(unit, resolution());
-
1589 QList<QVariant> margins(d->printEngine->property(QPrintEngine::PPK_PageMargins).toList());
executed (the execution status of this line is deduced): QList<QVariant> margins(d->printEngine->property(QPrintEngine::PPK_PageMargins).toList());
-
1590 *left = margins.at(0).toReal() / multiplier;
executed (the execution status of this line is deduced): *left = margins.at(0).toReal() / multiplier;
-
1591 *top = margins.at(1).toReal() / multiplier;
executed (the execution status of this line is deduced): *top = margins.at(1).toReal() / multiplier;
-
1592 *right = margins.at(2).toReal() / multiplier;
executed (the execution status of this line is deduced): *right = margins.at(2).toReal() / multiplier;
-
1593 *bottom = margins.at(3).toReal() / multiplier;
executed (the execution status of this line is deduced): *bottom = margins.at(3).toReal() / multiplier;
-
1594}
executed: }
Execution Count:42
42
1595 -
1596/*! -
1597 \internal -
1598 -
1599 Returns the metric for the given \a id. -
1600*/ -
1601int QPrinter::metric(PaintDeviceMetric id) const -
1602{ -
1603 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1604 return d->printEngine->metric(id);
executed: return d->printEngine->metric(id);
Execution Count:150
150
1605} -
1606 -
1607/*! -
1608 Returns the paint engine used by the printer. -
1609*/ -
1610QPaintEngine *QPrinter::paintEngine() const -
1611{ -
1612 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1613 return d->paintEngine;
executed: return d->paintEngine;
Execution Count:21
21
1614} -
1615 -
1616/*! -
1617 \since 4.1 -
1618 -
1619 Returns the print engine used by the printer. -
1620*/ -
1621QPrintEngine *QPrinter::printEngine() const -
1622{ -
1623 Q_D(const QPrinter);
never executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1624 return d->printEngine;
never executed: return d->printEngine;
0
1625} -
1626 -
1627#if defined (Q_OS_WIN) -
1628/*! -
1629 Sets the page size to be used by the printer under Windows to \a -
1630 pageSize. -
1631 -
1632 \warning This function is not portable so you may prefer to use -
1633 setPaperSize() instead. -
1634 -
1635 \sa winPageSize() -
1636*/ -
1637void QPrinter::setWinPageSize(int pageSize) -
1638{ -
1639 Q_D(QPrinter); -
1640 ABORT_IF_ACTIVE("QPrinter::setWinPageSize"); -
1641 d->printEngine->setProperty(QPrintEngine::PPK_WindowsPageSize, pageSize); -
1642 d->addToManualSetList(QPrintEngine::PPK_WindowsPageSize); -
1643} -
1644 -
1645/*! -
1646 Returns the page size used by the printer under Windows. -
1647 -
1648 \warning This function is not portable so you may prefer to use -
1649 paperSize() instead. -
1650 -
1651 \sa setWinPageSize() -
1652*/ -
1653int QPrinter::winPageSize() const -
1654{ -
1655 Q_D(const QPrinter); -
1656 return d->printEngine->property(QPrintEngine::PPK_WindowsPageSize).toInt(); -
1657} -
1658#endif // Q_OS_WIN -
1659 -
1660/*! -
1661 Returns a list of the resolutions (a list of dots-per-inch -
1662 integers) that the printer says it supports. -
1663 -
1664 For X11 where all printing is directly to PDF, this -
1665 function will always return a one item list containing only the -
1666 PDF resolution, i.e., 72 (72 dpi -- but see PrinterMode). -
1667*/ -
1668QList<int> QPrinter::supportedResolutions() const -
1669{ -
1670 Q_D(const QPrinter);
never executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1671 QList<QVariant> varlist
never executed (the execution status of this line is deduced): QList<QVariant> varlist
-
1672 = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
never executed (the execution status of this line is deduced): = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList();
-
1673 QList<int> intlist;
never executed (the execution status of this line is deduced): QList<int> intlist;
-
1674 for (int i=0; i<varlist.size(); ++i)
never evaluated: i<varlist.size()
0
1675 intlist << varlist.at(i).toInt();
never executed: intlist << varlist.at(i).toInt();
0
1676 return intlist;
never executed: return intlist;
0
1677} -
1678 -
1679/*! -
1680 Tells the printer to eject the current page and to continue -
1681 printing on a new page. Returns true if this was successful; -
1682 otherwise returns false. -
1683 -
1684 Calling newPage() on an inactive QPrinter object will always -
1685 fail. -
1686*/ -
1687bool QPrinter::newPage() -
1688{ -
1689 Q_D(QPrinter);
never executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1690 if (d->printEngine->printerState() != QPrinter::Active)
never evaluated: d->printEngine->printerState() != QPrinter::Active
0
1691 return false;
never executed: return false;
0
1692 return d->printEngine->newPage();
never executed: return d->printEngine->newPage();
0
1693} -
1694 -
1695/*! -
1696 Aborts the current print run. Returns true if the print run was -
1697 successfully aborted and printerState() will return QPrinter::Aborted; otherwise -
1698 returns false. -
1699 -
1700 It is not always possible to abort a print job. For example, -
1701 all the data has gone to the printer but the printer cannot or -
1702 will not cancel the job when asked to. -
1703*/ -
1704bool QPrinter::abort() -
1705{ -
1706 Q_D(QPrinter);
never executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1707 return d->printEngine->abort();
never executed: return d->printEngine->abort();
0
1708} -
1709 -
1710/*! -
1711 Returns the current state of the printer. This may not always be -
1712 accurate (for example if the printer doesn't have the capability -
1713 of reporting its state to the operating system). -
1714*/ -
1715QPrinter::PrinterState QPrinter::printerState() const -
1716{ -
1717 Q_D(const QPrinter);
never executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1718 return d->printEngine->printerState();
never executed: return d->printEngine->printerState();
0
1719} -
1720 -
1721#ifdef Q_OS_WIN -
1722/*! -
1723 Returns the supported paper sizes for this printer. -
1724 -
1725 The values will be either a value that matches an entry in the -
1726 QPrinter::PaperSource enum or a driver spesific value. The driver -
1727 spesific values are greater than the constant DMBIN_USER declared -
1728 in wingdi.h. -
1729 -
1730 \warning This function is only available in windows. -
1731*/ -
1732 -
1733QList<QPrinter::PaperSource> QPrinter::supportedPaperSources() const -
1734{ -
1735 Q_D(const QPrinter); -
1736 QVariant v = d->printEngine->property(QPrintEngine::PPK_PaperSources); -
1737 -
1738 QList<QVariant> variant_list = v.toList(); -
1739 QList<QPrinter::PaperSource> int_list; -
1740 for (int i=0; i<variant_list.size(); ++i) -
1741 int_list << (QPrinter::PaperSource) variant_list.at(i).toInt(); -
1742 -
1743 return int_list; -
1744} -
1745 -
1746#endif // Q_OS_WIN -
1747 -
1748/*! -
1749 \fn QString QPrinter::printerSelectionOption() const -
1750 -
1751 Returns the printer options selection string. This is useful only -
1752 if the print command has been explicitly set. -
1753 -
1754 The default value (an empty string) implies that the printer should -
1755 be selected in a system-dependent manner. -
1756 -
1757 Any other value implies that the given value should be used. -
1758 -
1759 \warning This function is not available on Windows. -
1760 -
1761 \sa setPrinterSelectionOption() -
1762*/ -
1763 -
1764/*! -
1765 \fn void QPrinter::setPrinterSelectionOption(const QString &option) -
1766 -
1767 Sets the printer to use \a option to select the printer. \a option -
1768 is null by default (which implies that Qt should be smart enough -
1769 to guess correctly), but it can be set to other values to use a -
1770 specific printer selection option. -
1771 -
1772 If the printer selection option is changed while the printer is -
1773 active, the current print job may or may not be affected. -
1774 -
1775 \warning This function is not available on Windows. -
1776 -
1777 \sa printerSelectionOption() -
1778*/ -
1779 -
1780#ifndef Q_OS_WIN -
1781QString QPrinter::printerSelectionOption() const -
1782{ -
1783 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1784 return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();
executed: return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();
Execution Count:5
5
1785} -
1786 -
1787void QPrinter::setPrinterSelectionOption(const QString &option) -
1788{ -
1789 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1790 d->printEngine->setProperty(QPrintEngine::PPK_SelectionOption, option);
executed (the execution status of this line is deduced): d->printEngine->setProperty(QPrintEngine::PPK_SelectionOption, option);
-
1791 d->addToManualSetList(QPrintEngine::PPK_SelectionOption);
executed (the execution status of this line is deduced): d->addToManualSetList(QPrintEngine::PPK_SelectionOption);
-
1792}
executed: }
Execution Count:2
2
1793#endif -
1794 -
1795/*! -
1796 \since 4.1 -
1797 \fn int QPrinter::fromPage() const -
1798 -
1799 Returns the number of the first page in a range of pages to be printed -
1800 (the "from page" setting). Pages in a document are numbered according to -
1801 the convention that the first page is page 1. -
1802 -
1803 By default, this function returns a special value of 0, meaning that -
1804 the "from page" setting is unset. -
1805 -
1806 \note If fromPage() and toPage() both return 0, this indicates that -
1807 \e{the whole document will be printed}. -
1808 -
1809 \sa setFromTo(), toPage() -
1810*/ -
1811 -
1812int QPrinter::fromPage() const -
1813{ -
1814 return d->fromPage;
executed: return d->fromPage;
Execution Count:13
13
1815} -
1816 -
1817/*! -
1818 \since 4.1 -
1819 -
1820 Returns the number of the last page in a range of pages to be printed -
1821 (the "to page" setting). Pages in a document are numbered according to -
1822 the convention that the first page is page 1. -
1823 -
1824 By default, this function returns a special value of 0, meaning that -
1825 the "to page" setting is unset. -
1826 -
1827 \note If fromPage() and toPage() both return 0, this indicates that -
1828 \e{the whole document will be printed}. -
1829 -
1830 The programmer is responsible for reading this setting and -
1831 printing accordingly. -
1832 -
1833 \sa setFromTo(), fromPage() -
1834*/ -
1835 -
1836int QPrinter::toPage() const -
1837{ -
1838 return d->toPage;
executed: return d->toPage;
Execution Count:12
12
1839} -
1840 -
1841/*! -
1842 \since 4.1 -
1843 -
1844 Sets the range of pages to be printed to cover the pages with numbers -
1845 specified by \a from and \a to, where \a from corresponds to the first -
1846 page in the range and \a to corresponds to the last. -
1847 -
1848 \note Pages in a document are numbered according to the convention that -
1849 the first page is page 1. However, if \a from and \a to are both set to 0, -
1850 the \e{whole document will be printed}. -
1851 -
1852 This function is mostly used to set a default value that the user can -
1853 override in the print dialog when you call setup(). -
1854 -
1855 \sa fromPage(), toPage() -
1856*/ -
1857 -
1858void QPrinter::setFromTo(int from, int to) -
1859{ -
1860 if (from > to) {
partially evaluated: from > to
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1861 qWarning() << "QPrinter::setFromTo: 'from' must be less than or equal to 'to'";
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qprinter.cpp", 1861, __PRETTY_FUNCTION__).warning() << "QPrinter::setFromTo: 'from' must be less than or equal to 'to'";
-
1862 from = to;
never executed (the execution status of this line is deduced): from = to;
-
1863 }
never executed: }
0
1864 d->fromPage = from;
executed (the execution status of this line is deduced): d->fromPage = from;
-
1865 d->toPage = to;
executed (the execution status of this line is deduced): d->toPage = to;
-
1866}
executed: }
Execution Count:3
3
1867 -
1868/*! -
1869 \since 4.1 -
1870 -
1871 Sets the print range option in to be \a range. -
1872*/ -
1873void QPrinter::setPrintRange( PrintRange range ) -
1874{ -
1875 d->printSelectionOnly = (range == Selection);
executed (the execution status of this line is deduced): d->printSelectionOnly = (range == Selection);
-
1876 -
1877 Q_D(QPrinter);
executed (the execution status of this line is deduced): QPrinterPrivate * const d = d_func();
-
1878 d->printRange = range;
executed (the execution status of this line is deduced): d->printRange = range;
-
1879}
executed: }
Execution Count:8
8
1880 -
1881/*! -
1882 \since 4.1 -
1883 -
1884 Returns the page range of the QPrinter. After the print setup -
1885 dialog has been opened, this function returns the value selected -
1886 by the user. -
1887 -
1888 \sa setPrintRange() -
1889*/ -
1890QPrinter::PrintRange QPrinter::printRange() const -
1891{ -
1892 Q_D(const QPrinter);
executed (the execution status of this line is deduced): const QPrinterPrivate * const d = d_func();
-
1893 return d->printRange;
executed: return d->printRange;
Execution Count:8
8
1894} -
1895 -
1896 -
1897/*! -
1898 \class QPrintEngine -
1899 \reentrant -
1900 -
1901 \ingroup printing -
1902 \inmodule QtPrintSupport -
1903 -
1904 \brief The QPrintEngine class defines an interface for how QPrinter -
1905 interacts with a given printing subsystem. -
1906 -
1907 The common case when creating your own print engine is to derive from both -
1908 QPaintEngine and QPrintEngine. Various properties of a print engine are -
1909 given with property() and set with setProperty(). -
1910 -
1911 \sa QPaintEngine -
1912*/ -
1913 -
1914/*! -
1915 \enum QPrintEngine::PrintEnginePropertyKey -
1916 -
1917 This enum is used to communicate properties between the print -
1918 engine and QPrinter. A property may or may not be supported by a -
1919 given print engine. -
1920 -
1921 \value PPK_CollateCopies A boolean value indicating whether the -
1922 printout should be collated or not. -
1923 -
1924 \value PPK_ColorMode Refers to QPrinter::ColorMode, either color or -
1925 monochrome. -
1926 -
1927 \value PPK_Creator A string describing the document's creator. -
1928 -
1929 \value PPK_Duplex A boolean value indicating whether both sides of -
1930 the printer paper should be used for the printout. -
1931 -
1932 \value PPK_DocumentName A string describing the document name in -
1933 the spooler. -
1934 -
1935 \value PPK_FontEmbedding A boolean value indicating whether data for -
1936 the document's fonts should be embedded in the data sent to the -
1937 printer. -
1938 -
1939 \value PPK_FullPage A boolean describing if the printer should be -
1940 full page or not. -
1941 -
1942 \value PPK_NumberOfCopies Obsolete. An integer specifying the number of -
1943 copies. Use PPK_CopyCount instead. -
1944 -
1945 \value PPK_Orientation Specifies a QPrinter::Orientation value. -
1946 -
1947 \value PPK_OutputFileName The output file name as a string. An -
1948 empty file name indicates that the printer should not print to a file. -
1949 -
1950 \value PPK_PageOrder Specifies a QPrinter::PageOrder value. -
1951 -
1952 \value PPK_PageRect A QRect specifying the page rectangle -
1953 -
1954 \value PPK_PageSize Obsolete. Use PPK_PaperSize instead. -
1955 -
1956 \value PPK_PaperRect A QRect specifying the paper rectangle. -
1957 -
1958 \value PPK_PaperSource Specifies a QPrinter::PaperSource value. -
1959 -
1960 \value PPK_PaperSources Specifies more than one QPrinter::PaperSource value. -
1961 -
1962 \value PPK_PaperSize Specifies a QPrinter::PaperSize value. -
1963 -
1964 \value PPK_PrinterName A string specifying the name of the printer. -
1965 -
1966 \value PPK_PrinterProgram A string specifying the name of the -
1967 printer program used for printing, -
1968 -
1969 \value PPK_Resolution An integer describing the dots per inch for -
1970 this printer. -
1971 -
1972 \value PPK_SelectionOption -
1973 -
1974 \value PPK_SupportedResolutions A list of integer QVariants -
1975 describing the set of supported resolutions that the printer has. -
1976 -
1977 \value PPK_WindowsPageSize An integer specifying a DM_PAPER entry -
1978 on Windows. -
1979 -
1980 \value PPK_CustomPaperSize A QSizeF specifying a custom paper size -
1981 in the QPrinter::Point unit. -
1982 -
1983 \value PPK_PageMargins A QList<QVariant> containing the left, top, -
1984 right and bottom margin values. -
1985 -
1986 \value PPK_CopyCount An integer specifying the number of copies to print. -
1987 -
1988 \value PPK_SupportsMultipleCopies A boolean value indicating whether or not -
1989 the printer supports printing multiple copies in one job. -
1990 -
1991 \value PPK_CustomBase Basis for extension. -
1992*/ -
1993 -
1994/*! -
1995 \fn QPrintEngine::~QPrintEngine() -
1996 -
1997 Destroys the print engine. -
1998*/ -
1999 -
2000/*! -
2001 \fn void QPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value) -
2002 -
2003 Sets the print engine's property specified by \a key to the given \a value. -
2004 -
2005 \sa property() -
2006*/ -
2007 -
2008/*! -
2009 \fn void QPrintEngine::property(PrintEnginePropertyKey key) const -
2010 -
2011 Returns the print engine's property specified by \a key. -
2012 -
2013 \sa setProperty() -
2014*/ -
2015 -
2016/*! -
2017 \fn bool QPrintEngine::newPage() -
2018 -
2019 Instructs the print engine to start a new page. Returns true if -
2020 the printer was able to create the new page; otherwise returns false. -
2021*/ -
2022 -
2023/*! -
2024 \fn bool QPrintEngine::abort() -
2025 -
2026 Instructs the print engine to abort the printing process. Returns -
2027 true if successful; otherwise returns false. -
2028*/ -
2029 -
2030/*! -
2031 \fn int QPrintEngine::metric(QPaintDevice::PaintDeviceMetric id) const -
2032 -
2033 Returns the metric for the given \a id. -
2034*/ -
2035 -
2036/*! -
2037 \fn QPrinter::PrinterState QPrintEngine::printerState() const -
2038 -
2039 Returns the current state of the printer being used by the print engine. -
2040*/ -
2041 -
2042/* -
2043 Returns the dimensions for the given paper size, \a size, in millimeters. -
2044*/ -
2045QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size) -
2046{ -
2047 if (size == QPrinter::Custom) return QSizeF(0, 0);
never executed: return QSizeF(0, 0);
partially evaluated: size == QPrinter::Custom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
2048 return QSizeF(qt_paperSizes[size][0], qt_paperSizes[size][1]);
executed: return QSizeF(qt_paperSizes[size][0], qt_paperSizes[size][1]);
Execution Count:31
31
2049} -
2050 -
2051/* -
2052 Returns the PaperSize type that matches \a size, where \a size -
2053 is in millimeters. -
2054 -
2055 Because dimensions may not always be completely accurate (for -
2056 example when converting between units), a particular PaperSize -
2057 will be returned if it matches within -1/+1 millimeters. -
2058*/ -
2059QPrinter::PaperSize qSizeFTopaperSize(const QSizeF& size) -
2060{ -
2061 for (int i = 0; i < static_cast<int>(QPrinter::NPageSize); ++i) {
never evaluated: i < static_cast<int>(QPrinter::NPageSize)
0
2062 if (qt_paperSizes[i][0] >= size.width() - 1 &&
never evaluated: qt_paperSizes[i][0] >= size.width() - 1
0
2063 qt_paperSizes[i][0] <= size.width() + 1 &&
never evaluated: qt_paperSizes[i][0] <= size.width() + 1
0
2064 qt_paperSizes[i][1] >= size.height() - 1 &&
never evaluated: qt_paperSizes[i][1] >= size.height() - 1
0
2065 qt_paperSizes[i][1] <= size.height() + 1) {
never evaluated: qt_paperSizes[i][1] <= size.height() + 1
0
2066 return QPrinter::PaperSize(i);
never executed: return QPrinter::PaperSize(i);
0
2067 } -
2068 }
never executed: }
0
2069 -
2070 return QPrinter::Custom;
never executed: return QPrinter::Custom;
0
2071} -
2072 -
2073QT_END_NAMESPACE -
2074 -
2075#endif // QT_NO_PRINTER -
2076 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial