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