summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/qrcode
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-01-31 13:02:10 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-01-31 22:52:16 +0000
commitc8017b2581b7ade6b05ba086eb7221465414173f (patch)
treef606dadefe9d6e27e7782bd9c33e2498810a7b2f /xfa/fxbarcode/qrcode
parent00d4064e5414fc0845e354b50c7f1a8323449268 (diff)
downloadpdfium-c8017b2581b7ade6b05ba086eb7221465414173f.tar.xz
Remove BC_EXCEPTION_CHECK macroschromium/2999
These obfuscate control flow and save very few lines. Mechanical change (mostly), sed + clang-format and adding a few missing semicolons. Change-Id: If8ae06c23edea8c455c79eab589fee5142dc3409 Reviewed-on: https://pdfium-review.googlesource.com/2472 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxbarcode/qrcode')
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp6
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoder.cpp3
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp21
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp267
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp6
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp171
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp6
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp39
8 files changed, 347 insertions, 172 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
index adb12f25b1..617dd17ff7 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
@@ -85,7 +85,8 @@ uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents,
break;
default: {
e = BCExceptionUnSupportEclevel;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
}
}
CBC_QRCoder qr;
@@ -95,7 +96,8 @@ uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents,
} else {
CBC_QRCoderEncoder::Encode(contents, ec, &qr, e);
}
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
outWidth = qr.GetMatrixWidth();
outHeight = qr.GetMatrixWidth();
uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight);
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp
index c47374935f..bb0001d722 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoder.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp
@@ -85,7 +85,8 @@ int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) {
int32_t value = m_matrix->Get(x, y);
if (!(value == 0 || value == 1)) {
e = BCExceptionValueMustBeEither0or1;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ if (e != BCExceptionNO)
+ return 0;
}
return value;
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
index c770c15392..bdf73a9841 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
@@ -43,7 +43,8 @@ void CBC_QRCoderBitVector::Clear() {
int32_t CBC_QRCoderBitVector::At(int32_t index, int32_t& e) {
if (index < 0 || index >= m_sizeInBits) {
e = BCExceptionBadIndexException;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ if (e != BCExceptionNO)
+ return 0;
}
int32_t value = m_array[index >> 3] & 0xff;
return (value >> (7 - (index & 0x7))) & 1;
@@ -57,7 +58,8 @@ int32_t CBC_QRCoderBitVector::Size() {
void CBC_QRCoderBitVector::AppendBit(int32_t bit, int32_t& e) {
if (!(bit == 0 || bit == 1)) {
e = BCExceptionBadValueException;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t numBitsInLastByte = m_sizeInBits & 0x7;
if (numBitsInLastByte == 0) {
@@ -72,7 +74,8 @@ void CBC_QRCoderBitVector::AppendBits(int32_t value,
int32_t& e) {
if (numBits < 0 || numBits > 32) {
e = BCExceptionBadNumBitsException;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t numBitsLeft = numBits;
while (numBitsLeft > 0) {
@@ -83,7 +86,8 @@ void CBC_QRCoderBitVector::AppendBits(int32_t value,
} else {
int32_t bit = (value >> (numBitsLeft - 1)) & 1;
AppendBit(bit, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
--numBitsLeft;
}
}
@@ -93,15 +97,18 @@ void CBC_QRCoderBitVector::AppendBitVector(CBC_QRCoderBitVector* bits,
int32_t size = bits->Size();
for (int32_t i = 0; i < size; i++) {
int32_t num = bits->At(i, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendBit(num, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e)
+ if (e != BCExceptionNO)
+ return;
}
}
void CBC_QRCoderBitVector::XOR(CBC_QRCoderBitVector* other, int32_t& e) {
if (m_sizeInBits != other->Size()) {
e = BCExceptioncanNotOperatexorOperator;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t sizeInBytes = (m_sizeInBits + 7) >> 3;
for (int32_t i = 0; i < sizeInBytes; ++i) {
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index ab17d244fa..d8f5f4ed0f 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -63,13 +63,16 @@ void CBC_QRCoderEncoder::Encode(const CFX_ByteString& content,
int32_t versionSpecify) {
if (versionSpecify == 0) {
EncodeWithAutoVersion(content, ecLevel, qrCode, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e)
+ if (e != BCExceptionNO)
+ return;
} else if (versionSpecify > 0 && versionSpecify <= 40) {
EncodeWithSpecifyVersion(content, ecLevel, qrCode, versionSpecify, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else {
e = BCExceptionVersionMust1_40;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -87,44 +90,57 @@ void CBC_QRCoderEncoder::AppendDataModeLenghInfo(
tempMode = splitResult.first;
if (tempMode == CBC_QRCoderMode::sGBK) {
AppendModeInfo(tempMode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendLengthInfo(splitResult.second.GetLength(), qrCode->GetVersion(),
tempMode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendBytes(splitResult.second, tempMode, &headerAndDataBits, encoding,
e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else if (tempMode == CBC_QRCoderMode::sBYTE) {
CFX_ArrayTemplate<uint8_t> bytes;
CBC_UtilCodingConvert::LocaleToUtf8(splitResult.second, bytes);
AppendModeInfo(tempMode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendLengthInfo(bytes.GetSize(), qrCode->GetVersion(), tempMode,
&headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
Append8BitBytes(bytes, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else if (tempMode == CBC_QRCoderMode::sALPHANUMERIC) {
AppendModeInfo(tempMode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendLengthInfo(splitResult.second.GetLength(), qrCode->GetVersion(),
tempMode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendBytes(splitResult.second, tempMode, &headerAndDataBits, encoding,
e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else if (tempMode == CBC_QRCoderMode::sNUMERIC) {
AppendModeInfo(tempMode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendLengthInfo(splitResult.second.GetLength(), qrCode->GetVersion(),
tempMode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
AppendBytes(splitResult.second, tempMode, &headerAndDataBits, encoding,
e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else {
e = BCExceptionUnknown;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
}
@@ -212,7 +228,8 @@ int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst,
return 16;
} else {
e = BCExceptionNoSuchVersion;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ if (e != BCExceptionNO)
+ return 0;
}
} else if ((modeSecond == CBC_QRCoderMode::sALPHANUMERIC) &&
(modeFirst == CBC_QRCoderMode::sNUMERIC)) {
@@ -224,7 +241,8 @@ int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst,
return 17;
} else {
e = BCExceptionNoSuchVersion;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ if (e != BCExceptionNO)
+ return 0;
}
} else if ((modeSecond == CBC_QRCoderMode::sBYTE) &&
(modeFirst == CBC_QRCoderMode::sNUMERIC)) {
@@ -236,7 +254,8 @@ int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst,
return 9;
} else {
e = BCExceptionNoSuchVersion;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ if (e != BCExceptionNO)
+ return 0;
}
}
return -1;
@@ -253,7 +272,8 @@ void CBC_QRCoderEncoder::MergeString(
if (element1->first == CBC_QRCoderMode::sALPHANUMERIC) {
int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sALPHANUMERIC,
CBC_QRCoderMode::sBYTE, versionNum, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
if (element2->first == CBC_QRCoderMode::sBYTE &&
element1->second.GetLength() < tmp) {
element2->second = element1->second + element2->second;
@@ -271,7 +291,8 @@ void CBC_QRCoderEncoder::MergeString(
} else if (element1->first == CBC_QRCoderMode::sNUMERIC) {
int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sNUMERIC,
CBC_QRCoderMode::sBYTE, versionNum, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
if (element2->first == CBC_QRCoderMode::sBYTE &&
element1->second.GetLength() < tmp) {
element2->second = element1->second + element2->second;
@@ -281,7 +302,8 @@ void CBC_QRCoderEncoder::MergeString(
}
tmp = GetSpanByVersion(CBC_QRCoderMode::sNUMERIC,
CBC_QRCoderMode::sALPHANUMERIC, versionNum, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
if (element2->first == CBC_QRCoderMode::sALPHANUMERIC &&
element1->second.GetLength() < tmp) {
element2->second = element1->second + element2->second;
@@ -295,7 +317,8 @@ void CBC_QRCoderEncoder::MergeString(
return;
}
MergeString(result, versionNum, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes,
@@ -308,7 +331,8 @@ void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes,
qrCode->SetMode(mode);
CBC_QRCoderVersion* version =
CBC_QRCoderVersion::GetVersionForNumber(versionNumber, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t numBytes = version->GetTotalCodeWords();
CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel);
int32_t numEcBytes = ecBlocks->GetTotalECCodeWords();
@@ -324,7 +348,8 @@ void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes,
return;
}
e = BCExceptionCannotFindBlockInfo;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
@@ -340,7 +365,9 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
dataBits.Init();
SplitString(content, &splitResult);
MergeString(&splitResult, versionSpecify, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderMode* tempMode = nullptr;
+ if (e != BCExceptionNO)
+ return;
+ CBC_QRCoderMode* tempMode = nullptr;
for (const auto& result : splitResult) {
AppendBytes(result.second, result.first, &dataBits, encoding, e);
if (e != BCExceptionNO)
@@ -368,22 +395,26 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(),
qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(),
&finalBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
qrCode->SetMaskPattern(maskPattern);
CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(),
qrCode->GetVersion(),
qrCode->GetMaskPattern(), matrix.get(), e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
qrCode->SetMatrix(std::move(matrix));
if (!qrCode->IsValid()) {
e = BCExceptionInvalidQRCode;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -399,7 +430,8 @@ void CBC_QRCoderEncoder::EncodeWithAutoVersion(
dataBits.Init();
SplitString(content, &splitResult);
MergeString(&splitResult, 8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
CBC_QRCoderMode* tempMode = nullptr;
for (const auto& result : splitResult) {
AppendBytes(result.second, result.first, &dataBits, encoding, e);
@@ -408,7 +440,9 @@ void CBC_QRCoderEncoder::EncodeWithAutoVersion(
}
int32_t numInputBytes = dataBits.sizeInBytes();
InitQRCode(numInputBytes, ecLevel, mode, qrCode, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderBitVector headerAndDataBits;
+ if (e != BCExceptionNO)
+ return;
+ CBC_QRCoderBitVector headerAndDataBits;
headerAndDataBits.Init();
tempMode = nullptr;
int32_t versionNum = qrCode->GetVersion();
@@ -446,21 +480,25 @@ catchException:
InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(),
qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(),
&finalBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
qrCode->SetMaskPattern(maskPattern);
CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(),
qrCode->GetVersion(),
qrCode->GetMaskPattern(), matrix.get(), e);
- BC_EXCEPTION_CHECK_ReturnVoid(e) qrCode->SetMatrix(std::move(matrix));
+ if (e != BCExceptionNO)
+ return qrCode->SetMatrix(std::move(matrix));
if (!qrCode->IsValid()) {
e = BCExceptionInvalidQRCode;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -475,43 +513,52 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content,
CBC_QRCoderBitVector dataBits;
dataBits.Init();
AppendBytes(utf8Data, mode, &dataBits, encoding, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t numInputBytes = dataBits.sizeInBytes();
InitQRCode(numInputBytes, ecLevel, mode, qrCode, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
CBC_QRCoderBitVector headerAndDataBits;
headerAndDataBits.Init();
AppendModeInfo(mode, &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t numLetters = mode == CBC_QRCoderMode::sBYTE ? dataBits.sizeInBytes()
: content.GetLength();
AppendLengthInfo(numLetters, qrCode->GetVersion(), mode, &headerAndDataBits,
e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
headerAndDataBits.AppendBitVector(&dataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e)
- TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e);
+ if (e != BCExceptionNO)
+ return;
CBC_QRCoderBitVector finalBits;
finalBits.Init();
InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(),
qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(),
&finalBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
qrCode->SetMaskPattern(maskPattern);
CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(),
qrCode->GetVersion(),
qrCode->GetMaskPattern(), matrix.get(), e);
- BC_EXCEPTION_CHECK_ReturnVoid(e) qrCode->SetMatrix(std::move(matrix));
+ if (e != BCExceptionNO)
+ return qrCode->SetMatrix(std::move(matrix));
if (!qrCode->IsValid()) {
e = BCExceptionInvalidQRCode;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -521,37 +568,44 @@ void CBC_QRCoderEncoder::TerminateBits(int32_t numDataBytes,
int32_t capacity = numDataBytes << 3;
if (bits->Size() > capacity) {
e = BCExceptionDataTooMany;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
for (int32_t i = 0; i < 4 && bits->Size() < capacity; ++i) {
bits->AppendBit(0, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t numBitsInLastByte = bits->Size() % 8;
if (numBitsInLastByte > 0) {
int32_t numPaddingBits = 8 - numBitsInLastByte;
for (int32_t j = 0; j < numPaddingBits; ++j) {
bits->AppendBit(0, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e)
+ if (e != BCExceptionNO)
+ return;
}
}
if (bits->Size() % 8 != 0) {
e = BCExceptionDigitLengthMustBe8;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t numPaddingBytes = numDataBytes - bits->sizeInBytes();
for (int32_t k = 0; k < numPaddingBytes; ++k) {
if (k % 2 == 0) {
bits->AppendBits(0xec, 8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else {
bits->AppendBits(0x11, 8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
if (bits->Size() != capacity) {
e = BCExceptionBitsNotEqualCacity;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -567,7 +621,8 @@ int32_t CBC_QRCoderEncoder::ChooseMaskPattern(
maskPattern++) {
CBC_QRCoderMatrixUtil::BuildMatrix(bits, ecLevel, version, maskPattern,
matrix, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ if (e != BCExceptionNO)
+ return 0;
int32_t penalty = CalculateMaskPenalty(matrix);
if (penalty < minPenalty) {
minPenalty = penalty;
@@ -621,22 +676,28 @@ void CBC_QRCoderEncoder::AppendBytes(const CFX_ByteString& content,
int32_t& e) {
if (mode == CBC_QRCoderMode::sNUMERIC) {
AppendNumericBytes(content, bits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else if (mode == CBC_QRCoderMode::sALPHANUMERIC) {
AppendAlphaNumericBytes(content, bits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else if (mode == CBC_QRCoderMode::sBYTE) {
Append8BitBytes(content, bits, encoding, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else if (mode == CBC_QRCoderMode::sKANJI) {
AppendKanjiBytes(content, bits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else if (mode == CBC_QRCoderMode::sGBK) {
AppendGBKBytes(content, bits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
} else {
e = BCExceptionUnsupportedMode;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -651,14 +712,19 @@ void CBC_QRCoderEncoder::AppendNumericBytes(const CFX_ByteString& content,
int32_t num2 = content[i + 1] - '0';
int32_t num3 = content[i + 2] - '0';
bits->AppendBits(num1 * 100 + num2 * 10 + num3, 10, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e) i += 3;
+ if (e != BCExceptionNO)
+ return;
+ i += 3;
} else if (i + 1 < length) {
int32_t num2 = content[i + 1] - '0';
bits->AppendBits(num1 * 10 + num2, 7, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e) i += 2;
+ if (e != BCExceptionNO)
+ return;
+ i += 2;
} else {
bits->AppendBits(num1, 4, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
i++;
}
}
@@ -673,20 +739,25 @@ void CBC_QRCoderEncoder::AppendAlphaNumericBytes(const CFX_ByteString& content,
int32_t code1 = GetAlphaNumericCode(content[i]);
if (code1 == -1) {
e = BCExceptionInvalidateCharacter;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
if (i + 1 < length) {
int32_t code2 = GetAlphaNumericCode(content[i + 1]);
if (code2 == -1) {
e = BCExceptionInvalidateCharacter;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
bits->AppendBits(code1 * 45 + code2, 11, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
i += 2;
} else {
bits->AppendBits(code1, 6, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e) i++;
+ if (e != BCExceptionNO)
+ return;
+ i++;
}
}
}
@@ -704,11 +775,13 @@ void CBC_QRCoderEncoder::AppendGBKBytes(const CFX_ByteString& content,
value -= 0xA6A1;
} else {
e = BCExceptionInvalidateCharacter;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
value = (uint32_t)((value >> 8) * 0x60) + (uint32_t)(value & 0xff);
bits->AppendBits(value, 13, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -718,7 +791,8 @@ void CBC_QRCoderEncoder::Append8BitBytes(const CFX_ByteString& content,
int32_t& e) {
for (int32_t i = 0; i < content.GetLength(); i++) {
bits->AppendBits(content[i], 8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -727,7 +801,8 @@ void CBC_QRCoderEncoder::Append8BitBytes(CFX_ArrayTemplate<uint8_t>& bytes,
int32_t& e) {
for (int32_t i = 0; i < bytes.GetSize(); i++) {
bits->AppendBits(bytes[i], 8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -744,11 +819,13 @@ void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content,
value -= 0xc140;
} else {
e = BCExceptionInvalidateCharacter;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
value = (uint32_t)((value >> 8) * 0xc0) + (uint32_t)(value & 0xff);
bits->AppendBits(value, 13, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -762,7 +839,8 @@ void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes,
for (int32_t versionNum = 1; versionNum <= 40; versionNum++) {
CBC_QRCoderVersion* version =
CBC_QRCoderVersion::GetVersionForNumber(versionNum, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t numBytes = version->GetTotalCodeWords();
CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel);
int32_t numEcBytes = ecBlocks->GetTotalECCodeWords();
@@ -779,7 +857,8 @@ void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes,
}
}
e = BCExceptionCannotFindBlockInfo;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
void CBC_QRCoderEncoder::AppendModeInfo(CBC_QRCoderMode* mode,
@@ -788,7 +867,8 @@ void CBC_QRCoderEncoder::AppendModeInfo(CBC_QRCoderMode* mode,
bits->AppendBits(mode->GetBits(), 4, e);
if (mode == CBC_QRCoderMode::sGBK) {
bits->AppendBits(1, 4, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -798,18 +878,22 @@ void CBC_QRCoderEncoder::AppendLengthInfo(int32_t numLetters,
CBC_QRCoderBitVector* bits,
int32_t& e) {
CBC_QRCoderVersion* qcv = CBC_QRCoderVersion::GetVersionForNumber(version, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t numBits = mode->GetCharacterCountBits(qcv, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
if (numBits > ((1 << numBits) - 1)) {
return;
}
if (mode == CBC_QRCoderMode::sGBK) {
bits->AppendBits(numLetters / 2, numBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
bits->AppendBits(numLetters, numBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
@@ -820,7 +904,8 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
int32_t& e) {
if (bits->sizeInBytes() != numDataBytes) {
e = BCExceptionBitsBytesNotMatch;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t dataBytesOffset = 0;
int32_t maxNumDataBytes = 0;
@@ -837,7 +922,8 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock);
std::unique_ptr<CBC_CommonByteArray> ecBytes(
GenerateECBytes(dataBytes.get(), numEcBytesInBlosk, e));
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size());
maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size());
blocks.Add(
@@ -846,14 +932,16 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
}
if (numDataBytes != dataBytesOffset) {
e = BCExceptionBytesNotMatchOffset;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
for (int32_t x = 0; x < maxNumDataBytes; x++) {
for (int32_t j = 0; j < blocks.GetSize(); j++) {
const CBC_CommonByteArray* dataBytes = blocks[j]->GetDataBytes();
if (x < dataBytes->Size()) {
result->AppendBits(dataBytes->At(x), 8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
}
@@ -862,7 +950,8 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
const CBC_CommonByteArray* ecBytes = blocks[l]->GetErrorCorrectionBytes();
if (y < ecBytes->Size()) {
result->AppendBits(ecBytes->At(y), 8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
}
@@ -871,7 +960,8 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
}
if (numTotalBytes != result->sizeInBytes()) {
e = BCExceptionSizeInBytesDiffer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
@@ -915,7 +1005,8 @@ CBC_CommonByteArray* CBC_QRCoderEncoder::GenerateECBytes(
CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField);
encode.Init();
encode.Encode(&toEncode, numEcBytesInBlock, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock);
for (int32_t j = 0; j < numEcBytesInBlock; j++) {
ecBytes->Set(j, toEncode[numDataBytes + j]);
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
index 8342b9b6db..acc0cc9459 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
@@ -128,7 +128,8 @@ bool CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern,
int32_t& e) {
if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) {
e = (BCExceptionInvalidateMaskPattern);
- BC_EXCEPTION_CHECK_ReturnValue(e, false);
+ if (e != BCExceptionNO)
+ return false;
}
int32_t intermediate = 0, temp = 0;
switch (maskPattern) {
@@ -161,7 +162,8 @@ bool CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern,
break;
default: {
e = BCExceptionInvalidateMaskPattern;
- BC_EXCEPTION_CHECK_ReturnValue(e, false);
+ if (e != BCExceptionNO)
+ return false;
}
}
return intermediate == 0;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
index ca44e01293..757f4ef7f4 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
@@ -79,7 +79,8 @@ void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
matrix->clear((uint8_t)-1);
}
@@ -92,34 +93,45 @@ void CBC_QRCoderMatrixUtil::BuildMatrix(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
ClearMatrix(matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedBasicPatterns(version, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedTypeInfo(ecLevel, maskPattern, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
MaybeEmbedVersionInfo(version, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedDataBits(dataBits, maskPattern, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version,
CBC_CommonByteMatrix* matrix,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
EmbedPositionDetectionPatternsAndSeparators(matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedDarkDotAtLeftBottomCorner(matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
MaybeEmbedPositionAdjustmentPatterns(version, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedTimingPatterns(matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
void CBC_QRCoderMatrixUtil::EmbedTypeInfo(
CBC_QRCoderErrorCorrectionLevel* ecLevel,
@@ -128,15 +140,18 @@ void CBC_QRCoderMatrixUtil::EmbedTypeInfo(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
CBC_QRCoderBitVector typeInfoBits;
typeInfoBits.Init();
MakeTypeInfoBits(ecLevel, maskPattern, &typeInfoBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
for (int32_t i = 0; i < typeInfoBits.Size(); i++) {
int32_t bit = typeInfoBits.At(typeInfoBits.Size() - 1 - i, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t x1 = TYPE_INFO_COORDINATES[i][0];
int32_t y1 = TYPE_INFO_COORDINATES[i][1];
matrix->Set(x1, y1, bit);
@@ -156,7 +171,8 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
if (version < 7) {
return;
@@ -164,12 +180,14 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version,
CBC_QRCoderBitVector versionInfoBits;
versionInfoBits.Init();
MakeVersionInfoBits(version, &versionInfoBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t bitIndex = 6 * 3 - 1;
for (int32_t i = 0; i < 6; i++) {
for (int32_t j = 0; j < 3; j++) {
int32_t bit = versionInfoBits.At(bitIndex, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
bitIndex--;
matrix->Set(i, matrix->GetHeight() - 11 + j, bit);
matrix->Set(matrix->GetHeight() - 11 + j, i, bit);
@@ -182,7 +200,8 @@ void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits,
int32_t& e) {
if (!matrix || !dataBits) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t bitIndex = 0;
int32_t direction = -1;
@@ -205,14 +224,16 @@ void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits,
int32_t bit;
if (bitIndex < dataBits->Size()) {
bit = dataBits->At(bitIndex, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
bitIndex++;
} else {
bit = 0;
}
if (maskPattern != -1) {
bool bol = CBC_QRCoderMaskUtil::GetDataMaskBit(maskPattern, xx, y, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
if (bol) {
bit ^= 0x01;
}
@@ -244,27 +265,34 @@ void CBC_QRCoderMatrixUtil::MakeTypeInfoBits(
int32_t& e) {
if (!bits) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) {
e = BCExceptionBadMask;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
bits->AppendBits(typeInfo, 5, e);
int32_t bchCode = CalculateBCHCode(typeInfo, TYPE_INFO_POLY);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
bits->AppendBits(bchCode, 10, e);
CBC_QRCoderBitVector maskBits;
maskBits.Init();
maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
bits->XOR(&maskBits, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
if (bits->Size() != 15) {
e = BCExceptionBitSizeNot15;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version,
@@ -272,16 +300,20 @@ void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version,
int32_t& e) {
if (!bits) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
bits->AppendBits(version, 6, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY);
bits->AppendBits(bchCode, 12, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
if (bits->Size() != 18) {
e = BCExceptionBitSizeNot18;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
bool CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) {
@@ -295,20 +327,23 @@ void CBC_QRCoderMatrixUtil::EmbedTimingPatterns(CBC_CommonByteMatrix* matrix,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
for (int32_t i = 8; i < matrix->GetWidth() - 8; i++) {
int32_t bit = (i + 1) % 2;
if (!IsValidValue(matrix->Get(i, 6))) {
e = BCExceptionInvalidateImageData;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
if (IsEmpty(matrix->Get(i, 6))) {
matrix->Set(i, 6, bit);
}
if (!IsValidValue(matrix->Get(6, i))) {
e = BCExceptionInvalidateImageData;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
if (IsEmpty(matrix->Get(6, i))) {
matrix->Set(6, i, bit);
@@ -320,11 +355,13 @@ void CBC_QRCoderMatrixUtil::EmbedDarkDotAtLeftBottomCorner(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
if (matrix->Get(8, matrix->GetHeight() - 8) == 0) {
e = BCExceptionHeight_8BeZero;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
matrix->Set(8, matrix->GetHeight() - 8, 1);
}
@@ -335,12 +372,14 @@ void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
for (int32_t x = 0; x < 8; x++) {
if (!IsEmpty(matrix->Get(xStart + x, yStart))) {
e = BCExceptionInvalidateData;
- BC_EXCEPTION_CHECK_ReturnVoid(e)
+ if (e != BCExceptionNO)
+ return;
}
matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]);
}
@@ -352,12 +391,14 @@ void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
for (int32_t y = 0; y < 7; y++) {
if (!IsEmpty(matrix->Get(xStart, yStart + y))) {
e = BCExceptionInvalidateData;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]);
}
@@ -369,13 +410,15 @@ void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
for (int32_t y = 0; y < 5; y++) {
for (int32_t x = 0; x < 5; x++) {
if (!IsEmpty(matrix->Get(xStart + x, y + yStart))) {
e = BCExceptionInvalidateData;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
matrix->Set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]);
}
@@ -388,13 +431,15 @@ void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
for (int32_t y = 0; y < 7; y++) {
for (int32_t x = 0; x < 7; x++) {
if (!IsEmpty(matrix->Get(xStart + x, yStart + y))) {
e = BCExceptionInvalidateData;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
matrix->Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]);
}
@@ -405,32 +450,42 @@ void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPatternsAndSeparators(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
int32_t pdpWidth = 7;
EmbedPositionDetectionPattern(0, 0, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedPositionDetectionPattern(matrix->GetWidth() - pdpWidth, 0, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedPositionDetectionPattern(0, matrix->GetWidth() - pdpWidth, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t hspWidth = 8;
EmbedHorizontalSeparationPattern(0, hspWidth - 1, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedHorizontalSeparationPattern(matrix->GetWidth() - hspWidth, hspWidth - 1,
matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedHorizontalSeparationPattern(0, matrix->GetWidth() - hspWidth, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
int32_t vspSize = 7;
EmbedVerticalSeparationPattern(vspSize, 0, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedVerticalSeparationPattern(matrix->GetHeight() - vspSize - 1, 0, matrix,
e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
EmbedVerticalSeparationPattern(vspSize, matrix->GetHeight() - vspSize, matrix,
e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns(
int32_t version,
@@ -438,7 +493,8 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
if (version < 2) {
return;
@@ -456,7 +512,8 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns(
}
if (IsEmpty(matrix->Get(x, y))) {
EmbedPositionAdjustmentPattern(x - 2, y - 2, matrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ if (e != BCExceptionNO)
+ return;
}
}
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp
index 74c5563927..87f32edddf 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp
@@ -100,7 +100,8 @@ CBC_QRCoderMode* CBC_QRCoderMode::ForBits(int32_t bits, int32_t& e) {
return sGBK;
default: {
e = BCExceptionUnsupportedMode;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
}
}
return nullptr;
@@ -118,7 +119,8 @@ int32_t CBC_QRCoderMode::GetCharacterCountBits(CBC_QRCoderVersion* version,
int32_t& e) const {
if (m_characterCountBitsForVersions.empty()) {
e = BCExceptionCharacterNotThisMode;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ if (e != BCExceptionNO)
+ return 0;
}
int32_t number = version->GetVersionNumber();
int32_t offset;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
index b4effb91a5..58516913bc 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
@@ -372,10 +372,12 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension(
int32_t& e) {
if ((dimension % 4) != 1) {
e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
}
CBC_QRCoderVersion* qcv = GetVersionForNumber((dimension - 17) >> 2, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
return qcv;
}
CBC_QRCoderVersion* CBC_QRCoderVersion::DecodeVersionInformation(
@@ -387,7 +389,8 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::DecodeVersionInformation(
int32_t targetVersion = VERSION_DECODE_INFO[i];
if (targetVersion == versionBits) {
CBC_QRCoderVersion* qcv = GetVersionForNumber(i + 7, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
return qcv;
}
int32_t bitsDifference = NumBitsDiffering(versionBits, targetVersion);
@@ -398,7 +401,8 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::DecodeVersionInformation(
}
if (bestDifference <= 3) {
CBC_QRCoderVersion* qcv = GetVersionForNumber(bestVersion, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
return qcv;
}
return nullptr;
@@ -408,11 +412,14 @@ CBC_CommonBitMatrix* CBC_QRCoderVersion::BuildFunctionPattern(int32_t& e) {
CBC_CommonBitMatrix* bitMatrix = new CBC_CommonBitMatrix();
bitMatrix->Init(dimension);
bitMatrix->SetRegion(0, 0, 9, 9, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
bitMatrix->SetRegion(dimension - 8, 0, 8, 9, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
bitMatrix->SetRegion(0, dimension - 8, 9, 8, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
int32_t max = m_alignmentPatternCenters.GetSize();
for (int32_t x = 0; x < max; x++) {
int32_t i = m_alignmentPatternCenters[x] - 2;
@@ -421,18 +428,23 @@ CBC_CommonBitMatrix* CBC_QRCoderVersion::BuildFunctionPattern(int32_t& e) {
continue;
}
bitMatrix->SetRegion(m_alignmentPatternCenters[y] - 2, i, 5, 5, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
}
}
bitMatrix->SetRegion(6, 9, 1, dimension - 17, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
bitMatrix->SetRegion(9, 6, dimension - 17, 1, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
if (m_versionNumber > 6) {
bitMatrix->SetRegion(dimension - 11, 0, 3, 6, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
bitMatrix->SetRegion(0, dimension - 11, 6, 3, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
}
return bitMatrix;
}
@@ -771,7 +783,8 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::GetVersionForNumber(
}
if (versionNumber < 1 || versionNumber > 40) {
e = BCExceptionIllegalArgument;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ if (e != BCExceptionNO)
+ return nullptr;
}
return (*VERSION)[versionNumber - 1];
}