| 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 29 matching lines...) Expand all Loading... |
| 40 int32_t checksum = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) | 40 int32_t checksum = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) |
| 41 ->CalcChecksum(byteString); | 41 ->CalcChecksum(byteString); |
| 42 encodeContents += FX_WCHAR(checksum - 0 + '0'); | 42 encodeContents += FX_WCHAR(checksum - 0 + '0'); |
| 43 } | 43 } |
| 44 if (length > 8) | 44 if (length > 8) |
| 45 encodeContents = encodeContents.Mid(0, 8); | 45 encodeContents = encodeContents.Mid(0, 8); |
| 46 | 46 |
| 47 return encodeContents; | 47 return encodeContents; |
| 48 } | 48 } |
| 49 | 49 |
| 50 FX_BOOL CBC_EAN8::Encode(const CFX_WideStringC& contents, | 50 bool CBC_EAN8::Encode(const CFX_WideStringC& contents, |
| 51 FX_BOOL isDevice, | 51 bool isDevice, |
| 52 int32_t& e) { | 52 int32_t& e) { |
| 53 if (contents.IsEmpty()) { | 53 if (contents.IsEmpty()) { |
| 54 e = BCExceptionNoContents; | 54 e = BCExceptionNoContents; |
| 55 return FALSE; | 55 return false; |
| 56 } | 56 } |
| 57 BCFORMAT format = BCFORMAT_EAN_8; | 57 BCFORMAT format = BCFORMAT_EAN_8; |
| 58 int32_t outWidth = 0; | 58 int32_t outWidth = 0; |
| 59 int32_t outHeight = 0; | 59 int32_t outHeight = 0; |
| 60 CFX_WideString encodeContents = Preprocess(contents); | 60 CFX_WideString encodeContents = Preprocess(contents); |
| 61 CFX_ByteString byteString = encodeContents.UTF8Encode(); | 61 CFX_ByteString byteString = encodeContents.UTF8Encode(); |
| 62 m_renderContents = encodeContents; | 62 m_renderContents = encodeContents; |
| 63 uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) | 63 uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) |
| 64 ->Encode(byteString, format, outWidth, outHeight, e); | 64 ->Encode(byteString, format, outWidth, outHeight, e); |
| 65 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 65 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 66 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) | 66 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
| 67 ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); | 67 ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); |
| 68 FX_Free(data); | 68 FX_Free(data); |
| 69 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 69 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 70 return TRUE; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 FX_BOOL CBC_EAN8::RenderDevice(CFX_RenderDevice* device, | 73 bool CBC_EAN8::RenderDevice(CFX_RenderDevice* device, |
| 74 const CFX_Matrix* matrix, | 74 const CFX_Matrix* matrix, |
| 75 int32_t& e) { | 75 int32_t& e) { |
| 76 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) | 76 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
| 77 ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); | 77 ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); |
| 78 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 78 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 79 return TRUE; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 FX_BOOL CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { | 82 bool CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { |
| 83 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) | 83 static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
| 84 ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); | 84 ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); |
| 85 BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); | 85 BC_EXCEPTION_CHECK_ReturnValue(e, false); |
| 86 return TRUE; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 BC_TYPE CBC_EAN8::GetType() { | 89 BC_TYPE CBC_EAN8::GetType() { |
| 90 return BC_EAN8; | 90 return BC_EAN8; |
| 91 } | 91 } |
| OLD | NEW |