| 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 2008 ZXing authors | 8 * Copyright 2008 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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } else { | 733 } else { |
| 734 bits->AppendBits(code1, 6, e); | 734 bits->AppendBits(code1, 6, e); |
| 735 BC_EXCEPTION_CHECK_ReturnVoid(e) i++; | 735 BC_EXCEPTION_CHECK_ReturnVoid(e) i++; |
| 736 } | 736 } |
| 737 } | 737 } |
| 738 } | 738 } |
| 739 void CBC_QRCoderEncoder::AppendGBKBytes(const CFX_ByteString& content, | 739 void CBC_QRCoderEncoder::AppendGBKBytes(const CFX_ByteString& content, |
| 740 CBC_QRCoderBitVector* bits, | 740 CBC_QRCoderBitVector* bits, |
| 741 int32_t& e) { | 741 int32_t& e) { |
| 742 int32_t length = content.GetLength(); | 742 int32_t length = content.GetLength(); |
| 743 FX_DWORD value = 0; | 743 uint32_t value = 0; |
| 744 for (int32_t i = 0; i < length; i += 2) { | 744 for (int32_t i = 0; i < length; i += 2) { |
| 745 value = (FX_DWORD)((uint8_t)content[i] << 8 | (uint8_t)content[i + 1]); | 745 value = (uint32_t)((uint8_t)content[i] << 8 | (uint8_t)content[i + 1]); |
| 746 if (value <= 0xAAFE && value >= 0xA1A1) { | 746 if (value <= 0xAAFE && value >= 0xA1A1) { |
| 747 value -= 0xA1A1; | 747 value -= 0xA1A1; |
| 748 } else if (value <= 0xFAFE && value >= 0xB0A1) { | 748 } else if (value <= 0xFAFE && value >= 0xB0A1) { |
| 749 value -= 0xA6A1; | 749 value -= 0xA6A1; |
| 750 } else { | 750 } else { |
| 751 e = BCExceptionInvalidateCharacter; | 751 e = BCExceptionInvalidateCharacter; |
| 752 BC_EXCEPTION_CHECK_ReturnVoid(e); | 752 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 753 } | 753 } |
| 754 value = (FX_DWORD)((value >> 8) * 0x60) + (FX_DWORD)(value & 0xff); | 754 value = (uint32_t)((value >> 8) * 0x60) + (uint32_t)(value & 0xff); |
| 755 bits->AppendBits(value, 13, e); | 755 bits->AppendBits(value, 13, e); |
| 756 BC_EXCEPTION_CHECK_ReturnVoid(e); | 756 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 void CBC_QRCoderEncoder::Append8BitBytes(const CFX_ByteString& content, | 759 void CBC_QRCoderEncoder::Append8BitBytes(const CFX_ByteString& content, |
| 760 CBC_QRCoderBitVector* bits, | 760 CBC_QRCoderBitVector* bits, |
| 761 CFX_ByteString encoding, | 761 CFX_ByteString encoding, |
| 762 int32_t& e) { | 762 int32_t& e) { |
| 763 for (int32_t i = 0; i < content.GetLength(); i++) { | 763 for (int32_t i = 0; i < content.GetLength(); i++) { |
| 764 bits->AppendBits(content[i], 8, e); | 764 bits->AppendBits(content[i], 8, e); |
| 765 BC_EXCEPTION_CHECK_ReturnVoid(e); | 765 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 void CBC_QRCoderEncoder::Append8BitBytes(CFX_ByteArray& bytes, | 768 void CBC_QRCoderEncoder::Append8BitBytes(CFX_ByteArray& bytes, |
| 769 CBC_QRCoderBitVector* bits, | 769 CBC_QRCoderBitVector* bits, |
| 770 int32_t& e) { | 770 int32_t& e) { |
| 771 for (int32_t i = 0; i < bytes.GetSize(); i++) { | 771 for (int32_t i = 0; i < bytes.GetSize(); i++) { |
| 772 bits->AppendBits(bytes[i], 8, e); | 772 bits->AppendBits(bytes[i], 8, e); |
| 773 BC_EXCEPTION_CHECK_ReturnVoid(e); | 773 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 774 } | 774 } |
| 775 } | 775 } |
| 776 void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content, | 776 void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content, |
| 777 CBC_QRCoderBitVector* bits, | 777 CBC_QRCoderBitVector* bits, |
| 778 int32_t& e) { | 778 int32_t& e) { |
| 779 CFX_ByteArray bytes; | 779 CFX_ByteArray bytes; |
| 780 FX_DWORD value = 0; | 780 uint32_t value = 0; |
| 781 for (int32_t i = 0; i < bytes.GetSize(); i += 2) { | 781 for (int32_t i = 0; i < bytes.GetSize(); i += 2) { |
| 782 value = (FX_DWORD)((uint8_t)(content[i] << 8) | (uint8_t)content[i + 1]); | 782 value = (uint32_t)((uint8_t)(content[i] << 8) | (uint8_t)content[i + 1]); |
| 783 if (value <= 0x9ffc && value >= 0x8140) { | 783 if (value <= 0x9ffc && value >= 0x8140) { |
| 784 value -= 0x8140; | 784 value -= 0x8140; |
| 785 } else if (value <= 0xebbf && value >= 0xe040) { | 785 } else if (value <= 0xebbf && value >= 0xe040) { |
| 786 value -= 0xc140; | 786 value -= 0xc140; |
| 787 } else { | 787 } else { |
| 788 e = BCExceptionInvalidateCharacter; | 788 e = BCExceptionInvalidateCharacter; |
| 789 BC_EXCEPTION_CHECK_ReturnVoid(e); | 789 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 790 } | 790 } |
| 791 value = (FX_DWORD)((value >> 8) * 0xc0) + (FX_DWORD)(value & 0xff); | 791 value = (uint32_t)((value >> 8) * 0xc0) + (uint32_t)(value & 0xff); |
| 792 bits->AppendBits(value, 13, e); | 792 bits->AppendBits(value, 13, e); |
| 793 BC_EXCEPTION_CHECK_ReturnVoid(e); | 793 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 794 } | 794 } |
| 795 } | 795 } |
| 796 void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes, | 796 void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes, |
| 797 CBC_QRCoderErrorCorrectionLevel* ecLevel, | 797 CBC_QRCoderErrorCorrectionLevel* ecLevel, |
| 798 CBC_QRCoderMode* mode, | 798 CBC_QRCoderMode* mode, |
| 799 CBC_QRCoder* qrCode, | 799 CBC_QRCoder* qrCode, |
| 800 int32_t& e) { | 800 int32_t& e) { |
| 801 qrCode->SetECLevel(ecLevel); | 801 qrCode->SetECLevel(ecLevel); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); | 952 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); |
| 953 encode.Init(); | 953 encode.Init(); |
| 954 encode.Encode(&toEncode, numEcBytesInBlock, e); | 954 encode.Encode(&toEncode, numEcBytesInBlock, e); |
| 955 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 955 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 956 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); | 956 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); |
| 957 for (int32_t j = 0; j < numEcBytesInBlock; j++) { | 957 for (int32_t j = 0; j < numEcBytesInBlock; j++) { |
| 958 ecBytes->Set(j, toEncode[numDataBytes + j]); | 958 ecBytes->Set(j, toEncode[numDataBytes + j]); |
| 959 } | 959 } |
| 960 return ecBytes; | 960 return ecBytes; |
| 961 } | 961 } |
| OLD | NEW |