OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2010 ZXing authors | 8 * Copyright 2010 ZXing authors |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
(...skipping 28 matching lines...) Expand all Loading... |
39 m_extendedMode = extendedMode; | 39 m_extendedMode = extendedMode; |
40 } | 40 } |
41 CBC_OnedCode39Writer::~CBC_OnedCode39Writer() | 41 CBC_OnedCode39Writer::~CBC_OnedCode39Writer() |
42 { | 42 { |
43 } | 43 } |
44 FX_BOOL CBC_OnedCode39Writer::CheckContentValidity(FX_WSTR contents) | 44 FX_BOOL CBC_OnedCode39Writer::CheckContentValidity(FX_WSTR contents) |
45 { | 45 { |
46 if (m_extendedMode) { | 46 if (m_extendedMode) { |
47 return CheckExtendedContentValidity(contents); | 47 return CheckExtendedContentValidity(contents); |
48 } | 48 } |
49 for(FX_INT32 i = 0; i < contents.GetLength(); i++) { | 49 for(int32_t i = 0; i < contents.GetLength(); i++) { |
50 FX_WCHAR ch = contents.GetAt(i); | 50 FX_WCHAR ch = contents.GetAt(i); |
51 if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || (ch >= (FX_WCHAR)'A'
&& ch <= (FX_WCHAR)'Z') | 51 if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || (ch >= (FX_WCHAR)'A'
&& ch <= (FX_WCHAR)'Z') |
52 || ch == (FX_WCHAR)'-' || ch == (FX_WCHAR)'.' || ch == (FX_WCHAR
)' ' || ch == (FX_WCHAR)'*' | 52 || ch == (FX_WCHAR)'-' || ch == (FX_WCHAR)'.' || ch == (FX_WCHAR
)' ' || ch == (FX_WCHAR)'*' |
53 || ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR
)'+' || ch == (FX_WCHAR)'%') { | 53 || ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR
)'+' || ch == (FX_WCHAR)'%') { |
54 continue; | 54 continue; |
55 } | 55 } |
56 return FALSE; | 56 return FALSE; |
57 } | 57 } |
58 return TRUE; | 58 return TRUE; |
59 } | 59 } |
60 FX_BOOL CBC_OnedCode39Writer::CheckExtendedContentValidity(FX_WSTR contents) | 60 FX_BOOL CBC_OnedCode39Writer::CheckExtendedContentValidity(FX_WSTR contents) |
61 { | 61 { |
62 for(FX_INT32 i = 0; i < contents.GetLength(); i++) { | 62 for(int32_t i = 0; i < contents.GetLength(); i++) { |
63 FX_WCHAR ch = contents.GetAt(i); | 63 FX_WCHAR ch = contents.GetAt(i); |
64 if (ch > 127) { | 64 if (ch > 127) { |
65 return FALSE; | 65 return FALSE; |
66 } | 66 } |
67 } | 67 } |
68 return TRUE; | 68 return TRUE; |
69 } | 69 } |
70 CFX_WideString CBC_OnedCode39Writer::FilterContents(FX_WSTR contents) | 70 CFX_WideString CBC_OnedCode39Writer::FilterContents(FX_WSTR contents) |
71 { | 71 { |
72 if (m_extendedMode) { | 72 if (m_extendedMode) { |
73 return FilterExtendedContents(contents); | 73 return FilterExtendedContents(contents); |
74 } | 74 } |
75 CFX_WideString filtercontents; | 75 CFX_WideString filtercontents; |
76 for(FX_INT32 i = 0; i < contents.GetLength(); i++) { | 76 for(int32_t i = 0; i < contents.GetLength(); i++) { |
77 FX_WCHAR ch = contents.GetAt(i); | 77 FX_WCHAR ch = contents.GetAt(i); |
78 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ | 78 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ |
79 continue; | 79 continue; |
80 } | 80 } |
81 if(ch > 175) { | 81 if(ch > 175) { |
82 i++; | 82 i++; |
83 continue; | 83 continue; |
84 } else { | 84 } else { |
85 ch = Upper(ch); | 85 ch = Upper(ch); |
86 } | 86 } |
87 if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || (ch >= (FX_WCHAR)'A'
&& ch <= (FX_WCHAR)'Z') | 87 if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || (ch >= (FX_WCHAR)'A'
&& ch <= (FX_WCHAR)'Z') |
88 || ch == (FX_WCHAR)'-' || ch == (FX_WCHAR)'.' || ch == (FX_WCHAR
)' ' || ch == (FX_WCHAR)'*' | 88 || ch == (FX_WCHAR)'-' || ch == (FX_WCHAR)'.' || ch == (FX_WCHAR
)' ' || ch == (FX_WCHAR)'*' |
89 || ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR
)'+' || ch == (FX_WCHAR)'%') { | 89 || ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR
)'+' || ch == (FX_WCHAR)'%') { |
90 filtercontents += ch; | 90 filtercontents += ch; |
91 } | 91 } |
92 } | 92 } |
93 return filtercontents; | 93 return filtercontents; |
94 } | 94 } |
95 CFX_WideString CBC_OnedCode39Writer::FilterExtendedContents(FX_WSTR contents) | 95 CFX_WideString CBC_OnedCode39Writer::FilterExtendedContents(FX_WSTR contents) |
96 { | 96 { |
97 CFX_WideString filtercontents; | 97 CFX_WideString filtercontents; |
98 for(FX_INT32 i = 0; i < contents.GetLength(); i++) { | 98 for(int32_t i = 0; i < contents.GetLength(); i++) { |
99 FX_WCHAR ch = contents.GetAt(i); | 99 FX_WCHAR ch = contents.GetAt(i); |
100 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ | 100 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ |
101 continue; | 101 continue; |
102 } | 102 } |
103 if(ch > 175) { | 103 if(ch > 175) { |
104 i++; | 104 i++; |
105 continue; | 105 continue; |
106 } | 106 } |
107 if (ch > 127 && ch < 176) { | 107 if (ch > 127 && ch < 176) { |
108 continue; | 108 continue; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 } | 149 } |
150 return filtercontents; | 150 return filtercontents; |
151 } | 151 } |
152 CFX_WideString CBC_OnedCode39Writer::RenderTextContents(FX_WSTR contents) | 152 CFX_WideString CBC_OnedCode39Writer::RenderTextContents(FX_WSTR contents) |
153 { | 153 { |
154 if (m_extendedMode) { | 154 if (m_extendedMode) { |
155 return RenderExtendedTextContents(contents); | 155 return RenderExtendedTextContents(contents); |
156 } | 156 } |
157 CFX_WideString renderContents; | 157 CFX_WideString renderContents; |
158 for(FX_INT32 i = 0; i < contents.GetLength(); i++) { | 158 for(int32_t i = 0; i < contents.GetLength(); i++) { |
159 FX_WCHAR ch = contents.GetAt(i); | 159 FX_WCHAR ch = contents.GetAt(i); |
160 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ | 160 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ |
161 continue; | 161 continue; |
162 } | 162 } |
163 if(ch > 175) { | 163 if(ch > 175) { |
164 i++; | 164 i++; |
165 continue; | 165 continue; |
166 } | 166 } |
167 if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || (ch >= (FX_WCHAR)'A'
&& ch <= (FX_WCHAR)'Z') | 167 if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || (ch >= (FX_WCHAR)'A'
&& ch <= (FX_WCHAR)'Z') |
168 || (ch >= (FX_WCHAR)'a' && ch <= (FX_WCHAR)'z') || ch == (FX_WCH
AR)'-' || ch == (FX_WCHAR)'.' | 168 || (ch >= (FX_WCHAR)'a' && ch <= (FX_WCHAR)'z') || ch == (FX_WCH
AR)'-' || ch == (FX_WCHAR)'.' |
169 || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || ch == (FX_WCHAR
)'$' || ch == (FX_WCHAR)'/' | 169 || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || ch == (FX_WCHAR
)'$' || ch == (FX_WCHAR)'/' |
170 || ch == (FX_WCHAR)'+' || ch == (FX_WCHAR)'%') { | 170 || ch == (FX_WCHAR)'+' || ch == (FX_WCHAR)'%') { |
171 renderContents += ch; | 171 renderContents += ch; |
172 } | 172 } |
173 } | 173 } |
174 return renderContents; | 174 return renderContents; |
175 } | 175 } |
176 CFX_WideString CBC_OnedCode39Writer::RenderExtendedTextContents(FX_WSTR contents
) | 176 CFX_WideString CBC_OnedCode39Writer::RenderExtendedTextContents(FX_WSTR contents
) |
177 { | 177 { |
178 CFX_WideString renderContents; | 178 CFX_WideString renderContents; |
179 for(FX_INT32 i = 0; i < contents.GetLength(); i++) { | 179 for(int32_t i = 0; i < contents.GetLength(); i++) { |
180 FX_WCHAR ch = contents.GetAt(i); | 180 FX_WCHAR ch = contents.GetAt(i); |
181 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ | 181 if ( ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1) )
{ |
182 continue; | 182 continue; |
183 } | 183 } |
184 if(ch > 175) { | 184 if(ch > 175) { |
185 i++; | 185 i++; |
186 continue; | 186 continue; |
187 } | 187 } |
188 if (ch > 127 && ch < 176) { | 188 if (ch > 127 && ch < 176) { |
189 continue; | 189 continue; |
190 } | 190 } |
191 renderContents += ch; | 191 renderContents += ch; |
192 } | 192 } |
193 return renderContents; | 193 return renderContents; |
194 } | 194 } |
195 FX_BOOL CBC_OnedCode39Writer::SetTextLocation(BC_TEXT_LOC location) | 195 FX_BOOL CBC_OnedCode39Writer::SetTextLocation(BC_TEXT_LOC location) |
196 { | 196 { |
197 if ( location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { | 197 if ( location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { |
198 return FALSE; | 198 return FALSE; |
199 } | 199 } |
200 m_locTextLoc = location; | 200 m_locTextLoc = location; |
201 return TRUE; | 201 return TRUE; |
202 } | 202 } |
203 FX_BOOL CBC_OnedCode39Writer::SetWideNarrowRatio(FX_INT32 ratio) | 203 FX_BOOL CBC_OnedCode39Writer::SetWideNarrowRatio(int32_t ratio) |
204 { | 204 { |
205 if ( ratio < 2 || ratio > 3) { | 205 if ( ratio < 2 || ratio > 3) { |
206 return FALSE; | 206 return FALSE; |
207 } | 207 } |
208 m_iWideNarrRatio = ratio; | 208 m_iWideNarrRatio = ratio; |
209 return TRUE; | 209 return TRUE; |
210 } | 210 } |
211 FX_BYTE *CBC_OnedCode39Writer::Encode(const CFX_ByteString &contents, BCFORMAT f
ormat, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 &e) | 211 uint8_t *CBC_OnedCode39Writer::Encode(const CFX_ByteString &contents, BCFORMAT f
ormat, int32_t &outWidth, int32_t &outHeight, int32_t &e) |
212 { | 212 { |
213 FX_BYTE *ret = Encode(contents, format, outWidth, outHeight, 0 , e); | 213 uint8_t *ret = Encode(contents, format, outWidth, outHeight, 0 , e); |
214 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 214 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
215 return ret; | 215 return ret; |
216 } | 216 } |
217 FX_BYTE *CBC_OnedCode39Writer::Encode(const CFX_ByteString &contents, BCFORMAT f
ormat, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 hints, FX_INT32 &e) | 217 uint8_t *CBC_OnedCode39Writer::Encode(const CFX_ByteString &contents, BCFORMAT f
ormat, int32_t &outWidth, int32_t &outHeight, int32_t hints, int32_t &e) |
218 { | 218 { |
219 if(format != BCFORMAT_CODE_39) { | 219 if(format != BCFORMAT_CODE_39) { |
220 e = BCExceptionOnlyEncodeCODE_39; | 220 e = BCExceptionOnlyEncodeCODE_39; |
221 return NULL; | 221 return NULL; |
222 } | 222 } |
223 FX_BYTE *ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeigh
t, hints, e); | 223 uint8_t *ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeigh
t, hints, e); |
224 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 224 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
225 return ret; | 225 return ret; |
226 } | 226 } |
227 void CBC_OnedCode39Writer::ToIntArray(FX_INT32 a, FX_INT32 *toReturn) | 227 void CBC_OnedCode39Writer::ToIntArray(int32_t a, int32_t *toReturn) |
228 { | 228 { |
229 for(FX_INT32 i = 0; i < 9; i++) { | 229 for(int32_t i = 0; i < 9; i++) { |
230 toReturn[i] = (a & (1 << i) ) == 0 ? 1 : m_iWideNarrRatio; | 230 toReturn[i] = (a & (1 << i) ) == 0 ? 1 : m_iWideNarrRatio; |
231 } | 231 } |
232 } | 232 } |
233 FX_CHAR CBC_OnedCode39Writer::CalcCheckSum(const CFX_ByteString &contents, FX_IN
T32 &e) | 233 FX_CHAR CBC_OnedCode39Writer::CalcCheckSum(const CFX_ByteString &contents, int32
_t &e) |
234 { | 234 { |
235 FX_INT32 length = contents.GetLength(); | 235 int32_t length = contents.GetLength(); |
236 if (length > 80) { | 236 if (length > 80) { |
237 e = BCExceptionContentsLengthShouldBetween1and80; | 237 e = BCExceptionContentsLengthShouldBetween1and80; |
238 return '*'; | 238 return '*'; |
239 } | 239 } |
240 FX_INT32 checksum = 0; | 240 int32_t checksum = 0; |
241 FX_INT32 len = (FX_INT32)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); | 241 int32_t len = (int32_t)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); |
242 for(FX_INT32 i = 0; i < contents.GetLength(); i++) { | 242 for(int32_t i = 0; i < contents.GetLength(); i++) { |
243 FX_INT32 j = 0; | 243 int32_t j = 0; |
244 for (; j < len; j++) { | 244 for (; j < len; j++) { |
245 if (CBC_OnedCode39Reader::ALPHABET_STRING[j] == contents[i]) { | 245 if (CBC_OnedCode39Reader::ALPHABET_STRING[j] == contents[i]) { |
246 if(contents[i] != '*') { | 246 if(contents[i] != '*') { |
247 checksum += j; | 247 checksum += j; |
248 break; | 248 break; |
249 } else { | 249 } else { |
250 break; | 250 break; |
251 } | 251 } |
252 } | 252 } |
253 } | 253 } |
254 if (j >= len) { | 254 if (j >= len) { |
255 e = BCExceptionUnSupportedString; | 255 e = BCExceptionUnSupportedString; |
256 return '*'; | 256 return '*'; |
257 } | 257 } |
258 } | 258 } |
259 checksum = checksum % 43; | 259 checksum = checksum % 43; |
260 return CBC_OnedCode39Reader::CHECKSUM_STRING[checksum]; | 260 return CBC_OnedCode39Reader::CHECKSUM_STRING[checksum]; |
261 } | 261 } |
262 FX_BYTE *CBC_OnedCode39Writer::Encode(const CFX_ByteString &contents, FX_INT32 &
outlength , FX_INT32 &e) | 262 uint8_t *CBC_OnedCode39Writer::Encode(const CFX_ByteString &contents, int32_t &o
utlength , int32_t &e) |
263 { | 263 { |
264 FX_CHAR checksum = CalcCheckSum(contents, e); | 264 FX_CHAR checksum = CalcCheckSum(contents, e); |
265 if (checksum == '*') { | 265 if (checksum == '*') { |
266 return NULL; | 266 return NULL; |
267 } | 267 } |
268 FX_INT32 widths[9] = {0}; | 268 int32_t widths[9] = {0}; |
269 FX_INT32 wideStrideNum = 3; | 269 int32_t wideStrideNum = 3; |
270 FX_INT32 narrStrideNum = 9 - wideStrideNum; | 270 int32_t narrStrideNum = 9 - wideStrideNum; |
271 CFX_ByteString encodedContents = contents; | 271 CFX_ByteString encodedContents = contents; |
272 if ( m_bCalcChecksum ) { | 272 if ( m_bCalcChecksum ) { |
273 encodedContents += checksum; | 273 encodedContents += checksum; |
274 } | 274 } |
275 m_iContentLen = encodedContents.GetLength(); | 275 m_iContentLen = encodedContents.GetLength(); |
276 FX_INT32 codeWidth = (wideStrideNum * m_iWideNarrRatio + narrStrideNum) * 2
+ 1 + m_iContentLen; | 276 int32_t codeWidth = (wideStrideNum * m_iWideNarrRatio + narrStrideNum) * 2 +
1 + m_iContentLen; |
277 FX_INT32 len = (FX_INT32)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); | 277 int32_t len = (int32_t)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); |
278 for (FX_INT32 j = 0; j < m_iContentLen; j++) { | 278 for (int32_t j = 0; j < m_iContentLen; j++) { |
279 for (FX_INT32 i = 0; i < len; i++) { | 279 for (int32_t i = 0; i < len; i++) { |
280 if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[j])
{ | 280 if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[j])
{ |
281 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths)
; | 281 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths)
; |
282 for(FX_INT32 k = 0; k < 9; k++) { | 282 for(int32_t k = 0; k < 9; k++) { |
283 codeWidth += widths[k]; | 283 codeWidth += widths[k]; |
284 } | 284 } |
285 } | 285 } |
286 } | 286 } |
287 } | 287 } |
288 outlength = codeWidth; | 288 outlength = codeWidth; |
289 FX_BYTE *result = FX_Alloc(FX_BYTE, codeWidth); | 289 uint8_t *result = FX_Alloc(uint8_t, codeWidth); |
290 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); | 290 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); |
291 FX_INT32 pos = AppendPattern(result, 0, widths, 9, 1 , e); | 291 int32_t pos = AppendPattern(result, 0, widths, 9, 1 , e); |
292 if (e != BCExceptionNO) { | 292 if (e != BCExceptionNO) { |
293 FX_Free (result); | 293 FX_Free (result); |
294 return NULL; | 294 return NULL; |
295 } | 295 } |
296 FX_INT32 narrowWhite[] = {1}; | 296 int32_t narrowWhite[] = {1}; |
297 pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); | 297 pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); |
298 if (e != BCExceptionNO) { | 298 if (e != BCExceptionNO) { |
299 FX_Free (result); | 299 FX_Free (result); |
300 return NULL; | 300 return NULL; |
301 } | 301 } |
302 for(FX_INT32 l = m_iContentLen - 1; l >= 0; l--) { | 302 for(int32_t l = m_iContentLen - 1; l >= 0; l--) { |
303 for (FX_INT32 i = 0; i < len; i++) { | 303 for (int32_t i = 0; i < len; i++) { |
304 if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[l])
{ | 304 if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[l])
{ |
305 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths)
; | 305 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths)
; |
306 pos += AppendPattern(result, pos, widths, 9, 1, e); | 306 pos += AppendPattern(result, pos, widths, 9, 1, e); |
307 if (e != BCExceptionNO) { | 307 if (e != BCExceptionNO) { |
308 FX_Free (result); | 308 FX_Free (result); |
309 return NULL; | 309 return NULL; |
310 } | 310 } |
311 } | 311 } |
312 } | 312 } |
313 pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); | 313 pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); |
314 if (e != BCExceptionNO) { | 314 if (e != BCExceptionNO) { |
315 FX_Free (result); | 315 FX_Free (result); |
316 return NULL; | 316 return NULL; |
317 } | 317 } |
318 } | 318 } |
319 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); | 319 ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); |
320 pos += AppendPattern(result, pos, widths, 9, 1, e); | 320 pos += AppendPattern(result, pos, widths, 9, 1, e); |
321 if (e != BCExceptionNO) { | 321 if (e != BCExceptionNO) { |
322 FX_Free (result); | 322 FX_Free (result); |
323 return NULL; | 323 return NULL; |
324 } | 324 } |
325 for (FX_INT32 i = 0; i < codeWidth / 2; i++) { | 325 for (int32_t i = 0; i < codeWidth / 2; i++) { |
326 result[i] ^= result[codeWidth - 1 - i]; | 326 result[i] ^= result[codeWidth - 1 - i]; |
327 result[codeWidth - 1 - i] ^= result[i]; | 327 result[codeWidth - 1 - i] ^= result[i]; |
328 result[i] ^= result[codeWidth - 1 - i]; | 328 result[i] ^= result[codeWidth - 1 - i]; |
329 } | 329 } |
330 return result; | 330 return result; |
331 } | 331 } |
332 CFX_WideString CBC_OnedCode39Writer::encodedContents(FX_WSTR contents, FX_INT32
&e) | 332 CFX_WideString CBC_OnedCode39Writer::encodedContents(FX_WSTR contents, int32_t &
e) |
333 { | 333 { |
334 CFX_WideString encodedContents = contents; | 334 CFX_WideString encodedContents = contents; |
335 if (m_bCalcChecksum && m_bPrintChecksum) { | 335 if (m_bCalcChecksum && m_bPrintChecksum) { |
336 CFX_WideString checksumContent = FilterContents(contents); | 336 CFX_WideString checksumContent = FilterContents(contents); |
337 CFX_ByteString str = checksumContent.UTF8Encode(); | 337 CFX_ByteString str = checksumContent.UTF8Encode(); |
338 FX_CHAR checksum; | 338 FX_CHAR checksum; |
339 checksum = CalcCheckSum(str, e); | 339 checksum = CalcCheckSum(str, e); |
340 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); | 340 BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L"")); |
341 str += checksum; | 341 str += checksum; |
342 encodedContents += checksum; | 342 encodedContents += checksum; |
343 } | 343 } |
344 return encodedContents; | 344 return encodedContents; |
345 } | 345 } |
346 void CBC_OnedCode39Writer::RenderResult(FX_WSTR contents, FX_BYTE* code, FX_INT3
2 codeLength, FX_BOOL isDevice, FX_INT32 &e) | 346 void CBC_OnedCode39Writer::RenderResult(FX_WSTR contents, uint8_t* code, int32_t
codeLength, FX_BOOL isDevice, int32_t &e) |
347 { | 347 { |
348 CFX_WideString encodedCon = encodedContents(contents, e); | 348 CFX_WideString encodedCon = encodedContents(contents, e); |
349 BC_EXCEPTION_CHECK_ReturnVoid(e); | 349 BC_EXCEPTION_CHECK_ReturnVoid(e); |
350 CBC_OneDimWriter::RenderResult(encodedCon, code, codeLength, isDevice, e); | 350 CBC_OneDimWriter::RenderResult(encodedCon, code, codeLength, isDevice, e); |
351 } | 351 } |
OLD | NEW |