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

Side by Side Diff: xfa/src/fxbarcode/src/BC_QRCoderMode.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
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 2007 ZXing authors
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_QRCoderVersion.h"
25 #include "include/BC_QRCoderMode.h"
26 CBC_QRCoderMode* CBC_QRCoderMode::sBYTE = NULL;
27 CBC_QRCoderMode* CBC_QRCoderMode::sNUMERIC = NULL;
28 CBC_QRCoderMode* CBC_QRCoderMode::sALPHANUMERIC = NULL;
29 CBC_QRCoderMode* CBC_QRCoderMode::sKANJI = NULL;
30 CBC_QRCoderMode* CBC_QRCoderMode::sECI = NULL;
31 CBC_QRCoderMode* CBC_QRCoderMode::sGBK = NULL;
32 CBC_QRCoderMode* CBC_QRCoderMode::sTERMINATOR = NULL;
33 CBC_QRCoderMode* CBC_QRCoderMode::sFNC1_FIRST_POSITION = NULL;
34 CBC_QRCoderMode* CBC_QRCoderMode::sFNC1_SECOND_POSITION = NULL;
35 CBC_QRCoderMode* CBC_QRCoderMode::sSTRUCTURED_APPEND = NULL;
36 CBC_QRCoderMode::CBC_QRCoderMode(FX_INT32 *characterCountBitsForVersions,
37 FX_INT32 x1, FX_INT32 x2, FX_INT32 x3,
38 FX_INT32 bits, CFX_ByteString name)
39 {
40 m_characterCountBitsForVersions = characterCountBitsForVersions;
41 if (m_characterCountBitsForVersions != NULL) {
42 m_characterCountBitsForVersions[0] = x1;
43 m_characterCountBitsForVersions[1] = x2;
44 m_characterCountBitsForVersions[2] = x3;
45 }
46 m_name += name;
47 m_bits = bits;
48 }
49 CBC_QRCoderMode::~CBC_QRCoderMode()
50 {
51 if(m_characterCountBitsForVersions != NULL) {
52 FX_Free(m_characterCountBitsForVersions);
53 }
54 }
55 void CBC_QRCoderMode::Initialize()
56 {
57 sBYTE = FX_NEW CBC_QRCoderMode(FX_Alloc(FX_INT32, 3), 8, 16, 16, 0x4, "BYTE" );
58 sALPHANUMERIC = FX_NEW CBC_QRCoderMode(FX_Alloc(FX_INT32, 3), 9, 11, 13, 0x2 , "ALPHANUMERIC");
59 sECI = FX_NEW CBC_QRCoderMode(NULL, 0, 0, 0, 0x7, "ECI");
60 sKANJI = FX_NEW CBC_QRCoderMode(FX_Alloc(FX_INT32, 3), 8, 10, 12, 0x8, "KANJ I");
61 sNUMERIC = FX_NEW CBC_QRCoderMode(FX_Alloc(FX_INT32, 3), 10, 12, 14, 0x1, "N UMERIC");
62 sGBK = FX_NEW CBC_QRCoderMode(FX_Alloc(FX_INT32, 3), 8, 10, 12, 0x0D, "GBK") ;
63 sTERMINATOR = FX_NEW CBC_QRCoderMode(FX_Alloc(FX_INT32, 3), 0, 0, 0, 0x00, " TERMINATOR");
64 sFNC1_FIRST_POSITION = FX_NEW CBC_QRCoderMode(NULL, 0, 0, 0, 0x05, "FNC1_FIR ST_POSITION");
65 sFNC1_SECOND_POSITION = FX_NEW CBC_QRCoderMode(NULL, 0, 0, 0, 0x09, "FNC1_SE COND_POSITION");
66 sSTRUCTURED_APPEND = FX_NEW CBC_QRCoderMode(FX_Alloc(FX_INT32, 3), 0, 0, 0, 0x03, "STRUCTURED_APPEND");
67 }
68 void CBC_QRCoderMode::Finalize()
69 {
70 delete sBYTE;
71 delete sALPHANUMERIC;
72 delete sECI;
73 delete sKANJI;
74 delete sNUMERIC;
75 delete sGBK;
76 delete sTERMINATOR;
77 delete sFNC1_FIRST_POSITION;
78 delete sFNC1_SECOND_POSITION;
79 delete sSTRUCTURED_APPEND;
80 }
81 CBC_QRCoderMode* CBC_QRCoderMode::ForBits(FX_INT32 bits, FX_INT32 &e)
82 {
83 switch (bits) {
84 case 0x0:
85 return sTERMINATOR;
86 case 0x1:
87 return sNUMERIC;
88 case 0x2:
89 return sALPHANUMERIC;
90 case 0x3:
91 return sSTRUCTURED_APPEND;
92 case 0x4:
93 return sBYTE;
94 case 0x5:
95 return sFNC1_FIRST_POSITION;
96 case 0x7:
97 return sECI;
98 case 0x8:
99 return sKANJI;
100 case 0x9:
101 return sFNC1_SECOND_POSITION;
102 case 0x0D:
103 return sGBK;
104 default: {
105 e = BCExceptionUnsupportedMode;
106 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
107 }
108 }
109 return NULL;
110 }
111 FX_INT32 CBC_QRCoderMode::GetBits()
112 {
113 return m_bits;
114 }
115 CFX_ByteString CBC_QRCoderMode::GetName()
116 {
117 return m_name;
118 }
119 FX_INT32 CBC_QRCoderMode::GetCharacterCountBits(CBC_QRCoderVersion* version, FX_ INT32 &e)
120 {
121 if(m_characterCountBitsForVersions == NULL) {
122 e = BCExceptionCharacterNotThisMode;
123 BC_EXCEPTION_CHECK_ReturnValue(e, 0);
124 }
125 FX_INT32 number = version->GetVersionNumber();
126 FX_INT32 offset;
127 if(number <= 9) {
128 offset = 0;
129 } else if(number <= 26) {
130 offset = 1;
131 } else {
132 offset = 2;
133 }
134 return m_characterCountBitsForVersions[offset];
135 }
136 void CBC_QRCoderMode::Destroy()
137 {
138 if(sBYTE) {
139 delete CBC_QRCoderMode::sBYTE;
140 sBYTE = NULL;
141 }
142 if(sNUMERIC) {
143 delete CBC_QRCoderMode::sNUMERIC;
144 sNUMERIC = NULL;
145 }
146 if(sALPHANUMERIC) {
147 delete CBC_QRCoderMode::sALPHANUMERIC;
148 sALPHANUMERIC = NULL;
149 }
150 if(sKANJI) {
151 delete CBC_QRCoderMode::sKANJI;
152 sKANJI = NULL;
153 }
154 if(sECI) {
155 delete CBC_QRCoderMode::sECI;
156 sECI = NULL;
157 }
158 if(sGBK) {
159 delete CBC_QRCoderMode::sGBK;
160 sGBK = NULL;
161 }
162 if(sTERMINATOR) {
163 delete CBC_QRCoderMode::sTERMINATOR;
164 sTERMINATOR = NULL;
165 }
166 if(sFNC1_FIRST_POSITION) {
167 delete CBC_QRCoderMode::sFNC1_FIRST_POSITION;
168 sFNC1_FIRST_POSITION = NULL;
169 }
170 if(sFNC1_SECOND_POSITION) {
171 delete CBC_QRCoderMode::sFNC1_SECOND_POSITION;
172 sFNC1_SECOND_POSITION = NULL;
173 }
174 if(sSTRUCTURED_APPEND) {
175 delete CBC_QRCoderMode::sSTRUCTURED_APPEND;
176 sSTRUCTURED_APPEND = NULL;
177 }
178 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/src/BC_QRCoderMatrixUtil.cpp ('k') | xfa/src/fxbarcode/src/BC_QRCoderVersion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698