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

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

Issue 2031873003: Get rid of NULLs in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_fpdfsdk
Patch Set: Created 4 years, 6 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/fwl_tooltipctrlimp.cpp ('k') | xfa/fwl/core/cfwl_themetext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/basewidget/fxmath_barcodeimp.h" 7 #include "xfa/fwl/basewidget/fxmath_barcodeimp.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 26 matching lines...) Expand all
37 case BC_EAN13: 37 case BC_EAN13:
38 return new CBC_EAN13(); 38 return new CBC_EAN13();
39 case BC_QR_CODE: 39 case BC_QR_CODE:
40 return new CBC_QRCode(); 40 return new CBC_QRCode();
41 case BC_PDF417: 41 case BC_PDF417:
42 return new CBC_PDF417I(); 42 return new CBC_PDF417I();
43 case BC_DATAMATRIX: 43 case BC_DATAMATRIX:
44 return new CBC_DataMatrix(); 44 return new CBC_DataMatrix();
45 case BC_UNKNOWN: 45 case BC_UNKNOWN:
46 default: 46 default:
47 return NULL; 47 return nullptr;
48 } 48 }
49 } 49 }
50 50
51 CFX_Barcode::CFX_Barcode() {} 51 CFX_Barcode::CFX_Barcode() {}
52 52
53 CFX_Barcode::~CFX_Barcode() { 53 CFX_Barcode::~CFX_Barcode() {
54 delete m_pBCEngine; 54 delete m_pBCEngine;
55 } 55 }
56 56
57 FX_BOOL CFX_Barcode::Create(BC_TYPE type) { 57 FX_BOOL CFX_Barcode::Create(BC_TYPE type) {
58 m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type); 58 m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type);
59 return m_pBCEngine != NULL; 59 return !!m_pBCEngine;
60 } 60 }
61 BC_TYPE CFX_Barcode::GetType() { 61 BC_TYPE CFX_Barcode::GetType() {
62 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; 62 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN;
63 } 63 }
64 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { 64 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) {
65 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE; 65 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE;
66 } 66 }
67 FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) { 67 FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) {
68 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE; 68 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE;
69 } 69 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return m_pBCEngine 214 return m_pBCEngine
215 ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color), 215 ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color),
216 TRUE) 216 TRUE)
217 : FALSE; 217 : FALSE;
218 default: 218 default:
219 return FALSE; 219 return FALSE;
220 } 220 }
221 } 221 }
222 FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) { 222 FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) {
223 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC); 223 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC);
224 memptrtype memptr = NULL; 224 memptrtype memptr = nullptr;
225 switch (GetType()) { 225 switch (GetType()) {
226 case BC_CODE39: 226 case BC_CODE39:
227 memptr = (memptrtype)&CBC_Code39::SetTextLocation; 227 memptr = (memptrtype)&CBC_Code39::SetTextLocation;
228 break; 228 break;
229 case BC_CODABAR: 229 case BC_CODABAR:
230 memptr = (memptrtype)&CBC_Codabar::SetTextLocation; 230 memptr = (memptrtype)&CBC_Codabar::SetTextLocation;
231 break; 231 break;
232 case BC_CODE128: 232 case BC_CODE128:
233 case BC_CODE128_B: 233 case BC_CODE128_B:
234 case BC_CODE128_C: 234 case BC_CODE128_C:
235 memptr = (memptrtype)&CBC_Code128::SetTextLocation; 235 memptr = (memptrtype)&CBC_Code128::SetTextLocation;
236 break; 236 break;
237 default: 237 default:
238 break; 238 break;
239 } 239 }
240 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE; 240 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE;
241 } 241 }
242 FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) { 242 FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
243 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); 243 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
244 memptrtype memptr = NULL; 244 memptrtype memptr = nullptr;
245 switch (GetType()) { 245 switch (GetType()) {
246 case BC_CODE39: 246 case BC_CODE39:
247 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio; 247 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio;
248 break; 248 break;
249 case BC_CODABAR: 249 case BC_CODABAR:
250 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio; 250 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio;
251 break; 251 break;
252 default: 252 default:
253 break; 253 break;
254 } 254 }
255 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE; 255 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE;
256 } 256 }
257 FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) { 257 FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) {
258 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); 258 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
259 memptrtype memptr = NULL; 259 memptrtype memptr = nullptr;
260 switch (GetType()) { 260 switch (GetType()) {
261 case BC_CODABAR: 261 case BC_CODABAR:
262 memptr = (memptrtype)&CBC_Codabar::SetStartChar; 262 memptr = (memptrtype)&CBC_Codabar::SetStartChar;
263 break; 263 break;
264 default: 264 default:
265 break; 265 break;
266 } 266 }
267 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE; 267 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE;
268 } 268 }
269 FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) { 269 FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) {
270 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); 270 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
271 memptrtype memptr = NULL; 271 memptrtype memptr = nullptr;
272 switch (GetType()) { 272 switch (GetType()) {
273 case BC_CODABAR: 273 case BC_CODABAR:
274 memptr = (memptrtype)&CBC_Codabar::SetEndChar; 274 memptr = (memptrtype)&CBC_Codabar::SetEndChar;
275 break; 275 break;
276 default: 276 default:
277 break; 277 break;
278 } 278 }
279 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE; 279 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE;
280 } 280 }
281 FX_BOOL CFX_Barcode::SetVersion(int32_t version) { 281 FX_BOOL CFX_Barcode::SetVersion(int32_t version) {
282 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); 282 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
283 memptrtype memptr = NULL; 283 memptrtype memptr = nullptr;
284 switch (GetType()) { 284 switch (GetType()) {
285 case BC_QR_CODE: 285 case BC_QR_CODE:
286 memptr = (memptrtype)&CBC_QRCode::SetVersion; 286 memptr = (memptrtype)&CBC_QRCode::SetVersion;
287 break; 287 break;
288 default: 288 default:
289 break; 289 break;
290 } 290 }
291 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE; 291 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE;
292 } 292 }
293 FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) { 293 FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
294 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); 294 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
295 memptrtype memptr = NULL; 295 memptrtype memptr = nullptr;
296 switch (GetType()) { 296 switch (GetType()) {
297 case BC_QR_CODE: 297 case BC_QR_CODE:
298 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel; 298 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel;
299 break; 299 break;
300 case BC_PDF417: 300 case BC_PDF417:
301 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel; 301 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel;
302 break; 302 break;
303 default: 303 default:
304 return FALSE; 304 return FALSE;
305 } 305 }
306 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE; 306 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE;
307 } 307 }
308 FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) { 308 FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
309 typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL); 309 typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL);
310 memptrtype memptr = NULL; 310 memptrtype memptr = nullptr;
311 switch (GetType()) { 311 switch (GetType()) {
312 case BC_PDF417: 312 case BC_PDF417:
313 memptr = (memptrtype)&CBC_PDF417I::SetTruncated; 313 memptr = (memptrtype)&CBC_PDF417I::SetTruncated;
314 break; 314 break;
315 default: 315 default:
316 break; 316 break;
317 } 317 }
318 return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE) 318 return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE)
319 : FALSE; 319 : FALSE;
320 } 320 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 continue; 368 continue;
369 } 369 }
370 CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode); 370 CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode);
371 if (errorCode == BCExceptionNO) { 371 if (errorCode == BCExceptionNO) {
372 return ret; 372 return ret;
373 } 373 }
374 } 374 }
375 errorCode = BCExceptionUnSupportedBarcode; 375 errorCode = BCExceptionUnSupportedBarcode;
376 return CFX_WideString(); 376 return CFX_WideString();
377 } 377 }
OLDNEW
« no previous file with comments | « xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp ('k') | xfa/fwl/core/cfwl_themetext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698