Make CBC_CodeBase::SetWideNarrowRatio() not virtual.
Make CBC_Writer::SetWideNarrowRatio() virtual instead. Do the same for
SetStartChar(), SetEndChar(), and SetErrorCorrectionLevel().
Change-Id: I70e87c0e9f8b772331105e57dd26075db3cfcb95
Reviewed-on: https://pdfium-review.googlesource.com/42602
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/fxbarcode/BC_TwoDimWriter.h b/fxbarcode/BC_TwoDimWriter.h
index 228a2e0..22c80ad 100644
--- a/fxbarcode/BC_TwoDimWriter.h
+++ b/fxbarcode/BC_TwoDimWriter.h
@@ -25,7 +25,7 @@
int32_t codeHeight);
virtual void RenderDeviceResult(CFX_RenderDevice* device,
const CFX_Matrix* matrix);
- virtual bool SetErrorCorrectionLevel(int32_t level) = 0;
+
int32_t GetErrorCorrectionLevel() const;
protected:
diff --git a/fxbarcode/BC_Writer.cpp b/fxbarcode/BC_Writer.cpp
index 8d639d3..711b82a 100644
--- a/fxbarcode/BC_Writer.cpp
+++ b/fxbarcode/BC_Writer.cpp
@@ -53,6 +53,22 @@
return false;
}
+bool CBC_Writer::SetWideNarrowRatio(int8_t ratio) {
+ return false;
+}
+
+bool CBC_Writer::SetStartChar(char start) {
+ return false;
+}
+
+bool CBC_Writer::SetEndChar(char end) {
+ return false;
+}
+
+bool CBC_Writer::SetErrorCorrectionLevel(int32_t level) {
+ return false;
+}
+
RetainPtr<CFX_DIBitmap> CBC_Writer::CreateDIBitmap(int32_t width,
int32_t height) {
auto pDIBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
diff --git a/fxbarcode/BC_Writer.h b/fxbarcode/BC_Writer.h
index 3751b93..7435807 100644
--- a/fxbarcode/BC_Writer.h
+++ b/fxbarcode/BC_Writer.h
@@ -25,6 +25,10 @@
virtual void SetBackgroundColor(FX_ARGB backgroundColor);
virtual void SetBarcodeColor(FX_ARGB foregroundColor);
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);
protected:
RetainPtr<CFX_DIBitmap> CreateDIBitmap(int32_t width, int32_t height);
diff --git a/fxbarcode/cbc_codabar.cpp b/fxbarcode/cbc_codabar.cpp
index f3a3a62..700291b 100644
--- a/fxbarcode/cbc_codabar.cpp
+++ b/fxbarcode/cbc_codabar.cpp
@@ -31,18 +31,6 @@
CBC_Codabar::~CBC_Codabar() {}
-bool CBC_Codabar::SetStartChar(char start) {
- return GetOnedCodaBarWriter()->SetStartChar(start);
-}
-
-bool CBC_Codabar::SetEndChar(char end) {
- return GetOnedCodaBarWriter()->SetEndChar(end);
-}
-
-bool CBC_Codabar::SetWideNarrowRatio(int8_t ratio) {
- return GetOnedCodaBarWriter()->SetWideNarrowRatio(ratio);
-}
-
bool CBC_Codabar::Encode(const WideStringView& contents) {
if (contents.IsEmpty())
return false;
diff --git a/fxbarcode/cbc_codabar.h b/fxbarcode/cbc_codabar.h
index bf8a21e..e8a6279 100644
--- a/fxbarcode/cbc_codabar.h
+++ b/fxbarcode/cbc_codabar.h
@@ -24,9 +24,6 @@
bool Encode(const WideStringView& contents) override;
bool RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix) 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_code39.cpp b/fxbarcode/cbc_code39.cpp
index 6aa3646..2031650 100644
--- a/fxbarcode/cbc_code39.cpp
+++ b/fxbarcode/cbc_code39.cpp
@@ -61,10 +61,6 @@
return BC_CODE39;
}
-bool CBC_Code39::SetWideNarrowRatio(int8_t ratio) {
- return GetOnedCode39Writer()->SetWideNarrowRatio(ratio);
-}
-
CBC_OnedCode39Writer* CBC_Code39::GetOnedCode39Writer() {
return static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get());
}
diff --git a/fxbarcode/cbc_code39.h b/fxbarcode/cbc_code39.h
index 4f87ba7..26f0457 100644
--- a/fxbarcode/cbc_code39.h
+++ b/fxbarcode/cbc_code39.h
@@ -25,7 +25,6 @@
bool Encode(const WideStringView& contents) override;
bool RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix) override;
- bool SetWideNarrowRatio(int8_t ratio) override;
private:
CBC_OnedCode39Writer* GetOnedCode39Writer();
diff --git a/fxbarcode/cbc_codebase.cpp b/fxbarcode/cbc_codebase.cpp
index 6a04a25..c31ee6c 100644
--- a/fxbarcode/cbc_codebase.cpp
+++ b/fxbarcode/cbc_codebase.cpp
@@ -35,19 +35,19 @@
}
bool CBC_CodeBase::SetWideNarrowRatio(int8_t ratio) {
- return false;
+ return m_pBCWriter->SetWideNarrowRatio(ratio);
}
bool CBC_CodeBase::SetStartChar(char start) {
- return false;
+ return m_pBCWriter->SetStartChar(start);
}
bool CBC_CodeBase::SetEndChar(char end) {
- return false;
+ return m_pBCWriter->SetEndChar(end);
}
bool CBC_CodeBase::SetErrorCorrectionLevel(int32_t level) {
- return false;
+ return m_pBCWriter->SetErrorCorrectionLevel(level);
}
bool CBC_CodeBase::SetCharEncoding(int32_t encoding) {
diff --git a/fxbarcode/cbc_codebase.h b/fxbarcode/cbc_codebase.h
index be49f8a..86d10c3 100644
--- a/fxbarcode/cbc_codebase.h
+++ b/fxbarcode/cbc_codebase.h
@@ -29,12 +29,12 @@
virtual bool Encode(const WideStringView& contents) = 0;
virtual bool RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix) = 0;
- virtual bool SetWideNarrowRatio(int8_t ratio);
- virtual bool SetStartChar(char start);
- virtual bool SetEndChar(char end);
- virtual bool SetErrorCorrectionLevel(int32_t level);
bool SetTextLocation(BC_TEXT_LOC location);
+ bool SetWideNarrowRatio(int8_t ratio);
+ bool SetStartChar(char start);
+ bool SetEndChar(char end);
+ bool SetErrorCorrectionLevel(int32_t level);
bool SetCharEncoding(int32_t encoding);
bool SetModuleHeight(int32_t moduleHeight);
bool SetModuleWidth(int32_t moduleWidth);
diff --git a/fxbarcode/cbc_pdf417i.cpp b/fxbarcode/cbc_pdf417i.cpp
index b011979..d259516 100644
--- a/fxbarcode/cbc_pdf417i.cpp
+++ b/fxbarcode/cbc_pdf417i.cpp
@@ -31,11 +31,6 @@
CBC_PDF417I::~CBC_PDF417I() {}
-bool CBC_PDF417I::SetErrorCorrectionLevel(int32_t level) {
- GetPDF417Writer()->SetErrorCorrectionLevel(level);
- return true;
-}
-
bool CBC_PDF417I::Encode(const WideStringView& contents) {
int32_t outWidth;
int32_t outHeight;
diff --git a/fxbarcode/cbc_pdf417i.h b/fxbarcode/cbc_pdf417i.h
index b12fa74..37dd5b4 100644
--- a/fxbarcode/cbc_pdf417i.h
+++ b/fxbarcode/cbc_pdf417i.h
@@ -24,7 +24,6 @@
bool RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix) override;
BC_TYPE GetType() override;
- bool SetErrorCorrectionLevel(int32_t level) override;
private:
CBC_PDF417Writer* GetPDF417Writer();
diff --git a/fxbarcode/cbc_qrcode.cpp b/fxbarcode/cbc_qrcode.cpp
index 0f3a65e..a5679a0 100644
--- a/fxbarcode/cbc_qrcode.cpp
+++ b/fxbarcode/cbc_qrcode.cpp
@@ -31,12 +31,6 @@
CBC_QRCode::~CBC_QRCode() {}
-bool CBC_QRCode::SetErrorCorrectionLevel(int32_t level) {
- if (level < 0 || level > 3)
- return false;
- return GetQRCodeWriter()->SetErrorCorrectionLevel(level);
-}
-
bool CBC_QRCode::Encode(const WideStringView& contents) {
int32_t outWidth = 0;
int32_t outHeight = 0;
diff --git a/fxbarcode/cbc_qrcode.h b/fxbarcode/cbc_qrcode.h
index 8502933..e40fbc8 100644
--- a/fxbarcode/cbc_qrcode.h
+++ b/fxbarcode/cbc_qrcode.h
@@ -24,7 +24,6 @@
bool RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix) override;
BC_TYPE GetType() override;
- bool SetErrorCorrectionLevel(int32_t level) override;
private:
CBC_QRCodeWriter* GetQRCodeWriter();
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.h b/fxbarcode/oned/BC_OnedCodaBarWriter.h
index ff30ab6..8147e04 100644
--- a/fxbarcode/oned/BC_OnedCodaBarWriter.h
+++ b/fxbarcode/oned/BC_OnedCodaBarWriter.h
@@ -31,10 +31,10 @@
WideString FilterContents(const WideStringView& contents) override;
void SetDataLength(int32_t length) override;
bool SetTextLocation(BC_TEXT_LOC location) override;
+ bool SetWideNarrowRatio(int8_t ratio) override;
+ bool SetStartChar(char start) override;
+ bool SetEndChar(char end) override;
- virtual bool SetStartChar(char start);
- virtual bool SetEndChar(char end);
- virtual bool SetWideNarrowRatio(int8_t ratio);
virtual bool FindChar(wchar_t ch, bool isContent);
WideString encodedContents(const WideStringView& contents);
diff --git a/fxbarcode/oned/BC_OnedCode39Writer.h b/fxbarcode/oned/BC_OnedCode39Writer.h
index e136073..b6102bc 100644
--- a/fxbarcode/oned/BC_OnedCode39Writer.h
+++ b/fxbarcode/oned/BC_OnedCode39Writer.h
@@ -29,8 +29,7 @@
WideString FilterContents(const WideStringView& contents) override;
WideString RenderTextContents(const WideStringView& contents) override;
bool SetTextLocation(BC_TEXT_LOC location) override;
-
- virtual bool SetWideNarrowRatio(int8_t ratio);
+ bool SetWideNarrowRatio(int8_t ratio) override;
bool encodedContents(const WideStringView& contents, WideString* result);