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

Side by Side Diff: xfa/fwl/core/cfx_barcode.cpp

Issue 2506493003: Continue nit cleanup in fwl/core (Closed)
Patch Set: Prior review comment Created 4 years, 1 month 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
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 6
7 #include "xfa/fwl/core/cfx_barcode.h" 7 #include "xfa/fwl/core/cfx_barcode.h"
8 8
9 #include "xfa/fxbarcode/cbc_codabar.h" 9 #include "xfa/fxbarcode/cbc_codabar.h"
10 #include "xfa/fxbarcode/cbc_code128.h" 10 #include "xfa/fxbarcode/cbc_code128.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } // namespace 53 } // namespace
54 54
55 CFX_Barcode::CFX_Barcode() {} 55 CFX_Barcode::CFX_Barcode() {}
56 56
57 CFX_Barcode::~CFX_Barcode() {} 57 CFX_Barcode::~CFX_Barcode() {}
58 58
59 bool CFX_Barcode::Create(BC_TYPE type) { 59 bool CFX_Barcode::Create(BC_TYPE type) {
60 m_pBCEngine.reset(CreateBarCodeEngineObject(type)); 60 m_pBCEngine.reset(CreateBarCodeEngineObject(type));
61 return !!m_pBCEngine; 61 return !!m_pBCEngine;
62 } 62 }
63
63 BC_TYPE CFX_Barcode::GetType() { 64 BC_TYPE CFX_Barcode::GetType() {
64 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; 65 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN;
65 } 66 }
67
66 bool CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { 68 bool CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) {
67 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : false; 69 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : false;
68 } 70 }
71
69 bool CFX_Barcode::SetModuleHeight(int32_t moduleHeight) { 72 bool CFX_Barcode::SetModuleHeight(int32_t moduleHeight) {
70 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : false; 73 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : false;
71 } 74 }
75
72 bool CFX_Barcode::SetModuleWidth(int32_t moduleWidth) { 76 bool CFX_Barcode::SetModuleWidth(int32_t moduleWidth) {
73 return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : false; 77 return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : false;
74 } 78 }
79
75 bool CFX_Barcode::SetHeight(int32_t height) { 80 bool CFX_Barcode::SetHeight(int32_t height) {
76 return m_pBCEngine ? m_pBCEngine->SetHeight(height) : false; 81 return m_pBCEngine ? m_pBCEngine->SetHeight(height) : false;
77 } 82 }
83
78 bool CFX_Barcode::SetWidth(int32_t width) { 84 bool CFX_Barcode::SetWidth(int32_t width) {
79 return m_pBCEngine ? m_pBCEngine->SetWidth(width) : false; 85 return m_pBCEngine ? m_pBCEngine->SetWidth(width) : false;
80 } 86 }
81 87
82 bool CFX_Barcode::SetPrintChecksum(bool checksum) { 88 bool CFX_Barcode::SetPrintChecksum(bool checksum) {
83 switch (GetType()) { 89 switch (GetType()) {
84 case BC_CODE39: 90 case BC_CODE39:
85 case BC_CODABAR: 91 case BC_CODABAR:
86 case BC_CODE128: 92 case BC_CODE128:
87 case BC_CODE128_B: 93 case BC_CODE128_B:
88 case BC_CODE128_C: 94 case BC_CODE128_C:
89 case BC_EAN8: 95 case BC_EAN8:
90 case BC_EAN13: 96 case BC_EAN13:
91 case BC_UPCA: 97 case BC_UPCA:
92 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get()) 98 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
93 ->SetPrintChecksum(checksum), 99 ->SetPrintChecksum(checksum),
94 true) 100 true)
95 : false; 101 : false;
96 default: 102 default:
97 return false; 103 return false;
98 } 104 }
99 } 105 }
106
100 bool CFX_Barcode::SetDataLength(int32_t length) { 107 bool CFX_Barcode::SetDataLength(int32_t length) {
101 switch (GetType()) { 108 switch (GetType()) {
102 case BC_CODE39: 109 case BC_CODE39:
103 case BC_CODABAR: 110 case BC_CODABAR:
104 case BC_CODE128: 111 case BC_CODE128:
105 case BC_CODE128_B: 112 case BC_CODE128_B:
106 case BC_CODE128_C: 113 case BC_CODE128_C:
107 case BC_EAN8: 114 case BC_EAN8:
108 case BC_EAN13: 115 case BC_EAN13:
109 case BC_UPCA: 116 case BC_UPCA:
110 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get()) 117 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
111 ->SetDataLength(length), 118 ->SetDataLength(length),
112 true) 119 true)
113 : false; 120 : false;
114 default: 121 default:
115 return false; 122 return false;
116 } 123 }
117 } 124 }
125
118 bool CFX_Barcode::SetCalChecksum(bool state) { 126 bool CFX_Barcode::SetCalChecksum(bool state) {
119 switch (GetType()) { 127 switch (GetType()) {
120 case BC_CODE39: 128 case BC_CODE39:
121 case BC_CODABAR: 129 case BC_CODABAR:
122 case BC_CODE128: 130 case BC_CODE128:
123 case BC_CODE128_B: 131 case BC_CODE128_B:
124 case BC_CODE128_C: 132 case BC_CODE128_C:
125 case BC_EAN8: 133 case BC_EAN8:
126 case BC_EAN13: 134 case BC_EAN13:
127 case BC_UPCA: 135 case BC_UPCA:
128 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get()) 136 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
129 ->SetCalChecksum(state), 137 ->SetCalChecksum(state),
130 true) 138 true)
131 : false; 139 : false;
132 default: 140 default:
133 return false; 141 return false;
134 } 142 }
135 } 143 }
144
136 bool CFX_Barcode::SetFont(CFX_Font* pFont) { 145 bool CFX_Barcode::SetFont(CFX_Font* pFont) {
137 switch (GetType()) { 146 switch (GetType()) {
138 case BC_CODE39: 147 case BC_CODE39:
139 case BC_CODABAR: 148 case BC_CODABAR:
140 case BC_CODE128: 149 case BC_CODE128:
141 case BC_CODE128_B: 150 case BC_CODE128_B:
142 case BC_CODE128_C: 151 case BC_CODE128_C:
143 case BC_EAN8: 152 case BC_EAN8:
144 case BC_EAN13: 153 case BC_EAN13:
145 case BC_UPCA: 154 case BC_UPCA:
146 return m_pBCEngine 155 return m_pBCEngine
147 ? static_cast<CBC_OneCode*>(m_pBCEngine.get())->SetFont(pFont) 156 ? static_cast<CBC_OneCode*>(m_pBCEngine.get())->SetFont(pFont)
148 : false; 157 : false;
149 default: 158 default:
150 return false; 159 return false;
151 } 160 }
152 } 161 }
162
153 bool CFX_Barcode::SetFontSize(FX_FLOAT size) { 163 bool CFX_Barcode::SetFontSize(FX_FLOAT size) {
154 switch (GetType()) { 164 switch (GetType()) {
155 case BC_CODE39: 165 case BC_CODE39:
156 case BC_CODABAR: 166 case BC_CODABAR:
157 case BC_CODE128: 167 case BC_CODE128:
158 case BC_CODE128_B: 168 case BC_CODE128_B:
159 case BC_CODE128_C: 169 case BC_CODE128_C:
160 case BC_EAN8: 170 case BC_EAN8:
161 case BC_EAN13: 171 case BC_EAN13:
162 case BC_UPCA: 172 case BC_UPCA:
(...skipping 17 matching lines...) Expand all
180 case BC_EAN13: 190 case BC_EAN13:
181 case BC_UPCA: 191 case BC_UPCA:
182 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get()) 192 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
183 ->SetFontColor(color), 193 ->SetFontColor(color),
184 true) 194 true)
185 : false; 195 : false;
186 default: 196 default:
187 return false; 197 return false;
188 } 198 }
189 } 199 }
200
190 bool CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) { 201 bool CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) {
191 typedef bool (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC); 202 typedef bool (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC);
192 memptrtype memptr = nullptr; 203 memptrtype memptr = nullptr;
193 switch (GetType()) { 204 switch (GetType()) {
194 case BC_CODE39: 205 case BC_CODE39:
195 memptr = (memptrtype)&CBC_Code39::SetTextLocation; 206 memptr = (memptrtype)&CBC_Code39::SetTextLocation;
196 break; 207 break;
197 case BC_CODABAR: 208 case BC_CODABAR:
198 memptr = (memptrtype)&CBC_Codabar::SetTextLocation; 209 memptr = (memptrtype)&CBC_Codabar::SetTextLocation;
199 break; 210 break;
200 case BC_CODE128: 211 case BC_CODE128:
201 case BC_CODE128_B: 212 case BC_CODE128_B:
202 case BC_CODE128_C: 213 case BC_CODE128_C:
203 memptr = (memptrtype)&CBC_Code128::SetTextLocation; 214 memptr = (memptrtype)&CBC_Code128::SetTextLocation;
204 break; 215 break;
205 default: 216 default:
206 break; 217 break;
207 } 218 }
208 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(location) : false; 219 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(location) : false;
209 } 220 }
221
210 bool CFX_Barcode::SetWideNarrowRatio(int32_t ratio) { 222 bool CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
211 typedef bool (CBC_CodeBase::*memptrtype)(int32_t); 223 typedef bool (CBC_CodeBase::*memptrtype)(int32_t);
212 memptrtype memptr = nullptr; 224 memptrtype memptr = nullptr;
213 switch (GetType()) { 225 switch (GetType()) {
214 case BC_CODE39: 226 case BC_CODE39:
215 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio; 227 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio;
216 break; 228 break;
217 case BC_CODABAR: 229 case BC_CODABAR:
218 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio; 230 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio;
219 break; 231 break;
220 default: 232 default:
221 break; 233 break;
222 } 234 }
223 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(ratio) : false; 235 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(ratio) : false;
224 } 236 }
237
225 bool CFX_Barcode::SetStartChar(FX_CHAR start) { 238 bool CFX_Barcode::SetStartChar(FX_CHAR start) {
226 typedef bool (CBC_CodeBase::*memptrtype)(FX_CHAR); 239 typedef bool (CBC_CodeBase::*memptrtype)(FX_CHAR);
227 memptrtype memptr = nullptr; 240 memptrtype memptr = nullptr;
228 switch (GetType()) { 241 switch (GetType()) {
229 case BC_CODABAR: 242 case BC_CODABAR:
230 memptr = (memptrtype)&CBC_Codabar::SetStartChar; 243 memptr = (memptrtype)&CBC_Codabar::SetStartChar;
231 break; 244 break;
232 default: 245 default:
233 break; 246 break;
234 } 247 }
235 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(start) : false; 248 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(start) : false;
236 } 249 }
250
237 bool CFX_Barcode::SetEndChar(FX_CHAR end) { 251 bool CFX_Barcode::SetEndChar(FX_CHAR end) {
238 typedef bool (CBC_CodeBase::*memptrtype)(FX_CHAR); 252 typedef bool (CBC_CodeBase::*memptrtype)(FX_CHAR);
239 memptrtype memptr = nullptr; 253 memptrtype memptr = nullptr;
240 switch (GetType()) { 254 switch (GetType()) {
241 case BC_CODABAR: 255 case BC_CODABAR:
242 memptr = (memptrtype)&CBC_Codabar::SetEndChar; 256 memptr = (memptrtype)&CBC_Codabar::SetEndChar;
243 break; 257 break;
244 default: 258 default:
245 break; 259 break;
246 } 260 }
247 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(end) : false; 261 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(end) : false;
248 } 262 }
263
249 bool CFX_Barcode::SetVersion(int32_t version) { 264 bool CFX_Barcode::SetVersion(int32_t version) {
250 typedef bool (CBC_CodeBase::*memptrtype)(int32_t); 265 typedef bool (CBC_CodeBase::*memptrtype)(int32_t);
251 memptrtype memptr = nullptr; 266 memptrtype memptr = nullptr;
252 switch (GetType()) { 267 switch (GetType()) {
253 case BC_QR_CODE: 268 case BC_QR_CODE:
254 memptr = (memptrtype)&CBC_QRCode::SetVersion; 269 memptr = (memptrtype)&CBC_QRCode::SetVersion;
255 break; 270 break;
256 default: 271 default:
257 break; 272 break;
258 } 273 }
259 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(version) : false; 274 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(version) : false;
260 } 275 }
276
261 bool CFX_Barcode::SetErrorCorrectionLevel(int32_t level) { 277 bool CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
262 typedef bool (CBC_CodeBase::*memptrtype)(int32_t); 278 typedef bool (CBC_CodeBase::*memptrtype)(int32_t);
263 memptrtype memptr = nullptr; 279 memptrtype memptr = nullptr;
264 switch (GetType()) { 280 switch (GetType()) {
265 case BC_QR_CODE: 281 case BC_QR_CODE:
266 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel; 282 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel;
267 break; 283 break;
268 case BC_PDF417: 284 case BC_PDF417:
269 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel; 285 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel;
270 break; 286 break;
(...skipping 20 matching lines...) Expand all
291 bool isDevice, 307 bool isDevice,
292 int32_t& e) { 308 int32_t& e) {
293 return m_pBCEngine && m_pBCEngine->Encode(contents, isDevice, e); 309 return m_pBCEngine && m_pBCEngine->Encode(contents, isDevice, e);
294 } 310 }
295 311
296 bool CFX_Barcode::RenderDevice(CFX_RenderDevice* device, 312 bool CFX_Barcode::RenderDevice(CFX_RenderDevice* device,
297 const CFX_Matrix* matrix, 313 const CFX_Matrix* matrix,
298 int32_t& e) { 314 int32_t& e) {
299 return m_pBCEngine && m_pBCEngine->RenderDevice(device, matrix, e); 315 return m_pBCEngine && m_pBCEngine->RenderDevice(device, matrix, e);
300 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698