summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-09-17 22:22:36 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-17 22:22:36 +0000
commit4c3b4aa6d1df54fe02912fed04a08adc6826310f (patch)
tree29294bd608b815d503abaa218ca940c4f5a562df
parentc397a9003207f14e02a09d611d91a6d14a2de771 (diff)
downloadpdfium-4c3b4aa6d1df54fe02912fed04a08adc6826310f.tar.xz
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>
-rw-r--r--fxbarcode/BC_TwoDimWriter.h2
-rw-r--r--fxbarcode/BC_Writer.cpp16
-rw-r--r--fxbarcode/BC_Writer.h4
-rw-r--r--fxbarcode/cbc_codabar.cpp12
-rw-r--r--fxbarcode/cbc_codabar.h3
-rw-r--r--fxbarcode/cbc_code39.cpp4
-rw-r--r--fxbarcode/cbc_code39.h1
-rw-r--r--fxbarcode/cbc_codebase.cpp8
-rw-r--r--fxbarcode/cbc_codebase.h8
-rw-r--r--fxbarcode/cbc_pdf417i.cpp5
-rw-r--r--fxbarcode/cbc_pdf417i.h1
-rw-r--r--fxbarcode/cbc_qrcode.cpp6
-rw-r--r--fxbarcode/cbc_qrcode.h1
-rw-r--r--fxbarcode/oned/BC_OnedCodaBarWriter.h6
-rw-r--r--fxbarcode/oned/BC_OnedCode39Writer.h3
15 files changed, 33 insertions, 47 deletions
diff --git a/fxbarcode/BC_TwoDimWriter.h b/fxbarcode/BC_TwoDimWriter.h
index 228a2e03e9..22c80ad80b 100644
--- a/fxbarcode/BC_TwoDimWriter.h
+++ b/fxbarcode/BC_TwoDimWriter.h
@@ -25,7 +25,7 @@ class CBC_TwoDimWriter : public CBC_Writer {
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 8d639d3f01..711b82a5b4 100644
--- a/fxbarcode/BC_Writer.cpp
+++ b/fxbarcode/BC_Writer.cpp
@@ -53,6 +53,22 @@ bool CBC_Writer::SetTextLocation(BC_TEXT_LOC location) {
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 3751b93457..7435807c8d 100644
--- a/fxbarcode/BC_Writer.h
+++ b/fxbarcode/BC_Writer.h
@@ -25,6 +25,10 @@ class CBC_Writer {
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 f3a3a62dac..700291b2c7 100644
--- a/fxbarcode/cbc_codabar.cpp
+++ b/fxbarcode/cbc_codabar.cpp
@@ -31,18 +31,6 @@ CBC_Codabar::CBC_Codabar()
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 bf8a21e42e..e8a62799c6 100644
--- a/fxbarcode/cbc_codabar.h
+++ b/fxbarcode/cbc_codabar.h
@@ -24,9 +24,6 @@ class CBC_Codabar final : public CBC_OneCode {
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 6aa3646e97..20316508c2 100644
--- a/fxbarcode/cbc_code39.cpp
+++ b/fxbarcode/cbc_code39.cpp
@@ -61,10 +61,6 @@ BC_TYPE CBC_Code39::GetType() {
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 4f87ba774a..26f0457334 100644
--- a/fxbarcode/cbc_code39.h
+++ b/fxbarcode/cbc_code39.h
@@ -25,7 +25,6 @@ class CBC_Code39 final : public CBC_OneCode {
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 6a04a25bda..c31ee6c434 100644
--- a/fxbarcode/cbc_codebase.cpp
+++ b/fxbarcode/cbc_codebase.cpp
@@ -35,19 +35,19 @@ bool CBC_CodeBase::SetTextLocation(BC_TEXT_LOC location) {
}
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 be49f8a0e7..86d10c3b92 100644
--- a/fxbarcode/cbc_codebase.h
+++ b/fxbarcode/cbc_codebase.h
@@ -29,12 +29,12 @@ class CBC_CodeBase {
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 b01197954c..d259516ee4 100644
--- a/fxbarcode/cbc_pdf417i.cpp
+++ b/fxbarcode/cbc_pdf417i.cpp
@@ -31,11 +31,6 @@ CBC_PDF417I::CBC_PDF417I()
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 b12fa74c60..37dd5b4b0c 100644
--- a/fxbarcode/cbc_pdf417i.h
+++ b/fxbarcode/cbc_pdf417i.h
@@ -24,7 +24,6 @@ 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) override;
private:
CBC_PDF417Writer* GetPDF417Writer();
diff --git a/fxbarcode/cbc_qrcode.cpp b/fxbarcode/cbc_qrcode.cpp
index 0f3a65ef3a..a5679a0943 100644
--- a/fxbarcode/cbc_qrcode.cpp
+++ b/fxbarcode/cbc_qrcode.cpp
@@ -31,12 +31,6 @@ CBC_QRCode::CBC_QRCode()
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 8502933df5..e40fbc80a0 100644
--- a/fxbarcode/cbc_qrcode.h
+++ b/fxbarcode/cbc_qrcode.h
@@ -24,7 +24,6 @@ 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) override;
private:
CBC_QRCodeWriter* GetQRCodeWriter();
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.h b/fxbarcode/oned/BC_OnedCodaBarWriter.h
index ff30ab64d9..8147e04bb7 100644
--- a/fxbarcode/oned/BC_OnedCodaBarWriter.h
+++ b/fxbarcode/oned/BC_OnedCodaBarWriter.h
@@ -31,10 +31,10 @@ class CBC_OnedCodaBarWriter final : public CBC_OneDimWriter {
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 e136073209..b6102bc535 100644
--- a/fxbarcode/oned/BC_OnedCode39Writer.h
+++ b/fxbarcode/oned/BC_OnedCode39Writer.h
@@ -29,8 +29,7 @@ class CBC_OnedCode39Writer final : public CBC_OneDimWriter {
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);