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 XFA_FXBARCODE_PDF417_BC_PDF417_H_ 8 #define XFA_FXBARCODE_PDF417_BC_PDF417_H_ 9 10 #include <memory> 11 12 #include "core/fxcrt/fx_basic.h" 13 #include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" 14 15 class CBC_BarcodeRow; 16 class CBC_BarcodeMatrix; 17 18 class CBC_PDF417 { 19 public: 20 CBC_PDF417(); 21 explicit CBC_PDF417(bool compact); 22 virtual ~CBC_PDF417(); 23 24 CBC_BarcodeMatrix* getBarcodeMatrix(); 25 void generateBarcodeLogic(CFX_WideString msg, 26 int32_t errorCorrectionLevel, 27 int32_t& e); 28 void setDimensions(int32_t maxCols, 29 int32_t minCols, 30 int32_t maxRows, 31 int32_t minRows); 32 void setCompaction(Compaction compaction); 33 void setCompact(bool compact); 34 35 private: 36 static const int32_t START_PATTERN = 0x1fea8; 37 static const int32_t STOP_PATTERN = 0x3fa29; 38 static const int32_t CODEWORD_TABLE[][929]; 39 static constexpr FX_FLOAT PREFERRED_RATIO = 3.0f; 40 static constexpr FX_FLOAT DEFAULT_MODULE_WIDTH = 0.357f; 41 static constexpr FX_FLOAT HEIGHT = 2.0f; 42 43 static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c); 44 static int32_t getNumberOfPadCodewords(int32_t m, 45 int32_t k, 46 int32_t c, 47 int32_t r); 48 static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic); 49 void encodeLowLevel(CFX_WideString fullCodewords, 50 int32_t c, 51 int32_t r, 52 int32_t errorCorrectionLevel, 53 CBC_BarcodeMatrix* logic); 54 CFX_ArrayTemplate<int32_t>* determineDimensions( 55 int32_t sourceCodeWords, 56 int32_t errorCorrectionCodeWords, 57 int32_t& e); 58 59 std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix; 60 bool m_compact; 61 Compaction m_compaction; 62 int32_t m_minCols; 63 int32_t m_maxCols; 64 int32_t m_maxRows; 65 int32_t m_minRows; 66 }; 67 68 #endif // XFA_FXBARCODE_PDF417_BC_PDF417_H_ 69