summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
commit9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch)
treec97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp
parent780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff)
downloadpdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz
XFA: clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \ xargs ../../buildtools/mac/clang-format -i Then manually merged https://codereview.chromium.org/1269223002/ See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none
Diffstat (limited to 'xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp')
-rw-r--r--xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp121
1 files changed, 62 insertions, 59 deletions
diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp
index 288aace861..74c4cd9826 100644
--- a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp
+++ b/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp
@@ -27,68 +27,71 @@
#include "BC_OneDimReader.h"
#include "BC_OnedEAN13Reader.h"
const int32_t CBC_OnedEAN13Reader::FIRST_DIGIT_ENCODINGS[10] = {
- 0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A
-};
-CBC_OnedEAN13Reader::CBC_OnedEAN13Reader()
-{
-}
-CBC_OnedEAN13Reader::~CBC_OnedEAN13Reader()
-{
-}
-void CBC_OnedEAN13Reader::DetermineFirstDigit(CFX_ByteString &result, int32_t lgPatternFound, int32_t &e)
-{
- for (int32_t d = 0; d < 10; d++) {
- if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
- result.Insert(0, (FX_CHAR) ('0' + d));
- return;
- }
+ 0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A};
+CBC_OnedEAN13Reader::CBC_OnedEAN13Reader() {}
+CBC_OnedEAN13Reader::~CBC_OnedEAN13Reader() {}
+void CBC_OnedEAN13Reader::DetermineFirstDigit(CFX_ByteString& result,
+ int32_t lgPatternFound,
+ int32_t& e) {
+ for (int32_t d = 0; d < 10; d++) {
+ if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
+ result.Insert(0, (FX_CHAR)('0' + d));
+ return;
}
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+ }
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
}
-int32_t CBC_OnedEAN13Reader::DecodeMiddle(CBC_CommonBitArray *row, CFX_Int32Array *startRange, CFX_ByteString &resultString, int32_t &e)
-{
- CFX_Int32Array counters;
- counters.Add(0);
- counters.Add(0);
- counters.Add(0);
- counters.Add(0);
- int32_t end = row->GetSize();
- int32_t rowOffset = (*startRange)[1];
- int32_t lgPatternFound = 0;
- for (int32_t x = 0; x < 6 && rowOffset < end; x++) {
- int32_t bestMatch = DecodeDigit(row, &counters, rowOffset, &(CBC_OneDimReader::L_AND_G_PATTERNS[0][0]), 20, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- resultString += (FX_CHAR) ('0' + bestMatch % 10);
- for (int32_t i = 0; i < counters.GetSize(); i++) {
- rowOffset += counters[i];
- }
- if (bestMatch >= 10) {
- lgPatternFound |= 1 << (5 - x);
- }
- }
- DetermineFirstDigit(resultString, lgPatternFound, e);
+int32_t CBC_OnedEAN13Reader::DecodeMiddle(CBC_CommonBitArray* row,
+ CFX_Int32Array* startRange,
+ CFX_ByteString& resultString,
+ int32_t& e) {
+ CFX_Int32Array counters;
+ counters.Add(0);
+ counters.Add(0);
+ counters.Add(0);
+ counters.Add(0);
+ int32_t end = row->GetSize();
+ int32_t rowOffset = (*startRange)[1];
+ int32_t lgPatternFound = 0;
+ for (int32_t x = 0; x < 6 && rowOffset < end; x++) {
+ int32_t bestMatch =
+ DecodeDigit(row, &counters, rowOffset,
+ &(CBC_OneDimReader::L_AND_G_PATTERNS[0][0]), 20, e);
BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- CFX_Int32Array result;
- result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]);
- result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]);
- result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]);
- result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]);
- result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]);
- CFX_Int32Array *middleRange = FindGuardPattern(row, rowOffset, TRUE, &result, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- rowOffset = (*middleRange)[1];
- if(middleRange != NULL) {
- delete middleRange;
- middleRange = NULL;
+ resultString += (FX_CHAR)('0' + bestMatch % 10);
+ for (int32_t i = 0; i < counters.GetSize(); i++) {
+ rowOffset += counters[i];
+ }
+ if (bestMatch >= 10) {
+ lgPatternFound |= 1 << (5 - x);
}
- for (int32_t Y = 0; Y < 6 && rowOffset < end; Y++) {
- int32_t bestMatch = DecodeDigit(row, &counters, rowOffset, &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- resultString += (FX_CHAR) ('0' + bestMatch);
- for (int32_t k = 0; k < counters.GetSize(); k++) {
- rowOffset += counters[k];
- }
+ }
+ DetermineFirstDigit(resultString, lgPatternFound, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ CFX_Int32Array result;
+ result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]);
+ result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]);
+ result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]);
+ result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]);
+ result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]);
+ CFX_Int32Array* middleRange =
+ FindGuardPattern(row, rowOffset, TRUE, &result, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ rowOffset = (*middleRange)[1];
+ if (middleRange != NULL) {
+ delete middleRange;
+ middleRange = NULL;
+ }
+ for (int32_t Y = 0; Y < 6 && rowOffset < end; Y++) {
+ int32_t bestMatch =
+ DecodeDigit(row, &counters, rowOffset,
+ &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ resultString += (FX_CHAR)('0' + bestMatch);
+ for (int32_t k = 0; k < counters.GetSize(); k++) {
+ rowOffset += counters[k];
}
- return rowOffset;
+ }
+ return rowOffset;
}