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

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

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 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/fwl/basewidget/cfx_barcode.h ('k') | xfa/fwl/basewidget/fwl_barcodeimp.h » ('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
7 #include "xfa/fwl/basewidget/cfx_barcode.h"
8
9 #include "xfa/fxbarcode/cbc_codabar.h"
10 #include "xfa/fxbarcode/cbc_code128.h"
11 #include "xfa/fxbarcode/cbc_code39.h"
12 #include "xfa/fxbarcode/cbc_codebase.h"
13 #include "xfa/fxbarcode/cbc_datamatrix.h"
14 #include "xfa/fxbarcode/cbc_ean13.h"
15 #include "xfa/fxbarcode/cbc_ean8.h"
16 #include "xfa/fxbarcode/cbc_pdf417i.h"
17 #include "xfa/fxbarcode/cbc_qrcode.h"
18 #include "xfa/fxbarcode/cbc_upca.h"
19 #include "xfa/fxbarcode/utils.h"
20
21 namespace {
22
23 CBC_CodeBase* CreateBarCodeEngineObject(BC_TYPE type) {
24 switch (type) {
25 case BC_CODE39:
26 return new CBC_Code39();
27 case BC_CODABAR:
28 return new CBC_Codabar();
29 case BC_CODE128:
30 return new CBC_Code128(BC_CODE128_B);
31 case BC_CODE128_B:
32 return new CBC_Code128(BC_CODE128_B);
33 case BC_CODE128_C:
34 return new CBC_Code128(BC_CODE128_C);
35 case BC_EAN8:
36 return new CBC_EAN8();
37 case BC_UPCA:
38 return new CBC_UPCA();
39 case BC_EAN13:
40 return new CBC_EAN13();
41 case BC_QR_CODE:
42 return new CBC_QRCode();
43 case BC_PDF417:
44 return new CBC_PDF417I();
45 case BC_DATAMATRIX:
46 return new CBC_DataMatrix();
47 case BC_UNKNOWN:
48 default:
49 return nullptr;
50 }
51 }
52
53 } // namespace
54
55 CFX_Barcode::CFX_Barcode() {}
56
57 CFX_Barcode::~CFX_Barcode() {}
58
59 FX_BOOL CFX_Barcode::Create(BC_TYPE type) {
60 m_pBCEngine.reset(CreateBarCodeEngineObject(type));
61 return !!m_pBCEngine;
62 }
63 BC_TYPE CFX_Barcode::GetType() {
64 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN;
65 }
66 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) {
67 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE;
68 }
69 FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) {
70 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE;
71 }
72 FX_BOOL CFX_Barcode::SetModuleWidth(int32_t moduleWidth) {
73 return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : FALSE;
74 }
75 FX_BOOL CFX_Barcode::SetHeight(int32_t height) {
76 return m_pBCEngine ? m_pBCEngine->SetHeight(height) : FALSE;
77 }
78 FX_BOOL CFX_Barcode::SetWidth(int32_t width) {
79 return m_pBCEngine ? m_pBCEngine->SetWidth(width) : FALSE;
80 }
81 FX_BOOL CFX_Barcode::CheckContentValidity(const CFX_WideStringC& contents) {
82 switch (GetType()) {
83 case BC_CODE39:
84 case BC_CODABAR:
85 case BC_CODE128:
86 case BC_CODE128_B:
87 case BC_CODE128_C:
88 case BC_EAN8:
89 case BC_EAN13:
90 case BC_UPCA:
91 return m_pBCEngine
92 ? static_cast<CBC_OneCode*>(m_pBCEngine.get())
93 ->CheckContentValidity(contents)
94 : TRUE;
95 default:
96 return TRUE;
97 }
98 }
99 FX_BOOL CFX_Barcode::SetPrintChecksum(FX_BOOL checksum) {
100 switch (GetType()) {
101 case BC_CODE39:
102 case BC_CODABAR:
103 case BC_CODE128:
104 case BC_CODE128_B:
105 case BC_CODE128_C:
106 case BC_EAN8:
107 case BC_EAN13:
108 case BC_UPCA:
109 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
110 ->SetPrintChecksum(checksum),
111 TRUE)
112 : FALSE;
113 default:
114 return FALSE;
115 }
116 }
117 FX_BOOL CFX_Barcode::SetDataLength(int32_t length) {
118 switch (GetType()) {
119 case BC_CODE39:
120 case BC_CODABAR:
121 case BC_CODE128:
122 case BC_CODE128_B:
123 case BC_CODE128_C:
124 case BC_EAN8:
125 case BC_EAN13:
126 case BC_UPCA:
127 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
128 ->SetDataLength(length),
129 TRUE)
130 : FALSE;
131 default:
132 return FALSE;
133 }
134 }
135 FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state) {
136 switch (GetType()) {
137 case BC_CODE39:
138 case BC_CODABAR:
139 case BC_CODE128:
140 case BC_CODE128_B:
141 case BC_CODE128_C:
142 case BC_EAN8:
143 case BC_EAN13:
144 case BC_UPCA:
145 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
146 ->SetCalChecksum(state),
147 TRUE)
148 : FALSE;
149 default:
150 return FALSE;
151 }
152 }
153 FX_BOOL CFX_Barcode::SetFont(CFX_Font* pFont) {
154 switch (GetType()) {
155 case BC_CODE39:
156 case BC_CODABAR:
157 case BC_CODE128:
158 case BC_CODE128_B:
159 case BC_CODE128_C:
160 case BC_EAN8:
161 case BC_EAN13:
162 case BC_UPCA:
163 return m_pBCEngine
164 ? static_cast<CBC_OneCode*>(m_pBCEngine.get())->SetFont(pFont)
165 : FALSE;
166 default:
167 return FALSE;
168 }
169 }
170 FX_BOOL CFX_Barcode::SetFontSize(FX_FLOAT size) {
171 switch (GetType()) {
172 case BC_CODE39:
173 case BC_CODABAR:
174 case BC_CODE128:
175 case BC_CODE128_B:
176 case BC_CODE128_C:
177 case BC_EAN8:
178 case BC_EAN13:
179 case BC_UPCA:
180 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
181 ->SetFontSize(size),
182 TRUE)
183 : FALSE;
184 default:
185 return FALSE;
186 }
187 }
188 FX_BOOL CFX_Barcode::SetFontStyle(int32_t style) {
189 switch (GetType()) {
190 case BC_CODE39:
191 case BC_CODABAR:
192 case BC_CODE128:
193 case BC_CODE128_B:
194 case BC_CODE128_C:
195 case BC_EAN8:
196 case BC_EAN13:
197 case BC_UPCA:
198 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
199 ->SetFontStyle(style),
200 TRUE)
201 : FALSE;
202 default:
203 return FALSE;
204 }
205 }
206 FX_BOOL CFX_Barcode::SetFontColor(FX_ARGB color) {
207 switch (GetType()) {
208 case BC_CODE39:
209 case BC_CODABAR:
210 case BC_CODE128:
211 case BC_CODE128_B:
212 case BC_CODE128_C:
213 case BC_EAN8:
214 case BC_EAN13:
215 case BC_UPCA:
216 return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
217 ->SetFontColor(color),
218 TRUE)
219 : FALSE;
220 default:
221 return FALSE;
222 }
223 }
224 FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) {
225 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC);
226 memptrtype memptr = nullptr;
227 switch (GetType()) {
228 case BC_CODE39:
229 memptr = (memptrtype)&CBC_Code39::SetTextLocation;
230 break;
231 case BC_CODABAR:
232 memptr = (memptrtype)&CBC_Codabar::SetTextLocation;
233 break;
234 case BC_CODE128:
235 case BC_CODE128_B:
236 case BC_CODE128_C:
237 memptr = (memptrtype)&CBC_Code128::SetTextLocation;
238 break;
239 default:
240 break;
241 }
242 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(location) : FALSE;
243 }
244 FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
245 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
246 memptrtype memptr = nullptr;
247 switch (GetType()) {
248 case BC_CODE39:
249 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio;
250 break;
251 case BC_CODABAR:
252 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio;
253 break;
254 default:
255 break;
256 }
257 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(ratio) : FALSE;
258 }
259 FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) {
260 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
261 memptrtype memptr = nullptr;
262 switch (GetType()) {
263 case BC_CODABAR:
264 memptr = (memptrtype)&CBC_Codabar::SetStartChar;
265 break;
266 default:
267 break;
268 }
269 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(start) : FALSE;
270 }
271 FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) {
272 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
273 memptrtype memptr = nullptr;
274 switch (GetType()) {
275 case BC_CODABAR:
276 memptr = (memptrtype)&CBC_Codabar::SetEndChar;
277 break;
278 default:
279 break;
280 }
281 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(end) : FALSE;
282 }
283 FX_BOOL CFX_Barcode::SetVersion(int32_t version) {
284 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
285 memptrtype memptr = nullptr;
286 switch (GetType()) {
287 case BC_QR_CODE:
288 memptr = (memptrtype)&CBC_QRCode::SetVersion;
289 break;
290 default:
291 break;
292 }
293 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(version) : FALSE;
294 }
295 FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
296 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
297 memptrtype memptr = nullptr;
298 switch (GetType()) {
299 case BC_QR_CODE:
300 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel;
301 break;
302 case BC_PDF417:
303 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel;
304 break;
305 default:
306 return FALSE;
307 }
308 return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(level) : FALSE;
309 }
310 FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
311 typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL);
312 memptrtype memptr = nullptr;
313 switch (GetType()) {
314 case BC_PDF417:
315 memptr = (memptrtype)&CBC_PDF417I::SetTruncated;
316 break;
317 default:
318 break;
319 }
320 return m_pBCEngine && memptr ? ((m_pBCEngine.get()->*memptr)(truncated), TRUE)
321 : FALSE;
322 }
323
324 FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents,
325 FX_BOOL isDevice,
326 int32_t& e) {
327 return m_pBCEngine && m_pBCEngine->Encode(contents, isDevice, e);
328 }
329
330 FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device,
331 const CFX_Matrix* matrix,
332 int32_t& e) {
333 return m_pBCEngine && m_pBCEngine->RenderDevice(device, matrix, e);
334 }
335
336 FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
337 return m_pBCEngine && m_pBCEngine->RenderBitmap(pOutBitmap, e);
338 }
OLDNEW
« no previous file with comments | « xfa/fwl/basewidget/cfx_barcode.h ('k') | xfa/fwl/basewidget/fwl_barcodeimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698