Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | static const bool do_compress = true; | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | static const bool interpolateImages = false; | - |
14 | | - |
15 | | - |
16 | | - |
17 | inline QPaintEngine::PaintEngineFeatures qt_pdf_decide_features() | - |
18 | { | - |
19 | QPaintEngine::PaintEngineFeatures f = QPaintEngine::AllFeatures; | - |
20 | f &= ~(QPaintEngine::PorterDuff | QPaintEngine::PerspectiveTransform | - |
21 | | QPaintEngine::ObjectBoundingModeGradients | - |
22 | | - |
23 | | QPaintEngine::LinearGradientFill | - |
24 | | - |
25 | | QPaintEngine::RadialGradientFill | - |
26 | | QPaintEngine::ConicalGradientFill); | - |
27 | return f; executed: return f; Execution Count:234 | 234 |
28 | } | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | const char *qt_real_to_string(qreal val, char *buf) { | - |
34 | const char *ret = buf; | - |
35 | | - |
36 | if (qIsNaN(val)) { partially evaluated: qIsNaN(val) no Evaluation Count:0 | yes Evaluation Count:136 |
| 0-136 |
37 | *(buf++) = '0'; | - |
38 | *(buf++) = ' '; | - |
39 | *buf = 0; | - |
40 | return ret; never executed: return ret; | 0 |
41 | } | - |
42 | | - |
43 | if (val < 0) { evaluated: val < 0 yes Evaluation Count:20 | yes Evaluation Count:116 |
| 20-116 |
44 | *(buf++) = '-'; | - |
45 | val = -val; | - |
46 | } executed: } Execution Count:20 | 20 |
47 | unsigned int ival = (unsigned int) val; | - |
48 | qreal frac = val - (qreal)ival; | - |
49 | | - |
50 | int ifrac = (int)(frac * 1000000000); | - |
51 | if (ifrac == 1000000000) { partially evaluated: ifrac == 1000000000 no Evaluation Count:0 | yes Evaluation Count:136 |
| 0-136 |
52 | ++ival; | - |
53 | ifrac = 0; | - |
54 | } | 0 |
55 | char output[256]; | - |
56 | int i = 0; | - |
57 | while (ival) { evaluated: ival yes Evaluation Count:104 | yes Evaluation Count:136 |
| 104-136 |
58 | output[i] = '0' + (ival % 10); | - |
59 | ++i; | - |
60 | ival /= 10; | - |
61 | } executed: } Execution Count:104 | 104 |
62 | int fact = 100000000; | - |
63 | if (i == 0) { evaluated: i == 0 yes Evaluation Count:88 | yes Evaluation Count:48 |
| 48-88 |
64 | *(buf++) = '0'; | - |
65 | } else { executed: } Execution Count:88 | 88 |
66 | while (i) { evaluated: i yes Evaluation Count:104 | yes Evaluation Count:48 |
| 48-104 |
67 | *(buf++) = output[--i]; | - |
68 | fact /= 10; | - |
69 | ifrac /= 10; | - |
70 | } executed: } Execution Count:104 | 104 |
71 | } executed: } Execution Count:48 | 48 |
72 | | - |
73 | if (ifrac) { evaluated: ifrac yes Evaluation Count:76 | yes Evaluation Count:60 |
| 60-76 |
74 | *(buf++) = '.'; | - |
75 | while (fact) { evaluated: fact yes Evaluation Count:604 | yes Evaluation Count:76 |
| 76-604 |
76 | *(buf++) = '0' + ((ifrac/fact) % 10); | - |
77 | fact /= 10; | - |
78 | } executed: } Execution Count:604 | 604 |
79 | } executed: } Execution Count:76 | 76 |
80 | *(buf++) = ' '; | - |
81 | *buf = 0; | - |
82 | return ret; executed: return ret; Execution Count:136 | 136 |
83 | } | - |
84 | | - |
85 | const char *qt_int_to_string(int val, char *buf) { | - |
86 | const char *ret = buf; | - |
87 | if (val < 0) { partially evaluated: val < 0 no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
88 | *(buf++) = '-'; | - |
89 | val = -val; | - |
90 | } | 0 |
91 | char output[256]; | - |
92 | int i = 0; | - |
93 | while (val) { evaluated: val yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
94 | output[i] = '0' + (val % 10); | - |
95 | ++i; | - |
96 | val /= 10; | - |
97 | } executed: } Execution Count:4 | 4 |
98 | if (i == 0) { partially evaluated: i == 0 no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
99 | *(buf++) = '0'; | - |
100 | } else { | 0 |
101 | while (i) evaluated: i yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
102 | *(buf++) = output[--i]; executed: *(buf++) = output[--i]; Execution Count:4 | 4 |
103 | } executed: } Execution Count:4 | 4 |
104 | *(buf++) = ' '; | - |
105 | *buf = 0; | - |
106 | return ret; executed: return ret; Execution Count:4 | 4 |
107 | } | - |
108 | | - |
109 | | - |
110 | namespace QPdf { | - |
111 | ByteStream::ByteStream(QByteArray *byteArray, bool fileBacking) | - |
112 | : dev(new QBuffer(byteArray)), | - |
113 | fileBackingEnabled(fileBacking), | - |
114 | fileBackingActive(false), | - |
115 | handleDirty(false) | - |
116 | { | - |
117 | dev->open(QIODevice::ReadWrite | QIODevice::Append); | - |
118 | } executed: } Execution Count:22 | 22 |
119 | | - |
120 | ByteStream::ByteStream(bool fileBacking) | - |
121 | : dev(new QBuffer(&ba)), | - |
122 | fileBackingEnabled(fileBacking), | - |
123 | fileBackingActive(false), | - |
124 | handleDirty(false) | - |
125 | { | - |
126 | dev->open(QIODevice::ReadWrite); | - |
127 | } executed: } Execution Count:40 | 40 |
128 | | - |
129 | ByteStream::~ByteStream() | - |
130 | { | - |
131 | delete dev; | - |
132 | } executed: } Execution Count:62 | 62 |
133 | | - |
134 | ByteStream &ByteStream::operator <<(char chr) | - |
135 | { | - |
136 | if (handleDirty) prepareBuffer(); never executed: prepareBuffer(); partially evaluated: handleDirty no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
137 | dev->write(&chr, 1); | - |
138 | return *this; executed: return *this; Execution Count:4 | 4 |
139 | } | - |
140 | | - |
141 | ByteStream &ByteStream::operator <<(const char *str) | - |
142 | { | - |
143 | if (handleDirty) prepareBuffer(); never executed: prepareBuffer(); partially evaluated: handleDirty no Evaluation Count:0 | yes Evaluation Count:298 |
| 0-298 |
144 | dev->write(str, strlen(str)); | - |
145 | return *this; executed: return *this; Execution Count:298 | 298 |
146 | } | - |
147 | | - |
148 | ByteStream &ByteStream::operator <<(const QByteArray &str) | - |
149 | { | - |
150 | if (handleDirty) prepareBuffer(); never executed: prepareBuffer(); partially evaluated: handleDirty no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
151 | dev->write(str); | - |
152 | return *this; executed: return *this; Execution Count:22 | 22 |
153 | } | - |
154 | | - |
155 | ByteStream &ByteStream::operator <<(const ByteStream &src) | - |
156 | { | - |
157 | qt_noop(); | - |
158 | if (handleDirty) prepareBuffer(); never executed: prepareBuffer(); never evaluated: handleDirty | 0 |
159 | | - |
160 | | - |
161 | ByteStream &s = const_cast<ByteStream&>(src); | - |
162 | qint64 pos = s.dev->pos(); | - |
163 | s.dev->reset(); | - |
164 | while (!s.dev->atEnd()) { never evaluated: !s.dev->atEnd() | 0 |
165 | QByteArray buf = s.dev->read(chunkSize()); | - |
166 | dev->write(buf); | - |
167 | } | 0 |
168 | s.dev->seek(pos); | - |
169 | return *this; never executed: return *this; | 0 |
170 | } | - |
171 | | - |
172 | ByteStream &ByteStream::operator <<(qreal val) { | - |
173 | char buf[256]; | - |
174 | qt_real_to_string(val, buf); | - |
175 | *this << buf; | - |
176 | return *this; executed: return *this; Execution Count:136 | 136 |
177 | } | - |
178 | | - |
179 | ByteStream &ByteStream::operator <<(int val) { | - |
180 | char buf[256]; | - |
181 | qt_int_to_string(val, buf); | - |
182 | *this << buf; | - |
183 | return *this; executed: return *this; Execution Count:4 | 4 |
184 | } | - |
185 | | - |
186 | ByteStream &ByteStream::operator <<(const QPointF &p) { | - |
187 | char buf[256]; | - |
188 | qt_real_to_string(p.x(), buf); | - |
189 | *this << buf; | - |
190 | qt_real_to_string(p.y(), buf); | - |
191 | *this << buf; | - |
192 | return *this; never executed: return *this; | 0 |
193 | } | - |
194 | | - |
195 | QIODevice *ByteStream::stream() | - |
196 | { | - |
197 | dev->reset(); | - |
198 | handleDirty = true; | - |
199 | return dev; executed: return dev; Execution Count:20 | 20 |
200 | } | - |
201 | | - |
202 | void ByteStream::clear() | - |
203 | { | - |
204 | dev->open(QIODevice::ReadWrite | QIODevice::Truncate); | - |
205 | } | 0 |
206 | | - |
207 | void ByteStream::constructor_helper(QByteArray *ba) | - |
208 | { | - |
209 | delete dev; | - |
210 | dev = new QBuffer(ba); | - |
211 | dev->open(QIODevice::ReadWrite); | - |
212 | } | 0 |
213 | | - |
214 | void ByteStream::prepareBuffer() | - |
215 | { | - |
216 | qt_noop(); | - |
217 | qint64 size = dev->size(); | - |
218 | if (fileBackingEnabled && !fileBackingActive never evaluated: fileBackingEnabled never evaluated: !fileBackingActive | 0 |
219 | && size > maxMemorySize()) { never evaluated: size > maxMemorySize() | 0 |
220 | | - |
221 | QTemporaryFile *newFile = new QTemporaryFile; | - |
222 | newFile->open(); | - |
223 | dev->reset(); | - |
224 | while (!dev->atEnd()) { never evaluated: !dev->atEnd() | 0 |
225 | QByteArray buf = dev->read(chunkSize()); | - |
226 | newFile->write(buf); | - |
227 | } | 0 |
228 | delete dev; | - |
229 | dev = newFile; | - |
230 | ba.clear(); | - |
231 | fileBackingActive = true; | - |
232 | } | 0 |
233 | if (dev->pos() != size) { never evaluated: dev->pos() != size | 0 |
234 | dev->seek(size); | - |
235 | handleDirty = false; | - |
236 | } | 0 |
237 | } | 0 |
238 | } | - |
239 | | - |
240 | | - |
241 | | - |
242 | QByteArray QPdf::generatePath(const QPainterPath &path, const QTransform &matrix, PathFlags flags) | - |
243 | { | - |
244 | QByteArray result; | - |
245 | if (!path.elementCount()) never evaluated: !path.elementCount() | 0 |
246 | return result; never executed: return result; | 0 |
247 | | - |
248 | ByteStream s(&result); | - |
249 | | - |
250 | int start = -1; | - |
251 | for (int i = 0; i < path.elementCount(); ++i) { never evaluated: i < path.elementCount() | 0 |
252 | const QPainterPath::Element &elm = path.elementAt(i); | - |
253 | switch (elm.type) { | - |
254 | case QPainterPath::MoveToElement: | - |
255 | if (start >= 0 never evaluated: start >= 0 | 0 |
256 | && path.elementAt(start).x == path.elementAt(i-1).x never evaluated: path.elementAt(start).x == path.elementAt(i-1).x | 0 |
257 | && path.elementAt(start).y == path.elementAt(i-1).y) never evaluated: path.elementAt(start).y == path.elementAt(i-1).y | 0 |
258 | s << "h\n"; never executed: s << "h\n"; | 0 |
259 | s << matrix.map(QPointF(elm.x, elm.y)) << "m\n"; | - |
260 | start = i; | - |
261 | break; | 0 |
262 | case QPainterPath::LineToElement: | - |
263 | s << matrix.map(QPointF(elm.x, elm.y)) << "l\n"; | - |
264 | break; | 0 |
265 | case QPainterPath::CurveToElement: | - |
266 | qt_noop(); | - |
267 | qt_noop(); | - |
268 | s << matrix.map(QPointF(elm.x, elm.y)) | - |
269 | << matrix.map(QPointF(path.elementAt(i+1).x, path.elementAt(i+1).y)) | - |
270 | << matrix.map(QPointF(path.elementAt(i+2).x, path.elementAt(i+2).y)) | - |
271 | << "c\n"; | - |
272 | i += 2; | - |
273 | break; | 0 |
274 | default: | - |
275 | QMessageLogger("painting/qpdf.cpp", 328, __PRETTY_FUNCTION__).fatal("QPdf::generatePath(), unhandled type: %d", elm.type); | - |
276 | } | 0 |
277 | } | 0 |
278 | if (start >= 0 never evaluated: start >= 0 | 0 |
279 | && path.elementAt(start).x == path.elementAt(path.elementCount()-1).x never evaluated: path.elementAt(start).x == path.elementAt(path.elementCount()-1).x | 0 |
280 | && path.elementAt(start).y == path.elementAt(path.elementCount()-1).y) never evaluated: path.elementAt(start).y == path.elementAt(path.elementCount()-1).y | 0 |
281 | s << "h\n"; never executed: s << "h\n"; | 0 |
282 | | - |
283 | Qt::FillRule fillRule = path.fillRule(); | - |
284 | | - |
285 | const char *op = ""; | - |
286 | switch (flags) { | - |
287 | case ClipPath: | - |
288 | op = (fillRule == Qt::WindingFill) ? "W n\n" : "W* n\n"; never evaluated: (fillRule == Qt::WindingFill) | 0 |
289 | break; | 0 |
290 | case FillPath: | - |
291 | op = (fillRule == Qt::WindingFill) ? "f\n" : "f*\n"; never evaluated: (fillRule == Qt::WindingFill) | 0 |
292 | break; | 0 |
293 | case StrokePath: | - |
294 | op = "S\n"; | - |
295 | break; | 0 |
296 | case FillAndStrokePath: | - |
297 | op = (fillRule == Qt::WindingFill) ? "B\n" : "B*\n"; never evaluated: (fillRule == Qt::WindingFill) | 0 |
298 | break; | 0 |
299 | } | - |
300 | s << op; | - |
301 | return result; never executed: return result; | 0 |
302 | } | - |
303 | | - |
304 | QByteArray QPdf::generateMatrix(const QTransform &matrix) | - |
305 | { | - |
306 | QByteArray result; | - |
307 | ByteStream s(&result); | - |
308 | s << matrix.m11() | - |
309 | << matrix.m12() | - |
310 | << matrix.m21() | - |
311 | << matrix.m22() | - |
312 | << matrix.dx() | - |
313 | << matrix.dy() | - |
314 | << "cm\n"; | - |
315 | return result; executed: return result; Execution Count:20 | 20 |
316 | } | - |
317 | | - |
318 | QByteArray QPdf::generateDashes(const QPen &pen) | - |
319 | { | - |
320 | QByteArray result; | - |
321 | ByteStream s(&result); | - |
322 | s << '['; | - |
323 | | - |
324 | QVector<qreal> dasharray = pen.dashPattern(); | - |
325 | qreal w = pen.widthF(); | - |
326 | if (w < 0.001) partially evaluated: w < 0.001 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
327 | w = 1; | 0 |
328 | for (int i = 0; i < dasharray.size(); ++i) { partially evaluated: i < dasharray.size() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
329 | qreal dw = dasharray.at(i)*w; | - |
330 | if (dw < 0.0001) dw = 0.0001; never evaluated: dw < 0.0001 never executed: dw = 0.0001; | 0 |
331 | s << dw; | - |
332 | } | 0 |
333 | s << ']'; | - |
334 | | - |
335 | | - |
336 | return result; executed: return result; Execution Count:2 | 2 |
337 | } | - |
338 | | - |
339 | | - |
340 | | - |
341 | static const char* pattern_for_brush[] = { | - |
342 | 0, | - |
343 | 0, | - |
344 | "0 J\n" | - |
345 | "6 w\n" | - |
346 | "[] 0 d\n" | - |
347 | "4 0 m\n" | - |
348 | "4 8 l\n" | - |
349 | "0 4 m\n" | - |
350 | "8 4 l\n" | - |
351 | "S\n", | - |
352 | | - |
353 | "0 J\n" | - |
354 | "2 w\n" | - |
355 | "[6 2] 1 d\n" | - |
356 | "0 0 m\n" | - |
357 | "0 8 l\n" | - |
358 | "8 0 m\n" | - |
359 | "8 8 l\n" | - |
360 | "S\n" | - |
361 | "[] 0 d\n" | - |
362 | "2 0 m\n" | - |
363 | "2 8 l\n" | - |
364 | "6 0 m\n" | - |
365 | "6 8 l\n" | - |
366 | "S\n" | - |
367 | "[6 2] -3 d\n" | - |
368 | "4 0 m\n" | - |
369 | "4 8 l\n" | - |
370 | "S\n", | - |
371 | | - |
372 | "0 J\n" | - |
373 | "2 w\n" | - |
374 | "[6 2] 1 d\n" | - |
375 | "0 0 m\n" | - |
376 | "0 8 l\n" | - |
377 | "8 0 m\n" | - |
378 | "8 8 l\n" | - |
379 | "S\n" | - |
380 | "[2 2] -1 d\n" | - |
381 | "2 0 m\n" | - |
382 | "2 8 l\n" | - |
383 | "6 0 m\n" | - |
384 | "6 8 l\n" | - |
385 | "S\n" | - |
386 | "[6 2] -3 d\n" | - |
387 | "4 0 m\n" | - |
388 | "4 8 l\n" | - |
389 | "S\n", | - |
390 | | - |
391 | "0 J\n" | - |
392 | "2 w\n" | - |
393 | "[2 2] 1 d\n" | - |
394 | "0 0 m\n" | - |
395 | "0 8 l\n" | - |
396 | "8 0 m\n" | - |
397 | "8 8 l\n" | - |
398 | "S\n" | - |
399 | "[2 2] -1 d\n" | - |
400 | "2 0 m\n" | - |
401 | "2 8 l\n" | - |
402 | "6 0 m\n" | - |
403 | "6 8 l\n" | - |
404 | "S\n" | - |
405 | "[2 2] 1 d\n" | - |
406 | "4 0 m\n" | - |
407 | "4 8 l\n" | - |
408 | "S\n", | - |
409 | | - |
410 | "0 J\n" | - |
411 | "2 w\n" | - |
412 | "[2 6] -1 d\n" | - |
413 | "0 0 m\n" | - |
414 | "0 8 l\n" | - |
415 | "8 0 m\n" | - |
416 | "8 8 l\n" | - |
417 | "S\n" | - |
418 | "[2 2] 1 d\n" | - |
419 | "2 0 m\n" | - |
420 | "2 8 l\n" | - |
421 | "6 0 m\n" | - |
422 | "6 8 l\n" | - |
423 | "S\n" | - |
424 | "[2 6] 3 d\n" | - |
425 | "4 0 m\n" | - |
426 | "4 8 l\n" | - |
427 | "S\n", | - |
428 | | - |
429 | "0 J\n" | - |
430 | "2 w\n" | - |
431 | "[2 6] -1 d\n" | - |
432 | "0 0 m\n" | - |
433 | "0 8 l\n" | - |
434 | "8 0 m\n" | - |
435 | "8 8 l\n" | - |
436 | "S\n" | - |
437 | "[2 6] 3 d\n" | - |
438 | "4 0 m\n" | - |
439 | "4 8 l\n" | - |
440 | "S\n", | - |
441 | | - |
442 | "0 J\n" | - |
443 | "2 w\n" | - |
444 | "[2 6] -1 d\n" | - |
445 | "0 0 m\n" | - |
446 | "0 8 l\n" | - |
447 | "8 0 m\n" | - |
448 | "8 8 l\n" | - |
449 | "S\n", | - |
450 | | - |
451 | "1 w\n" | - |
452 | "0 4 m\n" | - |
453 | "8 4 l\n" | - |
454 | "S\n", | - |
455 | | - |
456 | "1 w\n" | - |
457 | "4 0 m\n" | - |
458 | "4 8 l\n" | - |
459 | "S\n", | - |
460 | | - |
461 | "1 w\n" | - |
462 | "4 0 m\n" | - |
463 | "4 8 l\n" | - |
464 | "0 4 m\n" | - |
465 | "8 4 l\n" | - |
466 | "S\n", | - |
467 | | - |
468 | "1 w\n" | - |
469 | "-1 5 m\n" | - |
470 | "5 -1 l\n" | - |
471 | "3 9 m\n" | - |
472 | "9 3 l\n" | - |
473 | "S\n", | - |
474 | | - |
475 | "1 w\n" | - |
476 | "-1 3 m\n" | - |
477 | "5 9 l\n" | - |
478 | "3 -1 m\n" | - |
479 | "9 5 l\n" | - |
480 | "S\n", | - |
481 | | - |
482 | "1 w\n" | - |
483 | "-1 3 m\n" | - |
484 | "5 9 l\n" | - |
485 | "3 -1 m\n" | - |
486 | "9 5 l\n" | - |
487 | "-1 5 m\n" | - |
488 | "5 -1 l\n" | - |
489 | "3 9 m\n" | - |
490 | "9 3 l\n" | - |
491 | "S\n", | - |
492 | }; | - |
493 | | - |
494 | QByteArray QPdf::patternForBrush(const QBrush &b) | - |
495 | { | - |
496 | int style = b.style(); | - |
497 | if (style > Qt::DiagCrossPattern) never evaluated: style > Qt::DiagCrossPattern | 0 |
498 | return QByteArray(); never executed: return QByteArray(); | 0 |
499 | return pattern_for_brush[style]; never executed: return pattern_for_brush[style]; | 0 |
500 | } | - |
501 | static void moveToHook(qfixed x, qfixed y, void *data) | - |
502 | { | - |
503 | QPdf::Stroker *t = (QPdf::Stroker *)data; | - |
504 | if (!t->first) never evaluated: !t->first | 0 |
505 | *t->stream << "h\n"; never executed: *t->stream << "h\n"; | 0 |
506 | if (!t->cosmeticPen) never evaluated: !t->cosmeticPen | 0 |
507 | t->matrix.map(x, y, &x, &y); never executed: t->matrix.map(x, y, &x, &y); | 0 |
508 | *t->stream << x << y << "m\n"; | - |
509 | t->first = false; | - |
510 | } | 0 |
511 | | - |
512 | static void lineToHook(qfixed x, qfixed y, void *data) | - |
513 | { | - |
514 | QPdf::Stroker *t = (QPdf::Stroker *)data; | - |
515 | if (!t->cosmeticPen) never evaluated: !t->cosmeticPen | 0 |
516 | t->matrix.map(x, y, &x, &y); never executed: t->matrix.map(x, y, &x, &y); | 0 |
517 | *t->stream << x << y << "l\n"; | - |
518 | } | 0 |
519 | | - |
520 | static void cubicToHook(qfixed c1x, qfixed c1y, | - |
521 | qfixed c2x, qfixed c2y, | - |
522 | qfixed ex, qfixed ey, | - |
523 | void *data) | - |
524 | { | - |
525 | QPdf::Stroker *t = (QPdf::Stroker *)data; | - |
526 | if (!t->cosmeticPen) { never evaluated: !t->cosmeticPen | 0 |
527 | t->matrix.map(c1x, c1y, &c1x, &c1y); | - |
528 | t->matrix.map(c2x, c2y, &c2x, &c2y); | - |
529 | t->matrix.map(ex, ey, &ex, &ey); | - |
530 | } | 0 |
531 | *t->stream << c1x << c1y | - |
532 | << c2x << c2y | - |
533 | << ex << ey | - |
534 | << "c\n"; | - |
535 | } | 0 |
536 | | - |
537 | QPdf::Stroker::Stroker() | - |
538 | : stream(0), | - |
539 | first(true), | - |
540 | dashStroker(&basicStroker) | - |
541 | { | - |
542 | stroker = &basicStroker; | - |
543 | basicStroker.setMoveToHook(moveToHook); | - |
544 | basicStroker.setLineToHook(lineToHook); | - |
545 | basicStroker.setCubicToHook(cubicToHook); | - |
546 | cosmeticPen = true; | - |
547 | basicStroker.setStrokeWidth(.1); | - |
548 | } executed: } Execution Count:234 | 234 |
549 | | - |
550 | void QPdf::Stroker::setPen(const QPen &pen, QPainter::RenderHints hints) | - |
551 | { | - |
552 | if (pen.style() == Qt::NoPen) { partially evaluated: pen.style() == Qt::NoPen no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
553 | stroker = 0; | - |
554 | return; | 0 |
555 | } | - |
556 | qreal w = pen.widthF(); | - |
557 | bool zeroWidth = w < 0.0001; | - |
558 | cosmeticPen = qt_pen_is_cosmetic(pen, hints); | - |
559 | if (zeroWidth) partially evaluated: zeroWidth no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
560 | w = .1; | 0 |
561 | | - |
562 | basicStroker.setStrokeWidth(w); | - |
563 | basicStroker.setCapStyle(pen.capStyle()); | - |
564 | basicStroker.setJoinStyle(pen.joinStyle()); | - |
565 | basicStroker.setMiterLimit(pen.miterLimit()); | - |
566 | | - |
567 | QVector<qreal> dashpattern = pen.dashPattern(); | - |
568 | if (zeroWidth) { partially evaluated: zeroWidth no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
569 | for (int i = 0; i < dashpattern.size(); ++i) never evaluated: i < dashpattern.size() | 0 |
570 | dashpattern[i] *= 10.; never executed: dashpattern[i] *= 10.; | 0 |
571 | } | 0 |
572 | if (!dashpattern.isEmpty()) { partially evaluated: !dashpattern.isEmpty() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
573 | dashStroker.setDashPattern(dashpattern); | - |
574 | dashStroker.setDashOffset(pen.dashOffset()); | - |
575 | stroker = &dashStroker; | - |
576 | } else { | 0 |
577 | stroker = &basicStroker; | - |
578 | } executed: } Execution Count:2 | 2 |
579 | } | - |
580 | | - |
581 | void QPdf::Stroker::strokePath(const QPainterPath &path) | - |
582 | { | - |
583 | if (!stroker) never evaluated: !stroker | 0 |
584 | return; | 0 |
585 | first = true; | - |
586 | | - |
587 | stroker->strokePath(path, this, cosmeticPen ? matrix : QTransform()); | - |
588 | *stream << "h f\n"; | - |
589 | } | 0 |
590 | | - |
591 | QByteArray QPdf::ascii85Encode(const QByteArray &input) | - |
592 | { | - |
593 | int isize = input.size()/4*4; | - |
594 | QByteArray output; | - |
595 | output.resize(input.size()*5/4+7); | - |
596 | char *out = output.data(); | - |
597 | const uchar *in = (const uchar *)input.constData(); | - |
598 | for (int i = 0; i < isize; i += 4) { never evaluated: i < isize | 0 |
599 | uint val = (((uint)in[i])<<24) + (((uint)in[i+1])<<16) + (((uint)in[i+2])<<8) + (uint)in[i+3]; | - |
600 | if (val == 0) { never evaluated: val == 0 | 0 |
601 | *out = 'z'; | - |
602 | ++out; | - |
603 | } else { | 0 |
604 | char base[5]; | - |
605 | base[4] = val % 85; | - |
606 | val /= 85; | - |
607 | base[3] = val % 85; | - |
608 | val /= 85; | - |
609 | base[2] = val % 85; | - |
610 | val /= 85; | - |
611 | base[1] = val % 85; | - |
612 | val /= 85; | - |
613 | base[0] = val % 85; | - |
614 | *(out++) = base[0] + '!'; | - |
615 | *(out++) = base[1] + '!'; | - |
616 | *(out++) = base[2] + '!'; | - |
617 | *(out++) = base[3] + '!'; | - |
618 | *(out++) = base[4] + '!'; | - |
619 | } | 0 |
620 | } | - |
621 | | - |
622 | int remaining = input.size() - isize; | - |
623 | if (remaining) { never evaluated: remaining | 0 |
624 | uint val = 0; | - |
625 | for (int i = isize; i < input.size(); ++i) never evaluated: i < input.size() | 0 |
626 | val = (val << 8) + in[i]; never executed: val = (val << 8) + in[i]; | 0 |
627 | val <<= 8*(4-remaining); | - |
628 | char base[5]; | - |
629 | base[4] = val % 85; | - |
630 | val /= 85; | - |
631 | base[3] = val % 85; | - |
632 | val /= 85; | - |
633 | base[2] = val % 85; | - |
634 | val /= 85; | - |
635 | base[1] = val % 85; | - |
636 | val /= 85; | - |
637 | base[0] = val % 85; | - |
638 | for (int i = 0; i < remaining+1; ++i) never evaluated: i < remaining+1 | 0 |
639 | *(out++) = base[i] + '!'; never executed: *(out++) = base[i] + '!'; | 0 |
640 | } | 0 |
641 | *(out++) = '~'; | - |
642 | *(out++) = '>'; | - |
643 | output.resize(out-output.data()); | - |
644 | return output; never executed: return output; | 0 |
645 | } | - |
646 | | - |
647 | const char *QPdf::toHex(ushort u, char *buffer) | - |
648 | { | - |
649 | int i = 3; | - |
650 | while (i >= 0) { | 0 |
651 | ushort hex = (u & 0x000f); | - |
652 | if (hex < 0x0a) never evaluated: hex < 0x0a | 0 |
653 | buffer[i] = '0'+hex; never executed: buffer[i] = '0'+hex; | 0 |
654 | else | - |
655 | buffer[i] = 'A'+(hex-0x0a); never executed: buffer[i] = 'A'+(hex-0x0a); | 0 |
656 | u = u >> 4; | - |
657 | i--; | - |
658 | } | 0 |
659 | buffer[4] = '\0'; | - |
660 | return buffer; never executed: return buffer; | 0 |
661 | } | - |
662 | | - |
663 | const char *QPdf::toHex(uchar u, char *buffer) | - |
664 | { | - |
665 | int i = 1; | - |
666 | while (i >= 0) { | 0 |
667 | ushort hex = (u & 0x000f); | - |
668 | if (hex < 0x0a) never evaluated: hex < 0x0a | 0 |
669 | buffer[i] = '0'+hex; never executed: buffer[i] = '0'+hex; | 0 |
670 | else | - |
671 | buffer[i] = 'A'+(hex-0x0a); never executed: buffer[i] = 'A'+(hex-0x0a); | 0 |
672 | u = u >> 4; | - |
673 | i--; | - |
674 | } | 0 |
675 | buffer[2] = '\0'; | - |
676 | return buffer; never executed: return buffer; | 0 |
677 | } | - |
678 | | - |
679 | | - |
680 | QPdfPage::QPdfPage() | - |
681 | : QPdf::ByteStream(true) | - |
682 | { | - |
683 | } executed: } Execution Count:40 | 40 |
684 | | - |
685 | void QPdfPage::streamImage(int w, int h, int object) | - |
686 | { | - |
687 | *this << w << "0 0 " << -h << "0 " << h << "cm /Im" << object << " Do\n"; | - |
688 | if (!images.contains(object)) never evaluated: !images.contains(object) | 0 |
689 | images.append(object); never executed: images.append(object); | 0 |
690 | } | 0 |
691 | | - |
692 | | - |
693 | QPdfEngine::QPdfEngine(QPdfEnginePrivate &dd) | - |
694 | : QPaintEngine(dd, qt_pdf_decide_features()) | - |
695 | { | - |
696 | } executed: } Execution Count:234 | 234 |
697 | | - |
698 | QPdfEngine::QPdfEngine() | - |
699 | : QPaintEngine(*new QPdfEnginePrivate(), qt_pdf_decide_features()) | - |
700 | { | - |
701 | } | 0 |
702 | | - |
703 | void QPdfEngine::setOutputFilename(const QString &filename) | - |
704 | { | - |
705 | QPdfEnginePrivate * const d = d_func(); | - |
706 | d->outputFileName = filename; | - |
707 | } | 0 |
708 | | - |
709 | | - |
710 | void QPdfEngine::drawPoints (const QPointF *points, int pointCount) | - |
711 | { | - |
712 | if (!points) | 0 |
713 | return; | 0 |
714 | | - |
715 | QPdfEnginePrivate * const d = d_func(); | - |
716 | QPainterPath p; | - |
717 | for (int i=0; i!=pointCount;++i) { never evaluated: i!=pointCount | 0 |
718 | p.moveTo(points[i]); | - |
719 | p.lineTo(points[i] + QPointF(0, 0.001)); | - |
720 | } | 0 |
721 | | - |
722 | bool hadBrush = d->hasBrush; | - |
723 | d->hasBrush = false; | - |
724 | drawPath(p); | - |
725 | d->hasBrush = hadBrush; | - |
726 | } | 0 |
727 | | - |
728 | void QPdfEngine::drawLines (const QLineF *lines, int lineCount) | - |
729 | { | - |
730 | if (!lines) | 0 |
731 | return; | 0 |
732 | | - |
733 | QPdfEnginePrivate * const d = d_func(); | - |
734 | QPainterPath p; | - |
735 | for (int i=0; i!=lineCount;++i) { never evaluated: i!=lineCount | 0 |
736 | p.moveTo(lines[i].p1()); | - |
737 | p.lineTo(lines[i].p2()); | - |
738 | } | 0 |
739 | bool hadBrush = d->hasBrush; | - |
740 | d->hasBrush = false; | - |
741 | drawPath(p); | - |
742 | d->hasBrush = hadBrush; | - |
743 | } | 0 |
744 | | - |
745 | void QPdfEngine::drawRects (const QRectF *rects, int rectCount) | - |
746 | { | - |
747 | if (!rects) partially evaluated: !rects no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
748 | return; | 0 |
749 | | - |
750 | QPdfEnginePrivate * const d = d_func(); | - |
751 | | - |
752 | if (d->clipEnabled && d->allClipped) partially evaluated: d->clipEnabled no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: d->allClipped | 0-2 |
753 | return; | 0 |
754 | if (!d->hasPen && !d->hasBrush) partially evaluated: !d->hasPen no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: !d->hasBrush | 0-2 |
755 | return; | 0 |
756 | | - |
757 | QBrush penBrush = d->pen.brush(); | - |
758 | if (d->simplePen || !d->hasPen) { partially evaluated: d->simplePen yes Evaluation Count:2 | no Evaluation Count:0 |
never evaluated: !d->hasPen | 0-2 |
759 | | - |
760 | if(!d->simplePen && !d->stroker.matrix.isIdentity()) partially evaluated: !d->simplePen no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: !d->stroker.matrix.isIdentity() | 0-2 |
761 | *d->currentPage << "q\n" << QPdf::generateMatrix(d->stroker.matrix); never executed: *d->currentPage << "q\n" << QPdf::generateMatrix(d->stroker.matrix); | 0 |
762 | for (int i = 0; i < rectCount; ++i) evaluated: i < rectCount yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
763 | *d->currentPage << rects[i].x() << rects[i].y() << rects[i].width() << rects[i].height() << "re\n"; executed: *d->currentPage << rects[i].x() << rects[i].y() << rects[i].width() << rects[i].height() << "re\n"; Execution Count:2 | 2 |
764 | *d->currentPage << (d->hasPen ? (d->hasBrush ? "B\n" : "S\n") : "f\n"); | - |
765 | if(!d->simplePen && !d->stroker.matrix.isIdentity()) partially evaluated: !d->simplePen no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: !d->stroker.matrix.isIdentity() | 0-2 |
766 | *d->currentPage << "Q\n"; never executed: *d->currentPage << "Q\n"; | 0 |
767 | } else { executed: } Execution Count:2 | 2 |
768 | QPainterPath p; | - |
769 | for (int i=0; i!=rectCount; ++i) never evaluated: i!=rectCount | 0 |
770 | p.addRect(rects[i]); never executed: p.addRect(rects[i]); | 0 |
771 | drawPath(p); | - |
772 | } | 0 |
773 | } | - |
774 | | - |
775 | void QPdfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) | - |
776 | { | - |
777 | QPdfEnginePrivate * const d = d_func(); | - |
778 | | - |
779 | if (!points || !pointCount) never evaluated: !pointCount | 0 |
780 | return; | 0 |
781 | | - |
782 | bool hb = d->hasBrush; | - |
783 | QPainterPath p; | - |
784 | | - |
785 | switch(mode) { | - |
786 | case OddEvenMode: | - |
787 | p.setFillRule(Qt::OddEvenFill); | - |
788 | break; | 0 |
789 | case ConvexMode: | - |
790 | case WindingMode: | - |
791 | p.setFillRule(Qt::WindingFill); | - |
792 | break; | 0 |
793 | case PolylineMode: | - |
794 | d->hasBrush = false; | - |
795 | break; | 0 |
796 | default: | - |
797 | break; | 0 |
798 | } | - |
799 | | - |
800 | p.moveTo(points[0]); | - |
801 | for (int i = 1; i < pointCount; ++i) never evaluated: i < pointCount | 0 |
802 | p.lineTo(points[i]); never executed: p.lineTo(points[i]); | 0 |
803 | | - |
804 | if (mode != PolylineMode) never evaluated: mode != PolylineMode | 0 |
805 | p.closeSubpath(); never executed: p.closeSubpath(); | 0 |
806 | drawPath(p); | - |
807 | | - |
808 | d->hasBrush = hb; | - |
809 | } | 0 |
810 | | - |
811 | void QPdfEngine::drawPath (const QPainterPath &p) | - |
812 | { | - |
813 | QPdfEnginePrivate * const d = d_func(); | - |
814 | | - |
815 | if (d->clipEnabled && d->allClipped) never evaluated: d->clipEnabled never evaluated: d->allClipped | 0 |
816 | return; | 0 |
817 | if (!d->hasPen && !d->hasBrush) never evaluated: !d->hasPen never evaluated: !d->hasBrush | 0 |
818 | return; | 0 |
819 | | - |
820 | if (d->simplePen) { never evaluated: d->simplePen | 0 |
821 | | - |
822 | *d->currentPage << QPdf::generatePath(p, QTransform(), d->hasBrush ? QPdf::FillAndStrokePath : QPdf::StrokePath); | - |
823 | } else { | 0 |
824 | if (d->hasBrush) never evaluated: d->hasBrush | 0 |
825 | *d->currentPage << QPdf::generatePath(p, d->stroker.matrix, QPdf::FillPath); never executed: *d->currentPage << QPdf::generatePath(p, d->stroker.matrix, QPdf::FillPath); | 0 |
826 | if (d->hasPen) { never evaluated: d->hasPen | 0 |
827 | *d->currentPage << "q\n"; | - |
828 | QBrush b = d->brush; | - |
829 | d->brush = d->pen.brush(); | - |
830 | setBrush(); | - |
831 | d->stroker.strokePath(p); | - |
832 | *d->currentPage << "Q\n"; | - |
833 | d->brush = b; | - |
834 | } | 0 |
835 | } | 0 |
836 | } | - |
837 | | - |
838 | void QPdfEngine::drawPixmap (const QRectF &rectangle, const QPixmap &pixmap, const QRectF &sr) | - |
839 | { | - |
840 | if (sr.isEmpty() || rectangle.isEmpty() || pixmap.isNull()) never evaluated: sr.isEmpty() never evaluated: rectangle.isEmpty() never evaluated: pixmap.isNull() | 0 |
841 | return; | 0 |
842 | QPdfEnginePrivate * const d = d_func(); | - |
843 | | - |
844 | QBrush b = d->brush; | - |
845 | | - |
846 | QRect sourceRect = sr.toRect(); | - |
847 | QPixmap pm = sourceRect != pixmap.rect() ? pixmap.copy(sourceRect) : pixmap; never evaluated: sourceRect != pixmap.rect() | 0 |
848 | QImage image = pm.toImage(); | - |
849 | bool bitmap = true; | - |
850 | const int object = d->addImage(image, &bitmap, pm.cacheKey()); | - |
851 | if (object < 0) never evaluated: object < 0 | 0 |
852 | return; | 0 |
853 | | - |
854 | *d->currentPage << "q\n/GSa gs\n"; | - |
855 | *d->currentPage | - |
856 | << QPdf::generateMatrix(QTransform(rectangle.width() / sr.width(), 0, 0, rectangle.height() / sr.height(), | - |
857 | rectangle.x(), rectangle.y()) * (d->simplePen ? QTransform() : d->stroker.matrix)); | - |
858 | if (bitmap) { | 0 |
859 | | - |
860 | d->brush = d->pen.brush(); | - |
861 | } | 0 |
862 | setBrush(); | - |
863 | d->currentPage->streamImage(image.width(), image.height(), object); | - |
864 | *d->currentPage << "Q\n"; | - |
865 | | - |
866 | d->brush = b; | - |
867 | } | 0 |
868 | | - |
869 | void QPdfEngine::drawImage(const QRectF &rectangle, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags) | - |
870 | { | - |
871 | if (sr.isEmpty() || rectangle.isEmpty() || image.isNull()) never evaluated: sr.isEmpty() never evaluated: rectangle.isEmpty() never evaluated: image.isNull() | 0 |
872 | return; | 0 |
873 | QPdfEnginePrivate * const d = d_func(); | - |
874 | | - |
875 | QRect sourceRect = sr.toRect(); | - |
876 | QImage im = sourceRect != image.rect() ? image.copy(sourceRect) : image; never evaluated: sourceRect != image.rect() | 0 |
877 | bool bitmap = true; | - |
878 | const int object = d->addImage(im, &bitmap, im.cacheKey()); | - |
879 | if (object < 0) never evaluated: object < 0 | 0 |
880 | return; | 0 |
881 | | - |
882 | *d->currentPage << "q\n/GSa gs\n"; | - |
883 | *d->currentPage | - |
884 | << QPdf::generateMatrix(QTransform(rectangle.width() / sr.width(), 0, 0, rectangle.height() / sr.height(), | - |
885 | rectangle.x(), rectangle.y()) * (d->simplePen ? QTransform() : d->stroker.matrix)); | - |
886 | setBrush(); | - |
887 | d->currentPage->streamImage(im.width(), im.height(), object); | - |
888 | *d->currentPage << "Q\n"; | - |
889 | } | 0 |
890 | | - |
891 | void QPdfEngine::drawTiledPixmap (const QRectF &rectangle, const QPixmap &pixmap, const QPointF &point) | - |
892 | { | - |
893 | QPdfEnginePrivate * const d = d_func(); | - |
894 | | - |
895 | bool bitmap = (pixmap.depth() == 1); | - |
896 | QBrush b = d->brush; | - |
897 | QPointF bo = d->brushOrigin; | - |
898 | bool hp = d->hasPen; | - |
899 | d->hasPen = false; | - |
900 | bool hb = d->hasBrush; | - |
901 | d->hasBrush = true; | - |
902 | | - |
903 | d->brush = QBrush(pixmap); | - |
904 | if (bitmap) | 0 |
905 | | - |
906 | d->brush.setColor(d->pen.color()); never executed: d->brush.setColor(d->pen.color()); | 0 |
907 | | - |
908 | d->brushOrigin = -point; | - |
909 | *d->currentPage << "q\n"; | - |
910 | setBrush(); | - |
911 | | - |
912 | drawRects(&rectangle, 1); | - |
913 | *d->currentPage << "Q\n"; | - |
914 | | - |
915 | d->hasPen = hp; | - |
916 | d->hasBrush = hb; | - |
917 | d->brush = b; | - |
918 | d->brushOrigin = bo; | - |
919 | } | 0 |
920 | | - |
921 | void QPdfEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) | - |
922 | { | - |
923 | QPdfEnginePrivate * const d = d_func(); | - |
924 | | - |
925 | if (!d->hasPen || (d->clipEnabled && d->allClipped)) never evaluated: !d->hasPen never evaluated: d->clipEnabled never evaluated: d->allClipped | 0 |
926 | return; | 0 |
927 | | - |
928 | if (d->stroker.matrix.type() >= QTransform::TxProject) { never evaluated: d->stroker.matrix.type() >= QTransform::TxProject | 0 |
929 | QPaintEngine::drawTextItem(p, textItem); | - |
930 | return; | 0 |
931 | } | - |
932 | | - |
933 | *d->currentPage << "q\n"; | - |
934 | if(!d->simplePen) never evaluated: !d->simplePen | 0 |
935 | *d->currentPage << QPdf::generateMatrix(d->stroker.matrix); never executed: *d->currentPage << QPdf::generateMatrix(d->stroker.matrix); | 0 |
936 | | - |
937 | bool hp = d->hasPen; | - |
938 | d->hasPen = false; | - |
939 | QBrush b = d->brush; | - |
940 | d->brush = d->pen.brush(); | - |
941 | setBrush(); | - |
942 | | - |
943 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - |
944 | qt_noop(); | - |
945 | d->drawTextItem(p, ti); | - |
946 | d->hasPen = hp; | - |
947 | d->brush = b; | - |
948 | *d->currentPage << "Q\n"; | - |
949 | } | 0 |
950 | | - |
951 | | - |
952 | void QPdfEngine::updateState(const QPaintEngineState &state) | - |
953 | { | - |
954 | QPdfEnginePrivate * const d = d_func(); | - |
955 | | - |
956 | QPaintEngine::DirtyFlags flags = state.state(); | - |
957 | | - |
958 | if (flags & DirtyTransform) partially evaluated: flags & DirtyTransform no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
959 | d->stroker.matrix = state.transform(); never executed: d->stroker.matrix = state.transform(); | 0 |
960 | | - |
961 | if (flags & DirtyPen) { partially evaluated: flags & DirtyPen yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
962 | d->pen = state.pen(); | - |
963 | d->hasPen = d->pen.style() != Qt::NoPen; | - |
964 | d->stroker.setPen(d->pen, state.renderHints()); | - |
965 | QBrush penBrush = d->pen.brush(); | - |
966 | bool oldSimple = d->simplePen; | - |
967 | d->simplePen = (d->hasPen && (penBrush.style() == Qt::SolidPattern) && penBrush.isOpaque()); partially evaluated: d->hasPen yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: (penBrush.style() == Qt::SolidPattern) yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: penBrush.isOpaque() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
968 | if (oldSimple != d->simplePen) partially evaluated: oldSimple != d->simplePen yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
969 | flags |= DirtyTransform; executed: flags |= DirtyTransform; Execution Count:2 | 2 |
970 | } else if (flags & DirtyHints) { executed: } Execution Count:2 never evaluated: flags & DirtyHints | 0-2 |
971 | d->stroker.setPen(d->pen, state.renderHints()); | - |
972 | } | 0 |
973 | if (flags & DirtyBrush) { partially evaluated: flags & DirtyBrush no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
974 | d->brush = state.brush(); | - |
975 | if (d->brush.color().alpha() == 0 && d->brush.style() == Qt::SolidPattern) never evaluated: d->brush.color().alpha() == 0 never evaluated: d->brush.style() == Qt::SolidPattern | 0 |
976 | d->brush.setStyle(Qt::NoBrush); never executed: d->brush.setStyle(Qt::NoBrush); | 0 |
977 | d->hasBrush = d->brush.style() != Qt::NoBrush; | - |
978 | } | 0 |
979 | if (flags & DirtyBrushOrigin) { partially evaluated: flags & DirtyBrushOrigin no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
980 | d->brushOrigin = state.brushOrigin(); | - |
981 | flags |= DirtyBrush; | - |
982 | } | 0 |
983 | if (flags & DirtyOpacity) partially evaluated: flags & DirtyOpacity no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
984 | d->opacity = state.opacity(); never executed: d->opacity = state.opacity(); | 0 |
985 | | - |
986 | bool ce = d->clipEnabled; | - |
987 | if (flags & DirtyClipPath) { partially evaluated: flags & DirtyClipPath no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
988 | d->clipEnabled = true; | - |
989 | updateClipPath(state.clipPath(), state.clipOperation()); | - |
990 | } else if (flags & DirtyClipRegion) { partially evaluated: flags & DirtyClipRegion no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
991 | d->clipEnabled = true; | - |
992 | QPainterPath path; | - |
993 | QVector<QRect> rects = state.clipRegion().rects(); | - |
994 | for (int i = 0; i < rects.size(); ++i) never evaluated: i < rects.size() | 0 |
995 | path.addRect(rects.at(i)); never executed: path.addRect(rects.at(i)); | 0 |
996 | updateClipPath(path, state.clipOperation()); | - |
997 | flags |= DirtyClipPath; | - |
998 | } else if (flags & DirtyClipEnabled) { partially evaluated: flags & DirtyClipEnabled no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
999 | d->clipEnabled = state.isClipEnabled(); | - |
1000 | } | 0 |
1001 | | - |
1002 | if (ce != d->clipEnabled) partially evaluated: ce != d->clipEnabled no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1003 | flags |= DirtyClipPath; never executed: flags |= DirtyClipPath; | 0 |
1004 | else if (!d->clipEnabled) partially evaluated: !d->clipEnabled yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1005 | flags &= ~DirtyClipPath; executed: flags &= ~DirtyClipPath; Execution Count:2 | 2 |
1006 | | - |
1007 | setupGraphicsState(flags); | - |
1008 | } executed: } Execution Count:2 | 2 |
1009 | | - |
1010 | void QPdfEngine::setupGraphicsState(QPaintEngine::DirtyFlags flags) | - |
1011 | { | - |
1012 | QPdfEnginePrivate * const d = d_func(); | - |
1013 | if (flags & DirtyClipPath) evaluated: flags & DirtyClipPath yes Evaluation Count:20 | yes Evaluation Count:2 |
| 2-20 |
1014 | flags |= DirtyTransform|DirtyPen|DirtyBrush; executed: flags |= DirtyTransform|DirtyPen|DirtyBrush; Execution Count:20 | 20 |
1015 | | - |
1016 | if (flags & DirtyTransform) { partially evaluated: flags & DirtyTransform yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
1017 | *d->currentPage << "Q\n"; | - |
1018 | flags |= DirtyPen|DirtyBrush; | - |
1019 | } executed: } Execution Count:22 | 22 |
1020 | | - |
1021 | if (flags & DirtyClipPath) { evaluated: flags & DirtyClipPath yes Evaluation Count:20 | yes Evaluation Count:2 |
| 2-20 |
1022 | *d->currentPage << "Q q\n"; | - |
1023 | | - |
1024 | d->allClipped = false; | - |
1025 | if (d->clipEnabled && !d->clips.isEmpty()) { partially evaluated: d->clipEnabled no Evaluation Count:0 | yes Evaluation Count:20 |
never evaluated: !d->clips.isEmpty() | 0-20 |
1026 | for (int i = 0; i < d->clips.size(); ++i) { never evaluated: i < d->clips.size() | 0 |
1027 | if (d->clips.at(i).isEmpty()) { never evaluated: d->clips.at(i).isEmpty() | 0 |
1028 | d->allClipped = true; | - |
1029 | break; | 0 |
1030 | } | - |
1031 | } | 0 |
1032 | if (!d->allClipped) { never evaluated: !d->allClipped | 0 |
1033 | for (int i = 0; i < d->clips.size(); ++i) { never evaluated: i < d->clips.size() | 0 |
1034 | *d->currentPage << QPdf::generatePath(d->clips.at(i), QTransform(), QPdf::ClipPath); | - |
1035 | } | 0 |
1036 | } | 0 |
1037 | } | 0 |
1038 | } executed: } Execution Count:20 | 20 |
1039 | | - |
1040 | if (flags & DirtyTransform) { partially evaluated: flags & DirtyTransform yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
1041 | *d->currentPage << "q\n"; | - |
1042 | if (d->simplePen && !d->stroker.matrix.isIdentity()) evaluated: d->simplePen yes Evaluation Count:2 | yes Evaluation Count:20 |
partially evaluated: !d->stroker.matrix.isIdentity() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-20 |
1043 | *d->currentPage << QPdf::generateMatrix(d->stroker.matrix); never executed: *d->currentPage << QPdf::generateMatrix(d->stroker.matrix); | 0 |
1044 | } executed: } Execution Count:22 | 22 |
1045 | if (flags & DirtyBrush) partially evaluated: flags & DirtyBrush yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
1046 | setBrush(); executed: setBrush(); Execution Count:22 | 22 |
1047 | if (d->simplePen && (flags & DirtyPen)) evaluated: d->simplePen yes Evaluation Count:2 | yes Evaluation Count:20 |
partially evaluated: (flags & DirtyPen) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-20 |
1048 | setPen(); executed: setPen(); Execution Count:2 | 2 |
1049 | } executed: } Execution Count:22 | 22 |
1050 | | - |
1051 | extern QPainterPath qt_regionToPath(const QRegion ®ion); | - |
1052 | | - |
1053 | void QPdfEngine::updateClipPath(const QPainterPath &p, Qt::ClipOperation op) | - |
1054 | { | - |
1055 | QPdfEnginePrivate * const d = d_func(); | - |
1056 | QPainterPath path = d->stroker.matrix.map(p); | - |
1057 | | - |
1058 | | - |
1059 | if (op == Qt::NoClip) { never evaluated: op == Qt::NoClip | 0 |
1060 | d->clipEnabled = false; | - |
1061 | d->clips.clear(); | - |
1062 | } else if (op == Qt::ReplaceClip) { never evaluated: op == Qt::ReplaceClip | 0 |
1063 | d->clips.clear(); | - |
1064 | d->clips.append(path); | - |
1065 | } else if (op == Qt::IntersectClip) { never evaluated: op == Qt::IntersectClip | 0 |
1066 | d->clips.append(path); | - |
1067 | } else { | 0 |
1068 | | - |
1069 | path = painter()->clipPath(); | - |
1070 | path = d->stroker.matrix.map(path); | - |
1071 | d->clips.clear(); | - |
1072 | d->clips.append(path); | - |
1073 | } | 0 |
1074 | } | - |
1075 | | - |
1076 | void QPdfEngine::setPen() | - |
1077 | { | - |
1078 | QPdfEnginePrivate * const d = d_func(); | - |
1079 | if (d->pen.style() == Qt::NoPen) partially evaluated: d->pen.style() == Qt::NoPen no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1080 | return; | 0 |
1081 | QBrush b = d->pen.brush(); | - |
1082 | qt_noop(); | - |
1083 | | - |
1084 | QColor rgba = b.color(); | - |
1085 | if (d->grayscale) { partially evaluated: d->grayscale no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1086 | qreal gray = qGray(rgba.rgba())/255.; | - |
1087 | *d->currentPage << gray << gray << gray; | - |
1088 | } else { | 0 |
1089 | *d->currentPage << rgba.redF() | - |
1090 | << rgba.greenF() | - |
1091 | << rgba.blueF(); | - |
1092 | } executed: } Execution Count:2 | 2 |
1093 | *d->currentPage << "SCN\n"; | - |
1094 | | - |
1095 | *d->currentPage << d->pen.widthF() << "w "; | - |
1096 | | - |
1097 | int pdfCapStyle = 0; | - |
1098 | switch(d->pen.capStyle()) { | - |
1099 | case Qt::FlatCap: | - |
1100 | pdfCapStyle = 0; | - |
1101 | break; | 0 |
1102 | case Qt::SquareCap: | - |
1103 | pdfCapStyle = 2; | - |
1104 | break; executed: break; Execution Count:2 | 2 |
1105 | case Qt::RoundCap: | - |
1106 | pdfCapStyle = 1; | - |
1107 | break; | 0 |
1108 | default: | - |
1109 | break; | 0 |
1110 | } | - |
1111 | *d->currentPage << pdfCapStyle << "J "; | - |
1112 | | - |
1113 | int pdfJoinStyle = 0; | - |
1114 | switch(d->pen.joinStyle()) { | - |
1115 | case Qt::MiterJoin: | - |
1116 | pdfJoinStyle = 0; | - |
1117 | break; | 0 |
1118 | case Qt::BevelJoin: | - |
1119 | pdfJoinStyle = 2; | - |
1120 | break; executed: break; Execution Count:2 | 2 |
1121 | case Qt::RoundJoin: | - |
1122 | pdfJoinStyle = 1; | - |
1123 | break; | 0 |
1124 | default: | - |
1125 | break; | 0 |
1126 | } | - |
1127 | *d->currentPage << pdfJoinStyle << "j "; | - |
1128 | | - |
1129 | *d->currentPage << QPdf::generateDashes(d->pen) << " 0 d\n"; | - |
1130 | } executed: } Execution Count:2 | 2 |
1131 | | - |
1132 | | - |
1133 | void QPdfEngine::setBrush() | - |
1134 | { | - |
1135 | QPdfEnginePrivate * const d = d_func(); | - |
1136 | Qt::BrushStyle style = d->brush.style(); | - |
1137 | if (style == Qt::NoBrush) partially evaluated: style == Qt::NoBrush yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
1138 | return; executed: return; Execution Count:22 | 22 |
1139 | | - |
1140 | bool specifyColor; | - |
1141 | int gStateObject = 0; | - |
1142 | int patternObject = d->addBrushPattern(d->stroker.matrix, &specifyColor, &gStateObject); | - |
1143 | | - |
1144 | *d->currentPage << (patternObject ? "/PCSp cs " : "/CSp cs "); | - |
1145 | if (specifyColor) { never evaluated: specifyColor | 0 |
1146 | QColor rgba = d->brush.color(); | - |
1147 | if (d->grayscale) { never evaluated: d->grayscale | 0 |
1148 | qreal gray = qGray(rgba.rgba())/255.; | - |
1149 | *d->currentPage << gray << gray << gray; | - |
1150 | } else { | 0 |
1151 | *d->currentPage << rgba.redF() | - |
1152 | << rgba.greenF() | - |
1153 | << rgba.blueF(); | - |
1154 | } | 0 |
1155 | } | - |
1156 | if (patternObject) never evaluated: patternObject | 0 |
1157 | *d->currentPage << "/Pat" << patternObject; never executed: *d->currentPage << "/Pat" << patternObject; | 0 |
1158 | *d->currentPage << "scn\n"; | - |
1159 | | - |
1160 | if (gStateObject) never evaluated: gStateObject | 0 |
1161 | *d->currentPage << "/GState" << gStateObject << "gs\n"; never executed: *d->currentPage << "/GState" << gStateObject << "gs\n"; | 0 |
1162 | else | - |
1163 | *d->currentPage << "/GSa gs\n"; never executed: *d->currentPage << "/GSa gs\n"; | 0 |
1164 | } | - |
1165 | | - |
1166 | | - |
1167 | bool QPdfEngine::newPage() | - |
1168 | { | - |
1169 | QPdfEnginePrivate * const d = d_func(); | - |
1170 | if (!isActive()) partially evaluated: !isActive() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1171 | return false; never executed: return false; | 0 |
1172 | d->newPage(); | - |
1173 | | - |
1174 | setupGraphicsState(DirtyBrush|DirtyPen|DirtyClipPath); | - |
1175 | QFile *outfile = qobject_cast<QFile*> (d->outDevice); | - |
1176 | if (outfile && outfile->error() != QFile::NoError) partially evaluated: outfile yes Evaluation Count:20 | no Evaluation Count:0 |
partially evaluated: outfile->error() != QFile::NoError no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1177 | return false; never executed: return false; | 0 |
1178 | return true; executed: return true; Execution Count:20 | 20 |
1179 | } | - |
1180 | | - |
1181 | QPaintEngine::Type QPdfEngine::type() const | - |
1182 | { | - |
1183 | return QPaintEngine::Pdf; executed: return QPaintEngine::Pdf; Execution Count:37 | 37 |
1184 | } | - |
1185 | | - |
1186 | | - |
1187 | | - |
1188 | int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const | - |
1189 | { | - |
1190 | const QPdfEnginePrivate * const d = d_func(); | - |
1191 | int val; | - |
1192 | QRect r = d->pageRect(); | - |
1193 | switch (metricType) { | - |
1194 | case QPaintDevice::PdmWidth: | - |
1195 | val = r.width(); | - |
1196 | break; executed: break; Execution Count:20 | 20 |
1197 | case QPaintDevice::PdmHeight: | - |
1198 | val = r.height(); | - |
1199 | break; executed: break; Execution Count:20 | 20 |
1200 | case QPaintDevice::PdmDpiX: | - |
1201 | case QPaintDevice::PdmDpiY: | - |
1202 | val = d->resolution; | - |
1203 | break; executed: break; Execution Count:74 | 74 |
1204 | case QPaintDevice::PdmPhysicalDpiX: | - |
1205 | case QPaintDevice::PdmPhysicalDpiY: | - |
1206 | val = 1200; | - |
1207 | break; | 0 |
1208 | case QPaintDevice::PdmWidthMM: | - |
1209 | val = qRound(r.width()*25.4/d->resolution); | - |
1210 | break; executed: break; Execution Count:18 | 18 |
1211 | case QPaintDevice::PdmHeightMM: | - |
1212 | val = qRound(r.height()*25.4/d->resolution); | - |
1213 | break; executed: break; Execution Count:18 | 18 |
1214 | case QPaintDevice::PdmNumColors: | - |
1215 | val = 2147483647; | - |
1216 | break; | 0 |
1217 | case QPaintDevice::PdmDepth: | - |
1218 | val = 32; | - |
1219 | break; | 0 |
1220 | default: | - |
1221 | QMessageLogger("painting/qpdf.cpp", 1459, __PRETTY_FUNCTION__).warning("QPdfWriter::metric: Invalid metric command"); | - |
1222 | return 0; never executed: return 0; | 0 |
1223 | } | - |
1224 | return val; executed: return val; Execution Count:150 | 150 |
1225 | } | - |
1226 | | - |
1227 | | - |
1228 | | - |
1229 | QPdfEnginePrivate::QPdfEnginePrivate() | - |
1230 | : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false), | - |
1231 | outDevice(0), ownsDevice(false), | - |
1232 | fullPage(false), embedFonts(true), | - |
1233 | landscape(false), | - |
1234 | grayscale(false), | - |
1235 | paperSize(int((210 * 720 + 127) / 254), int((297 * 720 + 127) / 254)), | - |
1236 | leftMargin(10), topMargin(10), rightMargin(10), bottomMargin(10) | - |
1237 | { | - |
1238 | resolution = 1200; | - |
1239 | postscript = false; | - |
1240 | currentObject = 1; | - |
1241 | currentPage = 0; | - |
1242 | stroker.stream = 0; | - |
1243 | | - |
1244 | streampos = 0; | - |
1245 | | - |
1246 | stream = new QDataStream; | - |
1247 | } executed: } Execution Count:234 | 234 |
1248 | | - |
1249 | bool QPdfEngine::begin(QPaintDevice *pdev) | - |
1250 | { | - |
1251 | QPdfEnginePrivate * const d = d_func(); | - |
1252 | d->pdev = pdev; | - |
1253 | | - |
1254 | if (!d->outDevice) { partially evaluated: !d->outDevice no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1255 | if (!d->outputFileName.isEmpty()) { never evaluated: !d->outputFileName.isEmpty() | 0 |
1256 | QFile *file = new QFile(d->outputFileName); | - |
1257 | if (!file->open(QFile::WriteOnly|QFile::Truncate)) { never evaluated: !file->open(QFile::WriteOnly|QFile::Truncate) | 0 |
1258 | delete file; | - |
1259 | return false; never executed: return false; | 0 |
1260 | } | - |
1261 | d->outDevice = file; | - |
1262 | } else { | 0 |
1263 | return false; never executed: return false; | 0 |
1264 | } | - |
1265 | d->ownsDevice = true; | - |
1266 | } | 0 |
1267 | | - |
1268 | d->postscript = false; | - |
1269 | d->currentObject = 1; | - |
1270 | | - |
1271 | d->currentPage = new QPdfPage; | - |
1272 | d->stroker.stream = d->currentPage; | - |
1273 | d->opacity = 1.0; | - |
1274 | | - |
1275 | d->stream->setDevice(d->outDevice); | - |
1276 | | - |
1277 | d->streampos = 0; | - |
1278 | d->hasPen = true; | - |
1279 | d->hasBrush = false; | - |
1280 | d->clipEnabled = false; | - |
1281 | d->allClipped = false; | - |
1282 | | - |
1283 | d->xrefPositions.clear(); | - |
1284 | d->pageRoot = 0; | - |
1285 | d->catalog = 0; | - |
1286 | d->info = 0; | - |
1287 | d->graphicsState = 0; | - |
1288 | d->patternColorSpace = 0; | - |
1289 | d->simplePen = false; | - |
1290 | | - |
1291 | d->pages.clear(); | - |
1292 | d->imageCache.clear(); | - |
1293 | d->alphaCache.clear(); | - |
1294 | | - |
1295 | setActive(true); | - |
1296 | d->writeHeader(); | - |
1297 | newPage(); | - |
1298 | | - |
1299 | return true; executed: return true; Execution Count:20 | 20 |
1300 | } | - |
1301 | | - |
1302 | bool QPdfEngine::end() | - |
1303 | { | - |
1304 | QPdfEnginePrivate * const d = d_func(); | - |
1305 | d->writeTail(); | - |
1306 | | - |
1307 | d->stream->unsetDevice(); | - |
1308 | | - |
1309 | qDeleteAll(d->fonts); | - |
1310 | d->fonts.clear(); | - |
1311 | delete d->currentPage; | - |
1312 | d->currentPage = 0; | - |
1313 | | - |
1314 | if (d->outDevice && d->ownsDevice) { partially evaluated: d->outDevice yes Evaluation Count:20 | no Evaluation Count:0 |
partially evaluated: d->ownsDevice no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1315 | d->outDevice->close(); | - |
1316 | delete d->outDevice; | - |
1317 | d->outDevice = 0; | - |
1318 | } | 0 |
1319 | | - |
1320 | setActive(false); | - |
1321 | return true; executed: return true; Execution Count:20 | 20 |
1322 | } | - |
1323 | | - |
1324 | QPdfEnginePrivate::~QPdfEnginePrivate() | - |
1325 | { | - |
1326 | qDeleteAll(fonts); | - |
1327 | delete currentPage; | - |
1328 | delete stream; | - |
1329 | } executed: } Execution Count:234 | 234 |
1330 | | - |
1331 | QRect QPdfEnginePrivate::paperRect() const | - |
1332 | { | - |
1333 | int w = qRound(paperSize.width()*resolution/72.); | - |
1334 | int h = qRound(paperSize.height()*resolution/72.); | - |
1335 | | - |
1336 | if (!landscape) evaluated: !landscape yes Evaluation Count:239 | yes Evaluation Count:131 |
| 131-239 |
1337 | return QRect(0, 0, w, h); executed: return QRect(0, 0, w, h); Execution Count:239 | 239 |
1338 | else | - |
1339 | return QRect(0, 0, h, w); executed: return QRect(0, 0, h, w); Execution Count:131 | 131 |
1340 | } | - |
1341 | | - |
1342 | QRect QPdfEnginePrivate::pageRect() const | - |
1343 | { | - |
1344 | QRect r = paperRect(); | - |
1345 | | - |
1346 | if(!fullPage) evaluated: !fullPage yes Evaluation Count:96 | yes Evaluation Count:96 |
| 96 |
1347 | r.adjust(qRound(leftMargin*(resolution/72.)), | 96 |
1348 | qRound(topMargin*(resolution/72.)), | 96 |
1349 | -qRound(rightMargin*(resolution/72.)), | 96 |
1350 | -qRound(bottomMargin*(resolution/72.))); executed: r.adjust(qRound(leftMargin*(resolution/72.)), qRound(topMargin*(resolution/72.)), -qRound(rightMargin*(resolution/72.)), -qRound(bottomMargin*(resolution/72.))); Execution Count:96 | 96 |
1351 | | - |
1352 | return r; executed: return r; Execution Count:192 | 192 |
1353 | } | - |
1354 | | - |
1355 | | - |
1356 | void QPdfEnginePrivate::writeHeader() | - |
1357 | { | - |
1358 | addXrefEntry(0,false); | - |
1359 | | - |
1360 | xprintf("%%PDF-1.4\n"); | - |
1361 | | - |
1362 | writeInfo(); | - |
1363 | | - |
1364 | catalog = addXrefEntry(-1); | - |
1365 | pageRoot = requestObject(); | - |
1366 | xprintf("<<\n" | - |
1367 | "/Type /Catalog\n" | - |
1368 | "/Pages %d 0 R\n" | - |
1369 | ">>\n" | - |
1370 | "endobj\n", pageRoot); | - |
1371 | | - |
1372 | | - |
1373 | graphicsState = addXrefEntry(-1); | - |
1374 | xprintf("<<\n" | - |
1375 | "/Type /ExtGState\n" | - |
1376 | "/SA true\n" | - |
1377 | "/SM 0.02\n" | - |
1378 | "/ca 1.0\n" | - |
1379 | "/CA 1.0\n" | - |
1380 | "/AIS false\n" | - |
1381 | "/SMask /None" | - |
1382 | ">>\n" | - |
1383 | "endobj\n"); | - |
1384 | | - |
1385 | | - |
1386 | patternColorSpace = addXrefEntry(-1); | - |
1387 | xprintf("[/Pattern /DeviceRGB]\n" | - |
1388 | "endobj\n"); | - |
1389 | } executed: } Execution Count:20 | 20 |
1390 | | - |
1391 | void QPdfEnginePrivate::writeInfo() | - |
1392 | { | - |
1393 | info = addXrefEntry(-1); | - |
1394 | xprintf("<<\n/Title "); | - |
1395 | printString(title); | - |
1396 | xprintf("\n/Creator "); | - |
1397 | printString(creator); | - |
1398 | xprintf("\n/Producer "); | - |
1399 | printString(QString::fromLatin1("Qt " "5.0.2" " (C) 2012 Digia Plc and/or its subsidiary(-ies)")); | - |
1400 | QDateTime now = QDateTime::currentDateTime().toUTC(); | - |
1401 | QTime t = now.time(); | - |
1402 | QDate d = now.date(); | - |
1403 | xprintf("\n/CreationDate (D:%d%02d%02d%02d%02d%02d)\n", | - |
1404 | d.year(), | - |
1405 | d.month(), | - |
1406 | d.day(), | - |
1407 | t.hour(), | - |
1408 | t.minute(), | - |
1409 | t.second()); | - |
1410 | xprintf(">>\n" | - |
1411 | "endobj\n"); | - |
1412 | } executed: } Execution Count:20 | 20 |
1413 | | - |
1414 | void QPdfEnginePrivate::writePageRoot() | - |
1415 | { | - |
1416 | addXrefEntry(pageRoot); | - |
1417 | | - |
1418 | xprintf("<<\n" | - |
1419 | "/Type /Pages\n" | - |
1420 | "/Kids \n" | - |
1421 | "[\n"); | - |
1422 | int size = pages.size(); | - |
1423 | for (int i = 0; i < size; ++i) evaluated: i < size yes Evaluation Count:20 | yes Evaluation Count:20 |
| 20 |
1424 | xprintf("%d 0 R\n", pages[i]); executed: xprintf("%d 0 R\n", pages[i]); Execution Count:20 | 20 |
1425 | xprintf("]\n"); | - |
1426 | | - |
1427 | | - |
1428 | xprintf("/Count %d\n", pages.size()); | - |
1429 | | - |
1430 | xprintf("/ProcSet [/PDF /Text /ImageB /ImageC]\n" | - |
1431 | ">>\n" | - |
1432 | "endobj\n"); | - |
1433 | } executed: } Execution Count:20 | 20 |
1434 | | - |
1435 | | - |
1436 | void QPdfEnginePrivate::embedFont(QFontSubset *font) | - |
1437 | { | - |
1438 | | - |
1439 | int fontObject = font->object_id; | - |
1440 | QByteArray fontData = font->toTruetype(); | - |
1441 | int fontDescriptor = requestObject(); | - |
1442 | int fontstream = requestObject(); | - |
1443 | int cidfont = requestObject(); | - |
1444 | int toUnicode = requestObject(); | - |
1445 | | - |
1446 | QFontEngine::Properties properties = font->fontEngine->properties(); | - |
1447 | | - |
1448 | { | - |
1449 | qreal scale = 1000/properties.emSquare.toReal(); | - |
1450 | addXrefEntry(fontDescriptor); | - |
1451 | QByteArray descriptor; | - |
1452 | QPdf::ByteStream s(&descriptor); | - |
1453 | s << "<< /Type /FontDescriptor\n" | - |
1454 | "/FontName /Q"; | - |
1455 | int tag = fontDescriptor; | - |
1456 | for (int i = 0; i < 5; ++i) { | 0 |
1457 | s << (char)('A' + (tag % 26)); | - |
1458 | tag /= 26; | - |
1459 | } | 0 |
1460 | s << '+' << properties.postscriptName << "\n" | - |
1461 | "/Flags " << 4 << "\n" | - |
1462 | "/FontBBox [" | - |
1463 | << properties.boundingBox.x()*scale | - |
1464 | << -(properties.boundingBox.y() + properties.boundingBox.height())*scale | - |
1465 | << (properties.boundingBox.x() + properties.boundingBox.width())*scale | - |
1466 | << -properties.boundingBox.y()*scale << "]\n" | - |
1467 | "/ItalicAngle " << properties.italicAngle.toReal() << "\n" | - |
1468 | "/Ascent " << properties.ascent.toReal()*scale << "\n" | - |
1469 | "/Descent " << -properties.descent.toReal()*scale << "\n" | - |
1470 | "/CapHeight " << properties.capHeight.toReal()*scale << "\n" | - |
1471 | "/StemV " << properties.lineWidth.toReal()*scale << "\n" | - |
1472 | "/FontFile2 " << fontstream << "0 R\n" | - |
1473 | ">> endobj\n"; | - |
1474 | write(descriptor); | - |
1475 | } | - |
1476 | { | - |
1477 | addXrefEntry(fontstream); | - |
1478 | QByteArray header; | - |
1479 | QPdf::ByteStream s(&header); | - |
1480 | | - |
1481 | int length_object = requestObject(); | - |
1482 | s << "<<\n" | - |
1483 | "/Length1 " << fontData.size() << "\n" | - |
1484 | "/Length " << length_object << "0 R\n"; | - |
1485 | if (do_compress) never evaluated: do_compress | 0 |
1486 | s << "/Filter /FlateDecode\n"; never executed: s << "/Filter /FlateDecode\n"; | 0 |
1487 | s << ">>\n" | - |
1488 | "stream\n"; | - |
1489 | write(header); | - |
1490 | int len = writeCompressed(fontData); | - |
1491 | write("endstream\n" | - |
1492 | "endobj\n"); | - |
1493 | addXrefEntry(length_object); | - |
1494 | xprintf("%d\n" | - |
1495 | "endobj\n", len); | - |
1496 | } | - |
1497 | { | - |
1498 | addXrefEntry(cidfont); | - |
1499 | QByteArray cid; | - |
1500 | QPdf::ByteStream s(&cid); | - |
1501 | s << "<< /Type /Font\n" | - |
1502 | "/Subtype /CIDFontType2\n" | - |
1503 | "/BaseFont /" << properties.postscriptName << "\n" | - |
1504 | "/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>\n" | - |
1505 | "/FontDescriptor " << fontDescriptor << "0 R\n" | - |
1506 | "/CIDToGIDMap /Identity\n" | - |
1507 | << font->widthArray() << | - |
1508 | ">>\n" | - |
1509 | "endobj\n"; | - |
1510 | write(cid); | - |
1511 | } | - |
1512 | { | - |
1513 | addXrefEntry(toUnicode); | - |
1514 | QByteArray touc = font->createToUnicodeMap(); | - |
1515 | xprintf("<< /Length %d >>\n" | - |
1516 | "stream\n", touc.length()); | - |
1517 | write(touc); | - |
1518 | write("endstream\n" | - |
1519 | "endobj\n"); | - |
1520 | } | - |
1521 | { | - |
1522 | addXrefEntry(fontObject); | - |
1523 | QByteArray font; | - |
1524 | QPdf::ByteStream s(&font); | - |
1525 | s << "<< /Type /Font\n" | - |
1526 | "/Subtype /Type0\n" | - |
1527 | "/BaseFont /" << properties.postscriptName << "\n" | - |
1528 | "/Encoding /Identity-H\n" | - |
1529 | "/DescendantFonts [" << cidfont << "0 R]\n" | - |
1530 | "/ToUnicode " << toUnicode << "0 R" | - |
1531 | ">>\n" | - |
1532 | "endobj\n"; | - |
1533 | write(font); | - |
1534 | } | - |
1535 | } | 0 |
1536 | | - |
1537 | | - |
1538 | void QPdfEnginePrivate::writeFonts() | - |
1539 | { | - |
1540 | for (QHash<QFontEngine::FaceId, QFontSubset *>::iterator it = fonts.begin(); it != fonts.end(); ++it) { partially evaluated: it != fonts.end() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1541 | embedFont(*it); | - |
1542 | delete *it; | - |
1543 | } | 0 |
1544 | fonts.clear(); | - |
1545 | } executed: } Execution Count:20 | 20 |
1546 | | - |
1547 | void QPdfEnginePrivate::writePage() | - |
1548 | { | - |
1549 | if (pages.empty()) evaluated: pages.empty() yes Evaluation Count:20 | yes Evaluation Count:20 |
| 20 |
1550 | return; executed: return; Execution Count:20 | 20 |
1551 | | - |
1552 | *currentPage << "Q Q\n"; | - |
1553 | | - |
1554 | uint pageStream = requestObject(); | - |
1555 | uint pageStreamLength = requestObject(); | - |
1556 | uint resources = requestObject(); | - |
1557 | uint annots = requestObject(); | - |
1558 | | - |
1559 | addXrefEntry(pages.last()); | - |
1560 | xprintf("<<\n" | - |
1561 | "/Type /Page\n" | - |
1562 | "/Parent %d 0 R\n" | - |
1563 | "/Contents %d 0 R\n" | - |
1564 | "/Resources %d 0 R\n" | - |
1565 | "/Annots %d 0 R\n" | - |
1566 | "/MediaBox [0 0 %d %d]\n" | - |
1567 | ">>\n" | - |
1568 | "endobj\n", | - |
1569 | pageRoot, pageStream, resources, annots, | - |
1570 | | - |
1571 | currentPage->pageSize.width(), currentPage->pageSize.height()); | - |
1572 | | - |
1573 | addXrefEntry(resources); | - |
1574 | xprintf("<<\n" | - |
1575 | "/ColorSpace <<\n" | - |
1576 | "/PCSp %d 0 R\n" | - |
1577 | "/CSp /DeviceRGB\n" | - |
1578 | "/CSpg /DeviceGray\n" | - |
1579 | ">>\n" | - |
1580 | "/ExtGState <<\n" | - |
1581 | "/GSa %d 0 R\n", | - |
1582 | patternColorSpace, graphicsState); | - |
1583 | | - |
1584 | for (int i = 0; i < currentPage->graphicStates.size(); ++i) partially evaluated: i < currentPage->graphicStates.size() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1585 | xprintf("/GState%d %d 0 R\n", currentPage->graphicStates.at(i), currentPage->graphicStates.at(i)); never executed: xprintf("/GState%d %d 0 R\n", currentPage->graphicStates.at(i), currentPage->graphicStates.at(i)); | 0 |
1586 | xprintf(">>\n"); | - |
1587 | | - |
1588 | xprintf("/Pattern <<\n"); | - |
1589 | for (int i = 0; i < currentPage->patterns.size(); ++i) partially evaluated: i < currentPage->patterns.size() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1590 | xprintf("/Pat%d %d 0 R\n", currentPage->patterns.at(i), currentPage->patterns.at(i)); never executed: xprintf("/Pat%d %d 0 R\n", currentPage->patterns.at(i), currentPage->patterns.at(i)); | 0 |
1591 | xprintf(">>\n"); | - |
1592 | | - |
1593 | xprintf("/Font <<\n"); | - |
1594 | for (int i = 0; i < currentPage->fonts.size();++i) partially evaluated: i < currentPage->fonts.size() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1595 | xprintf("/F%d %d 0 R\n", currentPage->fonts[i], currentPage->fonts[i]); never executed: xprintf("/F%d %d 0 R\n", currentPage->fonts[i], currentPage->fonts[i]); | 0 |
1596 | xprintf(">>\n"); | - |
1597 | | - |
1598 | xprintf("/XObject <<\n"); | - |
1599 | for (int i = 0; i<currentPage->images.size(); ++i) { partially evaluated: i<currentPage->images.size() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1600 | xprintf("/Im%d %d 0 R\n", currentPage->images.at(i), currentPage->images.at(i)); | - |
1601 | } | 0 |
1602 | xprintf(">>\n"); | - |
1603 | | - |
1604 | xprintf(">>\n" | - |
1605 | "endobj\n"); | - |
1606 | | - |
1607 | addXrefEntry(annots); | - |
1608 | xprintf("[ "); | - |
1609 | for (int i = 0; i<currentPage->annotations.size(); ++i) { partially evaluated: i<currentPage->annotations.size() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1610 | xprintf("%d 0 R ", currentPage->annotations.at(i)); | - |
1611 | } | 0 |
1612 | xprintf("]\nendobj\n"); | - |
1613 | | - |
1614 | addXrefEntry(pageStream); | - |
1615 | xprintf("<<\n" | - |
1616 | "/Length %d 0 R\n", pageStreamLength); | - |
1617 | if (do_compress) partially evaluated: do_compress yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-20 |
1618 | xprintf("/Filter /FlateDecode\n"); executed: xprintf("/Filter /FlateDecode\n"); Execution Count:20 | 20 |
1619 | | - |
1620 | xprintf(">>\n"); | - |
1621 | xprintf("stream\n"); | - |
1622 | QIODevice *content = currentPage->stream(); | - |
1623 | int len = writeCompressed(content); | - |
1624 | xprintf("endstream\n" | - |
1625 | "endobj\n"); | - |
1626 | | - |
1627 | addXrefEntry(pageStreamLength); | - |
1628 | xprintf("%d\nendobj\n",len); | - |
1629 | } executed: } Execution Count:20 | 20 |
1630 | | - |
1631 | void QPdfEnginePrivate::writeTail() | - |
1632 | { | - |
1633 | writePage(); | - |
1634 | writeFonts(); | - |
1635 | writePageRoot(); | - |
1636 | addXrefEntry(xrefPositions.size(),false); | - |
1637 | xprintf("xref\n" | - |
1638 | "0 %d\n" | - |
1639 | "%010d 65535 f \n", xrefPositions.size()-1, xrefPositions[0]); | - |
1640 | | - |
1641 | for (int i = 1; i < xrefPositions.size()-1; ++i) evaluated: i < xrefPositions.size()-1 yes Evaluation Count:200 | yes Evaluation Count:20 |
| 20-200 |
1642 | xprintf("%010d 00000 n \n", xrefPositions[i]); executed: xprintf("%010d 00000 n \n", xrefPositions[i]); Execution Count:200 | 200 |
1643 | | - |
1644 | xprintf("trailer\n" | - |
1645 | "<<\n" | - |
1646 | "/Size %d\n" | - |
1647 | "/Info %d 0 R\n" | - |
1648 | "/Root %d 0 R\n" | - |
1649 | ">>\n" | - |
1650 | "startxref\n%d\n" | - |
1651 | "%%%%EOF\n", | - |
1652 | xrefPositions.size()-1, info, catalog, xrefPositions.last()); | - |
1653 | } executed: } Execution Count:20 | 20 |
1654 | | - |
1655 | int QPdfEnginePrivate::addXrefEntry(int object, bool printostr) | - |
1656 | { | - |
1657 | if (object < 0) evaluated: object < 0 yes Evaluation Count:80 | yes Evaluation Count:160 |
| 80-160 |
1658 | object = requestObject(); executed: object = requestObject(); Execution Count:80 | 80 |
1659 | | - |
1660 | if (object>=xrefPositions.size()) evaluated: object>=xrefPositions.size() yes Evaluation Count:180 | yes Evaluation Count:60 |
| 60-180 |
1661 | xrefPositions.resize(object+1); executed: xrefPositions.resize(object+1); Execution Count:180 | 180 |
1662 | | - |
1663 | xrefPositions[object] = streampos; | - |
1664 | if (printostr) evaluated: printostr yes Evaluation Count:200 | yes Evaluation Count:40 |
| 40-200 |
1665 | xprintf("%d 0 obj\n",object); executed: xprintf("%d 0 obj\n",object); Execution Count:200 | 200 |
1666 | | - |
1667 | return object; executed: return object; Execution Count:240 | 240 |
1668 | } | - |
1669 | | - |
1670 | void QPdfEnginePrivate::printString(const QString &string) { | - |
1671 | | - |
1672 | | - |
1673 | | - |
1674 | QByteArray array("(\xfe\xff"); | - |
1675 | const ushort *utf16 = string.utf16(); | - |
1676 | | - |
1677 | for (int i=0; i < string.size(); ++i) { evaluated: i < string.size() yes Evaluation Count:1106 | yes Evaluation Count:60 |
| 60-1106 |
1678 | char part[2] = {char((*(utf16 + i)) >> 8), char((*(utf16 + i)) & 0xff)}; | - |
1679 | for(int j=0; j < 2; ++j) { evaluated: j < 2 yes Evaluation Count:2212 | yes Evaluation Count:1106 |
| 1106-2212 |
1680 | if (part[j] == '(' || part[j] == ')' || part[j] == '\\') evaluated: part[j] == '(' yes Evaluation Count:41 | yes Evaluation Count:2171 |
evaluated: part[j] == ')' yes Evaluation Count:41 | yes Evaluation Count:2130 |
evaluated: part[j] == '\\' yes Evaluation Count:1 | yes Evaluation Count:2129 |
| 1-2171 |
1681 | array.append('\\'); executed: array.append('\\'); Execution Count:83 | 83 |
1682 | array.append(part[j]); | - |
1683 | } executed: } Execution Count:2212 | 2212 |
1684 | } executed: } Execution Count:1106 | 1106 |
1685 | array.append(")"); | - |
1686 | write(array); | - |
1687 | } executed: } Execution Count:60 | 60 |
1688 | | - |
1689 | | - |
1690 | | - |
1691 | void QPdfEnginePrivate::xprintf(const char* fmt, ...) | - |
1692 | { | - |
1693 | if (!stream) partially evaluated: !stream no Evaluation Count:0 | yes Evaluation Count:1080 |
| 0-1080 |
1694 | return; | 0 |
1695 | | - |
1696 | const int msize = 10000; | - |
1697 | char buf[msize]; | - |
1698 | | - |
1699 | va_list args; | - |
1700 | __builtin_va_start(args,fmt); | - |
1701 | int bufsize = qvsnprintf(buf, msize, fmt, args); | - |
1702 | | - |
1703 | qt_noop(); | - |
1704 | | - |
1705 | __builtin_va_end(args); | - |
1706 | | - |
1707 | stream->writeRawData(buf, bufsize); | - |
1708 | streampos += bufsize; | - |
1709 | } executed: } Execution Count:1080 | 1080 |
1710 | | - |
1711 | int QPdfEnginePrivate::writeCompressed(QIODevice *dev) | - |
1712 | { | - |
1713 | | - |
1714 | if (do_compress) { partially evaluated: do_compress yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-20 |
1715 | int size = QPdfPage::chunkSize(); | - |
1716 | int sum = 0; | - |
1717 | ::z_stream zStruct; | - |
1718 | zStruct.zalloc = 0; | - |
1719 | zStruct.zfree = 0; | - |
1720 | zStruct.opaque = 0; | - |
1721 | if (::deflateInit_((&zStruct), ((-1)), "1.2.3.4", sizeof(z_stream)) != 0) { partially evaluated: ::deflateInit_((&zStruct), ((-1)), "1.2.3.4", sizeof(z_stream)) != 0 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1722 | QMessageLogger("painting/qpdf.cpp", 1970, __PRETTY_FUNCTION__).warning("QPdfStream::writeCompressed: Error in deflateInit()"); | - |
1723 | return sum; never executed: return sum; | 0 |
1724 | } | - |
1725 | zStruct.avail_in = 0; | - |
1726 | QByteArray in, out; | - |
1727 | out.resize(size); | - |
1728 | while (!dev->atEnd() || zStruct.avail_in != 0) { evaluated: !dev->atEnd() yes Evaluation Count:20 | yes Evaluation Count:20 |
partially evaluated: zStruct.avail_in != 0 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1729 | if (zStruct.avail_in == 0) { partially evaluated: zStruct.avail_in == 0 yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-20 |
1730 | in = dev->read(size); | - |
1731 | zStruct.avail_in = in.size(); | - |
1732 | zStruct.next_in = reinterpret_cast<unsigned char*>(in.data()); | - |
1733 | if (in.size() <= 0) { partially evaluated: in.size() <= 0 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1734 | QMessageLogger("painting/qpdf.cpp", 1982, __PRETTY_FUNCTION__).warning("QPdfStream::writeCompressed: Error in read()"); | - |
1735 | ::deflateEnd(&zStruct); | - |
1736 | return sum; never executed: return sum; | 0 |
1737 | } | - |
1738 | } executed: } Execution Count:20 | 20 |
1739 | zStruct.next_out = reinterpret_cast<unsigned char*>(out.data()); | - |
1740 | zStruct.avail_out = out.size(); | - |
1741 | if (::deflate(&zStruct, 0) != 0) { partially evaluated: ::deflate(&zStruct, 0) != 0 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1742 | QMessageLogger("painting/qpdf.cpp", 1990, __PRETTY_FUNCTION__).warning("QPdfStream::writeCompressed: Error in deflate()"); | - |
1743 | ::deflateEnd(&zStruct); | - |
1744 | return sum; never executed: return sum; | 0 |
1745 | } | - |
1746 | int written = out.size() - zStruct.avail_out; | - |
1747 | stream->writeRawData(out.constData(), written); | - |
1748 | streampos += written; | - |
1749 | sum += written; | - |
1750 | } executed: } Execution Count:20 | 20 |
1751 | int ret; | - |
1752 | do { | - |
1753 | zStruct.next_out = reinterpret_cast<unsigned char*>(out.data()); | - |
1754 | zStruct.avail_out = out.size(); | - |
1755 | ret = ::deflate(&zStruct, 4); | - |
1756 | if (ret != 0 && ret != 1) { partially evaluated: ret != 0 yes Evaluation Count:20 | no Evaluation Count:0 |
partially evaluated: ret != 1 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1757 | QMessageLogger("painting/qpdf.cpp", 2005, __PRETTY_FUNCTION__).warning("QPdfStream::writeCompressed: Error in deflate()"); | - |
1758 | ::deflateEnd(&zStruct); | - |
1759 | return sum; never executed: return sum; | 0 |
1760 | } | - |
1761 | int written = out.size() - zStruct.avail_out; | - |
1762 | stream->writeRawData(out.constData(), written); | - |
1763 | streampos += written; | - |
1764 | sum += written; | - |
1765 | } while (ret == 0); executed: } Execution Count:20 partially evaluated: ret == 0 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1766 | | - |
1767 | ::deflateEnd(&zStruct); | - |
1768 | | - |
1769 | return sum; executed: return sum; Execution Count:20 | 20 |
1770 | } else | - |
1771 | | - |
1772 | { | - |
1773 | QByteArray arr; | - |
1774 | int sum = 0; | - |
1775 | while (!dev->atEnd()) { never evaluated: !dev->atEnd() | 0 |
1776 | arr = dev->read(QPdfPage::chunkSize()); | - |
1777 | stream->writeRawData(arr.constData(), arr.size()); | - |
1778 | streampos += arr.size(); | - |
1779 | sum += arr.size(); | - |
1780 | } | 0 |
1781 | return sum; never executed: return sum; | 0 |
1782 | } | - |
1783 | } | - |
1784 | | - |
1785 | int QPdfEnginePrivate::writeCompressed(const char *src, int len) | - |
1786 | { | - |
1787 | | - |
1788 | if(do_compress) { never evaluated: do_compress | 0 |
1789 | uLongf destLen = len + len/100 + 13; | - |
1790 | Bytef* dest = new Bytef[destLen]; | - |
1791 | if (0 == ::compress(dest, &destLen, (const Bytef*) src, (uLongf)len)) { never evaluated: 0 == ::compress(dest, &destLen, (const Bytef*) src, (uLongf)len) | 0 |
1792 | stream->writeRawData((const char*)dest, destLen); | - |
1793 | } else { | 0 |
1794 | QMessageLogger("painting/qpdf.cpp", 2042, __PRETTY_FUNCTION__).warning("QPdfStream::writeCompressed: Error in compress()"); | - |
1795 | destLen = 0; | - |
1796 | } | 0 |
1797 | delete [] dest; | - |
1798 | len = destLen; | - |
1799 | } else | 0 |
1800 | | - |
1801 | { | - |
1802 | stream->writeRawData(src,len); | - |
1803 | } | 0 |
1804 | streampos += len; | - |
1805 | return len; never executed: return len; | 0 |
1806 | } | - |
1807 | | - |
1808 | int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, int depth, | - |
1809 | int maskObject, int softMaskObject, bool dct) | - |
1810 | { | - |
1811 | int image = addXrefEntry(-1); | - |
1812 | xprintf("<<\n" | - |
1813 | "/Type /XObject\n" | - |
1814 | "/Subtype /Image\n" | - |
1815 | "/Width %d\n" | - |
1816 | "/Height %d\n", width, height); | - |
1817 | | - |
1818 | if (depth == 1) { never evaluated: depth == 1 | 0 |
1819 | xprintf("/ImageMask true\n" | - |
1820 | "/Decode [1 0]\n"); | - |
1821 | } else { | 0 |
1822 | xprintf("/BitsPerComponent 8\n" | - |
1823 | "/ColorSpace %s\n", (depth == 32) ? "/DeviceRGB" : "/DeviceGray"); | - |
1824 | } | 0 |
1825 | if (maskObject > 0) never evaluated: maskObject > 0 | 0 |
1826 | xprintf("/Mask %d 0 R\n", maskObject); never executed: xprintf("/Mask %d 0 R\n", maskObject); | 0 |
1827 | if (softMaskObject > 0) never evaluated: softMaskObject > 0 | 0 |
1828 | xprintf("/SMask %d 0 R\n", softMaskObject); never executed: xprintf("/SMask %d 0 R\n", softMaskObject); | 0 |
1829 | | - |
1830 | int lenobj = requestObject(); | - |
1831 | xprintf("/Length %d 0 R\n", lenobj); | - |
1832 | if (interpolateImages) never evaluated: interpolateImages | 0 |
1833 | xprintf("/Interpolate true\n"); never executed: xprintf("/Interpolate true\n"); | 0 |
1834 | int len = 0; | - |
1835 | if (dct) { | 0 |
1836 | | - |
1837 | xprintf("/Filter /DCTDecode\n>>\nstream\n"); | - |
1838 | write(data); | - |
1839 | len = data.length(); | - |
1840 | } else { | 0 |
1841 | if (do_compress) never evaluated: do_compress | 0 |
1842 | xprintf("/Filter /FlateDecode\n>>\nstream\n"); never executed: xprintf("/Filter /FlateDecode\n>>\nstream\n"); | 0 |
1843 | else | - |
1844 | xprintf(">>\nstream\n"); never executed: xprintf(">>\nstream\n"); | 0 |
1845 | len = writeCompressed(data); | - |
1846 | } | 0 |
1847 | xprintf("endstream\n" | - |
1848 | "endobj\n"); | - |
1849 | addXrefEntry(lenobj); | - |
1850 | xprintf("%d\n" | - |
1851 | "endobj\n", len); | - |
1852 | return image; never executed: return image; | 0 |
1853 | } | - |
1854 | int QPdfEnginePrivate::addConstantAlphaObject(int brushAlpha, int penAlpha) | - |
1855 | { | - |
1856 | if (brushAlpha == 255 && penAlpha == 255) never evaluated: brushAlpha == 255 never evaluated: penAlpha == 255 | 0 |
1857 | return 0; never executed: return 0; | 0 |
1858 | int object = alphaCache.value(QPair<uint, uint>(brushAlpha, penAlpha), 0); | - |
1859 | if (!object) { | 0 |
1860 | object = addXrefEntry(-1); | - |
1861 | QByteArray alphaDef; | - |
1862 | QPdf::ByteStream s(&alphaDef); | - |
1863 | s << "<<\n/ca " << (brushAlpha/qreal(255.)) << '\n'; | - |
1864 | s << "/CA " << (penAlpha/qreal(255.)) << "\n>>"; | - |
1865 | xprintf("%s\nendobj\n", alphaDef.constData()); | - |
1866 | alphaCache.insert(QPair<uint, uint>(brushAlpha, penAlpha), object); | - |
1867 | } | 0 |
1868 | if (currentPage->graphicStates.indexOf(object) < 0) never evaluated: currentPage->graphicStates.indexOf(object) < 0 | 0 |
1869 | currentPage->graphicStates.append(object); never executed: currentPage->graphicStates.append(object); | 0 |
1870 | | - |
1871 | return object; never executed: return object; | 0 |
1872 | } | - |
1873 | | - |
1874 | int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor, int *gStateObject) | - |
1875 | { | - |
1876 | int paintType = 2; | - |
1877 | int w = 8; | - |
1878 | int h = 8; | - |
1879 | | - |
1880 | *specifyColor = true; | - |
1881 | *gStateObject = 0; | - |
1882 | | - |
1883 | QTransform matrix = m; | - |
1884 | matrix.translate(brushOrigin.x(), brushOrigin.y()); | - |
1885 | matrix = matrix * pageMatrix(); | - |
1886 | | - |
1887 | | - |
1888 | Qt::BrushStyle style = brush.style(); | - |
1889 | if (style == Qt::LinearGradientPattern) { never evaluated: style == Qt::LinearGradientPattern | 0 |
1890 | | - |
1891 | | - |
1892 | | - |
1893 | | - |
1894 | return 0; never executed: return 0; | 0 |
1895 | | - |
1896 | } | - |
1897 | | - |
1898 | if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0) never evaluated: !brush.isOpaque() never evaluated: brush.style() < Qt::LinearGradientPattern never evaluated: opacity != 1.0 | 0 |
1899 | *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity), | 0 |
1900 | qRound(pen.color().alpha() * opacity)); never executed: *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity), qRound(pen.color().alpha() * opacity)); | 0 |
1901 | | - |
1902 | int imageObject = -1; | - |
1903 | QByteArray pattern = QPdf::patternForBrush(brush); | - |
1904 | if (pattern.isEmpty()) { never evaluated: pattern.isEmpty() | 0 |
1905 | if (brush.style() != Qt::TexturePattern) never evaluated: brush.style() != Qt::TexturePattern | 0 |
1906 | return 0; never executed: return 0; | 0 |
1907 | QImage image = brush.texture().toImage(); | - |
1908 | bool bitmap = true; | - |
1909 | imageObject = addImage(image, &bitmap, brush.texture().cacheKey()); | - |
1910 | if (imageObject != -1) { never evaluated: imageObject != -1 | 0 |
1911 | QImage::Format f = image.format(); | - |
1912 | if (f != QImage::Format_MonoLSB && f != QImage::Format_Mono) { never evaluated: f != QImage::Format_MonoLSB never evaluated: f != QImage::Format_Mono | 0 |
1913 | paintType = 1; | - |
1914 | *specifyColor = false; | - |
1915 | } | 0 |
1916 | w = image.width(); | - |
1917 | h = image.height(); | - |
1918 | QTransform m(w, 0, 0, -h, 0, h); | - |
1919 | QPdf::ByteStream s(&pattern); | - |
1920 | s << QPdf::generateMatrix(m); | - |
1921 | s << "/Im" << imageObject << " Do\n"; | - |
1922 | } | 0 |
1923 | } | 0 |
1924 | | - |
1925 | QByteArray str; | - |
1926 | QPdf::ByteStream s(&str); | - |
1927 | s << "<<\n" | - |
1928 | "/Type /Pattern\n" | - |
1929 | "/PatternType 1\n" | - |
1930 | "/PaintType " << paintType << "\n" | - |
1931 | "/TilingType 1\n" | - |
1932 | "/BBox [0 0 " << w << h << "]\n" | - |
1933 | "/XStep " << w << "\n" | - |
1934 | "/YStep " << h << "\n" | - |
1935 | "/Matrix [" | - |
1936 | << matrix.m11() | - |
1937 | << matrix.m12() | - |
1938 | << matrix.m21() | - |
1939 | << matrix.m22() | - |
1940 | << matrix.dx() | - |
1941 | << matrix.dy() << "]\n" | - |
1942 | "/Resources \n<< "; | - |
1943 | if (imageObject > 0) { never evaluated: imageObject > 0 | 0 |
1944 | s << "/XObject << /Im" << imageObject << ' ' << imageObject << "0 R >> "; | - |
1945 | } | 0 |
1946 | s << ">>\n" | - |
1947 | "/Length " << pattern.length() << "\n" | - |
1948 | ">>\n" | - |
1949 | "stream\n" | - |
1950 | << pattern | - |
1951 | << "endstream\n" | - |
1952 | "endobj\n"; | - |
1953 | | - |
1954 | int patternObj = addXrefEntry(-1); | - |
1955 | write(str); | - |
1956 | currentPage->patterns.append(patternObj); | - |
1957 | return patternObj; never executed: return patternObj; | 0 |
1958 | } | - |
1959 | | - |
1960 | | - |
1961 | | - |
1962 | | - |
1963 | int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_no) | - |
1964 | { | - |
1965 | if (img.isNull()) never evaluated: img.isNull() | 0 |
1966 | return -1; never executed: return -1; | 0 |
1967 | | - |
1968 | int object = imageCache.value(serial_no); | - |
1969 | if(object) | 0 |
1970 | return object; never executed: return object; | 0 |
1971 | | - |
1972 | QImage image = img; | - |
1973 | QImage::Format format = image.format(); | - |
1974 | if (image.depth() == 1 && *bitmap && img.colorTable().size() == 2 never evaluated: image.depth() == 1 never evaluated: img.colorTable().size() == 2 | 0 |
1975 | && img.colorTable().at(0) == QColor(Qt::black).rgba() never evaluated: img.colorTable().at(0) == QColor(Qt::black).rgba() | 0 |
1976 | && img.colorTable().at(1) == QColor(Qt::white).rgba()) never evaluated: img.colorTable().at(1) == QColor(Qt::white).rgba() | 0 |
1977 | { | - |
1978 | if (format == QImage::Format_MonoLSB) never evaluated: format == QImage::Format_MonoLSB | 0 |
1979 | image = image.convertToFormat(QImage::Format_Mono); never executed: image = image.convertToFormat(QImage::Format_Mono); | 0 |
1980 | format = QImage::Format_Mono; | - |
1981 | } else { | 0 |
1982 | *bitmap = false; | - |
1983 | if (format != QImage::Format_RGB32 && format != QImage::Format_ARGB32) { never evaluated: format != QImage::Format_RGB32 never evaluated: format != QImage::Format_ARGB32 | 0 |
1984 | image = image.convertToFormat(QImage::Format_ARGB32); | - |
1985 | format = QImage::Format_ARGB32; | - |
1986 | } | 0 |
1987 | } | 0 |
1988 | | - |
1989 | int w = image.width(); | - |
1990 | int h = image.height(); | - |
1991 | int d = image.depth(); | - |
1992 | | - |
1993 | if (format == QImage::Format_Mono) { never evaluated: format == QImage::Format_Mono | 0 |
1994 | int bytesPerLine = (w + 7) >> 3; | - |
1995 | QByteArray data; | - |
1996 | data.resize(bytesPerLine * h); | - |
1997 | char *rawdata = data.data(); | - |
1998 | for (int y = 0; y < h; ++y) { | 0 |
1999 | memcpy(rawdata, image.scanLine(y), bytesPerLine); | - |
2000 | rawdata += bytesPerLine; | - |
2001 | } | 0 |
2002 | object = writeImage(data, w, h, d, 0, 0); | - |
2003 | } else { | 0 |
2004 | QByteArray softMaskData; | - |
2005 | bool dct = false; | - |
2006 | QByteArray imageData; | - |
2007 | bool hasAlpha = false; | - |
2008 | bool hasMask = false; | - |
2009 | | - |
2010 | if (QImageWriter::supportedImageFormats().contains("jpeg") && !grayscale) { never evaluated: QImageWriter::supportedImageFormats().contains("jpeg") never evaluated: !grayscale | 0 |
2011 | QBuffer buffer(&imageData); | - |
2012 | QImageWriter writer(&buffer, "jpeg"); | - |
2013 | writer.setQuality(94); | - |
2014 | writer.write(image); | - |
2015 | dct = true; | - |
2016 | | - |
2017 | if (format != QImage::Format_RGB32) { never evaluated: format != QImage::Format_RGB32 | 0 |
2018 | softMaskData.resize(w * h); | - |
2019 | uchar *sdata = (uchar *)softMaskData.data(); | - |
2020 | for (int y = 0; y < h; ++y) { | 0 |
2021 | const QRgb *rgb = (const QRgb *)image.scanLine(y); | - |
2022 | for (int x = 0; x < w; ++x) { | 0 |
2023 | uchar alpha = qAlpha(*rgb); | - |
2024 | *sdata++ = alpha; | - |
2025 | hasMask |= (alpha < 255); | - |
2026 | hasAlpha |= (alpha != 0 && alpha != 255); never evaluated: alpha != 0 never evaluated: alpha != 255 | 0 |
2027 | ++rgb; | - |
2028 | } | 0 |
2029 | } | 0 |
2030 | } | 0 |
2031 | } else { | 0 |
2032 | imageData.resize(grayscale ? w * h : 3 * w * h); | - |
2033 | uchar *data = (uchar *)imageData.data(); | - |
2034 | softMaskData.resize(w * h); | - |
2035 | uchar *sdata = (uchar *)softMaskData.data(); | - |
2036 | for (int y = 0; y < h; ++y) { | 0 |
2037 | const QRgb *rgb = (const QRgb *)image.scanLine(y); | - |
2038 | if (grayscale) { never evaluated: grayscale | 0 |
2039 | for (int x = 0; x < w; ++x) { | 0 |
2040 | *(data++) = qGray(*rgb); | - |
2041 | uchar alpha = qAlpha(*rgb); | - |
2042 | *sdata++ = alpha; | - |
2043 | hasMask |= (alpha < 255); | - |
2044 | hasAlpha |= (alpha != 0 && alpha != 255); never evaluated: alpha != 0 never evaluated: alpha != 255 | 0 |
2045 | ++rgb; | - |
2046 | } | 0 |
2047 | } else { | 0 |
2048 | for (int x = 0; x < w; ++x) { | 0 |
2049 | *(data++) = qRed(*rgb); | - |
2050 | *(data++) = qGreen(*rgb); | - |
2051 | *(data++) = qBlue(*rgb); | - |
2052 | uchar alpha = qAlpha(*rgb); | - |
2053 | *sdata++ = alpha; | - |
2054 | hasMask |= (alpha < 255); | - |
2055 | hasAlpha |= (alpha != 0 && alpha != 255); never evaluated: alpha != 0 never evaluated: alpha != 255 | 0 |
2056 | ++rgb; | - |
2057 | } | 0 |
2058 | } | 0 |
2059 | } | - |
2060 | if (format == QImage::Format_RGB32) never evaluated: format == QImage::Format_RGB32 | 0 |
2061 | hasAlpha = hasMask = false; never executed: hasAlpha = hasMask = false; | 0 |
2062 | } | 0 |
2063 | int maskObject = 0; | - |
2064 | int softMaskObject = 0; | - |
2065 | if (hasAlpha) { never evaluated: hasAlpha | 0 |
2066 | softMaskObject = writeImage(softMaskData, w, h, 8, 0, 0); | - |
2067 | } else if (hasMask) { | 0 |
2068 | | - |
2069 | | - |
2070 | int bytesPerLine = (w + 7) >> 3; | - |
2071 | QByteArray mask(bytesPerLine * h, 0); | - |
2072 | uchar *mdata = (uchar *)mask.data(); | - |
2073 | const uchar *sdata = (const uchar *)softMaskData.constData(); | - |
2074 | for (int y = 0; y < h; ++y) { | 0 |
2075 | for (int x = 0; x < w; ++x) { | 0 |
2076 | if (*sdata) | 0 |
2077 | mdata[x>>3] |= (0x80 >> (x&7)); never executed: mdata[x>>3] |= (0x80 >> (x&7)); | 0 |
2078 | ++sdata; | - |
2079 | } | 0 |
2080 | mdata += bytesPerLine; | - |
2081 | } | 0 |
2082 | maskObject = writeImage(mask, w, h, 1, 0, 0); | - |
2083 | } | 0 |
2084 | object = writeImage(imageData, w, h, grayscale ? 8 : 32, | - |
2085 | maskObject, softMaskObject, dct); | - |
2086 | } | 0 |
2087 | imageCache.insert(serial_no, object); | - |
2088 | return object; never executed: return object; | 0 |
2089 | } | - |
2090 | | - |
2091 | void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti) | - |
2092 | { | - |
2093 | QPdfEngine * const q = q_func(); | - |
2094 | | - |
2095 | if (ti.charFormat.isAnchor()) { never evaluated: ti.charFormat.isAnchor() | 0 |
2096 | qreal size = ti.fontEngine->fontDef.pixelSize; | - |
2097 | int synthesized = ti.fontEngine->synthesized(); | - |
2098 | qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.; never evaluated: synthesized & QFontEngine::SynthesizedStretch | 0 |
2099 | | - |
2100 | QTransform trans; | - |
2101 | | - |
2102 | | - |
2103 | trans = QTransform(size*stretch, 0, 0, size, 0, 0); | - |
2104 | | - |
2105 | trans *= QTransform(1,0,0,-1,p.x(),p.y()); | - |
2106 | | - |
2107 | trans *= stroker.matrix; | - |
2108 | | - |
2109 | trans *= pageMatrix(); | - |
2110 | qreal x1, y1, x2, y2; | - |
2111 | trans.map(0, 0, &x1, &y1); | - |
2112 | trans.map(ti.width.toReal()/size, (ti.ascent.toReal()-ti.descent.toReal())/size, &x2, &y2); | - |
2113 | | - |
2114 | uint annot = addXrefEntry(-1); | - |
2115 | QByteArray x1s, y1s, x2s, y2s; | - |
2116 | x1s.setNum(static_cast<double>(x1), 'f'); | - |
2117 | y1s.setNum(static_cast<double>(y1), 'f'); | - |
2118 | x2s.setNum(static_cast<double>(x2), 'f'); | - |
2119 | y2s.setNum(static_cast<double>(y2), 'f'); | - |
2120 | QByteArray rectData = x1s + ' ' + y1s + ' ' + x2s + ' ' + y2s; | - |
2121 | xprintf("<<\n/Type /Annot\n/Subtype /Link\n/Rect ["); | - |
2122 | xprintf(rectData.constData()); | - |
2123 | | - |
2124 | | - |
2125 | | - |
2126 | xprintf("]\n/Border [0 0 0]\n/A <<\n"); | - |
2127 | | - |
2128 | xprintf("/Type /Action\n/S /URI\n/URI (%s)\n", | - |
2129 | ti.charFormat.anchorHref().toLatin1().constData()); | - |
2130 | xprintf(">>\n>>\n"); | - |
2131 | xprintf("endobj\n"); | - |
2132 | | - |
2133 | if (!currentPage->annotations.contains(annot)) { never evaluated: !currentPage->annotations.contains(annot) | 0 |
2134 | currentPage->annotations.append(annot); | - |
2135 | } | 0 |
2136 | } | 0 |
2137 | | - |
2138 | QFontEngine *fe = ti.fontEngine; | - |
2139 | | - |
2140 | QFontEngine::FaceId face_id = fe->faceId(); | - |
2141 | bool noEmbed = false; | - |
2142 | if (face_id.filename.isEmpty() never evaluated: face_id.filename.isEmpty() | 0 |
2143 | || (!postscript && ((fe->fsType & 0x200) never evaluated: !postscript never evaluated: (fe->fsType & 0x200) | 0 |
2144 | || (fe->fsType == 2) ))) { never evaluated: (fe->fsType == 2) | 0 |
2145 | *currentPage << "Q\n"; | - |
2146 | q->QPaintEngine::drawTextItem(p, ti); | - |
2147 | *currentPage << "q\n"; | - |
2148 | if (face_id.filename.isEmpty()) never evaluated: face_id.filename.isEmpty() | 0 |
2149 | return; | 0 |
2150 | noEmbed = true; | - |
2151 | } | 0 |
2152 | | - |
2153 | QFontSubset *font = fonts.value(face_id, 0); | - |
2154 | if (!font) { | 0 |
2155 | font = new QFontSubset(fe, requestObject()); | - |
2156 | font->noEmbed = noEmbed; | - |
2157 | } | 0 |
2158 | fonts.insert(face_id, font); | - |
2159 | | - |
2160 | if (!currentPage->fonts.contains(font->object_id)) never evaluated: !currentPage->fonts.contains(font->object_id) | 0 |
2161 | currentPage->fonts.append(font->object_id); never executed: currentPage->fonts.append(font->object_id); | 0 |
2162 | | - |
2163 | qreal size = ti.fontEngine->fontDef.pixelSize; | - |
2164 | | - |
2165 | QVarLengthArray<glyph_t> glyphs; | - |
2166 | QVarLengthArray<QFixedPoint> positions; | - |
2167 | QTransform m = QTransform::fromTranslate(p.x(), p.y()); | - |
2168 | ti.fontEngine->getGlyphPositions(ti.glyphs, m, ti.flags, | - |
2169 | glyphs, positions); | - |
2170 | if (glyphs.size() == 0) never evaluated: glyphs.size() == 0 | 0 |
2171 | return; | 0 |
2172 | int synthesized = ti.fontEngine->synthesized(); | - |
2173 | qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.; never evaluated: synthesized & QFontEngine::SynthesizedStretch | 0 |
2174 | | - |
2175 | *currentPage << "BT\n" | - |
2176 | << "/F" << font->object_id << size << "Tf " | - |
2177 | << stretch << (synthesized & QFontEngine::SynthesizedItalic | - |
2178 | ? "0 .3 -1 0 0 Tm\n" | - |
2179 | : "0 0 -1 0 0 Tm\n"); | - |
2180 | qreal last_x = 0.; | - |
2181 | qreal last_y = 0.; | - |
2182 | for (int i = 0; i < glyphs.size(); ++i) { never evaluated: i < glyphs.size() | 0 |
2183 | qreal x = positions[i].x.toReal(); | - |
2184 | qreal y = positions[i].y.toReal(); | - |
2185 | if (synthesized & QFontEngine::SynthesizedItalic) never evaluated: synthesized & QFontEngine::SynthesizedItalic | 0 |
2186 | x += .3*y; never executed: x += .3*y; | 0 |
2187 | x /= stretch; | - |
2188 | char buf[5]; | - |
2189 | int g = font->addGlyph(glyphs[i]); | - |
2190 | *currentPage << x - last_x << last_y - y << "Td <" | - |
2191 | << QPdf::toHex((ushort)g, buf) << "> Tj\n"; | - |
2192 | last_x = x; | - |
2193 | last_y = y; | - |
2194 | } | 0 |
2195 | if (synthesized & QFontEngine::SynthesizedBold) { never evaluated: synthesized & QFontEngine::SynthesizedBold | 0 |
2196 | *currentPage << stretch << (synthesized & QFontEngine::SynthesizedItalic | - |
2197 | ? "0 .3 -1 0 0 Tm\n" | - |
2198 | : "0 0 -1 0 0 Tm\n"); | - |
2199 | *currentPage << "/Span << /ActualText <> >> BDC\n"; | - |
2200 | last_x = 0.5*fe->lineThickness().toReal(); | - |
2201 | last_y = 0.; | - |
2202 | for (int i = 0; i < glyphs.size(); ++i) { never evaluated: i < glyphs.size() | 0 |
2203 | qreal x = positions[i].x.toReal(); | - |
2204 | qreal y = positions[i].y.toReal(); | - |
2205 | if (synthesized & QFontEngine::SynthesizedItalic) never evaluated: synthesized & QFontEngine::SynthesizedItalic | 0 |
2206 | x += .3*y; never executed: x += .3*y; | 0 |
2207 | x /= stretch; | - |
2208 | char buf[5]; | - |
2209 | int g = font->addGlyph(glyphs[i]); | - |
2210 | *currentPage << x - last_x << last_y - y << "Td <" | - |
2211 | << QPdf::toHex((ushort)g, buf) << "> Tj\n"; | - |
2212 | last_x = x; | - |
2213 | last_y = y; | - |
2214 | } | 0 |
2215 | *currentPage << "EMC\n"; | - |
2216 | } | 0 |
2217 | | - |
2218 | | - |
2219 | *currentPage << "ET\n"; | - |
2220 | } | 0 |
2221 | | - |
2222 | QTransform QPdfEnginePrivate::pageMatrix() const | - |
2223 | { | - |
2224 | qreal scale = 72./resolution; | - |
2225 | QTransform tmp(scale, 0.0, 0.0, -scale, 0.0, height()); | - |
2226 | if (!fullPage) { evaluated: !fullPage yes Evaluation Count:18 | yes Evaluation Count:2 |
| 2-18 |
2227 | QRect r = pageRect(); | - |
2228 | tmp.translate(r.left(), r.top()); | - |
2229 | } executed: } Execution Count:18 | 18 |
2230 | return tmp; executed: return tmp; Execution Count:20 | 20 |
2231 | } | - |
2232 | | - |
2233 | void QPdfEnginePrivate::newPage() | - |
2234 | { | - |
2235 | if (currentPage && currentPage->pageSize.isEmpty()) partially evaluated: currentPage yes Evaluation Count:20 | no Evaluation Count:0 |
partially evaluated: currentPage->pageSize.isEmpty() yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-20 |
2236 | currentPage->pageSize = QSize(width(), height()); executed: currentPage->pageSize = QSize(width(), height()); Execution Count:20 | 20 |
2237 | writePage(); | - |
2238 | | - |
2239 | delete currentPage; | - |
2240 | currentPage = new QPdfPage; | - |
2241 | currentPage->pageSize = QSize(width(), height()); | - |
2242 | stroker.stream = currentPage; | - |
2243 | pages.append(requestObject()); | - |
2244 | | - |
2245 | *currentPage << "/GSa gs /CSp cs /CSp CS\n" | - |
2246 | << QPdf::generateMatrix(pageMatrix()) | - |
2247 | << "q q\n"; | - |
2248 | } executed: } Execution Count:20 | 20 |
2249 | | - |
2250 | | - |
2251 | | - |
2252 | | - |
| | |