| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 * Copyright 2011 ZXing authors | 7 * Copyright 2011 ZXing authors |
| 8 * | 8 * |
| 9 * Licensed under the Apache License, Version 2.0 (the "License"); | 9 * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 * you may not use this file except in compliance with the License. | 10 * you may not use this file except in compliance with the License. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 #include "xfa/fxbarcode/cbc_code128.h" | 22 #include "xfa/fxbarcode/cbc_code128.h" |
| 23 | 23 |
| 24 #include "xfa/fxbarcode/oned/BC_OnedCode128Writer.h" | 24 #include "xfa/fxbarcode/oned/BC_OnedCode128Writer.h" |
| 25 | 25 |
| 26 CBC_Code128::CBC_Code128(BC_TYPE type) | 26 CBC_Code128::CBC_Code128(BC_TYPE type) |
| 27 : CBC_OneCode(new CBC_OnedCode128Writer(type)) {} | 27 : CBC_OneCode(new CBC_OnedCode128Writer(type)) {} |
| 28 | 28 |
| 29 CBC_Code128::~CBC_Code128() {} | 29 CBC_Code128::~CBC_Code128() {} |
| 30 | 30 |
| 31 FX_BOOL CBC_Code128::SetTextLocation(BC_TEXT_LOC location) { | 31 bool CBC_Code128::SetTextLocation(BC_TEXT_LOC location) { |
| 32 if (m_pBCWriter) | 32 if (m_pBCWriter) |
| 33 return static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get()) | 33 return static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get()) |
| 34 ->SetTextLocation(location); | 34 ->SetTextLocation(location); |
| 35 return FALSE; | 35 return false; |
| 36 } | 36 } |
| 37 | 37 |
| 38 FX_BOOL CBC_Code128::Encode(const CFX_WideStringC& contents, | 38 bool CBC_Code128::Encode(const CFX_WideStringC& contents, |
| 39 FX_BOOL isDevice, | 39 bool isDevice, |
| 40 int32_t& e) { | 40 int32_t& e) { |
| 41 if (contents.IsEmpty()) { | 41 if (contents.IsEmpty()) { |
| 42 e = BCExceptionNoContents; | 42 e = BCExceptionNoContents; |
| 43 return FALSE; | 43 return false; |
| 44 } | 44 } |
| 45 BCFORMAT format = BCFORMAT_CODE_128; | 45 BCFORMAT format = BCFORMAT_CODE_128; |
| 46 int32_t outWidth = 0; | 46 int32_t outWidth = 0; |
| 47 int32_t outHeight = 0; | 47 int32_t outHeight = 0; |
| 48 CFX_WideString content(contents); | 48 CFX_WideString content(contents); |
| 49 if (contents.GetLength() % 2 && | 49 if (contents.GetLength() % 2 && |
| 50 static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get())->GetType() == | 50 static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get())->GetType() == |
| 51 BC_CODE128_C) { | 51 BC_CODE128_C) { |
| 52 content += '0'; | 52 content += '0'; |
| 53 } | 53 } |
| 54 CFX_WideString encodeContents = | 54 CFX_WideString encodeContents = |
| 55 static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get()) | 55 static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get()) |
| 56 ->FilterContents(content.AsStringC()); | 56 ->FilterContents(content.AsStringC()); |
| 57 m_renderContents = encodeContents; | 57 m_renderContents = encodeContents; |
| 58 CFX_ByteString byteString = encodeContents.UTF8Encode(); | 58 CFX_ByteString byteString = encodeContents.UTF8Encode(); |
| 59 uint8_t* data = static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get()) | 59 uint8_t* data = static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get()) |
| 60 ->Encode(byteString, format, outWidth, outHeight, e); | 60 ->Encode(byteString, format, outWidth, outHeight, e); |
| 61 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 61 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 62 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) | 62 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
| 63 ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); | 63 ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); |
| 64 FX_Free(data); | 64 FX_Free(data); |
| 65 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 65 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 66 return TRUE; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 FX_BOOL CBC_Code128::RenderDevice(CFX_RenderDevice* device, | 69 bool CBC_Code128::RenderDevice(CFX_RenderDevice* device, |
| 70 const CFX_Matrix* matrix, | 70 const CFX_Matrix* matrix, |
| 71 int32_t& e) { | 71 int32_t& e) { |
| 72 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) | 72 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
| 73 ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); | 73 ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); |
| 74 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 74 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 75 return TRUE; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 FX_BOOL CBC_Code128::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { | 78 bool CBC_Code128::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { |
| 79 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) | 79 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
| 80 ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); | 80 ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); |
| 81 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 81 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 82 return TRUE; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 BC_TYPE CBC_Code128::GetType() { | 85 BC_TYPE CBC_Code128::GetType() { |
| 86 return BC_CODE128; | 86 return BC_CODE128; |
| 87 } | 87 } |
| 88 | 88 |
| OLD | NEW |