Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: xfa/src/fxbarcode/src/BC_EncoderContext.cpp

Issue 842043002: Organize barcode codes into modules. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fxbarcode/src/BC_Encoder.cpp ('k') | xfa/src/fxbarcode/src/BC_ErrorCorrection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 // 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 "barcode.h"
24 #include "include/BC_Encoder.h"
25 #include "include/BC_CommonBitMatrix.h"
26 #include "include/BC_Dimension.h"
27 #include "include/BC_SymbolShapeHint.h"
28 #include "include/BC_SymbolInfo.h"
29 #include "include/BC_EncoderContext.h"
30 #include "include/BC_UtilCodingConvert.h"
31 CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg, CFX_WideString ecLevel, FX_INT32 &e)
32 {
33 CFX_ByteString dststr;
34 CBC_UtilCodingConvert::UnicodeToUTF8(msg, dststr);
35 CFX_WideString sb;
36 FX_INT32 c = dststr.GetLength();
37 for (FX_INT32 i = 0; i < c; i++) {
38 FX_WCHAR ch = (FX_WCHAR)(dststr.GetAt(i) & 0xff);
39 if (ch == '?' && dststr.GetAt(i) != '?') {
40 e = BCExceptionCharactersOutsideISO88591Encoding;
41 }
42 sb += ch;
43 }
44 m_msg = sb;
45 m_shape = FORCE_NONE;
46 m_newEncoding = -1;
47 m_pos = 0;
48 m_symbolInfo = NULL;
49 m_skipAtEnd = 0;
50 m_maxSize = NULL;
51 m_minSize = NULL;
52 }
53 CBC_EncoderContext::~CBC_EncoderContext()
54 {
55 }
56 void CBC_EncoderContext::setSymbolShape(SymbolShapeHint shape)
57 {
58 m_shape = shape;
59 }
60 void CBC_EncoderContext::setSizeConstraints(CBC_Dimension* minSize, CBC_Dimensio n* maxSize)
61 {
62 m_maxSize = maxSize;
63 m_minSize = minSize;
64 }
65 CFX_WideString CBC_EncoderContext::getMessage()
66 {
67 return m_msg;
68 }
69 void CBC_EncoderContext::setSkipAtEnd(FX_INT32 count)
70 {
71 m_skipAtEnd = count;
72 }
73 FX_WCHAR CBC_EncoderContext::getCurrentChar()
74 {
75 return m_msg.GetAt(m_pos);
76 }
77 FX_WCHAR CBC_EncoderContext::getCurrent()
78 {
79 return m_msg.GetAt(m_pos);
80 }
81 void CBC_EncoderContext::writeCodewords(CFX_WideString codewords)
82 {
83 m_codewords += codewords;
84 }
85 void CBC_EncoderContext::writeCodeword(FX_WCHAR codeword)
86 {
87 m_codewords += codeword;
88 }
89 FX_INT32 CBC_EncoderContext::getCodewordCount()
90 {
91 return m_codewords.GetLength();
92 }
93 void CBC_EncoderContext::signalEncoderChange(FX_INT32 encoding)
94 {
95 m_newEncoding = encoding;
96 }
97 void CBC_EncoderContext::resetEncoderSignal()
98 {
99 m_newEncoding = -1;
100 }
101 FX_BOOL CBC_EncoderContext::hasMoreCharacters()
102 {
103 return m_pos < getTotalMessageCharCount();
104 }
105 FX_INT32 CBC_EncoderContext::getRemainingCharacters()
106 {
107 return getTotalMessageCharCount() - m_pos;
108 }
109 void CBC_EncoderContext::updateSymbolInfo(FX_INT32 &e)
110 {
111 updateSymbolInfo(getCodewordCount(), e);
112 }
113 void CBC_EncoderContext::updateSymbolInfo(FX_INT32 len, FX_INT32 &e)
114 {
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);
117 BC_EXCEPTION_CHECK_ReturnVoid(e);
118 }
119 }
120 void CBC_EncoderContext::resetSymbolInfo()
121 {
122 m_shape = FORCE_NONE;
123 }
124 FX_INT32 CBC_EncoderContext::getTotalMessageCharCount()
125 {
126 return m_msg.GetLength() - m_skipAtEnd;
127 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/src/BC_Encoder.cpp ('k') | xfa/src/fxbarcode/src/BC_ErrorCorrection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698