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