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_DATAMATRIX_BC_ENCODERCONTEXT_H_ |
| 8 | #define FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame^] | 10 | #include "core/fxcrt/cfx_unowned_ptr.h" |
Lei Zhang | 60cd033 | 2017-04-27 23:58:03 -0700 | [diff] [blame] | 11 | #include "core/fxcrt/cfx_widestring.h" |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 12 | #include "fxbarcode/datamatrix/BC_SymbolShapeHint.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 13 | |
| 14 | class CBC_SymbolInfo; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 15 | |
Lei Zhang | a861a7b | 2017-05-23 14:37:27 -0700 | [diff] [blame] | 16 | class CBC_EncoderContext { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 17 | public: |
Lei Zhang | 60cd033 | 2017-04-27 23:58:03 -0700 | [diff] [blame] | 18 | CBC_EncoderContext(const CFX_WideString& msg, |
| 19 | const CFX_WideString& ecLevel, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 20 | int32_t& e); |
Lei Zhang | a861a7b | 2017-05-23 14:37:27 -0700 | [diff] [blame] | 21 | ~CBC_EncoderContext(); |
weili | 29b8ad0 | 2016-06-14 18:20:04 -0700 | [diff] [blame] | 22 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 23 | void setSymbolShape(SymbolShapeHint shape); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 24 | void setSkipAtEnd(int32_t count); |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 25 | wchar_t getCurrentChar(); |
| 26 | wchar_t getCurrent(); |
Lei Zhang | 60cd033 | 2017-04-27 23:58:03 -0700 | [diff] [blame] | 27 | void writeCodewords(const CFX_WideString& codewords); |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 28 | void writeCodeword(wchar_t codeword); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 29 | int32_t getCodewordCount(); |
| 30 | void signalEncoderChange(int32_t encoding); |
| 31 | void resetEncoderSignal(); |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 32 | bool hasMoreCharacters(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 33 | int32_t getRemainingCharacters(); |
| 34 | void updateSymbolInfo(int32_t& e); |
| 35 | void updateSymbolInfo(int32_t len, int32_t& e); |
| 36 | void resetSymbolInfo(); |
| 37 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 38 | CFX_WideString m_msg; |
| 39 | CFX_WideString m_codewords; |
| 40 | int32_t m_pos; |
| 41 | int32_t m_newEncoding; |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame^] | 42 | CFX_UnownedPtr<CBC_SymbolInfo> m_symbolInfo; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 43 | |
| 44 | private: |
| 45 | int32_t getTotalMessageCharCount(); |
| 46 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 47 | SymbolShapeHint m_shape; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 48 | int32_t m_skipAtEnd; |
| 49 | }; |
| 50 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 51 | #endif // FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ |