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 _BC_PDF417_H_
8 #define _BC_PDF417_H_
9 class CBC_Compaction;
10 class CBC_BarcodeRow;
11 class CBC_BarcodeMatrix;
12 class CBC_PDF417 {
13  public:
14   CBC_PDF417();
15   CBC_PDF417(FX_BOOL compact);
16   virtual ~CBC_PDF417();
17   CBC_BarcodeMatrix* getBarcodeMatrix();
18   void generateBarcodeLogic(CFX_WideString msg,
19                             int32_t errorCorrectionLevel,
20                             int32_t& e);
21   void setDimensions(int32_t maxCols,
22                      int32_t minCols,
23                      int32_t maxRows,
24                      int32_t minRows);
25   void setCompaction(Compaction compaction);
26   void setCompact(FX_BOOL compact);
27 
28  private:
29   static int32_t START_PATTERN;
30   static int32_t STOP_PATTERN;
31   static int32_t CODEWORD_TABLE[][1000];
32   static FX_FLOAT PREFERRED_RATIO;
33   static FX_FLOAT DEFAULT_MODULE_WIDTH;
34   static FX_FLOAT HEIGHT;
35   CBC_BarcodeMatrix* m_barcodeMatrix;
36   FX_BOOL m_compact;
37   Compaction m_compaction;
38   int32_t m_minCols;
39   int32_t m_maxCols;
40   int32_t m_maxRows;
41   int32_t m_minRows;
42 
43  private:
44   static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c);
45   static int32_t getNumberOfPadCodewords(int32_t m,
46                                          int32_t k,
47                                          int32_t c,
48                                          int32_t r);
49   static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic);
50   void encodeLowLevel(CFX_WideString fullCodewords,
51                       int32_t c,
52                       int32_t r,
53                       int32_t errorCorrectionLevel,
54                       CBC_BarcodeMatrix* logic);
55   CFX_Int32Array* determineDimensions(int32_t sourceCodeWords,
56                                       int32_t errorCorrectionCodeWords,
57                                       int32_t& e);
58 };
59 #endif
60