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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 CFX_WideString msg; | 64 CFX_WideString msg; |
65 int32_t len = bytes.GetLength(); | 65 int32_t len = bytes.GetLength(); |
66 for (int32_t i = 0; i < len; i++) { | 66 for (int32_t i = 0; i < len; i++) { |
67 FX_WCHAR ch = (FX_WCHAR)(bytes.GetAt(i) & 0xff); | 67 FX_WCHAR ch = (FX_WCHAR)(bytes.GetAt(i) & 0xff); |
68 if (ch == '?' && bytes.GetAt(i) != '?') { | 68 if (ch == '?' && bytes.GetAt(i) != '?') { |
69 e = BCExceptionCharactersOutsideISO88591Encoding; | 69 e = BCExceptionCharactersOutsideISO88591Encoding; |
70 return CFX_WideString(); | 70 return CFX_WideString(); |
71 } | 71 } |
72 msg += ch; | 72 msg += ch; |
73 } | 73 } |
74 CFX_ByteArray byteArr; | 74 CFX_ArrayTemplate<uint8_t> byteArr; |
75 for (int32_t k = 0; k < bytes.GetLength(); k++) { | 75 for (int32_t k = 0; k < bytes.GetLength(); k++) { |
76 byteArr.Add(bytes.GetAt(k)); | 76 byteArr.Add(bytes.GetAt(k)); |
77 } | 77 } |
78 CFX_WideString sb; | 78 CFX_WideString sb; |
79 len = msg.GetLength(); | 79 len = msg.GetLength(); |
80 int32_t p = 0; | 80 int32_t p = 0; |
81 int32_t textSubMode = SUBMODE_ALPHA; | 81 int32_t textSubMode = SUBMODE_ALPHA; |
82 if (compaction == TEXT) { | 82 if (compaction == TEXT) { |
83 encodeText(msg, p, len, sb, textSubMode); | 83 encodeText(msg, p, len, sb, textSubMode); |
84 } else if (compaction == BYTES) { | 84 } else if (compaction == BYTES) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
261 return submode; | 261 return submode; |
262 } | 262 } |
263 void CBC_PDF417HighLevelEncoder::encodeBinary(CFX_ByteArray* bytes, | 263 void CBC_PDF417HighLevelEncoder::encodeBinary(CFX_ArrayTemplate<uint8_t>* bytes, |
264 int32_t startpos, | 264 int32_t startpos, |
265 int32_t count, | 265 int32_t count, |
266 int32_t startmode, | 266 int32_t startmode, |
267 CFX_WideString& sb) { | 267 CFX_WideString& sb) { |
268 if (count == 1 && startmode == TEXT_COMPACTION) { | 268 if (count == 1 && startmode == TEXT_COMPACTION) { |
269 sb += (FX_WCHAR)SHIFT_TO_BYTE; | 269 sb += (FX_WCHAR)SHIFT_TO_BYTE; |
270 } | 270 } |
271 int32_t idx = startpos; | 271 int32_t idx = startpos; |
272 int32_t i = 0; | 272 int32_t i = 0; |
273 if (count >= 6) { | 273 if (count >= 6) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 ch = msg.GetAt(idx); | 380 ch = msg.GetAt(idx); |
381 if (!isText(ch)) { | 381 if (!isText(ch)) { |
382 break; | 382 break; |
383 } | 383 } |
384 idx++; | 384 idx++; |
385 } | 385 } |
386 return idx - startpos; | 386 return idx - startpos; |
387 } | 387 } |
388 int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( | 388 int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( |
389 CFX_WideString msg, | 389 CFX_WideString msg, |
390 CFX_ByteArray* bytes, | 390 CFX_ArrayTemplate<uint8_t>* bytes, |
391 int32_t startpos, | 391 int32_t startpos, |
392 int32_t& e) { | 392 int32_t& e) { |
393 int32_t len = msg.GetLength(); | 393 int32_t len = msg.GetLength(); |
394 int32_t idx = startpos; | 394 int32_t idx = startpos; |
395 while (idx < len) { | 395 while (idx < len) { |
396 FX_WCHAR ch = msg.GetAt(idx); | 396 FX_WCHAR ch = msg.GetAt(idx); |
397 int32_t numericCount = 0; | 397 int32_t numericCount = 0; |
398 while (numericCount < 13 && isDigit(ch)) { | 398 while (numericCount < 13 && isDigit(ch)) { |
399 numericCount++; | 399 numericCount++; |
400 int32_t i = idx + numericCount; | 400 int32_t i = idx + numericCount; |
(...skipping 19 matching lines...) Expand all 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 |