OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2006-2007 Jeremias Maerki. | 8 * Copyright 2006-2007 Jeremias Maerki. |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
(...skipping 10 matching lines...) Expand all Loading... |
21 */ | 21 */ |
22 | 22 |
23 #include "../barcode.h" | 23 #include "../barcode.h" |
24 #include "../BC_Dimension.h" | 24 #include "../BC_Dimension.h" |
25 #include "../BC_UtilCodingConvert.h" | 25 #include "../BC_UtilCodingConvert.h" |
26 #include "../common/BC_CommonBitMatrix.h" | 26 #include "../common/BC_CommonBitMatrix.h" |
27 #include "BC_Encoder.h" | 27 #include "BC_Encoder.h" |
28 #include "BC_SymbolShapeHint.h" | 28 #include "BC_SymbolShapeHint.h" |
29 #include "BC_SymbolInfo.h" | 29 #include "BC_SymbolInfo.h" |
30 #include "BC_EncoderContext.h" | 30 #include "BC_EncoderContext.h" |
31 CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg, CFX_WideString
ecLevel, FX_INT32 &e) | 31 CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg, CFX_WideString
ecLevel, int32_t &e) |
32 { | 32 { |
33 CFX_ByteString dststr; | 33 CFX_ByteString dststr; |
34 CBC_UtilCodingConvert::UnicodeToUTF8(msg, dststr); | 34 CBC_UtilCodingConvert::UnicodeToUTF8(msg, dststr); |
35 CFX_WideString sb; | 35 CFX_WideString sb; |
36 FX_INT32 c = dststr.GetLength(); | 36 int32_t c = dststr.GetLength(); |
37 for (FX_INT32 i = 0; i < c; i++) { | 37 for (int32_t i = 0; i < c; i++) { |
38 FX_WCHAR ch = (FX_WCHAR)(dststr.GetAt(i) & 0xff); | 38 FX_WCHAR ch = (FX_WCHAR)(dststr.GetAt(i) & 0xff); |
39 if (ch == '?' && dststr.GetAt(i) != '?') { | 39 if (ch == '?' && dststr.GetAt(i) != '?') { |
40 e = BCExceptionCharactersOutsideISO88591Encoding; | 40 e = BCExceptionCharactersOutsideISO88591Encoding; |
41 } | 41 } |
42 sb += ch; | 42 sb += ch; |
43 } | 43 } |
44 m_msg = sb; | 44 m_msg = sb; |
45 m_shape = FORCE_NONE; | 45 m_shape = FORCE_NONE; |
46 m_newEncoding = -1; | 46 m_newEncoding = -1; |
47 m_pos = 0; | 47 m_pos = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
59 } | 59 } |
60 void CBC_EncoderContext::setSizeConstraints(CBC_Dimension* minSize, CBC_Dimensio
n* maxSize) | 60 void CBC_EncoderContext::setSizeConstraints(CBC_Dimension* minSize, CBC_Dimensio
n* maxSize) |
61 { | 61 { |
62 m_maxSize = maxSize; | 62 m_maxSize = maxSize; |
63 m_minSize = minSize; | 63 m_minSize = minSize; |
64 } | 64 } |
65 CFX_WideString CBC_EncoderContext::getMessage() | 65 CFX_WideString CBC_EncoderContext::getMessage() |
66 { | 66 { |
67 return m_msg; | 67 return m_msg; |
68 } | 68 } |
69 void CBC_EncoderContext::setSkipAtEnd(FX_INT32 count) | 69 void CBC_EncoderContext::setSkipAtEnd(int32_t count) |
70 { | 70 { |
71 m_skipAtEnd = count; | 71 m_skipAtEnd = count; |
72 } | 72 } |
73 FX_WCHAR CBC_EncoderContext::getCurrentChar() | 73 FX_WCHAR CBC_EncoderContext::getCurrentChar() |
74 { | 74 { |
75 return m_msg.GetAt(m_pos); | 75 return m_msg.GetAt(m_pos); |
76 } | 76 } |
77 FX_WCHAR CBC_EncoderContext::getCurrent() | 77 FX_WCHAR CBC_EncoderContext::getCurrent() |
78 { | 78 { |
79 return m_msg.GetAt(m_pos); | 79 return m_msg.GetAt(m_pos); |
80 } | 80 } |
81 void CBC_EncoderContext::writeCodewords(CFX_WideString codewords) | 81 void CBC_EncoderContext::writeCodewords(CFX_WideString codewords) |
82 { | 82 { |
83 m_codewords += codewords; | 83 m_codewords += codewords; |
84 } | 84 } |
85 void CBC_EncoderContext::writeCodeword(FX_WCHAR codeword) | 85 void CBC_EncoderContext::writeCodeword(FX_WCHAR codeword) |
86 { | 86 { |
87 m_codewords += codeword; | 87 m_codewords += codeword; |
88 } | 88 } |
89 FX_INT32 CBC_EncoderContext::getCodewordCount() | 89 int32_t CBC_EncoderContext::getCodewordCount() |
90 { | 90 { |
91 return m_codewords.GetLength(); | 91 return m_codewords.GetLength(); |
92 } | 92 } |
93 void CBC_EncoderContext::signalEncoderChange(FX_INT32 encoding) | 93 void CBC_EncoderContext::signalEncoderChange(int32_t encoding) |
94 { | 94 { |
95 m_newEncoding = encoding; | 95 m_newEncoding = encoding; |
96 } | 96 } |
97 void CBC_EncoderContext::resetEncoderSignal() | 97 void CBC_EncoderContext::resetEncoderSignal() |
98 { | 98 { |
99 m_newEncoding = -1; | 99 m_newEncoding = -1; |
100 } | 100 } |
101 FX_BOOL CBC_EncoderContext::hasMoreCharacters() | 101 FX_BOOL CBC_EncoderContext::hasMoreCharacters() |
102 { | 102 { |
103 return m_pos < getTotalMessageCharCount(); | 103 return m_pos < getTotalMessageCharCount(); |
104 } | 104 } |
105 FX_INT32 CBC_EncoderContext::getRemainingCharacters() | 105 int32_t CBC_EncoderContext::getRemainingCharacters() |
106 { | 106 { |
107 return getTotalMessageCharCount() - m_pos; | 107 return getTotalMessageCharCount() - m_pos; |
108 } | 108 } |
109 void CBC_EncoderContext::updateSymbolInfo(FX_INT32 &e) | 109 void CBC_EncoderContext::updateSymbolInfo(int32_t &e) |
110 { | 110 { |
111 updateSymbolInfo(getCodewordCount(), e); | 111 updateSymbolInfo(getCodewordCount(), e); |
112 } | 112 } |
113 void CBC_EncoderContext::updateSymbolInfo(FX_INT32 len, FX_INT32 &e) | 113 void CBC_EncoderContext::updateSymbolInfo(int32_t len, int32_t &e) |
114 { | 114 { |
115 if (m_symbolInfo == NULL || len > m_symbolInfo->m_dataCapacity) { | 115 if (m_symbolInfo == NULL || len > m_symbolInfo->m_dataCapacity) { |
116 m_symbolInfo = CBC_SymbolInfo::lookup(len, m_shape, m_minSize, m_maxSize
, true, e); | 116 m_symbolInfo = CBC_SymbolInfo::lookup(len, m_shape, m_minSize, m_maxSize
, true, e); |
117 BC_EXCEPTION_CHECK_ReturnVoid(e); | 117 BC_EXCEPTION_CHECK_ReturnVoid(e); |
118 } | 118 } |
119 } | 119 } |
120 void CBC_EncoderContext::resetSymbolInfo() | 120 void CBC_EncoderContext::resetSymbolInfo() |
121 { | 121 { |
122 m_shape = FORCE_NONE; | 122 m_shape = FORCE_NONE; |
123 } | 123 } |
124 FX_INT32 CBC_EncoderContext::getTotalMessageCharCount() | 124 int32_t CBC_EncoderContext::getTotalMessageCharCount() |
125 { | 125 { |
126 return m_msg.GetLength() - m_skipAtEnd; | 126 return m_msg.GetLength() - m_skipAtEnd; |
127 } | 127 } |
OLD | NEW |