kernel/qprinter.cpp

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

Generated by Squish Coco Non-Commercial