Remove dead code in fxbarcode.
Fix some nits along the way.
Change-Id: I0e137a5f8e47996ee2529b249c0394f250d10dcb
Reviewed-on: https://pdfium-review.googlesource.com/c/46790
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxbarcode/BC_Writer.cpp b/fxbarcode/BC_Writer.cpp
index 5af796b..911d90c 100644
--- a/fxbarcode/BC_Writer.cpp
+++ b/fxbarcode/BC_Writer.cpp
@@ -6,8 +6,6 @@
#include "fxbarcode/BC_Writer.h"
-#include "core/fxge/dib/cfx_dibitmap.h"
-
CBC_Writer::CBC_Writer() = default;
CBC_Writer::~CBC_Writer() = default;
@@ -70,10 +68,3 @@
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>();
- pDIBitmap->Create(width, height, m_colorSpace);
- return pDIBitmap;
-}
diff --git a/fxbarcode/BC_Writer.h b/fxbarcode/BC_Writer.h
index b517682..c358599 100644
--- a/fxbarcode/BC_Writer.h
+++ b/fxbarcode/BC_Writer.h
@@ -7,7 +7,6 @@
#ifndef FXBARCODE_BC_WRITER_H_
#define FXBARCODE_BC_WRITER_H_
-#include "core/fxcrt/fx_string.h"
#include "core/fxge/fx_dib.h"
#include "fxbarcode/BC_Library.h"
@@ -31,7 +30,6 @@
virtual bool SetErrorCorrectionLevel(int32_t level);
protected:
- RetainPtr<CFX_DIBitmap> CreateDIBitmap(int32_t width, int32_t height);
int32_t m_CharEncoding = 0;
int32_t m_ModuleHeight = 1;
int32_t m_ModuleWidth = 1;
diff --git a/fxbarcode/oned/BC_OneDimWriter.h b/fxbarcode/oned/BC_OneDimWriter.h
index 1268464..c910cd6 100644
--- a/fxbarcode/oned/BC_OneDimWriter.h
+++ b/fxbarcode/oned/BC_OneDimWriter.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/unowned_ptr.h"
#include "fxbarcode/BC_Library.h"
#include "fxbarcode/BC_Writer.h"
diff --git a/fxbarcode/qrcode/BC_QRCoder.cpp b/fxbarcode/qrcode/BC_QRCoder.cpp
index f6cead8..62c2886 100644
--- a/fxbarcode/qrcode/BC_QRCoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoder.cpp
@@ -27,22 +27,9 @@
#include "fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
#include "fxbarcode/qrcode/BC_QRCoderMode.h"
-CBC_QRCoder::CBC_QRCoder()
- : m_mode(nullptr),
- m_ecLevel(nullptr),
- m_version(-1),
- m_matrixWidth(-1),
- m_maskPattern(-1),
- m_numTotalBytes(-1),
- m_numDataBytes(-1),
- m_numECBytes(-1),
- m_numRSBlocks(-1) {}
+CBC_QRCoder::CBC_QRCoder() = default;
-CBC_QRCoder::~CBC_QRCoder() {}
-
-CBC_QRCoderMode* CBC_QRCoder::GetMode() const {
- return m_mode.Get();
-}
+CBC_QRCoder::~CBC_QRCoder() = default;
const CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() const {
return m_ecLevel.Get();
@@ -81,7 +68,7 @@
}
bool CBC_QRCoder::IsValid() const {
- return m_mode && m_ecLevel && m_version != -1 && m_matrixWidth != -1 &&
+ return m_ecLevel && m_version != -1 && m_matrixWidth != -1 &&
m_maskPattern != -1 && m_numTotalBytes != -1 && m_numDataBytes != -1 &&
m_numECBytes != -1 && m_numRSBlocks != -1 &&
IsValidMaskPattern(m_maskPattern) &&
@@ -90,10 +77,6 @@
m_matrix->GetWidth() == m_matrix->GetHeight();
}
-void CBC_QRCoder::SetMode(CBC_QRCoderMode* value) {
- m_mode = value;
-}
-
void CBC_QRCoder::SetECLevel(const CBC_QRCoderErrorCorrectionLevel* ecLevel) {
m_ecLevel = ecLevel;
}
diff --git a/fxbarcode/qrcode/BC_QRCoder.h b/fxbarcode/qrcode/BC_QRCoder.h
index 7b7e680..882822f 100644
--- a/fxbarcode/qrcode/BC_QRCoder.h
+++ b/fxbarcode/qrcode/BC_QRCoder.h
@@ -24,7 +24,6 @@
static bool IsValidMaskPattern(int32_t maskPattern);
- CBC_QRCoderMode* GetMode() const;
const CBC_QRCoderErrorCorrectionLevel* GetECLevel() const;
int32_t GetVersion() const;
int32_t GetMatrixWidth() const;
@@ -37,7 +36,6 @@
bool IsValid() const;
- void SetMode(CBC_QRCoderMode* value);
void SetECLevel(const CBC_QRCoderErrorCorrectionLevel* ecLevel);
void SetVersion(int32_t version);
void SetMatrixWidth(int32_t width);
@@ -49,15 +47,14 @@
void SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix);
private:
- UnownedPtr<CBC_QRCoderMode> m_mode;
UnownedPtr<const CBC_QRCoderErrorCorrectionLevel> m_ecLevel;
- int32_t m_version;
- int32_t m_matrixWidth;
- int32_t m_maskPattern;
- int32_t m_numTotalBytes;
- int32_t m_numDataBytes;
- int32_t m_numECBytes;
- int32_t m_numRSBlocks;
+ int32_t m_version = -1;
+ int32_t m_matrixWidth = -1;
+ int32_t m_maskPattern = -1;
+ int32_t m_numTotalBytes = -1;
+ int32_t m_numDataBytes = -1;
+ int32_t m_numECBytes = -1;
+ int32_t m_numRSBlocks = -1;
std::unique_ptr<CBC_CommonByteMatrix> m_matrix;
};
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index a82659d..34971e3 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -200,10 +200,8 @@
bool InitQRCode(int32_t numInputBytes,
const CBC_QRCoderErrorCorrectionLevel* ecLevel,
- CBC_QRCoderMode* mode,
CBC_QRCoder* qrCode) {
qrCode->SetECLevel(ecLevel);
- qrCode->SetMode(mode);
for (int32_t i = 1; i <= CBC_QRCoderVersion::kMaxVersion; ++i) {
const auto* version = CBC_QRCoderVersion::GetVersionForNumber(i);
int32_t numBytes = version->GetTotalCodeWords();
@@ -412,7 +410,7 @@
if (!AppendBytes(utf8Data, mode, &dataBits, encoding))
return false;
int32_t numInputBytes = dataBits.sizeInBytes();
- if (!InitQRCode(numInputBytes, ecLevel, mode, qrCode))
+ if (!InitQRCode(numInputBytes, ecLevel, qrCode))
return false;
CBC_QRCoderBitVector headerAndDataBits;
AppendModeInfo(mode, &headerAndDataBits);
diff --git a/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp b/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp
index 6d78753..a0e5c2b 100644
--- a/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp
@@ -29,17 +29,16 @@
CBC_QRCoderErrorCorrectionLevel::CBC_QRCoderErrorCorrectionLevel(
int32_t ordinal,
- int32_t bits,
- const char* name)
- : m_ordinal(ordinal), m_bits(bits), m_name(name) {}
+ int32_t bits)
+ : m_ordinal(ordinal), m_bits(bits) {}
-CBC_QRCoderErrorCorrectionLevel::~CBC_QRCoderErrorCorrectionLevel() {}
+CBC_QRCoderErrorCorrectionLevel::~CBC_QRCoderErrorCorrectionLevel() = default;
void CBC_QRCoderErrorCorrectionLevel::Initialize() {
- L = new CBC_QRCoderErrorCorrectionLevel(0, 0x01, "L");
- M = new CBC_QRCoderErrorCorrectionLevel(1, 0x00, "M");
- Q = new CBC_QRCoderErrorCorrectionLevel(2, 0x03, "Q");
- H = new CBC_QRCoderErrorCorrectionLevel(3, 0x02, "H");
+ L = new CBC_QRCoderErrorCorrectionLevel(0, 0x01);
+ M = new CBC_QRCoderErrorCorrectionLevel(1, 0x00);
+ Q = new CBC_QRCoderErrorCorrectionLevel(2, 0x03);
+ H = new CBC_QRCoderErrorCorrectionLevel(3, 0x02);
}
void CBC_QRCoderErrorCorrectionLevel::Finalize() {
diff --git a/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h b/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h
index a981a27..9a572a5 100644
--- a/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h
+++ b/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h
@@ -7,7 +7,7 @@
#ifndef FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_
#define FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_
-#include "core/fxcrt/fx_string.h"
+#include <stdint.h>
class CBC_QRCoderErrorCorrectionLevel {
public:
@@ -23,17 +23,12 @@
int32_t Ordinal() const { return m_ordinal; }
int32_t GetBits() const { return m_bits; }
- ByteString GetName() const { return m_name; }
private:
- CBC_QRCoderErrorCorrectionLevel(int32_t ordinal,
- int32_t bits,
- const char* name);
- CBC_QRCoderErrorCorrectionLevel();
+ CBC_QRCoderErrorCorrectionLevel(int32_t ordinal, int32_t bits);
int32_t m_ordinal;
int32_t m_bits;
- ByteString m_name;
};
#endif // FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_
diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
index b17564c..2c6b051 100644
--- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
@@ -20,12 +20,14 @@
* limitations under the License.
*/
+#include "fxbarcode/qrcode/BC_QRCoderMatrixUtil.h"
+
+#include "core/fxcrt/fx_memory.h"
#include "fxbarcode/common/BC_CommonByteMatrix.h"
#include "fxbarcode/qrcode/BC_QRCoder.h"
#include "fxbarcode/qrcode/BC_QRCoderBitVector.h"
#include "fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
#include "fxbarcode/qrcode/BC_QRCoderMaskUtil.h"
-#include "fxbarcode/qrcode/BC_QRCoderMatrixUtil.h"
namespace {
diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h
index 2952511..4bef5e1 100644
--- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h
+++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h
@@ -7,6 +7,8 @@
#ifndef FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_
#define FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_
+#include <stdint.h>
+
class CBC_CommonByteMatrix;
class CBC_QRCoderErrorCorrectionLevel;
class CBC_QRCoderBitVector;
diff --git a/fxbarcode/qrcode/BC_QRCoderMode.cpp b/fxbarcode/qrcode/BC_QRCoderMode.cpp
index 71e78e2..8648f8c 100644
--- a/fxbarcode/qrcode/BC_QRCoderMode.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderMode.cpp
@@ -24,6 +24,8 @@
#include <utility>
+#include "core/fxcrt/fx_system.h"
+
CBC_QRCoderMode* CBC_QRCoderMode::sBYTE = nullptr;
CBC_QRCoderMode* CBC_QRCoderMode::sNUMERIC = nullptr;
CBC_QRCoderMode* CBC_QRCoderMode::sALPHANUMERIC = nullptr;
@@ -36,28 +38,22 @@
CBC_QRCoderMode* CBC_QRCoderMode::sSTRUCTURED_APPEND = nullptr;
CBC_QRCoderMode::CBC_QRCoderMode(std::vector<int32_t> charCountBits,
- int32_t bits,
- ByteString name)
- : m_characterCountBitsForVersions(std::move(charCountBits)),
- m_bits(bits),
- m_name(name) {}
+ int32_t bits)
+ : m_characterCountBitsForVersions(std::move(charCountBits)), m_bits(bits) {}
-CBC_QRCoderMode::~CBC_QRCoderMode() {}
+CBC_QRCoderMode::~CBC_QRCoderMode() = default;
void CBC_QRCoderMode::Initialize() {
- sBYTE = new CBC_QRCoderMode({8, 16, 16}, 0x4, "BYTE");
- sALPHANUMERIC = new CBC_QRCoderMode({9, 11, 13}, 0x2, "ALPHANUMERIC");
- sECI = new CBC_QRCoderMode(std::vector<int32_t>(), 0x7, "ECI");
- sKANJI = new CBC_QRCoderMode({8, 10, 12}, 0x8, "KANJI");
- sNUMERIC = new CBC_QRCoderMode({10, 12, 14}, 0x1, "NUMERIC");
- sGBK = new CBC_QRCoderMode({8, 10, 12}, 0x0D, "GBK");
- sTERMINATOR = new CBC_QRCoderMode(std::vector<int32_t>(), 0x00, "TERMINATOR");
- sFNC1_FIRST_POSITION =
- new CBC_QRCoderMode(std::vector<int32_t>(), 0x05, "FNC1_FIRST_POSITION");
- sFNC1_SECOND_POSITION =
- new CBC_QRCoderMode(std::vector<int32_t>(), 0x09, "FNC1_SECOND_POSITION");
- sSTRUCTURED_APPEND =
- new CBC_QRCoderMode(std::vector<int32_t>(), 0x03, "STRUCTURED_APPEND");
+ sBYTE = new CBC_QRCoderMode({8, 16, 16}, 0x4);
+ sALPHANUMERIC = new CBC_QRCoderMode({9, 11, 13}, 0x2);
+ sECI = new CBC_QRCoderMode(std::vector<int32_t>(), 0x7);
+ sKANJI = new CBC_QRCoderMode({8, 10, 12}, 0x8);
+ sNUMERIC = new CBC_QRCoderMode({10, 12, 14}, 0x1);
+ sGBK = new CBC_QRCoderMode({8, 10, 12}, 0x0D);
+ sTERMINATOR = new CBC_QRCoderMode(std::vector<int32_t>(), 0x00);
+ sFNC1_FIRST_POSITION = new CBC_QRCoderMode(std::vector<int32_t>(), 0x05);
+ sFNC1_SECOND_POSITION = new CBC_QRCoderMode(std::vector<int32_t>(), 0x09);
+ sSTRUCTURED_APPEND = new CBC_QRCoderMode(std::vector<int32_t>(), 0x03);
}
void CBC_QRCoderMode::Finalize() {
@@ -87,10 +83,6 @@
return m_bits;
}
-ByteString CBC_QRCoderMode::GetName() const {
- return m_name;
-}
-
int32_t CBC_QRCoderMode::GetCharacterCountBits(int32_t number) const {
if (m_characterCountBitsForVersions.empty())
return 0;
diff --git a/fxbarcode/qrcode/BC_QRCoderMode.h b/fxbarcode/qrcode/BC_QRCoderMode.h
index 10d8f37..ba762f0 100644
--- a/fxbarcode/qrcode/BC_QRCoderMode.h
+++ b/fxbarcode/qrcode/BC_QRCoderMode.h
@@ -11,8 +11,6 @@
#include <vector>
-#include "core/fxcrt/fx_string.h"
-
class CBC_QRCoderMode {
public:
virtual ~CBC_QRCoderMode();
@@ -22,7 +20,6 @@
int32_t GetCharacterCountBits(int32_t number) const;
int32_t GetBits() const;
- ByteString GetName() const;
static CBC_QRCoderMode* sBYTE;
static CBC_QRCoderMode* sNUMERIC;
@@ -36,14 +33,10 @@
static CBC_QRCoderMode* sSTRUCTURED_APPEND;
private:
- CBC_QRCoderMode();
- CBC_QRCoderMode(std::vector<int32_t> charCountBits,
- int32_t bits,
- ByteString name);
+ CBC_QRCoderMode(std::vector<int32_t> charCountBits, int32_t bits);
std::vector<int32_t> m_characterCountBitsForVersions;
const int32_t m_bits;
- const ByteString m_name;
};
#endif // FXBARCODE_QRCODE_BC_QRCODERMODE_H_