summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.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/pdf417/BC_PDF417HighLevelEncoder.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/pdf417/BC_PDF417HighLevelEncoder.cpp')
-rw-r--r--xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp706
1 files changed, 357 insertions, 349 deletions
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
index 38efe93339..80694b91f3 100644
--- a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
+++ b/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
@@ -25,9 +25,9 @@
#include "../../../../third_party/bigint/BigIntegerLibrary.hh"
#include "BC_PDF417Compaction.h"
#include "BC_PDF417HighLevelEncoder.h"
-#define SUBMODE_ALPHA 0
-#define SUBMODE_LOWER 1
-#define SUBMODE_MIXED 2
+#define SUBMODE_ALPHA 0
+#define SUBMODE_LOWER 1
+#define SUBMODE_MIXED 2
int32_t CBC_PDF417HighLevelEncoder::TEXT_COMPACTION = 0;
int32_t CBC_PDF417HighLevelEncoder::BYTE_COMPACTION = 1;
int32_t CBC_PDF417HighLevelEncoder::NUMERIC_COMPACTION = 2;
@@ -37,384 +37,392 @@ int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE_PADDED = 901;
int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_NUMERIC = 902;
int32_t CBC_PDF417HighLevelEncoder::SHIFT_TO_BYTE = 913;
int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE = 924;
-uint8_t CBC_PDF417HighLevelEncoder::TEXT_MIXED_RAW[] = {48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 38, 13, 9, 44, 58,
- 35, 45, 46, 36, 47, 43, 37, 42, 61, 94, 0, 32, 0, 0, 0
- };
-uint8_t CBC_PDF417HighLevelEncoder::TEXT_PUNCTUATION_RAW[] = {59, 60, 62, 64, 91, 92, 93, 95, 96, 126, 33, 13, 9, 44, 58,
- 10, 45, 46, 36, 47, 34, 124, 42, 40, 41, 63, 123, 125, 39, 0
- };
+uint8_t CBC_PDF417HighLevelEncoder::TEXT_MIXED_RAW[] = {
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 38, 13, 9, 44, 58,
+ 35, 45, 46, 36, 47, 43, 37, 42, 61, 94, 0, 32, 0, 0, 0};
+uint8_t CBC_PDF417HighLevelEncoder::TEXT_PUNCTUATION_RAW[] = {
+ 59, 60, 62, 64, 91, 92, 93, 95, 96, 126, 33, 13, 9, 44, 58,
+ 10, 45, 46, 36, 47, 34, 124, 42, 40, 41, 63, 123, 125, 39, 0};
int32_t CBC_PDF417HighLevelEncoder::MIXED[128] = {0};
int32_t CBC_PDF417HighLevelEncoder::PUNCTUATION[128] = {0};
-void CBC_PDF417HighLevelEncoder::Initialize()
-{
- Inverse();
+void CBC_PDF417HighLevelEncoder::Initialize() {
+ Inverse();
}
-void CBC_PDF417HighLevelEncoder::Finalize()
-{
-}
-CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel(CFX_WideString wideMsg, Compaction compaction, int32_t &e)
-{
- CFX_ByteString bytes;
- CBC_UtilCodingConvert::UnicodeToUTF8(wideMsg, bytes);
- CFX_WideString msg;
- int32_t len = bytes.GetLength();
- for (int32_t i = 0; i < len; i++) {
- FX_WCHAR ch = (FX_WCHAR)(bytes.GetAt(i) & 0xff);
- if (ch == '?' && bytes.GetAt(i) != '?') {
- e = BCExceptionCharactersOutsideISO88591Encoding;
- return (FX_WCHAR*)"";
- }
- msg += ch;
+void CBC_PDF417HighLevelEncoder::Finalize() {}
+CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel(
+ CFX_WideString wideMsg,
+ Compaction compaction,
+ int32_t& e) {
+ CFX_ByteString bytes;
+ CBC_UtilCodingConvert::UnicodeToUTF8(wideMsg, bytes);
+ CFX_WideString msg;
+ int32_t len = bytes.GetLength();
+ for (int32_t i = 0; i < len; i++) {
+ FX_WCHAR ch = (FX_WCHAR)(bytes.GetAt(i) & 0xff);
+ if (ch == '?' && bytes.GetAt(i) != '?') {
+ e = BCExceptionCharactersOutsideISO88591Encoding;
+ return (FX_WCHAR*)"";
}
- CFX_ByteArray byteArr;
- for (int32_t k = 0; k < bytes.GetLength(); k++) {
- byteArr.Add(bytes.GetAt(k));
- }
- CFX_WideString sb;
- len = msg.GetLength();
- int32_t p = 0;
- int32_t textSubMode = SUBMODE_ALPHA;
- if (compaction == TEXT) {
- encodeText(msg, p, len, sb, textSubMode);
- } else if (compaction == BYTES) {
- encodeBinary(&byteArr, p, byteArr.GetSize(), BYTE_COMPACTION, sb);
- } else if (compaction == NUMERIC) {
- sb += (FX_WCHAR) LATCH_TO_NUMERIC;
- encodeNumeric(msg, p, len, sb);
- } else {
- int32_t encodingMode = LATCH_TO_TEXT;
- while (p < len) {
- int32_t n = determineConsecutiveDigitCount(msg, p);
- if (n >= 13) {
- sb += (FX_WCHAR) LATCH_TO_NUMERIC;
- encodingMode = NUMERIC_COMPACTION;
- textSubMode = SUBMODE_ALPHA;
- encodeNumeric(msg, p, n, sb);
- p += n;
- } else {
- int32_t t = determineConsecutiveTextCount(msg, p);
- if (t >= 5 || n == len) {
- if (encodingMode != TEXT_COMPACTION) {
- sb += (FX_WCHAR) LATCH_TO_TEXT;
- encodingMode = TEXT_COMPACTION;
- textSubMode = SUBMODE_ALPHA;
- }
- textSubMode = encodeText(msg, p, t, sb, textSubMode);
- p += t;
- } else {
- int32_t b = determineConsecutiveBinaryCount(msg, &byteArr, p, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' ');
- if (b == 0) {
- b = 1;
- }
- if (b == 1 && encodingMode == TEXT_COMPACTION) {
- encodeBinary(&byteArr, p, 1, TEXT_COMPACTION, sb);
- } else {
- encodeBinary(&byteArr, p, b, encodingMode, sb);
- encodingMode = BYTE_COMPACTION;
- textSubMode = SUBMODE_ALPHA;
- }
- p += b;
- }
- }
+ msg += ch;
+ }
+ CFX_ByteArray byteArr;
+ for (int32_t k = 0; k < bytes.GetLength(); k++) {
+ byteArr.Add(bytes.GetAt(k));
+ }
+ CFX_WideString sb;
+ len = msg.GetLength();
+ int32_t p = 0;
+ int32_t textSubMode = SUBMODE_ALPHA;
+ if (compaction == TEXT) {
+ encodeText(msg, p, len, sb, textSubMode);
+ } else if (compaction == BYTES) {
+ encodeBinary(&byteArr, p, byteArr.GetSize(), BYTE_COMPACTION, sb);
+ } else if (compaction == NUMERIC) {
+ sb += (FX_WCHAR)LATCH_TO_NUMERIC;
+ encodeNumeric(msg, p, len, sb);
+ } else {
+ int32_t encodingMode = LATCH_TO_TEXT;
+ while (p < len) {
+ int32_t n = determineConsecutiveDigitCount(msg, p);
+ if (n >= 13) {
+ sb += (FX_WCHAR)LATCH_TO_NUMERIC;
+ encodingMode = NUMERIC_COMPACTION;
+ textSubMode = SUBMODE_ALPHA;
+ encodeNumeric(msg, p, n, sb);
+ p += n;
+ } else {
+ int32_t t = determineConsecutiveTextCount(msg, p);
+ if (t >= 5 || n == len) {
+ if (encodingMode != TEXT_COMPACTION) {
+ sb += (FX_WCHAR)LATCH_TO_TEXT;
+ encodingMode = TEXT_COMPACTION;
+ textSubMode = SUBMODE_ALPHA;
+ }
+ textSubMode = encodeText(msg, p, t, sb, textSubMode);
+ p += t;
+ } else {
+ int32_t b = determineConsecutiveBinaryCount(msg, &byteArr, p, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' ');
+ if (b == 0) {
+ b = 1;
+ }
+ if (b == 1 && encodingMode == TEXT_COMPACTION) {
+ encodeBinary(&byteArr, p, 1, TEXT_COMPACTION, sb);
+ } else {
+ encodeBinary(&byteArr, p, b, encodingMode, sb);
+ encodingMode = BYTE_COMPACTION;
+ textSubMode = SUBMODE_ALPHA;
+ }
+ p += b;
}
+ }
}
- return sb;
+ }
+ return sb;
}
-void CBC_PDF417HighLevelEncoder::Inverse()
-{
- uint8_t i = 0;
- int32_t l = 0;
- for (l = 0; l < sizeof(MIXED) / sizeof(MIXED[0]); l++) {
- MIXED[l] = -1;
- }
- for (i = 0; i < sizeof(TEXT_MIXED_RAW) / sizeof(TEXT_MIXED_RAW[0]); i++) {
- uint8_t b = TEXT_MIXED_RAW[i];
- if (b > 0) {
- MIXED[b] = i;
- }
+void CBC_PDF417HighLevelEncoder::Inverse() {
+ uint8_t i = 0;
+ int32_t l = 0;
+ for (l = 0; l < sizeof(MIXED) / sizeof(MIXED[0]); l++) {
+ MIXED[l] = -1;
+ }
+ for (i = 0; i < sizeof(TEXT_MIXED_RAW) / sizeof(TEXT_MIXED_RAW[0]); i++) {
+ uint8_t b = TEXT_MIXED_RAW[i];
+ if (b > 0) {
+ MIXED[b] = i;
}
- for (l = 0; l < sizeof(PUNCTUATION) / sizeof(PUNCTUATION[0]); l++) {
- PUNCTUATION[l] = -1;
- }
- for (i = 0; i < sizeof(TEXT_PUNCTUATION_RAW) / sizeof(TEXT_PUNCTUATION_RAW[0]); i++) {
- uint8_t b = TEXT_PUNCTUATION_RAW[i];
- if (b > 0) {
- PUNCTUATION[b] = i;
- }
+ }
+ for (l = 0; l < sizeof(PUNCTUATION) / sizeof(PUNCTUATION[0]); l++) {
+ PUNCTUATION[l] = -1;
+ }
+ for (i = 0;
+ i < sizeof(TEXT_PUNCTUATION_RAW) / sizeof(TEXT_PUNCTUATION_RAW[0]);
+ i++) {
+ uint8_t b = TEXT_PUNCTUATION_RAW[i];
+ if (b > 0) {
+ PUNCTUATION[b] = i;
}
+ }
}
-int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, int32_t startpos, int32_t count, CFX_WideString &sb, int32_t initialSubmode)
-{
- CFX_WideString tmp;
- int32_t submode = initialSubmode;
- int32_t idx = 0;
- while (TRUE) {
- FX_WCHAR ch = msg.GetAt(startpos + idx);
- switch (submode) {
- case SUBMODE_ALPHA:
- if (isAlphaUpper(ch)) {
- if (ch == ' ') {
- tmp += (FX_WCHAR) 26;
- } else {
- tmp += (FX_WCHAR) (ch - 65);
- }
- } else {
- if (isAlphaLower(ch)) {
- submode = SUBMODE_LOWER;
- tmp += (FX_WCHAR) 27;
- continue;
- } else if (isMixed(ch)) {
- submode = SUBMODE_MIXED;
- tmp += (FX_WCHAR) 28;
- continue;
- } else {
- tmp += (FX_WCHAR) 29;
- tmp += PUNCTUATION[ch];
- break;
- }
- }
- break;
- case SUBMODE_LOWER:
- if (isAlphaLower(ch)) {
- if (ch == ' ') {
- tmp += (FX_WCHAR) 26;
- } else {
- tmp += (FX_WCHAR) (ch - 97);
- }
- } else {
- if (isAlphaUpper(ch)) {
- tmp += (FX_WCHAR) 27;
- tmp += (FX_WCHAR) (ch - 65);
- break;
- } else if (isMixed(ch)) {
- submode = SUBMODE_MIXED;
- tmp += (FX_WCHAR) 28;
- continue;
- } else {
- tmp += (FX_WCHAR) 29;
- tmp += PUNCTUATION[ch];
- break;
- }
- }
- break;
- case SUBMODE_MIXED:
- if (isMixed(ch)) {
- FX_WCHAR a = MIXED[ch];
- int32_t b = (int32_t)a;
- tmp += MIXED[ch];
- } else {
- if (isAlphaUpper(ch)) {
- submode = SUBMODE_ALPHA;
- tmp += (FX_WCHAR) 28;
- continue;
- } else if (isAlphaLower(ch)) {
- submode = SUBMODE_LOWER;
- tmp += (FX_WCHAR) 27;
- continue;
- } else {
- if (startpos + idx + 1 < count) {
- FX_WCHAR next = msg.GetAt(startpos + idx + 1);
- if (isPunctuation(next)) {
- submode = SUBMODE_PUNCTUATION;
- tmp += (FX_WCHAR) 25;
- continue;
- }
- }
- tmp += (FX_WCHAR) 29;
- tmp += PUNCTUATION[ch];
- }
- }
- break;
- default:
- if (isPunctuation(ch)) {
- tmp += PUNCTUATION[ch];
- } else {
- submode = SUBMODE_ALPHA;
- tmp += (FX_WCHAR) 29;
- continue;
- }
- }
- idx++;
- if (idx >= count) {
+int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg,
+ int32_t startpos,
+ int32_t count,
+ CFX_WideString& sb,
+ int32_t initialSubmode) {
+ CFX_WideString tmp;
+ int32_t submode = initialSubmode;
+ int32_t idx = 0;
+ while (TRUE) {
+ FX_WCHAR ch = msg.GetAt(startpos + idx);
+ switch (submode) {
+ case SUBMODE_ALPHA:
+ if (isAlphaUpper(ch)) {
+ if (ch == ' ') {
+ tmp += (FX_WCHAR)26;
+ } else {
+ tmp += (FX_WCHAR)(ch - 65);
+ }
+ } else {
+ if (isAlphaLower(ch)) {
+ submode = SUBMODE_LOWER;
+ tmp += (FX_WCHAR)27;
+ continue;
+ } else if (isMixed(ch)) {
+ submode = SUBMODE_MIXED;
+ tmp += (FX_WCHAR)28;
+ continue;
+ } else {
+ tmp += (FX_WCHAR)29;
+ tmp += PUNCTUATION[ch];
break;
+ }
}
- }
- FX_WCHAR h = 0;
- int32_t len = tmp.GetLength();
- for (int32_t i = 0; i < len; i++) {
- FX_BOOL odd = (i % 2) != 0;
- if (odd) {
- h = (FX_WCHAR) ((h * 30) + tmp.GetAt(i));
- sb += h;
+ break;
+ case SUBMODE_LOWER:
+ if (isAlphaLower(ch)) {
+ if (ch == ' ') {
+ tmp += (FX_WCHAR)26;
+ } else {
+ tmp += (FX_WCHAR)(ch - 97);
+ }
} else {
- h = tmp.GetAt(i);
+ if (isAlphaUpper(ch)) {
+ tmp += (FX_WCHAR)27;
+ tmp += (FX_WCHAR)(ch - 65);
+ break;
+ } else if (isMixed(ch)) {
+ submode = SUBMODE_MIXED;
+ tmp += (FX_WCHAR)28;
+ continue;
+ } else {
+ tmp += (FX_WCHAR)29;
+ tmp += PUNCTUATION[ch];
+ break;
+ }
}
- }
- if ((len % 2) != 0) {
- sb += (FX_WCHAR) ((h * 30) + 29);
- }
- return submode;
-}
-void CBC_PDF417HighLevelEncoder::encodeBinary(CFX_ByteArray* bytes, int32_t startpos, int32_t count, int32_t startmode, CFX_WideString &sb)
-{
- if (count == 1 && startmode == TEXT_COMPACTION) {
- sb += (FX_WCHAR) SHIFT_TO_BYTE;
- }
- int32_t idx = startpos;
- int32_t i = 0;
- if (count >= 6) {
- sb += (FX_WCHAR) LATCH_TO_BYTE;
- FX_WCHAR chars[5];
- while ((startpos + count - idx) >= 6) {
- int64_t t = 0;
- for (i = 0; i < 6; i++) {
- t <<= 8;
- t += bytes->GetAt(idx + i) & 0xff;
- }
- for (i = 0; i < 5; i++) {
- chars[i] = (FX_WCHAR) (t % 900);
- t /= 900;
- }
- for (i = 4; i >= 0; i--) {
- sb += (chars[i]);
+ break;
+ case SUBMODE_MIXED:
+ if (isMixed(ch)) {
+ FX_WCHAR a = MIXED[ch];
+ int32_t b = (int32_t)a;
+ tmp += MIXED[ch];
+ } else {
+ if (isAlphaUpper(ch)) {
+ submode = SUBMODE_ALPHA;
+ tmp += (FX_WCHAR)28;
+ continue;
+ } else if (isAlphaLower(ch)) {
+ submode = SUBMODE_LOWER;
+ tmp += (FX_WCHAR)27;
+ continue;
+ } else {
+ if (startpos + idx + 1 < count) {
+ FX_WCHAR next = msg.GetAt(startpos + idx + 1);
+ if (isPunctuation(next)) {
+ submode = SUBMODE_PUNCTUATION;
+ tmp += (FX_WCHAR)25;
+ continue;
+ }
}
- idx += 6;
+ tmp += (FX_WCHAR)29;
+ tmp += PUNCTUATION[ch];
+ }
+ }
+ break;
+ default:
+ if (isPunctuation(ch)) {
+ tmp += PUNCTUATION[ch];
+ } else {
+ submode = SUBMODE_ALPHA;
+ tmp += (FX_WCHAR)29;
+ continue;
}
}
- if (idx < startpos + count) {
- sb += (FX_WCHAR) LATCH_TO_BYTE_PADDED;
+ idx++;
+ if (idx >= count) {
+ break;
}
- for (i = idx; i < startpos + count; i++) {
- int32_t ch = bytes->GetAt(i) & 0xff;
- sb += (FX_WCHAR) ch;
+ }
+ FX_WCHAR h = 0;
+ int32_t len = tmp.GetLength();
+ for (int32_t i = 0; i < len; i++) {
+ FX_BOOL odd = (i % 2) != 0;
+ if (odd) {
+ h = (FX_WCHAR)((h * 30) + tmp.GetAt(i));
+ sb += h;
+ } else {
+ h = tmp.GetAt(i);
}
+ }
+ if ((len % 2) != 0) {
+ sb += (FX_WCHAR)((h * 30) + 29);
+ }
+ return submode;
}
-void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg, int32_t startpos, int32_t count, CFX_WideString &sb)
-{
- int32_t idx = 0;
- BigInteger num900 = 900;
- while (idx < count) {
- CFX_WideString tmp;
- int32_t len = 44 < count - idx ? 44 : count - idx;
- CFX_ByteString part = ((FX_WCHAR)'1' + msg.Mid(startpos + idx, len)).UTF8Encode();
- BigInteger bigint = stringToBigInteger(part.c_str());
- do {
- int32_t c = (bigint % num900).toInt();
- tmp += (FX_WCHAR)(c);
- bigint = bigint / num900;
- } while (!bigint.isZero());
- for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) {
- sb += tmp.GetAt(i);
- }
- idx += len;
+void CBC_PDF417HighLevelEncoder::encodeBinary(CFX_ByteArray* bytes,
+ int32_t startpos,
+ int32_t count,
+ int32_t startmode,
+ CFX_WideString& sb) {
+ if (count == 1 && startmode == TEXT_COMPACTION) {
+ sb += (FX_WCHAR)SHIFT_TO_BYTE;
+ }
+ int32_t idx = startpos;
+ int32_t i = 0;
+ if (count >= 6) {
+ sb += (FX_WCHAR)LATCH_TO_BYTE;
+ FX_WCHAR chars[5];
+ while ((startpos + count - idx) >= 6) {
+ int64_t t = 0;
+ for (i = 0; i < 6; i++) {
+ t <<= 8;
+ t += bytes->GetAt(idx + i) & 0xff;
+ }
+ for (i = 0; i < 5; i++) {
+ chars[i] = (FX_WCHAR)(t % 900);
+ t /= 900;
+ }
+ for (i = 4; i >= 0; i--) {
+ sb += (chars[i]);
+ }
+ idx += 6;
}
+ }
+ if (idx < startpos + count) {
+ sb += (FX_WCHAR)LATCH_TO_BYTE_PADDED;
+ }
+ for (i = idx; i < startpos + count; i++) {
+ int32_t ch = bytes->GetAt(i) & 0xff;
+ sb += (FX_WCHAR)ch;
+ }
}
-FX_BOOL CBC_PDF417HighLevelEncoder::isDigit(FX_WCHAR ch)
-{
- return ch >= '0' && ch <= '9';
+void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg,
+ int32_t startpos,
+ int32_t count,
+ CFX_WideString& sb) {
+ int32_t idx = 0;
+ BigInteger num900 = 900;
+ while (idx < count) {
+ CFX_WideString tmp;
+ int32_t len = 44 < count - idx ? 44 : count - idx;
+ CFX_ByteString part =
+ ((FX_WCHAR)'1' + msg.Mid(startpos + idx, len)).UTF8Encode();
+ BigInteger bigint = stringToBigInteger(part.c_str());
+ do {
+ int32_t c = (bigint % num900).toInt();
+ tmp += (FX_WCHAR)(c);
+ bigint = bigint / num900;
+ } while (!bigint.isZero());
+ for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) {
+ sb += tmp.GetAt(i);
+ }
+ idx += len;
+ }
}
-FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaUpper(FX_WCHAR ch)
-{
- return ch == ' ' || (ch >= 'A' && ch <= 'Z');
+FX_BOOL CBC_PDF417HighLevelEncoder::isDigit(FX_WCHAR ch) {
+ return ch >= '0' && ch <= '9';
}
-FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaLower(FX_WCHAR ch)
-{
- return ch == ' ' || (ch >= 'a' && ch <= 'z');
+FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaUpper(FX_WCHAR ch) {
+ return ch == ' ' || (ch >= 'A' && ch <= 'Z');
}
-FX_BOOL CBC_PDF417HighLevelEncoder::isMixed(FX_WCHAR ch)
-{
- return MIXED[ch] != -1;
+FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaLower(FX_WCHAR ch) {
+ return ch == ' ' || (ch >= 'a' && ch <= 'z');
}
-FX_BOOL CBC_PDF417HighLevelEncoder::isPunctuation(FX_WCHAR ch)
-{
- return PUNCTUATION[ch] != -1;
+FX_BOOL CBC_PDF417HighLevelEncoder::isMixed(FX_WCHAR ch) {
+ return MIXED[ch] != -1;
}
-FX_BOOL CBC_PDF417HighLevelEncoder::isText(FX_WCHAR ch)
-{
- return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126);
+FX_BOOL CBC_PDF417HighLevelEncoder::isPunctuation(FX_WCHAR ch) {
+ return PUNCTUATION[ch] != -1;
}
-int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount(CFX_WideString msg, int32_t startpos)
-{
- int32_t count = 0;
- int32_t len = msg.GetLength();
- int32_t idx = startpos;
- if (idx < len) {
- FX_WCHAR ch = msg.GetAt(idx);
- while (isDigit(ch) && idx < len) {
- count++;
- idx++;
- if (idx < len) {
- ch = msg.GetAt(idx);
- }
- }
- }
- return count;
+FX_BOOL CBC_PDF417HighLevelEncoder::isText(FX_WCHAR ch) {
+ return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126);
}
-int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(CFX_WideString msg, int32_t startpos)
-{
- int32_t len = msg.GetLength();
- int32_t idx = startpos;
- while (idx < len) {
- FX_WCHAR ch = msg.GetAt(idx);
- int32_t numericCount = 0;
- while (numericCount < 13 && isDigit(ch) && idx < len) {
- numericCount++;
- idx++;
- if (idx < len) {
- ch = msg.GetAt(idx);
- }
- }
- if (numericCount >= 13) {
- return idx - startpos - numericCount;
- }
- if (numericCount > 0) {
- continue;
- }
+int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount(
+ CFX_WideString msg,
+ int32_t startpos) {
+ int32_t count = 0;
+ int32_t len = msg.GetLength();
+ int32_t idx = startpos;
+ if (idx < len) {
+ FX_WCHAR ch = msg.GetAt(idx);
+ while (isDigit(ch) && idx < len) {
+ count++;
+ idx++;
+ if (idx < len) {
ch = msg.GetAt(idx);
- if (!isText(ch)) {
- break;
- }
- idx++;
+ }
}
- return idx - startpos;
+ }
+ return count;
}
-int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(CFX_WideString msg, CFX_ByteArray* bytes, int32_t startpos, int32_t &e)
-{
- int32_t len = msg.GetLength();
- int32_t idx = startpos;
- while (idx < len) {
- FX_WCHAR ch = msg.GetAt(idx);
- int32_t numericCount = 0;
- while (numericCount < 13 && isDigit(ch)) {
- numericCount++;
- int32_t i = idx + numericCount;
- if (i >= len) {
- break;
- }
- ch = msg.GetAt(i);
- }
- if (numericCount >= 13) {
- return idx - startpos;
- }
- int32_t textCount = 0;
- while (textCount < 5 && isText(ch)) {
- textCount++;
- int32_t i = idx + textCount;
- if (i >= len) {
- break;
- }
- ch = msg.GetAt(i);
- }
- if (textCount >= 5) {
- return idx - startpos;
- }
+int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(
+ CFX_WideString msg,
+ int32_t startpos) {
+ int32_t len = msg.GetLength();
+ int32_t idx = startpos;
+ while (idx < len) {
+ FX_WCHAR ch = msg.GetAt(idx);
+ int32_t numericCount = 0;
+ while (numericCount < 13 && isDigit(ch) && idx < len) {
+ numericCount++;
+ idx++;
+ if (idx < len) {
ch = msg.GetAt(idx);
- if (bytes->GetAt(idx) == 63 && ch != '?') {
- e = BCExceptionNonEncodableCharacterDetected;
- return -1;
- }
- idx++;
+ }
+ }
+ if (numericCount >= 13) {
+ return idx - startpos - numericCount;
+ }
+ if (numericCount > 0) {
+ continue;
+ }
+ ch = msg.GetAt(idx);
+ if (!isText(ch)) {
+ break;
+ }
+ idx++;
+ }
+ return idx - startpos;
+}
+int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(
+ CFX_WideString msg,
+ CFX_ByteArray* bytes,
+ int32_t startpos,
+ int32_t& e) {
+ int32_t len = msg.GetLength();
+ int32_t idx = startpos;
+ while (idx < len) {
+ FX_WCHAR ch = msg.GetAt(idx);
+ int32_t numericCount = 0;
+ while (numericCount < 13 && isDigit(ch)) {
+ numericCount++;
+ int32_t i = idx + numericCount;
+ if (i >= len) {
+ break;
+ }
+ ch = msg.GetAt(i);
+ }
+ if (numericCount >= 13) {
+ return idx - startpos;
+ }
+ int32_t textCount = 0;
+ while (textCount < 5 && isText(ch)) {
+ textCount++;
+ int32_t i = idx + textCount;
+ if (i >= len) {
+ break;
+ }
+ ch = msg.GetAt(i);
+ }
+ if (textCount >= 5) {
+ return idx - startpos;
+ }
+ ch = msg.GetAt(idx);
+ if (bytes->GetAt(idx) == 63 && ch != '?') {
+ e = BCExceptionNonEncodableCharacterDetected;
+ return -1;
}
- return idx - startpos;
+ idx++;
+ }
+ return idx - startpos;
}