KReport

ext3of9.cpp
1/* This file is part of the KDE project
2 * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
3 * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
4 * Copyright (C) 2015 Jarosław Staniek <staniek@kde.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21 * This file contains the code that will render the extended 3of9 barcode.
22 * This code will parse a string and build a compliant 3of9 string and then
23 * call the 3of9 renderer to do the actual drawing.
24 */
25
26#include <QString>
27#include <QRect>
28
29#include "barcodes.h"
30
31class _ext3of9map
32{
33public:
34 _ext3of9map(const char c, const char *s)
35 : code(c), conversion(QLatin1String(s))
36 {
37 }
38 const char code;
39 const QString conversion;
40};
41const _ext3of9map ext3of9map[] = {
42 _ext3of9map('\0' , "%U"), // NUL
43 _ext3of9map('\001' , "$A"), // SOH
44 _ext3of9map('\002' , "$B"), // STX
45 _ext3of9map('\003' , "$C"), // ETX
46 _ext3of9map('\004' , "$D"), // EOT
47 _ext3of9map('\005' , "$E"), // ENQ
48 _ext3of9map('\006' , "$F"), // ACK
49 _ext3of9map('\007' , "$G"), // BEL
50 _ext3of9map('\010' , "$H"), // BS
51 _ext3of9map('\011' , "$I"), // HT
52 _ext3of9map('\012' , "$J"), // LF
53 _ext3of9map('\013' , "$K"), // VT
54 _ext3of9map('\014' , "$L"), // FF
55 _ext3of9map('\015' , "$M"), // CR
56 _ext3of9map('\016' , "$N"), // SO
57 _ext3of9map('\017' , "$O"), // SI
58 _ext3of9map('\020' , "$P"), // DLE
59 _ext3of9map('\021' , "$Q"), // DC1
60 _ext3of9map('\022' , "$R"), // DC2
61 _ext3of9map('\023' , "$S"), // DC3
62 _ext3of9map('\024' , "$T"), // DC4
63 _ext3of9map('\025' , "$U"), // NAK
64 _ext3of9map('\026' , "$V"), // SYN
65 _ext3of9map('\027' , "$W"), // ETB
66 _ext3of9map('\030' , "$X"), // CAN
67 _ext3of9map('\031' , "$Y"), // EM
68 _ext3of9map('\032' , "$Z"), // SUB
69 _ext3of9map('\033' , "%A"), // ESC
70 _ext3of9map('\034' , "%B"), // FS
71 _ext3of9map('\035' , "%C"), // GS
72 _ext3of9map('\036' , "%D"), // RS
73 _ext3of9map('\037' , "%E"), // US
74 _ext3of9map(' ' , " "), // SPACE
75 _ext3of9map('!' , "/A"),
76 _ext3of9map('"' , "/B"),
77 _ext3of9map('#' , "/C"),
78 _ext3of9map('$' , "/D"),
79 _ext3of9map('%' , "/E"),
80 _ext3of9map('&' , "/F"),
81 _ext3of9map('\'' , "/G"),
82 _ext3of9map('(' , "/H"),
83 _ext3of9map(')' , "/I"),
84 _ext3of9map('*' , "/J"),
85 _ext3of9map('+' , "/K"),
86 _ext3of9map(',' , "/L"),
87 _ext3of9map('-' , "-"), // /M
88 _ext3of9map('.' , "."), // /N
89 _ext3of9map('/' , "/O"),
90 _ext3of9map('0' , "0"), // /P
91 _ext3of9map('1' , "1"), // /Q
92 _ext3of9map('2' , "2"), // /R
93 _ext3of9map('3' , "3"), // /S
94 _ext3of9map('4' , "4"), // /T
95 _ext3of9map('5' , "5"), // /U
96 _ext3of9map('6' , "6"), // /V
97 _ext3of9map('7' , "7"), // /W
98 _ext3of9map('8' , "8"), // /X
99 _ext3of9map('9' , "9"), // /Y
100 _ext3of9map(':' , "/Z"),
101 _ext3of9map(';' , "%F"),
102 _ext3of9map('<' , "%G"),
103 _ext3of9map('=' , "%H"),
104 _ext3of9map('>' , "%I"),
105 _ext3of9map('?' , "%J"),
106 _ext3of9map('@' , "%V"),
107 _ext3of9map('A' , "A"),
108 _ext3of9map('B' , "B"),
109 _ext3of9map('C' , "C"),
110 _ext3of9map('D' , "D"),
111 _ext3of9map('E' , "E"),
112 _ext3of9map('F' , "F"),
113 _ext3of9map('G' , "G"),
114 _ext3of9map('H' , "H"),
115 _ext3of9map('I' , "I"),
116 _ext3of9map('J' , "J"),
117 _ext3of9map('K' , "K"),
118 _ext3of9map('L' , "L"),
119 _ext3of9map('M' , "M"),
120 _ext3of9map('N' , "N"),
121 _ext3of9map('O' , "O"),
122 _ext3of9map('P' , "P"),
123 _ext3of9map('Q' , "Q"),
124 _ext3of9map('R' , "R"),
125 _ext3of9map('S' , "S"),
126 _ext3of9map('T' , "T"),
127 _ext3of9map('U' , "U"),
128 _ext3of9map('V' , "V"),
129 _ext3of9map('W' , "W"),
130 _ext3of9map('X' , "X"),
131 _ext3of9map('Y' , "Y"),
132 _ext3of9map('Z' , "Z"),
133 _ext3of9map('[' , "%K"),
134 _ext3of9map('\\' , "%L"),
135 _ext3of9map(']' , "%M"),
136 _ext3of9map('^' , "%N"),
137 _ext3of9map('_' , "%O"),
138 _ext3of9map('`' , "%W"),
139 _ext3of9map('a' , "+A"),
140 _ext3of9map('b' , "+B"),
141 _ext3of9map('c' , "+C"),
142 _ext3of9map('d' , "+D"),
143 _ext3of9map('e' , "+E"),
144 _ext3of9map('f' , "+F"),
145 _ext3of9map('g' , "+G"),
146 _ext3of9map('h' , "+H"),
147 _ext3of9map('i' , "+I"),
148 _ext3of9map('j' , "+J"),
149 _ext3of9map('k' , "+K"),
150 _ext3of9map('l' , "+L"),
151 _ext3of9map('m' , "+M"),
152 _ext3of9map('n' , "+N"),
153 _ext3of9map('o' , "+O"),
154 _ext3of9map('p' , "+P"),
155 _ext3of9map('q' , "+Q"),
156 _ext3of9map('r' , "+R"),
157 _ext3of9map('s' , "+S"),
158 _ext3of9map('t' , "+T"),
159 _ext3of9map('u' , "+U"),
160 _ext3of9map('v' , "+V"),
161 _ext3of9map('w' , "+W"),
162 _ext3of9map('x' , "+X"),
163 _ext3of9map('y' , "+Y"),
164 _ext3of9map('z' , "+Z"),
165 _ext3of9map('{' , "%P"),
166 _ext3of9map('|' , "%Q"),
167 _ext3of9map('}' , "%R"),
168 _ext3of9map('~' , "%S"),
169 _ext3of9map('\177' , "%T"), // DEL
170
171 _ext3of9map(-1 , nullptr)
172};
173
174inline QString convertTo3of9(char code)
175{
176 for (int i = 0; !ext3of9map[i].conversion.isEmpty(); i++)
177 if (ext3of9map[i].code == code)
178 return ext3of9map[i].conversion;
179 return QString();
180}
181
182QString convertTo3of9(const QString &str)
183{
184 QString result;
185 for (int i = 0; i < str.length(); i++) {
186 result += convertTo3of9(str.at(i).toLatin1());
187 }
188 return result;
189}
190
191void renderExtended3of9(OROPage * page, const QRectF & r, const QString & str, Qt::Alignment align)
192{
193 render3of9(page, r, convertTo3of9(str), align);
194}
Represents a single page in a document and may contain zero or more OROPrimitive objects all of which...
char toLatin1() const const
const QChar at(qsizetype position) const const
bool isEmpty() const const
qsizetype length() const const
typedef Alignment
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:21:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.