30#include "KReportRenderObjects.h"
32static const int LEFTHAND_ODD = 0;
33static const int LEFTHAND_EVEN = 1;
34static const int RIGHTHAND = 2;
36static const int _encodings[10][3][7] = {
38 { { 0, 0, 0, 1, 1, 0, 1}, { 0, 1, 0, 0, 1, 1, 1 }, { 1, 1, 1, 0, 0, 1, 0 } },
39 { { 0, 0, 1, 1, 0, 0, 1}, { 0, 1, 1, 0, 0, 1, 1 }, { 1, 1, 0, 0, 1, 1, 0 } },
40 { { 0, 0, 1, 0, 0, 1, 1}, { 0, 0, 1, 1, 0, 1, 1 }, { 1, 1, 0, 1, 1, 0, 0 } },
41 { { 0, 1, 1, 1, 1, 0, 1}, { 0, 1, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 1, 0 } },
42 { { 0, 1, 0, 0, 0, 1, 1}, { 0, 0, 1, 1, 1, 0, 1 }, { 1, 0, 1, 1, 1, 0, 0 } },
43 { { 0, 1, 1, 0, 0, 0, 1}, { 0, 1, 1, 1, 0, 0, 1 }, { 1, 0, 0, 1, 1, 1, 0 } },
44 { { 0, 1, 0, 1, 1, 1, 1}, { 0, 0, 0, 0, 1, 0, 1 }, { 1, 0, 1, 0, 0, 0, 0 } },
45 { { 0, 1, 1, 1, 0, 1, 1}, { 0, 0, 1, 0, 0, 0, 1 }, { 1, 0, 0, 0, 1, 0, 0 } },
46 { { 0, 1, 1, 0, 1, 1, 1}, { 0, 0, 0, 1, 0, 0, 1 }, { 1, 0, 0, 1, 0, 0, 0 } },
47 { { 0, 0, 0, 1, 0, 1, 1}, { 0, 0, 1, 0, 1, 1, 1 }, { 1, 1, 1, 0, 1, 0, 0 } }
50static const int odd = LEFTHAND_ODD;
51static const int even = LEFTHAND_EVEN;
53static const int _parity[10][6] = {
54 { odd, odd, odd, odd, odd, odd },
55 { odd, odd, even, odd, even, even },
56 { odd, odd, even, even, odd, even },
57 { odd, odd, even, even, even, odd },
58 { odd, even, odd, odd, even, even },
59 { odd, even, even, odd, odd, even },
60 { odd, even, even, even, odd, odd },
61 { odd, even, odd, even, odd, even },
62 { odd, even, odd, even, even, odd },
63 { odd, even, even, odd, even, odd }
66static const int _upcparenc[10][2][6] = {
68 { { even, even, even, odd, odd, odd }, { odd, odd, odd, even, even, even } },
69 { { even, even, odd, even, odd, odd }, { odd, odd, even, odd, even, even } },
70 { { even, even, odd, odd, even, odd }, { odd, odd, even, even, odd, even } },
71 { { even, even, odd, odd, odd, even }, { odd, odd, even, even, even, odd } },
72 { { even, odd, even, even, odd, odd }, { odd, even, odd, odd, even, even } },
73 { { even, odd, odd, even, even, odd }, { odd, even, even, odd, odd, even } },
74 { { even, odd, odd, odd, even, even }, { odd, even, even, even, odd, odd } },
75 { { even, odd, even, odd, even, odd }, { odd, even, odd, even, odd, even } },
76 { { even, odd, even, odd, odd, even }, { odd, even, odd, even, even, odd } },
77 { { even, odd, odd, even, odd, even }, { odd, even, even, odd, even, odd } }
91 for (
int i = 0; i < 13; ++i)
102 for (
int i = 0; i < _str.
length(); ++i) {
103 val[i] = ((
QChar)_str.
at(i)).digitValue();
109 int old_sum = val[12];
111 for (
int i = 0; i < 12; ++i) {
112 checksum += val[i] * ((i % 2) ? 3 : 1);
114 checksum = (checksum % 10);
115 if (checksum) checksum = 10 - checksum;
120 if (old_sum != -1 && old_sum != checksum)
128 qreal quiet_zone = bar_width * 10;
133 qreal draw_width = r.
width();
134 qreal draw_height = r.
height() - 2;
155 qreal nqz = (draw_width - L) / 2;
156 if (nqz > quiet_zone)
159 quiet_zone = draw_width - (L + quiet_zone);
163 qreal pos = r.
left() + quiet_zone;
173 rect->setBrush(brush);
174 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
175 page->insertPrimitive(rect);
177 pos += (bar_width * 2.0);
181 rect->setBrush(brush);
182 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
183 page->insertPrimitive(rect);
188 for (
int i = 0; i < 6; ++i) {
190 for (
int w = 0; w < 7; ++w) {
191 if (_encodings[b][_parity[val[0]][i]][w]) {
194 rect->setBrush(brush);
195 rect->setRect(
QRectF(pos, top, bar_width, draw_height - 0.07));
196 page->insertPrimitive(rect);
207 rect->setBrush(brush);
208 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
209 page->insertPrimitive(rect);
211 pos += (bar_width * 2.0);
215 rect->setBrush(brush);
216 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
217 page->insertPrimitive(rect);
219 pos += (bar_width * 2.0);
222 for (
int i = 0; i < 6; ++i) {
224 for (
int w = 0; w < 7; ++w) {
225 if (_encodings[b][RIGHTHAND][w]) {
228 rect->setBrush(brush);
229 rect->setRect(
QRectF(pos, top, bar_width, draw_height - 0.07));
230 page->insertPrimitive(rect);
239 rect->setBrush(brush);
240 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
241 page->insertPrimitive(rect);
243 pos += (bar_width * 2.0);
247 rect->setBrush(brush);
248 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
249 page->insertPrimitive(rect);
253 val[1], val[2], val[3], val[4], val[5], val[6]);
255 val[7], val[8], val[9], val[10], val[11], val[12]);
260 tb->setSize(
QSizeF(quiet_zone - 0.02, 0.12));
264 page->insertPrimitive(tb);
267 tb->setPosition(
QPointF(r.
left() + quiet_zone + 0.03, (r.
top() + draw_height) - 0.07));
268 tb->setSize(
QSizeF(0.42, 0.1));
270 tb->setText(leftstr);
272 page->insertPrimitive(tb);
275 tb->setPosition(
QPointF(r.
left() + quiet_zone + 0.5, (r.
top() + draw_height) - 0.07));
276 tb->setSize(
QSizeF(0.42, 0.1));
278 tb->setText(rightstr);
280 page->insertPrimitive(tb);
288 for (
int i = 0; i < 13; ++i) {
301 for (
int i = 0; i < _str.
length(); ++i) {
302 val[i+1] = ((
QChar)_str.
at(i)).digitValue();
308 int old_sum = val[12];
310 for (
int i = 0; i < 12; ++i) {
311 checksum += val[i] * ((i % 2) ? 3 : 1);
313 checksum = (checksum % 10);
314 if (checksum) checksum = 10 - checksum;
319 if (old_sum != -1 && old_sum != checksum)
326 qreal quiet_zone = bar_width * 10;
330 qreal draw_width = r.
width();
331 qreal draw_height = r.
height() - 2;
352 qreal nqz = (draw_width - L) / 2;
353 if (nqz > quiet_zone)
356 quiet_zone = draw_width - (L + quiet_zone);
360 qreal pos = r.
left() + quiet_zone;
369 rect->setBrush(brush);
370 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
371 page->insertPrimitive(rect);
373 pos += (bar_width * 2.0);
377 rect->setBrush(brush);
378 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
379 page->insertPrimitive(rect);
384 for (
int i = 0; i < 6; ++i) {
386 for (
int w = 0; w < 7; ++w) {
387 if (_encodings[b][_parity[val[0]][i]][w]) {
390 rect->setBrush(brush);
391 rect->setRect(
QRectF(pos, top, bar_width, draw_height - (i == 0 ? 0 : 0.07)));
392 page->insertPrimitive(rect);
402 rect->setBrush(brush);
403 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
404 page->insertPrimitive(rect);
406 pos += (bar_width * 2.0);
410 rect->setBrush(brush);
411 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
412 page->insertPrimitive(rect);
414 pos += (bar_width * 2.0);
417 for (
int i = 0; i < 6; ++i) {
419 for (
int w = 0; w < 7; ++w) {
420 if (_encodings[b][RIGHTHAND][w]) {
423 rect->setBrush(brush);
424 rect->setRect(
QRectF(pos, top, bar_width, draw_height - (i == 5 ? 0 : 0.07)));
425 page->insertPrimitive(rect);
434 rect->setBrush(brush);
435 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
436 page->insertPrimitive(rect);
438 pos += (bar_width * 2.0);
442 rect->setBrush(brush);
443 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
444 page->insertPrimitive(rect);
449 val[2], val[3], val[4], val[5], val[6]);
451 val[7], val[8], val[9], val[10], val[11]);
454 KReportTextStyleData ts;
458 ts.backgroundOpacity = 100;
463 tb->setSize(
QSizeF(quiet_zone - 2, 12));
464 tb->setTextStyle(ts);
467 page->insertPrimitive(tb);
470 tb->setPosition(
QPointF(r.
left() + quiet_zone + 10, (r.
top() + draw_height) - 7));
471 tb->setSize(
QSizeF(35, 10));
472 tb->setTextStyle(ts);
473 tb->setText(leftstr);
474 page->insertPrimitive(tb);
477 tb->setPosition(
QPointF(r.
left() + quiet_zone + 50, (r.
top() + draw_height) - 7));
478 tb->setSize(
QSizeF(35, 10));
479 tb->setTextStyle(ts);
480 tb->setText(rightstr);
481 page->insertPrimitive(tb);
484 tb->setPosition(
QPointF(r.
left() + quiet_zone + L + 2, (r.
top() + draw_height) - 12));
485 tb->setSize(
QSizeF(8, 12));
486 tb->setTextStyle(ts);
488 page->insertPrimitive(tb);
496 for (
int i = 0; i < 8; ++i) {
508 for (
int i = 0; i < _str.
length(); ++i) {
509 val[i] = ((
QChar)_str.
at(i)).digitValue();
515 int old_sum = val[7];
517 for (
int i = 0; i < 7; ++i) {
518 checksum += val[i] * ((i % 2) ? 1 : 3);
520 checksum = (checksum % 10);
521 if (checksum) checksum = 10 - checksum;
526 if (old_sum != -1 && old_sum != checksum)
534 qreal quiet_zone = bar_width * 10;
539 qreal draw_width = r.
width();
540 qreal draw_height = r.
height() - 0.02;
561 qreal nqz = (draw_width - L) / 2;
562 if (nqz > quiet_zone)
565 quiet_zone = draw_width - (L + quiet_zone);
569 qreal pos = r.
left() + quiet_zone;
578 rect->setBrush(brush);
579 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
580 page->insertPrimitive(rect);
582 pos += (bar_width * 2.0);
586 rect->setBrush(brush);
587 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
588 page->insertPrimitive(rect);
593 for (
int i = 0; i < 4; ++i) {
595 for (
int w = 0; w < 7; ++w) {
596 if (_encodings[b][LEFTHAND_ODD][w]) {
599 rect->setBrush(brush);
600 rect->setRect(
QRectF(pos, top, bar_width, draw_height - 0.06));
601 page->insertPrimitive(rect);
612 rect->setBrush(brush);
613 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
614 page->insertPrimitive(rect);
616 pos += (bar_width * 2.0);
620 rect->setBrush(brush);
621 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
622 page->insertPrimitive(rect);
624 pos += (bar_width * 2.0);
627 for (
int i = 0; i < 4; ++i) {
629 for (
int w = 0; w < 7; ++w) {
630 if (_encodings[b][RIGHTHAND][w]) {
633 rect->setBrush(brush);
634 rect->setRect(
QRectF(pos, top, bar_width, draw_height - 0.06));
635 page->insertPrimitive(rect);
644 rect->setBrush(brush);
645 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
646 page->insertPrimitive(rect);
648 pos += (bar_width * 2.0);
652 rect->setBrush(brush);
653 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
654 page->insertPrimitive(rect);
657 val[0], val[1], val[2], val[3]);
659 val[4], val[5], val[6], val[7]);
663 tb->setPosition(
QPointF(r.
left() + quiet_zone + 0.03, (r.
top() + draw_height) - 0.06));
664 tb->setSize(
QSizeF(0.28, 0.10));
666 tb->setText(leftstr);
668 page->insertPrimitive(tb);
671 tb->setPosition(
QPointF(r.
left() + quiet_zone + 0.36, (r.
top() + draw_height) - 0.06));
672 tb->setSize(
QSizeF(0.28, 0.10));
674 tb->setText(rightstr);
676 page->insertPrimitive(tb);
684 for (
int i = 0; i < 8; ++i) {
696 for (
int i = 0; i < _str.
length(); ++i) {
697 val[i] = ((
QChar)_str.
at(i)).digitValue();
707 if (val[0] != 0 && val[0] != 1)
714 qreal quiet_zone = bar_width * 0.10;
715 if (quiet_zone < 0.10)
719 qreal draw_width = r.
width();
720 qreal draw_height = r.
height() - 2;
741 qreal nqz = (draw_width - L) / 2;
742 if (nqz > quiet_zone)
745 quiet_zone = draw_width - (L + quiet_zone);
749 qreal pos = r.
left() + quiet_zone;
758 rect->setBrush(brush);
759 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
760 page->insertPrimitive(rect);
762 pos += (bar_width * 2.0);
766 rect->setBrush(brush);
767 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
768 page->insertPrimitive(rect);
773 for (
int i = 0; i < 6; ++i) {
775 for (
int w = 0; w < 7; ++w) {
776 if (_encodings[b][_upcparenc[val[7]][val[0]][i]][w]) {
779 rect->setBrush(brush);
780 rect->setRect(
QRectF(pos, top, bar_width, draw_height - 7));
781 page->insertPrimitive(rect);
792 rect->setBrush(brush);
793 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
794 page->insertPrimitive(rect);
796 pos += (bar_width * 2.0);
800 rect->setBrush(brush);
801 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
802 page->insertPrimitive(rect);
804 pos += (bar_width * 2.0);
810 rect->setBrush(brush);
811 rect->setRect(
QRectF(pos, top, bar_width, draw_height));
812 page->insertPrimitive(rect);
817 val[1], val[2], val[3], val[4], val[5], val[6]);
819 KReportTextStyleData ts;
823 ts.backgroundOpacity = 100;
828 tb->setSize(
QSizeF(quiet_zone - 2, 12));
829 tb->setTextStyle(ts);
831 page->insertPrimitive(tb);
834 tb->setPosition(
QPointF(r.
left() + quiet_zone + 3, (r.
top() + draw_height) - 7));
835 tb->setSize(
QSizeF(42, 10));
836 tb->setTextStyle(ts);
837 tb->setText(leftstr);
838 page->insertPrimitive(tb);
841 tb->setPosition(
QPointF(r.
left() + quiet_zone + L + 2, r.
top() + draw_height - 12));
842 tb->setSize(
QSizeF(8, 12));
843 tb->setTextStyle(ts);
845 page->insertPrimitive(tb);
Represents a single page in a document and may contain zero or more OROPrimitive objects all of which...
A text box primitive it defines a box region and text that will be rendered inside that region,...
qreal height() const const
qreal width() const const
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
QString fromLatin1(QByteArrayView str)
qsizetype length() const const
QString number(double n, char format, int precision)