From c5709dd345c748016a637b2104544895223f8fc7 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 17 Sep 2018 18:10:36 +0000 Subject: Make CBC_CodeBase::SetTextLocation() virtual. Do the same for a few other CBC_CodeBase methods, instead of trying to implement virtual methods manually using memory pointers. Change-Id: Iec0e3a4f8eabc54962c7ac0a00a1b80b192ff474 Reviewed-on: https://pdfium-review.googlesource.com/42600 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- fxbarcode/cbc_codabar.h | 11 +++++------ fxbarcode/cbc_code128.h | 5 ++--- fxbarcode/cbc_code39.h | 7 +++---- fxbarcode/cbc_codebase.cpp | 20 ++++++++++++++++++++ fxbarcode/cbc_codebase.h | 5 +++++ fxbarcode/cbc_pdf417i.h | 3 +-- fxbarcode/cbc_qrcode.h | 3 +-- fxbarcode/oned/BC_OnedCode39Writer.h | 2 +- 8 files changed, 38 insertions(+), 18 deletions(-) (limited to 'fxbarcode') diff --git a/fxbarcode/cbc_codabar.h b/fxbarcode/cbc_codabar.h index 036c65f829..7fc518b80f 100644 --- a/fxbarcode/cbc_codabar.h +++ b/fxbarcode/cbc_codabar.h @@ -20,15 +20,14 @@ class CBC_Codabar final : public CBC_OneCode { ~CBC_Codabar() override; // CBC_OneCode: + BC_TYPE GetType() override; bool Encode(const WideStringView& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; - BC_TYPE GetType() override; - - bool SetStartChar(char start); - bool SetEndChar(char end); - bool SetTextLocation(BC_TEXT_LOC location); - bool SetWideNarrowRatio(int8_t ratio); + bool SetTextLocation(BC_TEXT_LOC location) override; + bool SetWideNarrowRatio(int8_t ratio) override; + bool SetStartChar(char start) override; + bool SetEndChar(char end) override; private: CBC_OnedCodaBarWriter* GetOnedCodaBarWriter(); diff --git a/fxbarcode/cbc_code128.h b/fxbarcode/cbc_code128.h index 61bed6fe0f..ccd5a38243 100644 --- a/fxbarcode/cbc_code128.h +++ b/fxbarcode/cbc_code128.h @@ -20,12 +20,11 @@ class CBC_Code128 final : public CBC_OneCode { ~CBC_Code128() override; // CBC_OneCode: + BC_TYPE GetType() override; bool Encode(const WideStringView& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; - BC_TYPE GetType() override; - - bool SetTextLocation(BC_TEXT_LOC loction); + bool SetTextLocation(BC_TEXT_LOC location) override; private: CBC_OnedCode128Writer* GetOnedCode128Writer(); diff --git a/fxbarcode/cbc_code39.h b/fxbarcode/cbc_code39.h index 83c8daa32f..4e240b7f89 100644 --- a/fxbarcode/cbc_code39.h +++ b/fxbarcode/cbc_code39.h @@ -21,13 +21,12 @@ class CBC_Code39 final : public CBC_OneCode { ~CBC_Code39() override; // CBC_OneCode: + BC_TYPE GetType() override; bool Encode(const WideStringView& contents) override; bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; - BC_TYPE GetType() override; - - bool SetTextLocation(BC_TEXT_LOC location); - bool SetWideNarrowRatio(int8_t ratio); + bool SetTextLocation(BC_TEXT_LOC location) override; + bool SetWideNarrowRatio(int8_t ratio) override; private: CBC_OnedCode39Writer* GetOnedCode39Writer(); diff --git a/fxbarcode/cbc_codebase.cpp b/fxbarcode/cbc_codebase.cpp index 2278f931e8..b723f551d5 100644 --- a/fxbarcode/cbc_codebase.cpp +++ b/fxbarcode/cbc_codebase.cpp @@ -30,6 +30,26 @@ CBC_CodeBase::CBC_CodeBase(std::unique_ptr pWriter) CBC_CodeBase::~CBC_CodeBase() {} +bool CBC_CodeBase::SetTextLocation(BC_TEXT_LOC location) { + return false; +} + +bool CBC_CodeBase::SetWideNarrowRatio(int8_t ratio) { + return false; +} + +bool CBC_CodeBase::SetStartChar(char start) { + return false; +} + +bool CBC_CodeBase::SetEndChar(char end) { + return false; +} + +bool CBC_CodeBase::SetErrorCorrectionLevel(int32_t level) { + return false; +} + bool CBC_CodeBase::SetCharEncoding(int32_t encoding) { return m_pBCWriter->SetCharEncoding(encoding); } diff --git a/fxbarcode/cbc_codebase.h b/fxbarcode/cbc_codebase.h index aab98da32b..e0f402d91c 100644 --- a/fxbarcode/cbc_codebase.h +++ b/fxbarcode/cbc_codebase.h @@ -29,6 +29,11 @@ class CBC_CodeBase { virtual bool Encode(const WideStringView& contents) = 0; virtual bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) = 0; + virtual bool SetTextLocation(BC_TEXT_LOC location); + virtual bool SetWideNarrowRatio(int8_t ratio); + virtual bool SetStartChar(char start); + virtual bool SetEndChar(char end); + virtual bool SetErrorCorrectionLevel(int32_t level); bool SetCharEncoding(int32_t encoding); bool SetModuleHeight(int32_t moduleHeight); diff --git a/fxbarcode/cbc_pdf417i.h b/fxbarcode/cbc_pdf417i.h index ec686006cb..b12fa74c60 100644 --- a/fxbarcode/cbc_pdf417i.h +++ b/fxbarcode/cbc_pdf417i.h @@ -24,8 +24,7 @@ class CBC_PDF417I final : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; - - bool SetErrorCorrectionLevel(int32_t level); + bool SetErrorCorrectionLevel(int32_t level) override; private: CBC_PDF417Writer* GetPDF417Writer(); diff --git a/fxbarcode/cbc_qrcode.h b/fxbarcode/cbc_qrcode.h index 59d57ac648..8502933df5 100644 --- a/fxbarcode/cbc_qrcode.h +++ b/fxbarcode/cbc_qrcode.h @@ -24,8 +24,7 @@ class CBC_QRCode final : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix) override; BC_TYPE GetType() override; - - bool SetErrorCorrectionLevel(int32_t level); + bool SetErrorCorrectionLevel(int32_t level) override; private: CBC_QRCodeWriter* GetQRCodeWriter(); diff --git a/fxbarcode/oned/BC_OnedCode39Writer.h b/fxbarcode/oned/BC_OnedCode39Writer.h index 0791062660..97ef7a22b5 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.h +++ b/fxbarcode/oned/BC_OnedCode39Writer.h @@ -29,7 +29,7 @@ class CBC_OnedCode39Writer final : public CBC_OneDimWriter { WideString FilterContents(const WideStringView& contents) override; WideString RenderTextContents(const WideStringView& contents) override; - virtual bool SetTextLocation(BC_TEXT_LOC loction); + virtual bool SetTextLocation(BC_TEXT_LOC location); virtual bool SetWideNarrowRatio(int8_t ratio); bool encodedContents(const WideStringView& contents, WideString* result); -- cgit v1.2.3