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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content, | 139 void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content, |
140 CFX_PtrArray& result) { | 140 CFX_PtrArray& result) { |
141 int32_t index = 0, flag = 0; | 141 int32_t index = 0, flag = 0; |
142 while ( | 142 while ( |
143 (((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || | 143 (((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || |
144 ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && | 144 ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && |
145 (index < content.GetLength())) { | 145 (index < content.GetLength())) { |
146 index += 2; | 146 index += 2; |
147 } | 147 } |
148 if (index != flag) { | 148 if (index != flag) { |
149 result.Add(new Make_Pair(CBC_QRCoderMode::sGBK, | 149 result.Add( |
150 content.Mid(flag, index - flag))); | 150 new Make_Pair(CBC_QRCoderMode::sGBK, content.Mid(flag, index - flag))); |
151 } | 151 } |
152 flag = index; | 152 flag = index; |
153 if (index >= content.GetLength()) { | 153 if (index >= content.GetLength()) { |
154 return; | 154 return; |
155 } | 155 } |
156 while ( | 156 while ( |
157 GetAlphaNumericCode((uint8_t)content[index]) == -1 && | 157 GetAlphaNumericCode((uint8_t)content[index]) == -1 && |
158 !(((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || | 158 !(((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || |
159 ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && | 159 ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && |
160 (index < content.GetLength())) { | 160 (index < content.GetLength())) { |
161 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 161 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
162 if (IsDBCSLeadByte((uint8_t)content[index])) | 162 if (IsDBCSLeadByte((uint8_t)content[index])) |
163 #else | 163 #else |
164 if ((uint8_t)content[index] > 127) | 164 if ((uint8_t)content[index] > 127) |
165 #endif | 165 #endif |
166 { | 166 { |
167 index += 2; | 167 index += 2; |
168 } else { | 168 } else { |
169 index++; | 169 index++; |
170 } | 170 } |
171 } | 171 } |
172 if (index != flag) { | 172 if (index != flag) { |
173 result.Add(new Make_Pair(CBC_QRCoderMode::sBYTE, | 173 result.Add( |
174 content.Mid(flag, index - flag))); | 174 new Make_Pair(CBC_QRCoderMode::sBYTE, content.Mid(flag, index - flag))); |
175 } | 175 } |
176 flag = index; | 176 flag = index; |
177 if (index >= content.GetLength()) { | 177 if (index >= content.GetLength()) { |
178 return; | 178 return; |
179 } | 179 } |
180 while (FXSYS_Isdigit((uint8_t)content[index]) && | 180 while (FXSYS_Isdigit((uint8_t)content[index]) && |
181 (index < content.GetLength())) { | 181 (index < content.GetLength())) { |
182 index++; | 182 index++; |
183 } | 183 } |
184 if (index != flag) { | 184 if (index != flag) { |
185 result.Add(new Make_Pair(CBC_QRCoderMode::sNUMERIC, | 185 result.Add(new Make_Pair(CBC_QRCoderMode::sNUMERIC, |
186 content.Mid(flag, index - flag))); | 186 content.Mid(flag, index - flag))); |
187 } | 187 } |
188 flag = index; | 188 flag = index; |
189 if (index >= content.GetLength()) { | 189 if (index >= content.GetLength()) { |
190 return; | 190 return; |
191 } | 191 } |
192 while (GetAlphaNumericCode((uint8_t)content[index]) != -1 && | 192 while (GetAlphaNumericCode((uint8_t)content[index]) != -1 && |
193 (index < content.GetLength())) { | 193 (index < content.GetLength())) { |
194 index++; | 194 index++; |
195 } | 195 } |
196 if (index != flag) { | 196 if (index != flag) { |
197 result.Add(new Make_Pair(CBC_QRCoderMode::sALPHANUMERIC, | 197 result.Add(new Make_Pair(CBC_QRCoderMode::sALPHANUMERIC, |
198 content.Mid(flag, index - flag))); | 198 content.Mid(flag, index - flag))); |
199 } | 199 } |
200 flag = index; | 200 flag = index; |
201 if (index >= content.GetLength()) { | 201 if (index >= content.GetLength()) { |
202 return; | 202 return; |
203 } | 203 } |
204 SplitString(content.Mid(index, content.GetLength() - index), result); | 204 SplitString(content.Mid(index, content.GetLength() - index), result); |
205 } | 205 } |
206 int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst, | 206 int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst, |
207 CBC_QRCoderMode* modeSecond, | 207 CBC_QRCoderMode* modeSecond, |
208 int32_t versionNum, | 208 int32_t versionNum, |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); | 951 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); |
952 encode.Init(); | 952 encode.Init(); |
953 encode.Encode(&toEncode, numEcBytesInBlock, e); | 953 encode.Encode(&toEncode, numEcBytesInBlock, e); |
954 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 954 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
955 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); | 955 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); |
956 for (int32_t j = 0; j < numEcBytesInBlock; j++) { | 956 for (int32_t j = 0; j < numEcBytesInBlock; j++) { |
957 ecBytes->Set(j, toEncode[numDataBytes + j]); | 957 ecBytes->Set(j, toEncode[numDataBytes + j]); |
958 } | 958 } |
959 return ecBytes; | 959 return ecBytes; |
960 } | 960 } |
OLD | NEW |