From 1eae16d3b17d6b396969ecf81f6546f5a1d72dfd Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Tue, 5 Sep 2017 12:07:02 -0400 Subject: Remove isDevice parameter from barcode Render(). isDevice is currently false in tests and fuzzers and true in real usage. This CL changes it all to true. Change-Id: Idea14795d7f0bb70031e04e5c58e248de72fd39e Reviewed-on: https://pdfium-review.googlesource.com/13130 Commit-Queue: Henrique Nakashima Reviewed-by: Tom Sepez --- fxbarcode/cbc_codabar.cpp | 6 ++--- fxbarcode/cbc_codabar.h | 2 +- fxbarcode/cbc_code128.cpp | 6 ++--- fxbarcode/cbc_code128.h | 2 +- fxbarcode/cbc_code39.cpp | 6 ++--- fxbarcode/cbc_code39.h | 2 +- fxbarcode/cbc_codebase.h | 2 +- fxbarcode/cbc_datamatrix.cpp | 2 +- fxbarcode/cbc_datamatrix.h | 2 +- fxbarcode/cbc_ean13.cpp | 6 ++--- fxbarcode/cbc_ean13.h | 2 +- fxbarcode/cbc_ean8.cpp | 6 ++--- fxbarcode/cbc_ean8.h | 2 +- fxbarcode/cbc_pdf417i.cpp | 2 +- fxbarcode/cbc_pdf417i.h | 2 +- fxbarcode/cbc_qrcode.cpp | 2 +- fxbarcode/cbc_qrcode.h | 2 +- fxbarcode/cbc_upca.cpp | 6 ++--- fxbarcode/cbc_upca.h | 2 +- fxbarcode/oned/BC_OneDimWriter.cpp | 20 +++------------ fxbarcode/oned/BC_OneDimWriter.h | 3 +-- fxbarcode/oned/BC_OnedCodaBarWriter.cpp | 5 ++-- fxbarcode/oned/BC_OnedCodaBarWriter.h | 3 +-- fxbarcode/oned/BC_OnedCode39Writer.cpp | 5 ++-- fxbarcode/oned/BC_OnedCode39Writer.h | 3 +-- testing/libfuzzer/pdf_cfx_barcode_fuzzer.cc | 2 +- xfa/fwl/cfwl_barcode.cpp | 2 +- xfa/fwl/cfx_barcode.cpp | 4 +-- xfa/fwl/cfx_barcode.h | 2 +- xfa/fwl/cfx_barcode_unittest.cpp | 38 ++++++++++++++--------------- 30 files changed, 65 insertions(+), 84 deletions(-) diff --git a/fxbarcode/cbc_codabar.cpp b/fxbarcode/cbc_codabar.cpp index d1501212cc..a8729b64c6 100644 --- a/fxbarcode/cbc_codabar.cpp +++ b/fxbarcode/cbc_codabar.cpp @@ -47,7 +47,7 @@ bool CBC_Codabar::SetWideNarrowRatio(int8_t ratio) { return GetOnedCodaBarWriter()->SetWideNarrowRatio(ratio); } -bool CBC_Codabar::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_Codabar::Encode(const CFX_WideStringC& contents) { if (contents.IsEmpty()) return false; @@ -64,8 +64,8 @@ bool CBC_Codabar::Encode(const CFX_WideStringC& contents, bool isDevice) { if (!data) return false; - return pWriter->RenderResult(filtercontents.AsStringC(), data.get(), outWidth, - isDevice); + return pWriter->RenderResult(filtercontents.AsStringC(), data.get(), + outWidth); } bool CBC_Codabar::RenderDevice(CFX_RenderDevice* device, diff --git a/fxbarcode/cbc_codabar.h b/fxbarcode/cbc_codabar.h index 3877819f8d..092b840f49 100644 --- a/fxbarcode/cbc_codabar.h +++ b/fxbarcode/cbc_codabar.h @@ -20,7 +20,7 @@ class CBC_Codabar : public CBC_OneCode { ~CBC_Codabar() override; // CBC_OneCode: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_code128.cpp b/fxbarcode/cbc_code128.cpp index 93a4ae88f4..d802b28a17 100644 --- a/fxbarcode/cbc_code128.cpp +++ b/fxbarcode/cbc_code128.cpp @@ -35,7 +35,7 @@ bool CBC_Code128::SetTextLocation(BC_TEXT_LOC location) { return GetOnedCode128Writer()->SetTextLocation(location); } -bool CBC_Code128::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_Code128::Encode(const CFX_WideStringC& contents) { if (contents.IsEmpty()) return false; @@ -54,8 +54,8 @@ bool CBC_Code128::Encode(const CFX_WideStringC& contents, bool isDevice) { pWriter->Encode(byteString, format, outWidth, outHeight)); if (!data) return false; - return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), outWidth, - isDevice); + return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), + outWidth); } bool CBC_Code128::RenderDevice(CFX_RenderDevice* device, diff --git a/fxbarcode/cbc_code128.h b/fxbarcode/cbc_code128.h index 603587f908..571ee7e5a0 100644 --- a/fxbarcode/cbc_code128.h +++ b/fxbarcode/cbc_code128.h @@ -20,7 +20,7 @@ class CBC_Code128 : public CBC_OneCode { ~CBC_Code128() override; // CBC_OneCode: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_code39.cpp b/fxbarcode/cbc_code39.cpp index 97debaa88f..a46af14b9a 100644 --- a/fxbarcode/cbc_code39.cpp +++ b/fxbarcode/cbc_code39.cpp @@ -31,7 +31,7 @@ CBC_Code39::CBC_Code39() CBC_Code39::~CBC_Code39() {} -bool CBC_Code39::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_Code39::Encode(const CFX_WideStringC& contents) { if (contents.IsEmpty()) return false; @@ -47,8 +47,8 @@ bool CBC_Code39::Encode(const CFX_WideStringC& contents, bool isDevice) { pWriter->Encode(byteString, format, outWidth, outHeight)); if (!data) return false; - return pWriter->RenderResult(renderContents.AsStringC(), data.get(), outWidth, - isDevice); + return pWriter->RenderResult(renderContents.AsStringC(), data.get(), + outWidth); } bool CBC_Code39::RenderDevice(CFX_RenderDevice* device, diff --git a/fxbarcode/cbc_code39.h b/fxbarcode/cbc_code39.h index 4dea641a4f..66974c0947 100644 --- a/fxbarcode/cbc_code39.h +++ b/fxbarcode/cbc_code39.h @@ -21,7 +21,7 @@ class CBC_Code39 : public CBC_OneCode { ~CBC_Code39() override; // CBC_OneCode: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_codebase.h b/fxbarcode/cbc_codebase.h index ac9aaabcbb..f1a7b03ae2 100644 --- a/fxbarcode/cbc_codebase.h +++ b/fxbarcode/cbc_codebase.h @@ -26,7 +26,7 @@ class CBC_CodeBase { virtual ~CBC_CodeBase(); virtual BC_TYPE GetType() = 0; - virtual bool Encode(const CFX_WideStringC& contents, bool isDevice) = 0; + virtual bool Encode(const CFX_WideStringC& contents) = 0; virtual bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) = 0; diff --git a/fxbarcode/cbc_datamatrix.cpp b/fxbarcode/cbc_datamatrix.cpp index f1c98ced02..91ed10e8e0 100644 --- a/fxbarcode/cbc_datamatrix.cpp +++ b/fxbarcode/cbc_datamatrix.cpp @@ -31,7 +31,7 @@ CBC_DataMatrix::CBC_DataMatrix() CBC_DataMatrix::~CBC_DataMatrix() {} -bool CBC_DataMatrix::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_DataMatrix::Encode(const CFX_WideStringC& contents) { int32_t outWidth = 0; int32_t outHeight = 0; auto* pWriter = GetDataMatrixWriter(); diff --git a/fxbarcode/cbc_datamatrix.h b/fxbarcode/cbc_datamatrix.h index 73294f1a9e..9f6c914fb4 100644 --- a/fxbarcode/cbc_datamatrix.h +++ b/fxbarcode/cbc_datamatrix.h @@ -20,7 +20,7 @@ class CBC_DataMatrix : public CBC_CodeBase { ~CBC_DataMatrix() override; // CBC_OneCode: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_ean13.cpp b/fxbarcode/cbc_ean13.cpp index ac08a9d53e..3606527142 100644 --- a/fxbarcode/cbc_ean13.cpp +++ b/fxbarcode/cbc_ean13.cpp @@ -50,7 +50,7 @@ CFX_WideString CBC_EAN13::Preprocess(const CFX_WideStringC& contents) { return encodeContents; } -bool CBC_EAN13::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_EAN13::Encode(const CFX_WideStringC& contents) { if (contents.IsEmpty()) return false; @@ -65,8 +65,8 @@ bool CBC_EAN13::Encode(const CFX_WideStringC& contents, bool isDevice) { pWriter->Encode(byteString, format, outWidth, outHeight)); if (!data) return false; - return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), outWidth, - isDevice); + return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), + outWidth); } bool CBC_EAN13::RenderDevice(CFX_RenderDevice* device, diff --git a/fxbarcode/cbc_ean13.h b/fxbarcode/cbc_ean13.h index 11d40bb386..8a62151685 100644 --- a/fxbarcode/cbc_ean13.h +++ b/fxbarcode/cbc_ean13.h @@ -21,7 +21,7 @@ class CBC_EAN13 : public CBC_OneCode { ~CBC_EAN13() override; // CBC_OneCode: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_ean8.cpp b/fxbarcode/cbc_ean8.cpp index ce2cf2ba79..7fbe07fd7f 100644 --- a/fxbarcode/cbc_ean8.cpp +++ b/fxbarcode/cbc_ean8.cpp @@ -48,7 +48,7 @@ CFX_WideString CBC_EAN8::Preprocess(const CFX_WideStringC& contents) { return encodeContents; } -bool CBC_EAN8::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_EAN8::Encode(const CFX_WideStringC& contents) { if (contents.IsEmpty()) return false; @@ -63,8 +63,8 @@ bool CBC_EAN8::Encode(const CFX_WideStringC& contents, bool isDevice) { pWriter->Encode(byteString, format, outWidth, outHeight)); if (!data) return false; - return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), outWidth, - isDevice); + return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), + outWidth); } bool CBC_EAN8::RenderDevice(CFX_RenderDevice* device, diff --git a/fxbarcode/cbc_ean8.h b/fxbarcode/cbc_ean8.h index d0f6ff8965..df0ca6246a 100644 --- a/fxbarcode/cbc_ean8.h +++ b/fxbarcode/cbc_ean8.h @@ -20,7 +20,7 @@ class CBC_EAN8 : public CBC_OneCode { ~CBC_EAN8() override; // CBC_OneCode: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_pdf417i.cpp b/fxbarcode/cbc_pdf417i.cpp index 23ad3ef74d..545a7d8cbf 100644 --- a/fxbarcode/cbc_pdf417i.cpp +++ b/fxbarcode/cbc_pdf417i.cpp @@ -40,7 +40,7 @@ void CBC_PDF417I::SetTruncated(bool truncated) { GetPDF417Writer()->SetTruncated(truncated); } -bool CBC_PDF417I::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_PDF417I::Encode(const CFX_WideStringC& contents) { int32_t outWidth = 0; int32_t outHeight = 0; auto* pWriter = GetPDF417Writer(); diff --git a/fxbarcode/cbc_pdf417i.h b/fxbarcode/cbc_pdf417i.h index 2d1c8d3284..73f99d3579 100644 --- a/fxbarcode/cbc_pdf417i.h +++ b/fxbarcode/cbc_pdf417i.h @@ -20,7 +20,7 @@ class CBC_PDF417I : public CBC_CodeBase { ~CBC_PDF417I() override; // CBC_CodeBase: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_qrcode.cpp b/fxbarcode/cbc_qrcode.cpp index 6565623db2..297ce77212 100644 --- a/fxbarcode/cbc_qrcode.cpp +++ b/fxbarcode/cbc_qrcode.cpp @@ -37,7 +37,7 @@ bool CBC_QRCode::SetErrorCorrectionLevel(int32_t level) { return GetQRCodeWriter()->SetErrorCorrectionLevel(level); } -bool CBC_QRCode::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_QRCode::Encode(const CFX_WideStringC& contents) { int32_t outWidth = 0; int32_t outHeight = 0; CBC_QRCodeWriter* pWriter = GetQRCodeWriter(); diff --git a/fxbarcode/cbc_qrcode.h b/fxbarcode/cbc_qrcode.h index 684993364e..638726769c 100644 --- a/fxbarcode/cbc_qrcode.h +++ b/fxbarcode/cbc_qrcode.h @@ -20,7 +20,7 @@ class CBC_QRCode : public CBC_CodeBase { ~CBC_QRCode() override; // CBC_CodeBase: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/cbc_upca.cpp b/fxbarcode/cbc_upca.cpp index 85b5d549ab..f4c273f764 100644 --- a/fxbarcode/cbc_upca.cpp +++ b/fxbarcode/cbc_upca.cpp @@ -49,7 +49,7 @@ CFX_WideString CBC_UPCA::Preprocess(const CFX_WideStringC& contents) { return encodeContents; } -bool CBC_UPCA::Encode(const CFX_WideStringC& contents, bool isDevice) { +bool CBC_UPCA::Encode(const CFX_WideStringC& contents) { if (contents.IsEmpty()) return false; @@ -66,8 +66,8 @@ bool CBC_UPCA::Encode(const CFX_WideStringC& contents, bool isDevice) { pWriter->Encode(byteString, format, outWidth, outHeight)); if (!data) return false; - return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), outWidth, - isDevice); + return pWriter->RenderResult(encodeContents.AsStringC(), data.get(), + outWidth); } bool CBC_UPCA::RenderDevice(CFX_RenderDevice* device, diff --git a/fxbarcode/cbc_upca.h b/fxbarcode/cbc_upca.h index ef77297be2..5955230c46 100644 --- a/fxbarcode/cbc_upca.h +++ b/fxbarcode/cbc_upca.h @@ -20,7 +20,7 @@ class CBC_UPCA : public CBC_OneCode { ~CBC_UPCA() override; // CBC_CodeBase: - bool Encode(const CFX_WideStringC& contents, bool isDevice) override; + bool Encode(const CFX_WideStringC& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp index 2927dda3af..1f96c4575b 100644 --- a/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/fxbarcode/oned/BC_OneDimWriter.cpp @@ -285,8 +285,7 @@ bool CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, bool CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, uint8_t* code, - int32_t codeLength, - bool isDevice) { + int32_t codeLength) { if (codeLength < 1) return false; @@ -299,28 +298,15 @@ bool CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, m_outputHScale = m_Width > 0 ? static_cast(m_Width) / static_cast(codeLength) : 1.0; - if (!isDevice) { - m_outputHScale = - std::max(m_outputHScale, static_cast(m_ModuleWidth)); - } float dataLengthScale = 1.0; if (m_iDataLenth > 0 && contents.GetLength() != 0) dataLengthScale = float(contents.GetLength()) / float(m_iDataLenth); if (m_iDataLenth > 0 && contents.GetLength() == 0) dataLengthScale = float(1) / float(m_iDataLenth); m_multiple = 1; - if (!isDevice) { - m_multiple = (int32_t)ceil(m_outputHScale * dataLengthScale); - } - int32_t outputHeight = 1; - if (!isDevice) - outputHeight = m_Height ? m_Height : std::max(20, m_ModuleHeight); - int32_t outputWidth = codeLength; - if (!isDevice) - outputWidth = (int32_t)(codeLength * m_multiple / dataLengthScale); + const int32_t outputHeight = 1; + const int32_t outputWidth = codeLength; m_barWidth = m_Width; - if (!isDevice) - m_barWidth = codeLength * m_multiple; m_output.clear(); for (int32_t inputX = 0, outputX = leftPadding * m_multiple; diff --git a/fxbarcode/oned/BC_OneDimWriter.h b/fxbarcode/oned/BC_OneDimWriter.h index c220f382ee..2d604b5b51 100644 --- a/fxbarcode/oned/BC_OneDimWriter.h +++ b/fxbarcode/oned/BC_OneDimWriter.h @@ -26,8 +26,7 @@ class CBC_OneDimWriter : public CBC_Writer { virtual bool RenderResult(const CFX_WideStringC& contents, uint8_t* code, - int32_t codeLength, - bool isDevice); + int32_t codeLength); virtual bool CheckContentValidity(const CFX_WideStringC& contents) = 0; virtual CFX_WideString FilterContents(const CFX_WideStringC& contents) = 0; virtual CFX_WideString RenderTextContents(const CFX_WideStringC& contents); diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp index 5a56acb37c..03a733a8c2 100644 --- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp @@ -197,8 +197,7 @@ CFX_WideString CBC_OnedCodaBarWriter::encodedContents( bool CBC_OnedCodaBarWriter::RenderResult(const CFX_WideStringC& contents, uint8_t* code, - int32_t codeLength, - bool isDevice) { + int32_t codeLength) { return CBC_OneDimWriter::RenderResult(encodedContents(contents).AsStringC(), - code, codeLength, isDevice); + code, codeLength); } diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.h b/fxbarcode/oned/BC_OnedCodaBarWriter.h index 94933612f5..6a5f315073 100644 --- a/fxbarcode/oned/BC_OnedCodaBarWriter.h +++ b/fxbarcode/oned/BC_OnedCodaBarWriter.h @@ -27,8 +27,7 @@ class CBC_OnedCodaBarWriter : public CBC_OneDimWriter { int32_t hints) override; bool RenderResult(const CFX_WideStringC& contents, uint8_t* code, - int32_t codeLength, - bool isDevice) override; + int32_t codeLength) override; bool CheckContentValidity(const CFX_WideStringC& contents) override; CFX_WideString FilterContents(const CFX_WideStringC& contents) override; void SetDataLength(int32_t length) override; diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp index ba8769ed95..72d7dc4df8 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -245,11 +245,10 @@ bool CBC_OnedCode39Writer::encodedContents(const CFX_WideStringC& contents, bool CBC_OnedCode39Writer::RenderResult(const CFX_WideStringC& contents, uint8_t* code, - int32_t codeLength, - bool isDevice) { + int32_t codeLength) { CFX_WideString encodedCon; if (!encodedContents(contents, &encodedCon)) return false; return CBC_OneDimWriter::RenderResult(encodedCon.AsStringC(), code, - codeLength, isDevice); + codeLength); } diff --git a/fxbarcode/oned/BC_OnedCode39Writer.h b/fxbarcode/oned/BC_OnedCode39Writer.h index 4892a1f8d5..fe57d3ca9a 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.h +++ b/fxbarcode/oned/BC_OnedCode39Writer.h @@ -25,8 +25,7 @@ class CBC_OnedCode39Writer : public CBC_OneDimWriter { int32_t& outLength) override; bool RenderResult(const CFX_WideStringC& contents, uint8_t* code, - int32_t codeLength, - bool isDevice) override; + int32_t codeLength) override; bool CheckContentValidity(const CFX_WideStringC& contents) override; CFX_WideString FilterContents(const CFX_WideStringC& contents) override; CFX_WideString RenderTextContents(const CFX_WideStringC& contents) override; diff --git a/testing/libfuzzer/pdf_cfx_barcode_fuzzer.cc b/testing/libfuzzer/pdf_cfx_barcode_fuzzer.cc index 24cf0ab516..e791102103 100644 --- a/testing/libfuzzer/pdf_cfx_barcode_fuzzer.cc +++ b/testing/libfuzzer/pdf_cfx_barcode_fuzzer.cc @@ -30,7 +30,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { CFX_WideStringC content(reinterpret_cast(data), size / sizeof(wchar_t)); - if (!barcode.Encode(content, false)) + if (!barcode.Encode(content)) return 0; // TODO(tsepez): Output to device. diff --git a/xfa/fwl/cfwl_barcode.cpp b/xfa/fwl/cfwl_barcode.cpp index 8db40d2b19..5e67c71435 100644 --- a/xfa/fwl/cfwl_barcode.cpp +++ b/xfa/fwl/cfwl_barcode.cpp @@ -203,7 +203,7 @@ void CFWL_Barcode::GenerateBarcodeImageCache() { if (m_dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED) m_pBarcodeEngine->SetTruncated(m_bTruncated); - m_dwStatus = m_pBarcodeEngine->Encode(GetText().AsStringC(), true) + m_dwStatus = m_pBarcodeEngine->Encode(GetText().AsStringC()) ? XFA_BCS_EncodeSuccess : 0; } diff --git a/xfa/fwl/cfx_barcode.cpp b/xfa/fwl/cfx_barcode.cpp index eeeac6164e..8b51f2d741 100644 --- a/xfa/fwl/cfx_barcode.cpp +++ b/xfa/fwl/cfx_barcode.cpp @@ -294,8 +294,8 @@ bool CFX_Barcode::SetTruncated(bool truncated) { : false; } -bool CFX_Barcode::Encode(const CFX_WideStringC& contents, bool isDevice) { - return m_pBCEngine && m_pBCEngine->Encode(contents, isDevice); +bool CFX_Barcode::Encode(const CFX_WideStringC& contents) { + return m_pBCEngine && m_pBCEngine->Encode(contents); } bool CFX_Barcode::RenderDevice(CFX_RenderDevice* device, diff --git a/xfa/fwl/cfx_barcode.h b/xfa/fwl/cfx_barcode.h index 83cb23437f..32a6db57cc 100644 --- a/xfa/fwl/cfx_barcode.h +++ b/xfa/fwl/cfx_barcode.h @@ -27,7 +27,7 @@ class CFX_Barcode { bool Create(BC_TYPE type); BC_TYPE GetType(); - bool Encode(const CFX_WideStringC& contents, bool isDevice); + bool Encode(const CFX_WideStringC& contents); bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix); diff --git a/xfa/fwl/cfx_barcode_unittest.cpp b/xfa/fwl/cfx_barcode_unittest.cpp index 3283dd132b..b66d90495e 100644 --- a/xfa/fwl/cfx_barcode_unittest.cpp +++ b/xfa/fwl/cfx_barcode_unittest.cpp @@ -69,77 +69,77 @@ class BarcodeTest : public testing::Test { TEST_F(BarcodeTest, Code39) { EXPECT_TRUE(Create(BC_CODE39)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("e0d784db2d4fb5dab7836722a1ad7001", BitmapChecksum()); + EXPECT_EQ("cd4cd3f36da38ff58d9f621827018903", BitmapChecksum()); } TEST_F(BarcodeTest, CodaBar) { EXPECT_TRUE(Create(BC_CODABAR)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("26b50593e698a0a9714fd2a60131ef70", BitmapChecksum()); + EXPECT_EQ("481189dc4f86eddb8c42343c9b8ef1dd", BitmapChecksum()); } TEST_F(BarcodeTest, Code128) { EXPECT_TRUE(Create(BC_CODE128)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("0beb98f447c632e3085a6b1eae49379f", BitmapChecksum()); + EXPECT_EQ("11b21c178a9fd866d8be196c2103b263", BitmapChecksum()); } TEST_F(BarcodeTest, Code128_B) { EXPECT_TRUE(Create(BC_CODE128_B)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("0beb98f447c632e3085a6b1eae49379f", BitmapChecksum()); + EXPECT_EQ("11b21c178a9fd866d8be196c2103b263", BitmapChecksum()); } TEST_F(BarcodeTest, Code128_C) { EXPECT_TRUE(Create(BC_CODE128_C)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("5d75bfdd601494fc4f6451cce7452922", BitmapChecksum()); + EXPECT_EQ("6284ec8503d5a948c9518108da33cdd3", BitmapChecksum()); } TEST_F(BarcodeTest, Ean8) { EXPECT_TRUE(Create(BC_EAN8)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("0a9a7bc34e6d0c82c2950fa592a0039e", BitmapChecksum()); + EXPECT_EQ("22d85bcb02d48f48813f02a1cc9cfe8c", BitmapChecksum()); } TEST_F(BarcodeTest, UPCA) { EXPECT_TRUE(Create(BC_UPCA)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("d3f993c0fc0131ce11b863a73e27f8e6", BitmapChecksum()); + EXPECT_EQ("cce41fc30852744c44b3353059b568b4", BitmapChecksum()); } TEST_F(BarcodeTest, Ean13) { EXPECT_TRUE(Create(BC_EAN13)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); - EXPECT_EQ("461acb9e4f1a284a8e699f9f121a09d3", BitmapChecksum()); + EXPECT_EQ("187091ec1fd1830fc4d41d40a923d4fb", BitmapChecksum()); } TEST_F(BarcodeTest, Pdf417) { EXPECT_TRUE(Create(BC_PDF417)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); EXPECT_EQ("2bdb9b39f20c5763da6a0d7c7b1f6933", BitmapChecksum()); } TEST_F(BarcodeTest, DataMatrix) { EXPECT_TRUE(Create(BC_DATAMATRIX)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); EXPECT_EQ("5e5cd9a680b86fcd4ffd53ed36e3c980", BitmapChecksum()); } TEST_F(BarcodeTest, QrCode) { EXPECT_TRUE(Create(BC_QR_CODE)); - EXPECT_TRUE(barcode()->Encode(L"clams", false)); + EXPECT_TRUE(barcode()->Encode(L"clams")); RenderDevice(); EXPECT_EQ("4751c6e0f67749fabe24f787128decee", BitmapChecksum()); } -- cgit v1.2.3