| OLD | NEW |
| 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" |
| 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 |
| 9 static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) { | 20 static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) { |
| 10 switch (type) { | 21 switch (type) { |
| 11 case BC_CODE39: | 22 case BC_CODE39: |
| 12 return new CBC_Code39(); | 23 return new CBC_Code39(); |
| 13 case BC_CODABAR: | 24 case BC_CODABAR: |
| 14 return new CBC_Codabar(); | 25 return new CBC_Codabar(); |
| 15 case BC_CODE128: | 26 case BC_CODE128: |
| 16 return new CBC_Code128(BC_CODE128_B); | 27 return new CBC_Code128(BC_CODE128_B); |
| 17 case BC_CODE128_B: | 28 case BC_CODE128_B: |
| 18 return new CBC_Code128(BC_CODE128_B); | 29 return new CBC_Code128(BC_CODE128_B); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 return NULL; | 46 return NULL; |
| 36 } | 47 } |
| 37 } | 48 } |
| 38 CFX_Barcode::CFX_Barcode() {} | 49 CFX_Barcode::CFX_Barcode() {} |
| 39 CFX_Barcode::~CFX_Barcode() { | 50 CFX_Barcode::~CFX_Barcode() { |
| 40 if (m_pBCEngine) { | 51 if (m_pBCEngine) { |
| 41 delete m_pBCEngine; | 52 delete m_pBCEngine; |
| 42 m_pBCEngine = NULL; | 53 m_pBCEngine = NULL; |
| 43 } | 54 } |
| 44 } | 55 } |
| 45 FX_BOOL CFX_Barcode::Crreate(BC_TYPE type) { | 56 FX_BOOL CFX_Barcode::Create(BC_TYPE type) { |
| 46 m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type); | 57 m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type); |
| 47 return m_pBCEngine != NULL; | 58 return m_pBCEngine != NULL; |
| 48 } | 59 } |
| 49 void CFX_Barcode::Release() { | 60 void CFX_Barcode::Release() { |
| 50 delete this; | 61 delete this; |
| 51 } | 62 } |
| 52 BC_TYPE CFX_Barcode::GetType() { | 63 BC_TYPE CFX_Barcode::GetType() { |
| 53 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; | 64 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; |
| 54 } | 65 } |
| 55 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { | 66 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode); | 381 CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode); |
| 371 if (errorCode == BCExceptionNO) { | 382 if (errorCode == BCExceptionNO) { |
| 372 return ret; | 383 return ret; |
| 373 } | 384 } |
| 374 } | 385 } |
| 375 errorCode = BCExceptionUnSupportedBarcode; | 386 errorCode = BCExceptionUnSupportedBarcode; |
| 376 return CFX_WideString(); | 387 return CFX_WideString(); |
| 377 } | 388 } |
| 378 IFX_Barcode* FX_Barcode_Create(BC_TYPE type) { | 389 IFX_Barcode* FX_Barcode_Create(BC_TYPE type) { |
| 379 CFX_Barcode* pBarcode = new CFX_Barcode; | 390 CFX_Barcode* pBarcode = new CFX_Barcode; |
| 380 if (pBarcode->Crreate(type)) { | 391 if (pBarcode->Create(type)) { |
| 381 return pBarcode; | 392 return pBarcode; |
| 382 } | 393 } |
| 383 pBarcode->Release(); | 394 pBarcode->Release(); |
| 384 return NULL; | 395 return NULL; |
| 385 } | 396 } |
| OLD | NEW |