Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 7 | #ifndef FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ |
| 8 | #define FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 12 | #include "core/fxcrt/fx_string.h" |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 13 | #include "fxbarcode/pdf417/BC_PDF417Compaction.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 14 | |
| 15 | class CBC_PDF417HighLevelEncoder { |
| 16 | public: |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 17 | static WideString encodeHighLevel(WideString msg, |
| 18 | Compaction compaction, |
| 19 | int32_t& e); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 20 | static void Inverse(); |
| 21 | static void Initialize(); |
| 22 | static void Finalize(); |
| 23 | |
| 24 | private: |
| 25 | static int32_t TEXT_COMPACTION; |
| 26 | static int32_t BYTE_COMPACTION; |
| 27 | static int32_t NUMERIC_COMPACTION; |
| 28 | static int32_t SUBMODE_PUNCTUATION; |
| 29 | static int32_t LATCH_TO_TEXT; |
| 30 | static int32_t LATCH_TO_BYTE_PADDED; |
| 31 | static int32_t LATCH_TO_NUMERIC; |
| 32 | static int32_t SHIFT_TO_BYTE; |
| 33 | static int32_t LATCH_TO_BYTE; |
| 34 | static uint8_t TEXT_MIXED_RAW[]; |
| 35 | static uint8_t TEXT_PUNCTUATION_RAW[]; |
| 36 | static int32_t MIXED[128]; |
| 37 | static int32_t PUNCTUATION[128]; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 38 | static int32_t encodeText(WideString msg, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 39 | int32_t startpos, |
| 40 | int32_t count, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 41 | WideString& sb, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 42 | int32_t initialSubmode); |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 43 | static void encodeBinary(std::vector<uint8_t>* bytes, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 44 | int32_t startpos, |
| 45 | int32_t count, |
| 46 | int32_t startmode, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 47 | WideString& sb); |
| 48 | static void encodeNumeric(WideString msg, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 49 | int32_t startpos, |
| 50 | int32_t count, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 51 | WideString& sb); |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 52 | static bool isDigit(wchar_t ch); |
| 53 | static bool isAlphaUpper(wchar_t ch); |
| 54 | static bool isAlphaLower(wchar_t ch); |
| 55 | static bool isMixed(wchar_t ch); |
| 56 | static bool isPunctuation(wchar_t ch); |
| 57 | static bool isText(wchar_t ch); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 58 | static int32_t determineConsecutiveDigitCount(WideString msg, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 59 | int32_t startpos); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 60 | static int32_t determineConsecutiveTextCount(WideString msg, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 61 | int32_t startpos); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 62 | static int32_t determineConsecutiveBinaryCount(WideString msg, |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 63 | std::vector<uint8_t>* bytes, |
| 64 | int32_t startpos, |
| 65 | int32_t& e); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 66 | |
| 67 | friend class PDF417HighLevelEncoder_EncodeNumeric_Test; |
| 68 | friend class PDF417HighLevelEncoder_EncodeBinary_Test; |
| 69 | friend class PDF417HighLevelEncoder_EncodeText_Test; |
| 70 | friend class PDF417HighLevelEncoder_ConsecutiveDigitCount_Test; |
| 71 | friend class PDF417HighLevelEncoder_ConsecutiveTextCount_Test; |
| 72 | friend class PDF417HighLevelEncoder_ConsecutiveBinaryCount_Test; |
| 73 | }; |
| 74 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 75 | #endif // FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ |