| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 // Original code is licensed as follows: | |
| 7 /* | |
| 8 * Copyright 2008 ZXing authors | |
| 9 * | |
| 10 * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 11 * you may not use this file except in compliance with the License. | |
| 12 * You may obtain a copy of the License at | |
| 13 * | |
| 14 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 15 * | |
| 16 * Unless required by applicable law or agreed to in writing, software | |
| 17 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 19 * See the License for the specific language governing permissions and | |
| 20 * limitations under the License. | |
| 21 */ | |
| 22 | |
| 23 #include "core/include/fxcrt/fx_basic.h" | |
| 24 #include "xfa/src/fxbarcode/BC_Reader.h" | |
| 25 #include "xfa/src/fxbarcode/oned/BC_OneDReader.h" | |
| 26 #include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" | |
| 27 #include "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h" | |
| 28 #include "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h" | |
| 29 #include "xfa/src/fxbarcode/utils.h" | |
| 30 | |
| 31 CBC_OnedUPCAReader::CBC_OnedUPCAReader() { | |
| 32 m_ean13Reader = NULL; | |
| 33 } | |
| 34 void CBC_OnedUPCAReader::Init() { | |
| 35 m_ean13Reader = new CBC_OnedEAN13Reader; | |
| 36 } | |
| 37 CBC_OnedUPCAReader::~CBC_OnedUPCAReader() { | |
| 38 delete m_ean13Reader; | |
| 39 } | |
| 40 CFX_ByteString CBC_OnedUPCAReader::DecodeRow(int32_t rowNumber, | |
| 41 CBC_CommonBitArray* row, | |
| 42 int32_t hints, | |
| 43 int32_t& e) { | |
| 44 CFX_ByteString bytestring = | |
| 45 m_ean13Reader->DecodeRow(rowNumber, row, hints, e); | |
| 46 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 47 CFX_ByteString temp = MaybeReturnResult(bytestring, e); | |
| 48 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 49 return temp; | |
| 50 } | |
| 51 CFX_ByteString CBC_OnedUPCAReader::DecodeRow(int32_t rowNumber, | |
| 52 CBC_CommonBitArray* row, | |
| 53 CFX_Int32Array* startGuardRange, | |
| 54 int32_t hints, | |
| 55 int32_t& e) { | |
| 56 CFX_ByteString bytestring = | |
| 57 m_ean13Reader->DecodeRow(rowNumber, row, startGuardRange, hints, e); | |
| 58 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 59 CFX_ByteString temp = MaybeReturnResult(bytestring, e); | |
| 60 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 61 return temp; | |
| 62 } | |
| 63 CFX_ByteString CBC_OnedUPCAReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { | |
| 64 CFX_ByteString bytestring = m_ean13Reader->Decode(image, e); | |
| 65 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 66 CFX_ByteString temp = MaybeReturnResult(bytestring, e); | |
| 67 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 68 return temp; | |
| 69 } | |
| 70 CFX_ByteString CBC_OnedUPCAReader::Decode(CBC_BinaryBitmap* image, | |
| 71 int32_t hints, | |
| 72 int32_t& e) { | |
| 73 CFX_ByteString bytestring = m_ean13Reader->Decode(image, hints, e); | |
| 74 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 75 CFX_ByteString temp = MaybeReturnResult(bytestring, e); | |
| 76 BC_EXCEPTION_CHECK_ReturnValue(e, ""); | |
| 77 return temp; | |
| 78 } | |
| 79 int32_t CBC_OnedUPCAReader::DecodeMiddle(CBC_CommonBitArray* row, | |
| 80 CFX_Int32Array* startRange, | |
| 81 CFX_ByteString& resultString, | |
| 82 int32_t& e) { | |
| 83 int32_t temp = m_ean13Reader->DecodeMiddle(row, startRange, resultString, e); | |
| 84 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | |
| 85 return temp; | |
| 86 } | |
| 87 CFX_ByteString CBC_OnedUPCAReader::MaybeReturnResult(CFX_ByteString& result, | |
| 88 int32_t& e) { | |
| 89 if (result[0] == '0') { | |
| 90 result.Delete(0); | |
| 91 return result; | |
| 92 } else { | |
| 93 e = BCExceptionFormatException; | |
| 94 return ""; | |
| 95 } | |
| 96 return ""; | |
| 97 } | |
| OLD | NEW |