Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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/common/BC_CommonBitMatrix.h"
29#include "fxbarcode/datamatrix/BC_Encoder.h"
30#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
31
32CBC_EncoderContext::CBC_EncoderContext(const WideString& msg) {
33 ByteString dststr = msg.ToUTF8();
34 size_t c = dststr.GetLength();
35 WideString sb;
36 sb.Reserve(c);
37 for (size_t i = 0; i < c; i++) {
38 wchar_t ch = static_cast<wchar_t>(dststr[i] & 0xff);
39 if (ch == '?' && dststr[i] != '?') {
40 m_bHasCharactersOutsideISO88591Encoding = true;
41 }
42 sb += ch;
43 }
44 m_msg = std::move(sb);
45 m_codewords.Reserve(m_msg.GetLength());
46}
47
49
50void CBC_EncoderContext::setSkipAtEnd(int32_t count) {
51 m_skipAtEnd = count;
52}
54 return m_msg[m_pos];
55}
57 return m_msg[m_pos];
58}
59
60void CBC_EncoderContext::writeCodewords(const WideString& codewords) {
61 m_codewords += codewords;
62}
63
64void CBC_EncoderContext::writeCodeword(wchar_t codeword) {
65 m_codewords += codeword;
66}
67
69 return m_codewords.GetLength();
70}
71
76
80
82 return m_pos < getTotalMessageCharCount();
83}
84
86 return getTotalMessageCharCount() - m_pos;
87}
88
90 return UpdateSymbolInfo(getCodewordCount());
91}
92
94 if (!m_symbolInfo || len > m_symbolInfo->data_capacity()) {
95 m_symbolInfo = CBC_SymbolInfo::Lookup(len, m_bAllowRectangular);
96 if (!m_symbolInfo)
97 return false;
98 }
99 return true;
100}
101
103 m_bAllowRectangular = true;
104}
105
106size_t CBC_EncoderContext::getTotalMessageCharCount() {
107 return m_msg.GetLength() - m_skipAtEnd;
108}
void writeCodewords(const WideString &codewords)
void writeCodeword(wchar_t codeword)
CBC_HighLevelEncoder::Encoding m_newEncoding
void setSkipAtEnd(int32_t count)
bool UpdateSymbolInfo(size_t len)
void SignalEncoderChange(CBC_HighLevelEncoder::Encoding encoding)
CBC_EncoderContext(const WideString &msg)
ByteString ToUTF8() const
WideString & operator+=(wchar_t ch)