blob: 0d8fbfaf5f9a6dd7171ec2304601c0c97833b984 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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
weilie76203d2016-08-09 13:45:03 -070010#include <memory>
Tom Sepez8b6186f2017-03-28 12:06:45 -070011#include <vector>
weilie76203d2016-08-09 13:45:03 -070012
dsinclaira52ab742016-09-29 13:59:29 -070013#include "core/fxcrt/fx_basic.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040014#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h"
15
16class CBC_BarcodeRow;
17class CBC_BarcodeMatrix;
18
19class CBC_PDF417 {
20 public:
21 CBC_PDF417();
tsepezd19e9122016-11-02 15:43:18 -070022 explicit CBC_PDF417(bool compact);
Dan Sinclair1770c022016-03-14 14:14:16 -040023 virtual ~CBC_PDF417();
weili29b8ad02016-06-14 18:20:04 -070024
Dan Sinclair1770c022016-03-14 14:14:16 -040025 CBC_BarcodeMatrix* getBarcodeMatrix();
26 void generateBarcodeLogic(CFX_WideString msg,
27 int32_t errorCorrectionLevel,
28 int32_t& e);
29 void setDimensions(int32_t maxCols,
30 int32_t minCols,
31 int32_t maxRows,
32 int32_t minRows);
33 void setCompaction(Compaction compaction);
tsepezd19e9122016-11-02 15:43:18 -070034 void setCompact(bool compact);
Dan Sinclair1770c022016-03-14 14:14:16 -040035
36 private:
Tom Sepez314743a2016-03-18 09:32:06 -070037 static const int32_t START_PATTERN = 0x1fea8;
38 static const int32_t STOP_PATTERN = 0x3fa29;
39 static const int32_t CODEWORD_TABLE[][929];
Dan Sinclair05df0752017-03-14 14:43:42 -040040 static constexpr float PREFERRED_RATIO = 3.0f;
41 static constexpr float DEFAULT_MODULE_WIDTH = 0.357f;
42 static constexpr float HEIGHT = 2.0f;
Dan Sinclair1770c022016-03-14 14:14:16 -040043
Dan Sinclair1770c022016-03-14 14:14:16 -040044 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);
Tom Sepez8b6186f2017-03-28 12:06:45 -070055 std::vector<int32_t>* determineDimensions(int32_t sourceCodeWords,
56 int32_t errorCorrectionCodeWords,
57 int32_t& e);
weilie76203d2016-08-09 13:45:03 -070058
59 std::unique_ptr<CBC_BarcodeMatrix> m_barcodeMatrix;
tsepezd19e9122016-11-02 15:43:18 -070060 bool m_compact;
weilie76203d2016-08-09 13:45:03 -070061 Compaction m_compaction;
62 int32_t m_minCols;
63 int32_t m_maxCols;
64 int32_t m_maxRows;
65 int32_t m_minRows;
Dan Sinclair1770c022016-03-14 14:14:16 -040066};
67
68#endif // XFA_FXBARCODE_PDF417_BC_PDF417_H_