Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp

Issue 2649563003: Replace CFX_ByteArray with CFX_ArrayTemplate<uint8_t> (Closed)
Patch Set: re-upload Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h ('k') | xfa/fxbarcode/qrcode/BC_QRCoderVersion.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (tempMode == CBC_QRCoderMode::sGBK) { 88 if (tempMode == CBC_QRCoderMode::sGBK) {
89 AppendModeInfo(tempMode, &headerAndDataBits, e); 89 AppendModeInfo(tempMode, &headerAndDataBits, e);
90 BC_EXCEPTION_CHECK_ReturnVoid(e); 90 BC_EXCEPTION_CHECK_ReturnVoid(e);
91 AppendLengthInfo(splitResult.second.GetLength(), qrCode->GetVersion(), 91 AppendLengthInfo(splitResult.second.GetLength(), qrCode->GetVersion(),
92 tempMode, &headerAndDataBits, e); 92 tempMode, &headerAndDataBits, e);
93 BC_EXCEPTION_CHECK_ReturnVoid(e); 93 BC_EXCEPTION_CHECK_ReturnVoid(e);
94 AppendBytes(splitResult.second, tempMode, &headerAndDataBits, encoding, 94 AppendBytes(splitResult.second, tempMode, &headerAndDataBits, encoding,
95 e); 95 e);
96 BC_EXCEPTION_CHECK_ReturnVoid(e); 96 BC_EXCEPTION_CHECK_ReturnVoid(e);
97 } else if (tempMode == CBC_QRCoderMode::sBYTE) { 97 } else if (tempMode == CBC_QRCoderMode::sBYTE) {
98 CFX_ByteArray bytes; 98 CFX_ArrayTemplate<uint8_t> bytes;
99 CBC_UtilCodingConvert::LocaleToUtf8(splitResult.second, bytes); 99 CBC_UtilCodingConvert::LocaleToUtf8(splitResult.second, bytes);
100 AppendModeInfo(tempMode, &headerAndDataBits, e); 100 AppendModeInfo(tempMode, &headerAndDataBits, e);
101 BC_EXCEPTION_CHECK_ReturnVoid(e); 101 BC_EXCEPTION_CHECK_ReturnVoid(e);
102 AppendLengthInfo(bytes.GetSize(), qrCode->GetVersion(), tempMode, 102 AppendLengthInfo(bytes.GetSize(), qrCode->GetVersion(), tempMode,
103 &headerAndDataBits, e); 103 &headerAndDataBits, e);
104 BC_EXCEPTION_CHECK_ReturnVoid(e); 104 BC_EXCEPTION_CHECK_ReturnVoid(e);
105 Append8BitBytes(bytes, &headerAndDataBits, e); 105 Append8BitBytes(bytes, &headerAndDataBits, e);
106 BC_EXCEPTION_CHECK_ReturnVoid(e); 106 BC_EXCEPTION_CHECK_ReturnVoid(e);
107 } else if (tempMode == CBC_QRCoderMode::sALPHANUMERIC) { 107 } else if (tempMode == CBC_QRCoderMode::sALPHANUMERIC) {
108 AppendModeInfo(tempMode, &headerAndDataBits, e); 108 AppendModeInfo(tempMode, &headerAndDataBits, e);
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 void CBC_QRCoderEncoder::Append8BitBytes(const CFX_ByteString& content, 715 void CBC_QRCoderEncoder::Append8BitBytes(const CFX_ByteString& content,
716 CBC_QRCoderBitVector* bits, 716 CBC_QRCoderBitVector* bits,
717 CFX_ByteString encoding, 717 CFX_ByteString encoding,
718 int32_t& e) { 718 int32_t& e) {
719 for (int32_t i = 0; i < content.GetLength(); i++) { 719 for (int32_t i = 0; i < content.GetLength(); i++) {
720 bits->AppendBits(content[i], 8, e); 720 bits->AppendBits(content[i], 8, e);
721 BC_EXCEPTION_CHECK_ReturnVoid(e); 721 BC_EXCEPTION_CHECK_ReturnVoid(e);
722 } 722 }
723 } 723 }
724 724
725 void CBC_QRCoderEncoder::Append8BitBytes(CFX_ByteArray& bytes, 725 void CBC_QRCoderEncoder::Append8BitBytes(CFX_ArrayTemplate<uint8_t>& bytes,
726 CBC_QRCoderBitVector* bits, 726 CBC_QRCoderBitVector* bits,
727 int32_t& e) { 727 int32_t& e) {
728 for (int32_t i = 0; i < bytes.GetSize(); i++) { 728 for (int32_t i = 0; i < bytes.GetSize(); i++) {
729 bits->AppendBits(bytes[i], 8, e); 729 bits->AppendBits(bytes[i], 8, e);
730 BC_EXCEPTION_CHECK_ReturnVoid(e); 730 BC_EXCEPTION_CHECK_ReturnVoid(e);
731 } 731 }
732 } 732 }
733 733
734 void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content, 734 void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content,
735 CBC_QRCoderBitVector* bits, 735 CBC_QRCoderBitVector* bits,
736 int32_t& e) { 736 int32_t& e) {
737 CFX_ByteArray bytes; 737 CFX_ArrayTemplate<uint8_t> bytes;
738 uint32_t value = 0; 738 uint32_t value = 0;
739 for (int32_t i = 0; i < bytes.GetSize(); i += 2) { 739 for (int32_t i = 0; i < bytes.GetSize(); i += 2) {
740 value = (uint32_t)((uint8_t)(content[i] << 8) | (uint8_t)content[i + 1]); 740 value = (uint32_t)((uint8_t)(content[i] << 8) | (uint8_t)content[i + 1]);
741 if (value <= 0x9ffc && value >= 0x8140) { 741 if (value <= 0x9ffc && value >= 0x8140) {
742 value -= 0x8140; 742 value -= 0x8140;
743 } else if (value <= 0xebbf && value >= 0xe040) { 743 } else if (value <= 0xebbf && value >= 0xe040) {
744 value -= 0xc140; 744 value -= 0xc140;
745 } else { 745 } else {
746 e = BCExceptionInvalidateCharacter; 746 e = BCExceptionInvalidateCharacter;
747 BC_EXCEPTION_CHECK_ReturnVoid(e); 747 BC_EXCEPTION_CHECK_ReturnVoid(e);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 numDataBytesInBlock = numDataBytesInGroup2; 900 numDataBytesInBlock = numDataBytesInGroup2;
901 numECBytesInBlock = numEcBytesInGroup2; 901 numECBytesInBlock = numEcBytesInGroup2;
902 } 902 }
903 } 903 }
904 904
905 CBC_CommonByteArray* CBC_QRCoderEncoder::GenerateECBytes( 905 CBC_CommonByteArray* CBC_QRCoderEncoder::GenerateECBytes(
906 CBC_CommonByteArray* dataBytes, 906 CBC_CommonByteArray* dataBytes,
907 int32_t numEcBytesInBlock, 907 int32_t numEcBytesInBlock,
908 int32_t& e) { 908 int32_t& e) {
909 int32_t numDataBytes = dataBytes->Size(); 909 int32_t numDataBytes = dataBytes->Size();
910 CFX_Int32Array toEncode; 910 CFX_ArrayTemplate<int32_t> toEncode;
911 toEncode.SetSize(numDataBytes + numEcBytesInBlock); 911 toEncode.SetSize(numDataBytes + numEcBytesInBlock);
912 for (int32_t i = 0; i < numDataBytes; i++) { 912 for (int32_t i = 0; i < numDataBytes; i++) {
913 toEncode[i] = (dataBytes->At(i)); 913 toEncode[i] = (dataBytes->At(i));
914 } 914 }
915 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField); 915 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField);
916 encode.Init(); 916 encode.Init();
917 encode.Encode(&toEncode, numEcBytesInBlock, e); 917 encode.Encode(&toEncode, numEcBytesInBlock, e);
918 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 918 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
919 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); 919 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock);
920 for (int32_t j = 0; j < numEcBytesInBlock; j++) { 920 for (int32_t j = 0; j < numEcBytesInBlock; j++) {
921 ecBytes->Set(j, toEncode[numDataBytes + j]); 921 ecBytes->Set(j, toEncode[numDataBytes + j]);
922 } 922 }
923 return ecBytes; 923 return ecBytes;
924 } 924 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h ('k') | xfa/fxbarcode/qrcode/BC_QRCoderVersion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698