Remove CBC_PDF417::m_compact and m_compaction.

They are never changed from the defaults. So get rid of them and code
that depends on them. In turn, remove the Compaction enum, since the
only value ever present is AUTO.

Also move some initializations to header file.

Change-Id: I55761490ae9a9d9f66f5433464185ab81b04d314
Reviewed-on: https://pdfium-review.googlesource.com/c/45910
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxbarcode/pdf417/BC_PDF417.cpp b/fxbarcode/pdf417/BC_PDF417.cpp
index 0e7fa0a..12f8533 100644
--- a/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/fxbarcode/pdf417/BC_PDF417.cpp
@@ -382,17 +382,9 @@
      0x10396, 0x107b6, 0x187d4, 0x187d2, 0x10794, 0x10fb4, 0x10792, 0x10fb2,
      0x1c7ea}};
 
-CBC_PDF417::CBC_PDF417() : CBC_PDF417(false) {}
+CBC_PDF417::CBC_PDF417() = default;
 
-CBC_PDF417::CBC_PDF417(bool compact)
-    : m_compact(compact),
-      m_compaction(Compaction::AUTO),
-      m_minCols(1),
-      m_maxCols(30),
-      m_maxRows(90),
-      m_minRows(3) {}
-
-CBC_PDF417::~CBC_PDF417() {}
+CBC_PDF417::~CBC_PDF417() = default;
 
 CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() {
   return m_barcodeMatrix.get();
@@ -407,9 +399,10 @@
     return false;
 
   Optional<WideString> high_level =
-      CBC_PDF417HighLevelEncoder::EncodeHighLevel(msg, m_compaction);
+      CBC_PDF417HighLevelEncoder::EncodeHighLevel(msg);
   if (!high_level.has_value())
     return false;
+
   int32_t sourceCodeWords = high_level.value().GetLength();
   std::vector<int32_t> dimensions =
       determineDimensions(sourceCodeWords, errorCorrectionCodeWords);
@@ -452,14 +445,6 @@
   m_minRows = minRows;
 }
 
-void CBC_PDF417::setCompaction(Compaction compaction) {
-  m_compaction = compaction;
-}
-
-void CBC_PDF417::setCompact(bool compact) {
-  m_compact = compact;
-}
-
 int32_t CBC_PDF417::calculateNumberOfRows(int32_t m, int32_t k, int32_t c) {
   int32_t r = ((m + 1 + k) / c) + 1;
   if (c * r >= (m + 1 + k + c)) {
@@ -525,13 +510,9 @@
       encodeChar(pattern, 17, logicRow);
       idx++;
     }
-    if (m_compact) {
-      encodeChar(STOP_PATTERN, 1, logicRow);
-    } else {
-      pattern = CODEWORD_TABLE[cluster][right];
-      encodeChar(pattern, 17, logicRow);
-      encodeChar(STOP_PATTERN, 18, logicRow);
-    }
+    pattern = CODEWORD_TABLE[cluster][right];
+    encodeChar(pattern, 17, logicRow);
+    encodeChar(STOP_PATTERN, 18, logicRow);
   }
 }
 
diff --git a/fxbarcode/pdf417/BC_PDF417.h b/fxbarcode/pdf417/BC_PDF417.h
index 15f9560..390d4f1 100644
--- a/fxbarcode/pdf417/BC_PDF417.h
+++ b/fxbarcode/pdf417/BC_PDF417.h
@@ -17,11 +17,8 @@
 
 class CBC_PDF417 {
  public:
-  enum class Compaction { AUTO, TEXT, BYTES, NUMERIC };
-
   CBC_PDF417();
-  explicit CBC_PDF417(bool compact);
-  virtual ~CBC_PDF417();
+  ~CBC_PDF417();
 
   CBC_BarcodeMatrix* getBarcodeMatrix();
   bool generateBarcodeLogic(WideString msg, int32_t errorCorrectionLevel);
@@ -29,8 +26,6 @@
                      int32_t minCols,
                      int32_t maxRows,
                      int32_t minRows);
-  void setCompaction(Compaction compaction);
-  void setCompact(bool compact);
 
  private:
   static const int32_t START_PATTERN = 0x1fea8;
@@ -56,12 +51,10 @@
       int32_t errorCorrectionCodeWords) const;
 
   std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix;
