Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
BC_EncoderContext.cpp
Go to the documentation of this file.
1
// Copyright 2014 The PDFium Authors
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
// Original code is licensed as follows:
7
/*
8
* Copyright 2006-2007 Jeremias Maerki.
9
*
10
* Licensed under the Apache License, Version 2.0 (the "License");
11
* you may not use this file except in compliance with the License.
12
* You may obtain a copy of the License at
13
*
14
* http://www.apache.org/licenses/LICENSE-2.0
15
*
16
* Unless required by applicable law or agreed to in writing, software
17
* distributed under the License is distributed on an "AS IS" BASIS,
18
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
* See the License for the specific language governing permissions and
20
* limitations under the License.
21
*/
22
23
#
include
"fxbarcode/datamatrix/BC_EncoderContext.h"
24
25
#
include
<
utility
>
26
27
#
include
"core/fxcrt/fx_string.h"
28
#
include
"fxbarcode/datamatrix/BC_Encoder.h"
29
#
include
"fxbarcode/datamatrix/BC_SymbolInfo.h"
30
31
CBC_EncoderContext
::
CBC_EncoderContext
(
const
WideString
& msg) {
32
ByteString
dststr = msg
.
ToUTF8
(
)
;
33
size_t c = dststr.GetLength();
34
WideString
sb;
35
sb.Reserve(c);
36
for
(size_t i = 0; i < c; i++) {
37
wchar_t
ch =
static_cast
<
wchar_t
>(dststr[i] & 0xff);
38
if
(ch ==
'?'
&& dststr[i] !=
'?'
) {
39
m_bHasCharactersOutsideISO88591Encoding =
true
;
40
}
41
sb
+=
ch;
42
}
43
m_msg = std::move(sb);
44
m_codewords.Reserve(m_msg.GetLength());
45
}
46
47
CBC_EncoderContext
::~
CBC_EncoderContext
() =
default
;
48
49
void
CBC_EncoderContext
::
setSkipAtEnd
(int32_t count) {
50
m_skipAtEnd = count;
51
}
52
wchar_t
CBC_EncoderContext
::
getCurrentChar
() {
53
return
m_msg[m_pos];
54
}
55
wchar_t
CBC_EncoderContext
::
getCurrent
() {
56
return
m_msg[m_pos];
57
}
58
59
void
CBC_EncoderContext
::
writeCodewords
(
const
WideString
& codewords) {
60
m_codewords += codewords;
61
}
62
63
void
CBC_EncoderContext
::
writeCodeword
(
wchar_t
codeword) {
64
m_codewords += codeword;
65
}
66
67
size_t
CBC_EncoderContext
::
getCodewordCount
() {
68
return
m_codewords.GetLength();
69
}
70
71
void
CBC_EncoderContext
::
SignalEncoderChange
(
72
CBC_HighLevelEncoder
::
Encoding
encoding) {
73
m_newEncoding
= encoding;
74
}
75
76
void
CBC_EncoderContext
::
ResetEncoderSignal
() {
77
m_newEncoding
=
CBC_HighLevelEncoder
::
Encoding
::
UNKNOWN
;
78
}
79
80
bool
CBC_EncoderContext
::
hasMoreCharacters
() {
81
return
m_pos < getTotalMessageCharCount();
82
}
83
84
size_t
CBC_EncoderContext
::
getRemainingCharacters
() {
85
return
getTotalMessageCharCount() - m_pos;
86
}
87
88
bool
CBC_EncoderContext
::
UpdateSymbolInfo
() {
89
return
UpdateSymbolInfo
(getCodewordCount());
90
}
91
92
bool
CBC_EncoderContext
::
UpdateSymbolInfo
(size_t len) {
93
if
(!m_symbolInfo || len > m_symbolInfo->data_capacity()) {
94
m_symbolInfo = CBC_SymbolInfo::Lookup(len, m_bAllowRectangular);
95
if
(!m_symbolInfo)
96
return
false
;
97
}
98
return
true
;
99
}
100
101
void
CBC_EncoderContext
::
resetSymbolInfo
() {
102
m_bAllowRectangular =
true
;
103
}
104
105
size_t
CBC_EncoderContext
::getTotalMessageCharCount() {
106
return
m_msg.GetLength() - m_skipAtEnd;
107
}
ByteString
fxcrt::ByteString ByteString
Definition
bytestring.h:180
CBC_EncoderContext
Definition
BC_EncoderContext.h:16
CBC_EncoderContext::writeCodewords
void writeCodewords(const WideString &codewords)
Definition
BC_EncoderContext.cpp:59
CBC_EncoderContext::ResetEncoderSignal
void ResetEncoderSignal()
Definition
BC_EncoderContext.cpp:76
CBC_EncoderContext::writeCodeword
void writeCodeword(wchar_t codeword)
Definition
BC_EncoderContext.cpp:63
CBC_EncoderContext::getCurrentChar
wchar_t getCurrentChar()
Definition
BC_EncoderContext.cpp:52
CBC_EncoderContext::getRemainingCharacters
size_t getRemainingCharacters()
Definition
BC_EncoderContext.cpp:84
CBC_EncoderContext::~CBC_EncoderContext
~CBC_EncoderContext()
CBC_EncoderContext::m_newEncoding
CBC_HighLevelEncoder::Encoding m_newEncoding
Definition
BC_EncoderContext.h:42
CBC_EncoderContext::setSkipAtEnd
void setSkipAtEnd(int32_t count)
Definition
BC_EncoderContext.cpp:49
CBC_EncoderContext::resetSymbolInfo
void resetSymbolInfo()
Definition
BC_EncoderContext.cpp:101
CBC_EncoderContext::getCodewordCount
size_t getCodewordCount()
Definition
BC_EncoderContext.cpp:67
CBC_EncoderContext::UpdateSymbolInfo
bool UpdateSymbolInfo(size_t len)
Definition
BC_EncoderContext.cpp:92
CBC_EncoderContext::UpdateSymbolInfo
bool UpdateSymbolInfo()
Definition
BC_EncoderContext.cpp:88
CBC_EncoderContext::hasMoreCharacters
bool hasMoreCharacters()
Definition
BC_EncoderContext.cpp:80
CBC_EncoderContext::SignalEncoderChange
void SignalEncoderChange(CBC_HighLevelEncoder::Encoding encoding)
Definition
BC_EncoderContext.cpp:71
CBC_EncoderContext::CBC_EncoderContext
CBC_EncoderContext(const WideString &msg)
Definition
BC_EncoderContext.cpp:31
CBC_EncoderContext::getCurrent
wchar_t getCurrent()
Definition
BC_EncoderContext.cpp:55
CBC_HighLevelEncoder
Definition
BC_HighLevelEncoder.h:12
CBC_HighLevelEncoder::Encoding
Encoding
Definition
BC_HighLevelEncoder.h:14
CBC_HighLevelEncoder::Encoding::UNKNOWN
@ UNKNOWN
Definition
BC_HighLevelEncoder.h:15
fxcrt::WideString::ToUTF8
ByteString ToUTF8() const
Definition
widestring.cpp:605
fxcrt::WideString::operator+=
WideString & operator+=(wchar_t ch)
Definition
widestring.cpp:486
WideString
fxcrt::WideString WideString
Definition
widestring.h:207
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxbarcode
datamatrix
BC_EncoderContext.cpp
Generated on
for Qt by
1.18.0