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_SRC_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ 8 #define XFA_SRC_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ 9 10 #include "core/include/fxcrt/fx_basic.h" 11 #include "core/include/fxcrt/fx_string.h" 12 #include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" 13 14 class CBC_PDF417HighLevelEncoder { 15 public: 16 static CFX_WideString encodeHighLevel(CFX_WideString msg, 17 Compaction compaction, 18 int32_t& e); 19 static void Inverse(); 20 static void Initialize(); 21 static void Finalize(); 22 23 private: 24 static int32_t TEXT_COMPACTION; 25 static int32_t BYTE_COMPACTION; 26 static int32_t NUMERIC_COMPACTION; 27 static int32_t SUBMODE_PUNCTUATION; 28 static int32_t LATCH_TO_TEXT; 29 static int32_t LATCH_TO_BYTE_PADDED; 30 static int32_t LATCH_TO_NUMERIC; 31 static int32_t SHIFT_TO_BYTE; 32 static int32_t LATCH_TO_BYTE; 33 static uint8_t TEXT_MIXED_RAW[]; 34 static uint8_t TEXT_PUNCTUATION_RAW[]; 35 static int32_t MIXED[128]; 36 static int32_t PUNCTUATION[128]; 37 static int32_t encodeText(CFX_WideString msg, 38 int32_t startpos, 39 int32_t count, 40 CFX_WideString& sb, 41 int32_t initialSubmode); 42 static void encodeBinary(CFX_ByteArray* bytes, 43 int32_t startpos, 44 int32_t count, 45 int32_t startmode, 46 CFX_WideString& sb); 47 static void encodeNumeric(CFX_WideString msg, 48 int32_t startpos, 49 int32_t count, 50 CFX_WideString& sb); 51 static FX_BOOL isDigit(FX_WCHAR ch); 52 static FX_BOOL isAlphaUpper(FX_WCHAR ch); 53 static FX_BOOL isAlphaLower(FX_WCHAR ch); 54 static FX_BOOL isMixed(FX_WCHAR ch); 55 static FX_BOOL isPunctuation(FX_WCHAR ch); 56 static FX_BOOL isText(FX_WCHAR ch); 57 static int32_t determineConsecutiveDigitCount(CFX_WideString msg, 58 int32_t startpos); 59 static int32_t determineConsecutiveTextCount(CFX_WideString msg, 60 int32_t startpos); 61 static int32_t determineConsecutiveBinaryCount(CFX_WideString msg, 62 CFX_ByteArray* bytes, 63 int32_t startpos, 64 int32_t& e); 65 66 friend class PDF417HighLevelEncoder_EncodeNumeric_Test; 67 friend class PDF417HighLevelEncoder_EncodeBinary_Test; 68 friend class PDF417HighLevelEncoder_EncodeText_Test; 69 friend class PDF417HighLevelEncoder_ConsecutiveDigitCount_Test; 70 friend class PDF417HighLevelEncoder_ConsecutiveTextCount_Test; 71 friend class PDF417HighLevelEncoder_ConsecutiveBinaryCount_Test; 72 }; 73 74 #endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ 75