diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-01-31 13:02:10 -0800 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-31 22:52:16 +0000 |
commit | c8017b2581b7ade6b05ba086eb7221465414173f (patch) | |
tree | f606dadefe9d6e27e7782bd9c33e2498810a7b2f /xfa/fxbarcode | |
parent | 00d4064e5414fc0845e354b50c7f1a8323449268 (diff) | |
download | pdfium-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')
41 files changed, 563 insertions, 286 deletions
diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp index 84678a81da..b9aae361d6 100644 --- a/xfa/fxbarcode/BC_TwoDimWriter.cpp +++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp @@ -145,7 +145,8 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code, inputX++, outputX += multiX) { if (code[inputX + inputY * inputWidth] == 1) { m_output->SetRegion(outputX, outputY, multiX, multiY, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } } } diff --git a/xfa/fxbarcode/cbc_codabar.cpp b/xfa/fxbarcode/cbc_codabar.cpp index e8e8cdc997..6f6ab4a96c 100644 --- a/xfa/fxbarcode/cbc_codabar.cpp +++ b/xfa/fxbarcode/cbc_codabar.cpp @@ -70,11 +70,13 @@ bool CBC_Codabar::Encode(const CFX_WideStringC& contents, m_renderContents = filtercontents; uint8_t* data = static_cast<CBC_OnedCodaBarWriter*>(m_pBCWriter.get()) ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderResult(filtercontents.AsStringC(), data, outWidth, isDevice, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -86,7 +88,8 @@ bool CBC_Codabar::RenderDevice(CFX_RenderDevice* device, ->encodedContents(m_renderContents.AsStringC()); static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderDeviceResult(device, matrix, renderCon.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -96,7 +99,8 @@ bool CBC_Codabar::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { ->encodedContents(m_renderContents.AsStringC()); static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_code128.cpp b/xfa/fxbarcode/cbc_code128.cpp index 99c3c21e0f..35bd136fd0 100644 --- a/xfa/fxbarcode/cbc_code128.cpp +++ b/xfa/fxbarcode/cbc_code128.cpp @@ -58,11 +58,13 @@ bool CBC_Code128::Encode(const CFX_WideStringC& contents, CFX_ByteString byteString = encodeContents.UTF8Encode(); uint8_t* data = static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get()) ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -71,14 +73,16 @@ bool CBC_Code128::RenderDevice(CFX_RenderDevice* device, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } bool CBC_Code128::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_code39.cpp b/xfa/fxbarcode/cbc_code39.cpp index e90abb9d72..af45ad4063 100644 --- a/xfa/fxbarcode/cbc_code39.cpp +++ b/xfa/fxbarcode/cbc_code39.cpp @@ -47,11 +47,13 @@ bool CBC_Code39::Encode(const CFX_WideStringC& contents, CFX_ByteString byteString = filtercontents.UTF8Encode(); uint8_t* data = static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get()) ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderResult(renderContents.AsStringC(), data, outWidth, isDevice, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -63,7 +65,8 @@ bool CBC_Code39::RenderDevice(CFX_RenderDevice* device, ->encodedContents(m_renderContents.AsStringC(), e); static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderDeviceResult(device, matrix, renderCon.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -73,7 +76,8 @@ bool CBC_Code39::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { ->encodedContents(m_renderContents.AsStringC(), e); static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_datamatrix.cpp b/xfa/fxbarcode/cbc_datamatrix.cpp index 86ca75d04a..6122368e84 100644 --- a/xfa/fxbarcode/cbc_datamatrix.cpp +++ b/xfa/fxbarcode/cbc_datamatrix.cpp @@ -35,11 +35,13 @@ bool CBC_DataMatrix::Encode(const CFX_WideStringC& contents, uint8_t* data = static_cast<CBC_DataMatrixWriter*>(m_pBCWriter.get()) ->Encode(CFX_WideString(contents), outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) ->RenderResult(data, outWidth, outHeight, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -54,7 +56,8 @@ bool CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, bool CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_ean13.cpp b/xfa/fxbarcode/cbc_ean13.cpp index d696897165..450fba04c9 100644 --- a/xfa/fxbarcode/cbc_ean13.cpp +++ b/xfa/fxbarcode/cbc_ean13.cpp @@ -63,11 +63,13 @@ bool CBC_EAN13::Encode(const CFX_WideStringC& contents, m_renderContents = encodeContents; uint8_t* data = static_cast<CBC_OnedEAN13Writer*>(m_pBCWriter.get()) ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -76,14 +78,16 @@ bool CBC_EAN13::RenderDevice(CFX_RenderDevice* device, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } bool CBC_EAN13::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_ean8.cpp b/xfa/fxbarcode/cbc_ean8.cpp index 2c1ce24b55..64ba617331 100644 --- a/xfa/fxbarcode/cbc_ean8.cpp +++ b/xfa/fxbarcode/cbc_ean8.cpp @@ -62,11 +62,13 @@ bool CBC_EAN8::Encode(const CFX_WideStringC& contents, m_renderContents = encodeContents; uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -75,14 +77,16 @@ bool CBC_EAN8::RenderDevice(CFX_RenderDevice* device, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } bool CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_pdf417i.cpp b/xfa/fxbarcode/cbc_pdf417i.cpp index 1e147d9448..1c5547d445 100644 --- a/xfa/fxbarcode/cbc_pdf417i.cpp +++ b/xfa/fxbarcode/cbc_pdf417i.cpp @@ -45,11 +45,13 @@ bool CBC_PDF417I::Encode(const CFX_WideStringC& contents, uint8_t* data = static_cast<CBC_PDF417Writer*>(m_pBCWriter.get()) ->Encode(CFX_WideString(contents), outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) ->RenderResult(data, outWidth, outHeight, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -64,7 +66,8 @@ bool CBC_PDF417I::RenderDevice(CFX_RenderDevice* device, bool CBC_PDF417I::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_qrcode.cpp b/xfa/fxbarcode/cbc_qrcode.cpp index 507b8f9ffe..26b74ca400 100644 --- a/xfa/fxbarcode/cbc_qrcode.cpp +++ b/xfa/fxbarcode/cbc_qrcode.cpp @@ -52,10 +52,12 @@ bool CBC_QRCode::Encode(const CFX_WideStringC& contents, uint8_t* data = pWriter->Encode(CFX_WideString(contents), pWriter->GetErrorCorrectionLevel(), outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; pWriter->RenderResult(data, outWidth, outHeight, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -70,7 +72,8 @@ bool CBC_QRCode::RenderDevice(CFX_RenderDevice* device, bool CBC_QRCode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast<CBC_TwoDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/cbc_upca.cpp b/xfa/fxbarcode/cbc_upca.cpp index db8f722828..b282d5cd79 100644 --- a/xfa/fxbarcode/cbc_upca.cpp +++ b/xfa/fxbarcode/cbc_upca.cpp @@ -66,11 +66,13 @@ bool CBC_UPCA::Encode(const CFX_WideStringC& contents, pWriter->Init(); uint8_t* data = pWriter->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; pWriter->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } @@ -79,14 +81,16 @@ bool CBC_UPCA::RenderDevice(CFX_RenderDevice* device, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } bool CBC_UPCA::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, false); + if (e != BCExceptionNO) + return false; return true; } diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp index eac1a1065a..25b4c852c1 100644 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp @@ -44,10 +44,12 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree, temp.Add(m_field->Exp(d - 1)); CBC_ReedSolomonGF256Poly temp_poly; temp_poly.Init(m_field, &temp, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; CBC_ReedSolomonGF256Poly* nextGenerator = lastGenerator->Multiply(&temp_poly, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; m_cachedGenerators.Add(nextGenerator); lastGenerator = nextGenerator; } @@ -59,15 +61,18 @@ void CBC_ReedSolomonEncoder::Encode(CFX_ArrayTemplate<int32_t>* toEncode, int32_t& e) { if (ecBytes == 0) { e = BCExceptionNoCorrectionBytes; - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } int32_t dataBytes = toEncode->GetSize() - ecBytes; if (dataBytes <= 0) { e = BCExceptionNoDataBytesProvided; - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CFX_ArrayTemplate<int32_t> infoCoefficients; infoCoefficients.SetSize(dataBytes); for (int32_t x = 0; x < dataBytes; x++) { @@ -75,13 +80,16 @@ void CBC_ReedSolomonEncoder::Encode(CFX_ArrayTemplate<int32_t>* toEncode, } CBC_ReedSolomonGF256Poly info; info.Init(m_field, &infoCoefficients, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; std::unique_ptr<CBC_ReedSolomonGF256Poly> infoTemp( info.MultiplyByMonomial(ecBytes, 1, e)); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; std::unique_ptr<CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>> temp( infoTemp->Divide(generator, e)); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CBC_ReedSolomonGF256Poly* remainder = (*temp)[1]; CFX_ArrayTemplate<int32_t>* coefficients = remainder->GetCoefficients(); int32_t numZeroCoefficients = ecBytes - coefficients->GetSize(); diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp index 030048a632..0fe215bd09 100644 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp @@ -78,11 +78,13 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial( int32_t& e) { if (degree < 0) { e = BCExceptionDegreeIsNegative; - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; } if (coefficient == 0) { CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return temp; } CFX_ArrayTemplate<int32_t> coefficients; @@ -90,7 +92,8 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial( coefficients[0] = coefficient; CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); temp->Init(this, &coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return temp; } @@ -105,7 +108,8 @@ int32_t CBC_ReedSolomonGF256::Exp(int32_t a) { int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { if (a == 0) { e = BCExceptionAIsZero; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); + if (e != BCExceptionNO) + return 0; } return m_logTable[a]; } @@ -113,7 +117,8 @@ int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t& e) { if (a == 0) { e = BCExceptionAIsZero; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); + if (e != BCExceptionNO) + return 0; } return m_expTable[255 - m_logTable[a]]; } diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp index 748646bcad..e37d62e112 100644 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp @@ -42,7 +42,8 @@ void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, int32_t& e) { if (!coefficients || coefficients->GetSize() == 0) { e = BCExceptionCoefficientsSizeIsNull; - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } m_field = field; int32_t coefficientsLength = coefficients->GetSize(); @@ -98,7 +99,8 @@ int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) { CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Clone(int32_t& e) { CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); temp->Init(m_field, &m_coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return temp; } CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract( @@ -132,7 +134,8 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract( } CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); temp->Init(m_field, &sumDiff, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return temp; } CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply( @@ -159,7 +162,8 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply( } CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); temp->Init(m_field, &product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return temp; } CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, @@ -177,7 +181,8 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, } CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); temp->Init(m_field, &product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return temp; } CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial( @@ -199,7 +204,8 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial( } CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); temp->Init(m_field, &product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return temp; } @@ -212,13 +218,16 @@ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide( } std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient( m_field->GetZero()->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); int32_t inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeadingTerm, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) { int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); int32_t scale = @@ -226,14 +235,18 @@ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide( inverseDenominatorLeadingTeam); std::unique_ptr<CBC_ReedSolomonGF256Poly> term( other->MultiplyByMonomial(degreeDifference, scale, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient( m_field->BuildMonomial(degreeDifference, scale, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; remainder.reset(remainder->AddOrSubtract(term.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; } CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* tempPtrA = new CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>(); diff --git a/xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp b/xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp index 8858f60012..50f02ca52d 100644 --- a/xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp +++ b/xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp @@ -163,7 +163,8 @@ int32_t CBC_C40Encoder::encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e) { sb += (FX_WCHAR)0x001e; int32_t len = 2; len += encodeChar((c - 128), sb, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); + if (e != BCExceptionNO) + return 0; return len; } else { e = BCExceptionIllegalArgument; @@ -180,7 +181,8 @@ int32_t CBC_C40Encoder::backtrackOneCharacter(CBC_EncoderContext& context, context.m_pos--; FX_WCHAR c = context.getCurrentChar(); lastCharSize = encodeChar(c, removed, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); + if (e != BCExceptionNO) + return -1; context.resetSymbolInfo(); return lastCharSize; } diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp index 1fe8018631..30ec1eef74 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp @@ -54,7 +54,8 @@ uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents, int32_t& e) { if (outWidth < 0 || outHeight < 0) { e = BCExceptionHeightAndWidthMustBeAtLeast1; - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; } CBC_SymbolShapeHint::SymbolShapeHint shape = CBC_SymbolShapeHint::FORCE_SQUARE; @@ -63,20 +64,25 @@ uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents, CFX_WideString ecLevel; CFX_WideString encoded = CBC_HighLevelEncoder::encodeHighLevel( contents, ecLevel, shape, minSize, maxSize, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; CBC_SymbolInfo* symbolInfo = CBC_SymbolInfo::lookup( encoded.GetLength(), shape, minSize, maxSize, true, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; CFX_WideString codewords = CBC_ErrorCorrection::encodeECC200(encoded, symbolInfo, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; CBC_DefaultPlacement* placement = new CBC_DefaultPlacement(codewords, symbolInfo->getSymbolDataWidth(e), symbolInfo->getSymbolDataHeight(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; placement->place(); CBC_CommonByteMatrix* bytematrix = encodeLowLevel(placement, symbolInfo, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; outWidth = bytematrix->GetWidth(); outHeight = bytematrix->GetHeight(); uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); @@ -90,12 +96,15 @@ CBC_CommonByteMatrix* CBC_DataMatrixWriter::encodeLowLevel( CBC_SymbolInfo* symbolInfo, int32_t& e) { int32_t symbolWidth = symbolInfo->getSymbolDataWidth(e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; int32_t symbolHeight = symbolInfo->getSymbolDataHeight(e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; CBC_CommonByteMatrix* matrix = new CBC_CommonByteMatrix( symbolInfo->getSymbolWidth(e), symbolInfo->getSymbolHeight(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; matrix->Init(); int32_t matrixY = 0; for (int32_t y = 0; y < symbolHeight; y++) { diff --git a/xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp b/xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp index c395f3a914..b01b3120e3 100644 --- a/xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp +++ b/xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp @@ -100,7 +100,8 @@ void CBC_EncoderContext::updateSymbolInfo(int32_t len, int32_t& e) { if (!m_symbolInfo || len > m_symbolInfo->m_dataCapacity) { m_symbolInfo = CBC_SymbolInfo::lookup(len, m_shape, m_minSize, m_maxSize, true, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } } void CBC_EncoderContext::resetSymbolInfo() { diff --git a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp index 7782830940..17eec1ee4f 100644 --- a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp +++ b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp @@ -129,7 +129,8 @@ CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, if (blockCount == 1) { CFX_WideString ecc = createECCBlock(codewords, symbolInfo->m_errorCodewords, e); - BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString()); + if (e != BCExceptionNO) + return CFX_WideString(); sb += ecc; } else { CFX_ArrayTemplate<int32_t> dataSizes; @@ -152,7 +153,8 @@ CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, temp += (FX_WCHAR)codewords.GetAt(d); } CFX_WideString ecc = createECCBlock(temp, errorSizes[block], e); - BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString()); + if (e != BCExceptionNO) + return CFX_WideString(); int32_t pos = 0; for (int32_t l = block; l < errorSizes[block] * blockCount; l += blockCount) { diff --git a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp index 4b4b246038..abd3584761 100644 --- a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp +++ b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp @@ -79,7 +79,8 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg, CBC_Dimension* maxSize, int32_t& e) { CBC_EncoderContext context(msg, ecLevel, e); - BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString()); + if (e != BCExceptionNO) + return CFX_WideString(); context.setSymbolShape(shape); context.setSizeConstraints(minSize, maxSize); if ((msg.Mid(0, 6) == MACRO_05_HEADER) && diff --git a/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp index 77a809a511..ae74b8b2d4 100644 --- a/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp +++ b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp @@ -151,12 +151,14 @@ CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, } if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() || symbol->getSymbolHeight(e) < minSize->getHeight())) { - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; continue; } if (maxSize && (symbol->getSymbolWidth(e) > maxSize->getWidth() || symbol->getSymbolHeight(e) > maxSize->getHeight())) { - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; continue; } if (dataCodewords <= symbol->m_dataCapacity) { diff --git a/xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp index c8b37e9c85..e3eb4a8c4e 100644 --- a/xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp +++ b/xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp @@ -90,7 +90,8 @@ int32_t CBC_TextEncoder::encodeChar(FX_WCHAR c, sb += (FX_WCHAR)0x001e; int32_t len = 2; len += encodeChar((FX_WCHAR)(c - 128), sb, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); + if (e != BCExceptionNO) + return -1; return len; } CBC_HighLevelEncoder::illegalCharacter(c, e); diff --git a/xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp b/xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp index 9ebfc46700..d77af9318a 100644 --- a/xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp +++ b/xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp @@ -94,7 +94,8 @@ int32_t CBC_X12Encoder::encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e) { sb += (FX_WCHAR)(c - 65 + 14); } else { CBC_HighLevelEncoder::illegalCharacter(c, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); + if (e != BCExceptionNO) + return -1; } return 1; } diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index 24d257a630..49b1847d9c 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -103,7 +103,8 @@ uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, } else { ret = Encode(contents, outWidth, e); } - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } @@ -113,7 +114,8 @@ uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } @@ -319,7 +321,8 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, const CFX_WideStringC& contents, int32_t& e) { if (!m_output) - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); pOutBitmap->Clear(m_backgroundColor); @@ -342,7 +345,8 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { ShowChars(contents, pOutBitmap, nullptr, nullptr, m_barWidth, m_multiple, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } std::unique_ptr<CFX_DIBitmap> pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); @@ -355,7 +359,8 @@ void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, const CFX_WideStringC& contents, int32_t& e) { if (!m_output) - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CFX_GraphStateData stateData; CFX_PathData path; @@ -382,7 +387,8 @@ void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, } if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { ShowChars(contents, nullptr, device, matrix, m_barWidth, m_multiple, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } } @@ -392,7 +398,8 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, bool isDevice, int32_t& e) { if (codeLength < 1) { - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } if (m_ModuleHeight < 20.0) { m_ModuleHeight = 20; @@ -456,7 +463,8 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, break; } m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } outputX += m_multiple; } diff --git a/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp index fb0d7dcd72..399e5e7d40 100644 --- a/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp @@ -144,7 +144,8 @@ uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, @@ -159,7 +160,8 @@ uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp index ed2d2c1b24..f163b18663 100644 --- a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp @@ -154,7 +154,8 @@ uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, @@ -163,7 +164,8 @@ uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } bool CBC_OnedCode128Writer::IsDigits(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp index 9d5fdda968..a1ba5c8086 100644 --- a/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -130,7 +130,8 @@ uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, @@ -145,7 +146,8 @@ uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } void CBC_OnedCode39Writer::ToIntArray(int32_t a, int32_t* toReturn) { @@ -263,7 +265,8 @@ CFX_WideString CBC_OnedCode39Writer::encodedContents( CFX_ByteString str = checksumContent.UTF8Encode(); FX_CHAR checksum; checksum = CalcCheckSum(str, e); - BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString()); + if (e != BCExceptionNO) + return CFX_WideString(); str += checksum; encodedContents += checksum; } @@ -275,7 +278,8 @@ void CBC_OnedCode39Writer::RenderResult(const CFX_WideStringC& contents, bool isDevice, int32_t& e) { CFX_WideString encodedCon = encodedContents(contents, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CBC_OneDimWriter::RenderResult(encodedCon.AsStringC(), code, codeLength, isDevice, e); } diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 71d9ac6505..d4b21a8325 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -97,7 +97,8 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, @@ -111,7 +112,8 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp index ad3ee6160f..94019627ea 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -100,7 +100,8 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, @@ -115,7 +116,8 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 42e84b7117..1f9a22d5f7 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -87,7 +87,8 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } @@ -105,7 +106,8 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, m_iDataLenth = 13; uint8_t* ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/fxbarcode/pdf417/BC_PDF417.cpp index 16ed6fdf12..2f01564b11 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417.cpp @@ -405,14 +405,17 @@ void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, int32_t errorCorrectionCodeWords = CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( errorCorrectionLevel, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CFX_WideString highLevel = CBC_PDF417HighLevelEncoder::encodeHighLevel(msg, m_compaction, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; int32_t sourceCodeWords = highLevel.GetLength(); CFX_ArrayTemplate<int32_t>* dimension = determineDimensions(sourceCodeWords, errorCorrectionCodeWords, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; int32_t cols = dimension->GetAt(0); int32_t rows = dimension->GetAt(1); delete dimension; @@ -432,7 +435,8 @@ void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, CFX_WideString dataCodewords(sb); CFX_WideString ec = CBC_PDF417ErrorCorrection::generateErrorCorrection( dataCodewords, errorCorrectionLevel, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CFX_WideString fullCodewords = dataCodewords + ec; m_barcodeMatrix = pdfium::MakeUnique<CBC_BarcodeMatrix>(rows, cols); encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel, diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp index cbdfffac60..bdec403970 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp @@ -161,7 +161,8 @@ CFX_WideString CBC_PDF417ErrorCorrection::generateErrorCorrection( int32_t errorCorrectionLevel, int32_t& e) { int32_t k = getErrorCorrectionCodewordCount(errorCorrectionLevel, e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' '); + if (e != BCExceptionNO) + return L" "; FX_WCHAR* ech = FX_Alloc(FX_WCHAR, k); FXSYS_memset(ech, 0, k * sizeof(FX_WCHAR)); int32_t sld = dataCodewords.GetLength(); diff --git a/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp index 183566f9e3..08a40c51b3 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp @@ -108,7 +108,8 @@ CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel( p += t; } else { int32_t b = determineConsecutiveBinaryCount(msg, &byteArr, p, e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' '); + if (e != BCExceptionNO) + return L" "; if (b == 0) { b = 1; } diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp index 72d1a05dfd..2c75a14a80 100644 --- a/xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp +++ b/xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp @@ -59,7 +59,8 @@ uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents, encoder.setDimensions(30, 1, row, row); } encoder.generateBarcodeLogic(contents, m_iCorrectLevel, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; int32_t lineThickness = 2; int32_t aspectRatio = 4; CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix(); 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]; } diff --git a/xfa/fxbarcode/utils.h b/xfa/fxbarcode/utils.h index cb6eed7fe1..e5f8e9f59f 100644 --- a/xfa/fxbarcode/utils.h +++ b/xfa/fxbarcode/utils.h @@ -169,11 +169,5 @@ enum BCFORMAT { #define THREE_DIGIT_DATA_LENGTH_SIZE 23 #define THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH_SIZE 57 #define FOUR_DIGIT_DATA_LENGTH_SIZE 17 -#define BC_EXCEPTION_CHECK_ReturnVoid(e) \ - if (e != BCExceptionNO) \ - return; -#define BC_EXCEPTION_CHECK_ReturnValue(e, v) \ - if (e != BCExceptionNO) \ - return v; #endif // XFA_FXBARCODE_UTILS_H_ |