From e93dbd6c18b8b58e5d6b4813052fafbc323e9692 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 27 Oct 2016 13:10:24 -0700 Subject: Fix some FX_BOOL / int noise in XFA barcodes Review-Url: https://codereview.chromium.org/2447163007 --- xfa/fwl/core/cfwl_barcode.cpp | 30 ++++++++++++------------- xfa/fwl/core/cfwl_barcode.h | 40 ++++++++++++++++++---------------- xfa/fwl/core/cfx_barcode.cpp | 2 +- xfa/fwl/core/cfx_barcode.h | 2 +- xfa/fwl/core/ifwl_barcode.h | 28 ++++++++++++------------ xfa/fxbarcode/oned/BC_OneDimWriter.cpp | 2 +- xfa/fxbarcode/oned/BC_OneDimWriter.h | 2 +- xfa/fxfa/app/xfa_ffbarcode.cpp | 4 ++-- xfa/fxfa/parser/cxfa_widgetdata.cpp | 6 ++--- xfa/fxfa/parser/cxfa_widgetdata.h | 2 +- 10 files changed, 60 insertions(+), 58 deletions(-) diff --git a/xfa/fwl/core/cfwl_barcode.cpp b/xfa/fwl/core/cfwl_barcode.cpp index 67cbc301bd..5a3f9dd545 100644 --- a/xfa/fwl/core/cfwl_barcode.cpp +++ b/xfa/fwl/core/cfwl_barcode.cpp @@ -54,58 +54,58 @@ FWL_Error CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget, return FWL_Error::Succeeded; } -BC_CHAR_ENCODING CFWL_Barcode::CFWL_BarcodeDP::GetCharEncoding() { +BC_CHAR_ENCODING CFWL_Barcode::CFWL_BarcodeDP::GetCharEncoding() const { return m_eCharEncoding; } -int32_t CFWL_Barcode::CFWL_BarcodeDP::GetModuleHeight() { +int32_t CFWL_Barcode::CFWL_BarcodeDP::GetModuleHeight() const { return m_nModuleHeight; } -int32_t CFWL_Barcode::CFWL_BarcodeDP::GetModuleWidth() { +int32_t CFWL_Barcode::CFWL_BarcodeDP::GetModuleWidth() const { return m_nModuleWidth; } -int32_t CFWL_Barcode::CFWL_BarcodeDP::GetDataLength() { +int32_t CFWL_Barcode::CFWL_BarcodeDP::GetDataLength() const { return m_nDataLength; } -int32_t CFWL_Barcode::CFWL_BarcodeDP::GetCalChecksum() { - return m_nCalChecksum; +FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetCalChecksum() const { + return m_bCalChecksum; } -FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetPrintChecksum() { +FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetPrintChecksum() const { return m_bPrintChecksum; } -BC_TEXT_LOC CFWL_Barcode::CFWL_BarcodeDP::GetTextLocation() { +BC_TEXT_LOC CFWL_Barcode::CFWL_BarcodeDP::GetTextLocation() const { return m_eTextLocation; } -int32_t CFWL_Barcode::CFWL_BarcodeDP::GetWideNarrowRatio() { +int32_t CFWL_Barcode::CFWL_BarcodeDP::GetWideNarrowRatio() const { return m_nWideNarrowRatio; } -FX_CHAR CFWL_Barcode::CFWL_BarcodeDP::GetStartChar() { +FX_CHAR CFWL_Barcode::CFWL_BarcodeDP::GetStartChar() const { return m_cStartChar; } -FX_CHAR CFWL_Barcode::CFWL_BarcodeDP::GetEndChar() { +FX_CHAR CFWL_Barcode::CFWL_BarcodeDP::GetEndChar() const { return m_cEndChar; } -int32_t CFWL_Barcode::CFWL_BarcodeDP::GetVersion() { +int32_t CFWL_Barcode::CFWL_BarcodeDP::GetVersion() const { return m_nVersion; } -int32_t CFWL_Barcode::CFWL_BarcodeDP::GetErrorCorrectionLevel() { +int32_t CFWL_Barcode::CFWL_BarcodeDP::GetErrorCorrectionLevel() const { return m_nECLevel; } -FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetTruncated() { +FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetTruncated() const { return m_bTruncated; } -uint32_t CFWL_Barcode::CFWL_BarcodeDP::GetBarcodeAttributeMask() { +uint32_t CFWL_Barcode::CFWL_BarcodeDP::GetBarcodeAttributeMask() const { return m_dwAttributeMask; } diff --git a/xfa/fwl/core/cfwl_barcode.h b/xfa/fwl/core/cfwl_barcode.h index 39006676e9..aa6f8fccf4 100644 --- a/xfa/fwl/core/cfwl_barcode.h +++ b/xfa/fwl/core/cfwl_barcode.h @@ -43,9 +43,9 @@ class CFWL_Barcode : public CFWL_Edit { m_barcodeData.m_nDataLength = dataLength; GetWidget()->SetLimit(dataLength); } - void SetCalChecksum(int32_t calChecksum) { + void SetCalChecksum(FX_BOOL calChecksum) { m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CALCHECKSUM; - m_barcodeData.m_nCalChecksum = calChecksum; + m_barcodeData.m_bCalChecksum = calChecksum; } void SetPrintChecksum(FX_BOOL printChecksum) { m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_PRINTCHECKSUM; @@ -93,29 +93,31 @@ class CFWL_Barcode : public CFWL_Edit { CFX_WideString& wsCaption) override; // IFWL_BarcodeDP - BC_CHAR_ENCODING GetCharEncoding() override; - int32_t GetModuleHeight() override; - int32_t GetModuleWidth() override; - int32_t GetDataLength() override; - int32_t GetCalChecksum() override; - FX_BOOL GetPrintChecksum() override; - BC_TEXT_LOC GetTextLocation() override; - int32_t GetWideNarrowRatio() override; - FX_CHAR GetStartChar() override; - FX_CHAR GetEndChar() override; - int32_t GetVersion() override; - int32_t GetErrorCorrectionLevel() override; - FX_BOOL GetTruncated() override; - uint32_t GetBarcodeAttributeMask() override; + BC_CHAR_ENCODING GetCharEncoding() const override; + int32_t GetModuleHeight() const override; + int32_t GetModuleWidth() const override; + int32_t GetDataLength() const override; + FX_BOOL GetCalChecksum() const override; + FX_BOOL GetPrintChecksum() const override; + BC_TEXT_LOC GetTextLocation() const override; + int32_t GetWideNarrowRatio() const override; + FX_CHAR GetStartChar() const override; + FX_CHAR GetEndChar() const override; + int32_t GetVersion() const override; + int32_t GetErrorCorrectionLevel() const override; + FX_BOOL GetTruncated() const override; + uint32_t GetBarcodeAttributeMask() const override; BC_CHAR_ENCODING m_eCharEncoding; - int32_t m_nModuleHeight, m_nModuleWidth; + int32_t m_nModuleHeight; + int32_t m_nModuleWidth; int32_t m_nDataLength; - int32_t m_nCalChecksum; + FX_BOOL m_bCalChecksum; FX_BOOL m_bPrintChecksum; BC_TEXT_LOC m_eTextLocation; int32_t m_nWideNarrowRatio; - FX_CHAR m_cStartChar, m_cEndChar; + FX_CHAR m_cStartChar; + FX_CHAR m_cEndChar; int32_t m_nVersion; int32_t m_nECLevel; FX_BOOL m_bTruncated; diff --git a/xfa/fwl/core/cfx_barcode.cpp b/xfa/fwl/core/cfx_barcode.cpp index 549f908229..f870833647 100644 --- a/xfa/fwl/core/cfx_barcode.cpp +++ b/xfa/fwl/core/cfx_barcode.cpp @@ -132,7 +132,7 @@ FX_BOOL CFX_Barcode::SetDataLength(int32_t length) { return FALSE; } } -FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state) { +FX_BOOL CFX_Barcode::SetCalChecksum(FX_BOOL state) { switch (GetType()) { case BC_CODE39: case BC_CODABAR: diff --git a/xfa/fwl/core/cfx_barcode.h b/xfa/fwl/core/cfx_barcode.h index 389ff52042..8a6a10adc2 100644 --- a/xfa/fwl/core/cfx_barcode.h +++ b/xfa/fwl/core/cfx_barcode.h @@ -40,7 +40,7 @@ class CFX_Barcode { FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); FX_BOOL SetPrintChecksum(FX_BOOL checksum); FX_BOOL SetDataLength(int32_t length); - FX_BOOL SetCalChecksum(int32_t state); + FX_BOOL SetCalChecksum(FX_BOOL state); FX_BOOL SetFont(CFX_Font* pFont); FX_BOOL SetFontSize(FX_FLOAT size); FX_BOOL SetFontStyle(int32_t style); diff --git a/xfa/fwl/core/ifwl_barcode.h b/xfa/fwl/core/ifwl_barcode.h index 2313f86d36..5bc800d9a1 100644 --- a/xfa/fwl/core/ifwl_barcode.h +++ b/xfa/fwl/core/ifwl_barcode.h @@ -40,20 +40,20 @@ enum FWL_BCDAttribute { class IFWL_BarcodeDP : public IFWL_EditDP { public: - virtual BC_CHAR_ENCODING GetCharEncoding() = 0; - virtual int32_t GetModuleHeight() = 0; - virtual int32_t GetModuleWidth() = 0; - virtual int32_t GetDataLength() = 0; - virtual int32_t GetCalChecksum() = 0; - virtual FX_BOOL GetPrintChecksum() = 0; - virtual BC_TEXT_LOC GetTextLocation() = 0; - virtual int32_t GetWideNarrowRatio() = 0; - virtual FX_CHAR GetStartChar() = 0; - virtual FX_CHAR GetEndChar() = 0; - virtual int32_t GetVersion() = 0; - virtual int32_t GetErrorCorrectionLevel() = 0; - virtual FX_BOOL GetTruncated() = 0; - virtual uint32_t GetBarcodeAttributeMask() = 0; + virtual BC_CHAR_ENCODING GetCharEncoding() const = 0; + virtual int32_t GetModuleHeight() const = 0; + virtual int32_t GetModuleWidth() const = 0; + virtual int32_t GetDataLength() const = 0; + virtual FX_BOOL GetCalChecksum() const = 0; + virtual FX_BOOL GetPrintChecksum() const = 0; + virtual BC_TEXT_LOC GetTextLocation() const = 0; + virtual int32_t GetWideNarrowRatio() const = 0; + virtual FX_CHAR GetStartChar() const = 0; + virtual FX_CHAR GetEndChar() const = 0; + virtual int32_t GetVersion() const = 0; + virtual int32_t GetErrorCorrectionLevel() const = 0; + virtual FX_BOOL GetTruncated() const = 0; + virtual uint32_t GetBarcodeAttributeMask() const = 0; }; class IFWL_Barcode : public IFWL_Edit { diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index 72c956ac11..cb145f52ed 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -58,7 +58,7 @@ void CBC_OneDimWriter::SetDataLength(int32_t length) { m_iDataLenth = length; } -void CBC_OneDimWriter::SetCalcChecksum(int32_t state) { +void CBC_OneDimWriter::SetCalcChecksum(FX_BOOL state) { m_bCalcChecksum = state; } diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.h b/xfa/fxbarcode/oned/BC_OneDimWriter.h index 432c91fbe2..16d02e903d 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.h +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.h @@ -54,7 +54,7 @@ class CBC_OneDimWriter : public CBC_Writer { virtual CFX_WideString RenderTextContents(const CFX_WideStringC& contents); virtual void SetPrintChecksum(FX_BOOL checksum); virtual void SetDataLength(int32_t length); - virtual void SetCalcChecksum(int32_t state); + virtual void SetCalcChecksum(FX_BOOL state); virtual void SetFontSize(FX_FLOAT size); virtual void SetFontStyle(int32_t style); virtual void SetFontColor(FX_ARGB color); diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index ce9b0454c9..6a5478049b 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -179,8 +179,8 @@ void CXFA_FFBarcode::UpdateWidgetProperty() { if (pAcc->GetBarcodeAttribute_CharEncoding(intVal)) { pBarCodeWidget->SetCharEncoding((BC_CHAR_ENCODING)intVal); } - if (pAcc->GetBarcodeAttribute_Checksum(intVal)) { - pBarCodeWidget->SetCalChecksum(intVal); + if (pAcc->GetBarcodeAttribute_Checksum(boolVal)) { + pBarCodeWidget->SetCalChecksum(boolVal); } if (pAcc->GetBarcodeAttribute_DataLength(intVal)) { pBarCodeWidget->SetDataLength(intVal); diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index a5a7807ac8..ce07faf60f 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -1260,16 +1260,16 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { return FALSE; } -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(int32_t& val) { +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(FX_BOOL& val) { CXFA_Node* pUIChild = GetUIChild(); XFA_ATTRIBUTEENUM eChecksum; if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) { switch (eChecksum) { case XFA_ATTRIBUTEENUM_None: - val = 0; + val = false; return TRUE; case XFA_ATTRIBUTEENUM_Auto: - val = 1; + val = true; return TRUE; case XFA_ATTRIBUTEENUM_1mod10: break; diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index f718b6ee59..ed217ada3d 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -138,7 +138,7 @@ class CXFA_WidgetData : public CXFA_Data { void NormalizeNumStr(const CFX_WideString& wsValue, CFX_WideString& wsOutput); CFX_WideString GetBarcodeType(); FX_BOOL GetBarcodeAttribute_CharEncoding(int32_t& val); - FX_BOOL GetBarcodeAttribute_Checksum(int32_t& val); + FX_BOOL GetBarcodeAttribute_Checksum(FX_BOOL& val); FX_BOOL GetBarcodeAttribute_DataLength(int32_t& val); FX_BOOL GetBarcodeAttribute_StartChar(FX_CHAR& val); FX_BOOL GetBarcodeAttribute_EndChar(FX_CHAR& val); -- cgit v1.2.3