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

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

Issue 2048983002: Get rid of NULLs in xfa/fxbarcode/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 6 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
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 e = BCExceptionNoSuchVersion; 249 e = BCExceptionNoSuchVersion;
250 BC_EXCEPTION_CHECK_ReturnValue(e, 0); 250 BC_EXCEPTION_CHECK_ReturnValue(e, 0);
251 } 251 }
252 } 252 }
253 return -1; 253 return -1;
254 } 254 }
255 255
256 void CBC_QRCoderEncoder::MergeString(CFX_ArrayTemplate<Make_Pair*>* result, 256 void CBC_QRCoderEncoder::MergeString(CFX_ArrayTemplate<Make_Pair*>* result,
257 int32_t versionNum, 257 int32_t versionNum,
258 int32_t& e) { 258 int32_t& e) {
259 Make_Pair* first = NULL; 259 Make_Pair* first = nullptr;
260 Make_Pair* second = NULL; 260 Make_Pair* second = nullptr;
261 size_t mergeNum = 0; 261 size_t mergeNum = 0;
262 int32_t i; 262 int32_t i;
263 for (i = 0; ((i < result->GetSize()) && (i + 1 < result->GetSize())); i++) { 263 for (i = 0; ((i < result->GetSize()) && (i + 1 < result->GetSize())); i++) {
264 first = (*result)[i]; 264 first = (*result)[i];
265 second = (*result)[i + 1]; 265 second = (*result)[i + 1];
266 if (first->m_mode == CBC_QRCoderMode::sALPHANUMERIC) { 266 if (first->m_mode == CBC_QRCoderMode::sALPHANUMERIC) {
267 int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sALPHANUMERIC, 267 int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sALPHANUMERIC,
268 CBC_QRCoderMode::sBYTE, versionNum, e); 268 CBC_QRCoderMode::sBYTE, versionNum, e);
269 BC_EXCEPTION_CHECK_ReturnVoid(e); 269 BC_EXCEPTION_CHECK_ReturnVoid(e);
270 if ((second->m_mode == CBC_QRCoderMode::sBYTE) && 270 if ((second->m_mode == CBC_QRCoderMode::sBYTE) &&
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 CBC_QRCoder* qrCode, 351 CBC_QRCoder* qrCode,
352 int32_t versionSpecify, 352 int32_t versionSpecify,
353 int32_t& e) { 353 int32_t& e) {
354 CFX_ByteString encoding = "utf8"; 354 CFX_ByteString encoding = "utf8";
355 CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE; 355 CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE;
356 CFX_ArrayTemplate<Make_Pair*> splitResult; 356 CFX_ArrayTemplate<Make_Pair*> splitResult;
357 CBC_QRCoderBitVector dataBits; 357 CBC_QRCoderBitVector dataBits;
358 dataBits.Init(); 358 dataBits.Init();
359 SplitString(content, &splitResult); 359 SplitString(content, &splitResult);
360 MergeString(&splitResult, versionSpecify, e); 360 MergeString(&splitResult, versionSpecify, e);
361 BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderMode* tempMode = NULL; 361 BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderMode* tempMode = nullptr;
362 for (int32_t i = 0; i < splitResult.GetSize(); i++) { 362 for (int32_t i = 0; i < splitResult.GetSize(); i++) {
363 AppendBytes(splitResult[i]->m_string, splitResult[i]->m_mode, &dataBits, 363 AppendBytes(splitResult[i]->m_string, splitResult[i]->m_mode, &dataBits,
364 encoding, e); 364 encoding, e);
365 if (e != BCExceptionNO) { 365 if (e != BCExceptionNO) {
366 for (int32_t y = 0; y < splitResult.GetSize(); y++) 366 for (int32_t y = 0; y < splitResult.GetSize(); y++)
367 delete splitResult[y]; 367 delete splitResult[y];
368 return; 368 return;
369 } 369 }
370 } 370 }
371 int32_t numInputBytes = dataBits.sizeInBytes(); 371 int32_t numInputBytes = dataBits.sizeInBytes();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 CBC_QRCoder* qrCode, 421 CBC_QRCoder* qrCode,
422 int32_t& e) { 422 int32_t& e) {
423 CFX_ByteString encoding = "utf8"; 423 CFX_ByteString encoding = "utf8";
424 CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE; 424 CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE;
425 CFX_ArrayTemplate<Make_Pair*> splitResult; 425 CFX_ArrayTemplate<Make_Pair*> splitResult;
426 CBC_QRCoderBitVector dataBits; 426 CBC_QRCoderBitVector dataBits;
427 dataBits.Init(); 427 dataBits.Init();
428 SplitString(content, &splitResult); 428 SplitString(content, &splitResult);
429 MergeString(&splitResult, 8, e); 429 MergeString(&splitResult, 8, e);
430 BC_EXCEPTION_CHECK_ReturnVoid(e); 430 BC_EXCEPTION_CHECK_ReturnVoid(e);
431 CBC_QRCoderMode* tempMode = NULL; 431 CBC_QRCoderMode* tempMode = nullptr;
432 for (int32_t i = 0; i < splitResult.GetSize(); i++) { 432 for (int32_t i = 0; i < splitResult.GetSize(); i++) {
433 AppendBytes(splitResult[i]->m_string, splitResult[i]->m_mode, &dataBits, 433 AppendBytes(splitResult[i]->m_string, splitResult[i]->m_mode, &dataBits,
434 encoding, e); 434 encoding, e);
435 if (e != BCExceptionNO) { 435 if (e != BCExceptionNO) {
436 for (int32_t l = 0; l < splitResult.GetSize(); l++) 436 for (int32_t l = 0; l < splitResult.GetSize(); l++)
437 delete splitResult[l]; 437 delete splitResult[l];
438 return; 438 return;
439 } 439 }
440 } 440 }
441 int32_t numInputBytes = dataBits.sizeInBytes(); 441 int32_t numInputBytes = dataBits.sizeInBytes();
442 InitQRCode(numInputBytes, ecLevel, mode, qrCode, e); 442 InitQRCode(numInputBytes, ecLevel, mode, qrCode, e);
443 BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderBitVector headerAndDataBits; 443 BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderBitVector headerAndDataBits;
444 headerAndDataBits.Init(); 444 headerAndDataBits.Init();
445 tempMode = NULL; 445 tempMode = nullptr;
446 int32_t versionNum = qrCode->GetVersion(); 446 int32_t versionNum = qrCode->GetVersion();
447 sign: 447 sign:
448 AppendDataModeLenghInfo(splitResult, headerAndDataBits, tempMode, qrCode, 448 AppendDataModeLenghInfo(splitResult, headerAndDataBits, tempMode, qrCode,
449 encoding, e); 449 encoding, e);
450 if (e != BCExceptionNO) { 450 if (e != BCExceptionNO) {
451 goto catchException; 451 goto catchException;
452 } 452 }
453 numInputBytes = headerAndDataBits.sizeInBytes(); 453 numInputBytes = headerAndDataBits.sizeInBytes();
454 TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e); 454 TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e);
455 if (e != BCExceptionNO) { 455 if (e != BCExceptionNO) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 int32_t& e) { 927 int32_t& e) {
928 int32_t numDataBytes = dataBytes->Size(); 928 int32_t numDataBytes = dataBytes->Size();
929 CFX_Int32Array toEncode; 929 CFX_Int32Array toEncode;
930 toEncode.SetSize(numDataBytes + numEcBytesInBlock); 930 toEncode.SetSize(numDataBytes + numEcBytesInBlock);
931 for (int32_t i = 0; i < numDataBytes; i++) { 931 for (int32_t i = 0; i < numDataBytes; i++) {
932 toEncode[i] = (dataBytes->At(i)); 932 toEncode[i] = (dataBytes->At(i));
933 } 933 }
934 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); 934 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild);
935 encode.Init(); 935 encode.Init();
936 encode.Encode(&toEncode, numEcBytesInBlock, e); 936 encode.Encode(&toEncode, numEcBytesInBlock, e);
937 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 937 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
938 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); 938 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock);
939 for (int32_t j = 0; j < numEcBytesInBlock; j++) { 939 for (int32_t j = 0; j < numEcBytesInBlock; j++) {
940 ecBytes->Set(j, toEncode[numDataBytes + j]); 940 ecBytes->Set(j, toEncode[numDataBytes + j]);
941 } 941 }
942 return ecBytes; 942 return ecBytes;
943 } 943 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp ('k') | xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698