1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef FXBARCODE_PDF417_BC_PDF417_H_ 8 #define FXBARCODE_PDF417_BC_PDF417_H_ 9 10 #include <memory> 11 #include <vector> 12 13 #include "core/fxcrt/fx_string.h" 14 #include "fxbarcode/pdf417/BC_PDF417Compaction.h" 15 16 class CBC_BarcodeRow; 17 class CBC_BarcodeMatrix; 18 19 class CBC_PDF417 { 20 public: 21 CBC_PDF417(); 22 explicit CBC_PDF417(bool compact); 23 virtual ~CBC_PDF417(); 24 25 CBC_BarcodeMatrix* getBarcodeMatrix(); 26 bool generateBarcodeLogic(WideString msg, int32_t errorCorrectionLevel); 27 void setDimensions(int32_t maxCols, 28 int32_t minCols, 29 int32_t maxRows, 30 int32_t minRows); 31 void setCompaction(Compaction compaction); 32 void setCompact(bool compact); 33 34 private: 35 static const int32_t START_PATTERN = 0x1fea8; 36 static const int32_t STOP_PATTERN = 0x3fa29; 37 static const int32_t CODEWORD_TABLE[][929]; 38 static constexpr float PREFERRED_RATIO = 3.0f; 39 static constexpr float DEFAULT_MODULE_WIDTH = 0.357f; 40 static constexpr float HEIGHT = 2.0f; 41 42 static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c); 43 static int32_t getNumberOfPadCodewords(int32_t m, 44 int32_t k, 45 int32_t c, 46 int32_t r); 47 static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic); 48 void encodeLowLevel(WideString fullCodewords, 49 int32_t c, 50 int32_t r, 51 int32_t errorCorrectionLevel, 52 CBC_BarcodeMatrix* logic); 53 std::vector<int32_t> determineDimensions( 54 int32_t sourceCodeWords, 55 int32_t errorCorrectionCodeWords) const; 56 57 std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix; 58 bool m_compact; 59 Compaction m_compaction; 60 int32_t m_minCols; 61 int32_t m_maxCols; 62 int32_t m_maxRows; 63 int32_t m_minRows; 64 }; 65 66 #endif // FXBARCODE_PDF417_BC_PDF417_H_ 67