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 2006 Jeremias Maerki in part, and ZXing Authors in part | 8 * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part |
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, | 150 int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, |
151 int32_t startpos, | 151 int32_t startpos, |
152 int32_t count, | 152 int32_t count, |
153 CFX_WideString& sb, | 153 CFX_WideString& sb, |
154 int32_t initialSubmode) { | 154 int32_t initialSubmode) { |
155 CFX_WideString tmp; | 155 CFX_WideString tmp; |
156 int32_t submode = initialSubmode; | 156 int32_t submode = initialSubmode; |
157 int32_t idx = 0; | 157 int32_t idx = 0; |
158 while (TRUE) { | 158 while (true) { |
159 FX_WCHAR ch = msg.GetAt(startpos + idx); | 159 FX_WCHAR ch = msg.GetAt(startpos + idx); |
160 switch (submode) { | 160 switch (submode) { |
161 case SUBMODE_ALPHA: | 161 case SUBMODE_ALPHA: |
162 if (isAlphaUpper(ch)) { | 162 if (isAlphaUpper(ch)) { |
163 if (ch == ' ') { | 163 if (ch == ' ') { |
164 tmp += (FX_WCHAR)26; | 164 tmp += (FX_WCHAR)26; |
165 } else { | 165 } else { |
166 tmp += (FX_WCHAR)(ch - 65); | 166 tmp += (FX_WCHAR)(ch - 65); |
167 } | 167 } |
168 } else { | 168 } else { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 240 } |
241 } | 241 } |
242 idx++; | 242 idx++; |
243 if (idx >= count) { | 243 if (idx >= count) { |
244 break; | 244 break; |
245 } | 245 } |
246 } | 246 } |
247 FX_WCHAR h = 0; | 247 FX_WCHAR h = 0; |
248 int32_t len = tmp.GetLength(); | 248 int32_t len = tmp.GetLength(); |
249 for (int32_t i = 0; i < len; i++) { | 249 for (int32_t i = 0; i < len; i++) { |
250 FX_BOOL odd = (i % 2) != 0; | 250 bool odd = (i % 2) != 0; |
251 if (odd) { | 251 if (odd) { |
252 h = (FX_WCHAR)((h * 30) + tmp.GetAt(i)); | 252 h = (FX_WCHAR)((h * 30) + tmp.GetAt(i)); |
253 sb += h; | 253 sb += h; |
254 } else { | 254 } else { |
255 h = tmp.GetAt(i); | 255 h = tmp.GetAt(i); |
256 } | 256 } |
257 } | 257 } |
258 if ((len % 2) != 0) { | 258 if ((len % 2) != 0) { |
259 sb += (FX_WCHAR)((h * 30) + 29); | 259 sb += (FX_WCHAR)((h * 30) + 29); |
260 } | 260 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 int32_t c = (bigint % num900).toInt(); | 313 int32_t c = (bigint % num900).toInt(); |
314 tmp += (FX_WCHAR)(c); | 314 tmp += (FX_WCHAR)(c); |
315 bigint = bigint / num900; | 315 bigint = bigint / num900; |
316 } while (!bigint.isZero()); | 316 } while (!bigint.isZero()); |
317 for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) { | 317 for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) { |
318 sb += tmp.GetAt(i); | 318 sb += tmp.GetAt(i); |
319 } | 319 } |
320 idx += len; | 320 idx += len; |
321 } | 321 } |
322 } | 322 } |
323 FX_BOOL CBC_PDF417HighLevelEncoder::isDigit(FX_WCHAR ch) { | 323 bool CBC_PDF417HighLevelEncoder::isDigit(FX_WCHAR ch) { |
324 return ch >= '0' && ch <= '9'; | 324 return ch >= '0' && ch <= '9'; |
325 } | 325 } |
326 FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaUpper(FX_WCHAR ch) { | 326 bool CBC_PDF417HighLevelEncoder::isAlphaUpper(FX_WCHAR ch) { |
327 return ch == ' ' || (ch >= 'A' && ch <= 'Z'); | 327 return ch == ' ' || (ch >= 'A' && ch <= 'Z'); |
328 } | 328 } |
329 FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaLower(FX_WCHAR ch) { | 329 bool CBC_PDF417HighLevelEncoder::isAlphaLower(FX_WCHAR ch) { |
330 return ch == ' ' || (ch >= 'a' && ch <= 'z'); | 330 return ch == ' ' || (ch >= 'a' && ch <= 'z'); |
331 } | 331 } |
332 FX_BOOL CBC_PDF417HighLevelEncoder::isMixed(FX_WCHAR ch) { | 332 bool CBC_PDF417HighLevelEncoder::isMixed(FX_WCHAR ch) { |
333 return MIXED[ch] != -1; | 333 return MIXED[ch] != -1; |
334 } | 334 } |
335 FX_BOOL CBC_PDF417HighLevelEncoder::isPunctuation(FX_WCHAR ch) { | 335 bool CBC_PDF417HighLevelEncoder::isPunctuation(FX_WCHAR ch) { |
336 return PUNCTUATION[ch] != -1; | 336 return PUNCTUATION[ch] != -1; |
337 } | 337 } |
338 FX_BOOL CBC_PDF417HighLevelEncoder::isText(FX_WCHAR ch) { | 338 bool CBC_PDF417HighLevelEncoder::isText(FX_WCHAR ch) { |
339 return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126); | 339 return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126); |
340 } | 340 } |
341 int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount( | 341 int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount( |
342 CFX_WideString msg, | 342 CFX_WideString msg, |
343 int32_t startpos) { | 343 int32_t startpos) { |
344 int32_t count = 0; | 344 int32_t count = 0; |
345 int32_t len = msg.GetLength(); | 345 int32_t len = msg.GetLength(); |
346 int32_t idx = startpos; | 346 int32_t idx = startpos; |
347 if (idx < len) { | 347 if (idx < len) { |
348 FX_WCHAR ch = msg.GetAt(idx); | 348 FX_WCHAR ch = msg.GetAt(idx); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 420 } |
421 ch = msg.GetAt(idx); | 421 ch = msg.GetAt(idx); |
422 if (bytes->GetAt(idx) == 63 && ch != '?') { | 422 if (bytes->GetAt(idx) == 63 && ch != '?') { |
423 e = BCExceptionNonEncodableCharacterDetected; | 423 e = BCExceptionNonEncodableCharacterDetected; |
424 return -1; | 424 return -1; |
425 } | 425 } |
426 idx++; | 426 idx++; |
427 } | 427 } |
428 return idx - startpos; | 428 return idx - startpos; |
429 } | 429 } |
OLD | NEW |