-  bool m_compact;
-  Compaction m_compaction;
-  int32_t m_minCols;
-  int32_t m_maxCols;
-  int32_t m_maxRows;
-  int32_t m_minRows;
+  int32_t m_minCols = 1;
+  int32_t m_maxCols = 30;
+  int32_t m_minRows = 3;
+  int32_t m_maxRows = 90;
 };
 
 #endif  // FXBARCODE_PDF417_BC_PDF417_H_
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
index a00b1e3..1fdb0bc 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
@@ -93,8 +93,7 @@
 void CBC_PDF417HighLevelEncoder::Finalize() {}
 
 Optional<WideString> CBC_PDF417HighLevelEncoder::EncodeHighLevel(
-    const WideString& msg,
-    CBC_PDF417::Compaction compaction) {
+    const WideString& msg) {
   ByteString bytes = msg.ToUTF8();
   size_t len = bytes.GetLength();
   WideString result;
@@ -112,52 +111,43 @@
   sb.Reserve(len);
   size_t p = 0;
   SubMode textSubMode = SubMode::kAlpha;
-  if (compaction == CBC_PDF417::Compaction::TEXT) {
-    EncodeText(result, p, len, textSubMode, &sb);
-  } else if (compaction == CBC_PDF417::Compaction::BYTES) {
-    EncodeBinary(byteArr, p, byteArr.size(), EncodingMode::kByte, &sb);
-  } else if (compaction == CBC_PDF417::Compaction::NUMERIC) {
-    sb += kLatchToNumeric;
-    EncodeNumeric(result, p, len, &sb);
-  } else {
-    EncodingMode encodingMode = EncodingMode::kUnknown;
-    while (p < len) {
-      size_t n = DetermineConsecutiveDigitCount(result, p);
-      if (n >= 13) {
-        sb += kLatchToNumeric;
-        encodingMode = EncodingMode::kNumeric;
-        textSubMode = SubMode::kAlpha;
-        EncodeNumeric(result, p, n, &sb);
-        p += n;
-      } else {
-        size_t t = DetermineConsecutiveTextCount(result, p);
-        if (t >= 5 || n == len) {
-          if (encodingMode != EncodingMode::kText) {
-            sb += kLatchToText;
-            encodingMode = EncodingMode::kText;
-            textSubMode = SubMode::kAlpha;
-          }
-          textSubMode = EncodeText(result, p, t, textSubMode, &sb);
-          p += t;
-        } else {
-          Optional<size_t> b =
-              DetermineConsecutiveBinaryCount(result, &byteArr, p);
-          if (!b)
-            return {};
-
-          size_t b_value = b.value();
-          if (b_value == 0) {
-            b_value = 1;
-          }
-          if (b_value == 1 && encodingMode == EncodingMode::kText) {
-            EncodeBinary(byteArr, p, 1, EncodingMode::kText, &sb);
-          } else {
-            EncodeBinary(byteArr, p, b_value, encodingMode, &sb);
-            encodingMode = EncodingMode::kByte;
-            textSubMode = SubMode::kAlpha;
-          }
-          p += b_value;
+  EncodingMode encodingMode = EncodingMode::kUnknown;
+  while (p < len) {
+    size_t n = DetermineConsecutiveDigitCount(result, p);
+    if (n >= 13) {
+      sb += kLatchToNumeric;
+      encodingMode = EncodingMode::kNumeric;
+      textSubMode = SubMode::kAlpha;
+      EncodeNumeric(result, p, n, &sb);
+      p += n;
+    } else {
+      size_t t = DetermineConsecutiveTextCount(result, p);
+      if (t >= 5 || n == len) {
+        if (encodingMode != EncodingMode::kText) {
+          sb += kLatchToText;
+          encodingMode = EncodingMode::kText;
+          textSubMode = SubMode::kAlpha;
         }
+        textSubMode = EncodeText(result, p, t, textSubMode, &sb);
+        p += t;
+      } else {
+        Optional<size_t> b =
+            DetermineConsecutiveBinaryCount(result, &byteArr, p);
+        if (!b)
+          return {};
+
+        size_t b_value = b.value();
+        if (b_value == 0) {
+          b_value = 1;
+        }
+        if (b_value == 1 && encodingMode == EncodingMode::kText) {
+          EncodeBinary(byteArr, p, 1, EncodingMode::kText, &sb);
+        } else {
+          EncodeBinary(byteArr, p, b_value, encodingMode, &sb);
+          encodingMode = EncodingMode::kByte;
+          textSubMode = SubMode::kAlpha;
+        }
+        p += b_value;
       }
     }
   }
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h
index fb4f45d..30700e1 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h
@@ -19,12 +19,9 @@
   CBC_PDF417HighLevelEncoder() = delete;
   ~CBC_PDF417HighLevelEncoder() = delete;
 
-  static Optional<WideString> EncodeHighLevel(
-      const WideString& msg,
-      CBC_PDF417::Compaction compaction);
-
   static void Initialize();
   static void Finalize();
+  static Optional<WideString> EncodeHighLevel(const WideString& msg);
 
  private:
   enum class EncodingMode { kUnknown = 0, kText, kByte, kNumeric };