summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h
blob: cf04c0661959e0b1a7e310bdc70855e81cf9a81f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_
#define XFA_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_

#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h"

#define ASCII_ENCODATION 0
#define C40_ENCODATION 1
#define TEXT_ENCODATION 2
#define X12_ENCODATION 3
#define EDIFACT_ENCODATION 4
#define BASE256_ENCODATION 5

class CBC_HighLevelEncoder : public CBC_SymbolShapeHint {
 public:
  CBC_HighLevelEncoder();
  ~CBC_HighLevelEncoder() override;

  CFX_ByteArray& getBytesForMessage(CFX_WideString msg);
  static CFX_WideString encodeHighLevel(CFX_WideString msg,
                                        CFX_WideString ecLevel,
                                        int32_t& e);
  static CFX_WideString encodeHighLevel(CFX_WideString msg,
                                        CFX_WideString ecLevel,
                                        SymbolShapeHint shape,
                                        CBC_Dimension* minSize,
                                        CBC_Dimension* maxSize,
                                        int32_t& e);
  static int32_t lookAheadTest(CFX_WideString msg,
                               int32_t startpos,
                               int32_t currentMode);
  static bool isDigit(FX_WCHAR ch);
  static bool isExtendedASCII(FX_WCHAR ch);
  static int32_t determineConsecutiveDigitCount(CFX_WideString msg,
                                                int32_t startpos);
  static void illegalCharacter(FX_WCHAR c, int32_t& e);

 public:
  static FX_WCHAR LATCH_TO_C40;
  static FX_WCHAR LATCH_TO_BASE256;
  static FX_WCHAR UPPER_SHIFT;
  static FX_WCHAR LATCH_TO_ANSIX12;
  static FX_WCHAR LATCH_TO_TEXT;
  static FX_WCHAR LATCH_TO_EDIFACT;
  static FX_WCHAR C40_UNLATCH;
  static FX_WCHAR X12_UNLATCH;

 private:
  static FX_WCHAR PAD;
  static FX_WCHAR MACRO_05;
  static FX_WCHAR MACRO_06;
  static const wchar_t* MACRO_05_HEADER;
  static const wchar_t* MACRO_06_HEADER;
  static const wchar_t MACRO_TRAILER;
  CFX_ByteArray m_bytearray;

 private:
  static FX_WCHAR randomize253State(FX_WCHAR ch, int32_t codewordPosition);
  static int32_t findMinimums(CFX_FloatArray& charCounts,
                              CFX_Int32Array& intCharCounts,
                              int32_t min,
                              CFX_ByteArray& mins);
  static int32_t getMinimumCount(CFX_ByteArray& mins);
  static bool isNativeC40(FX_WCHAR ch);
  static bool isNativeText(FX_WCHAR ch);
  static bool isNativeX12(FX_WCHAR ch);
  static bool isX12TermSep(FX_WCHAR ch);
  static bool isNativeEDIFACT(FX_WCHAR ch);
  static bool isSpecialB256(FX_WCHAR ch);
};

#endif  // XFA_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_