diff options
author | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
commit | 9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch) | |
tree | c97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp | |
parent | 780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff) | |
download | pdfium-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_OnedCodaBarWriter.cpp')
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp | 345 |
1 files changed, 176 insertions, 169 deletions
diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp index 584f7bf1d8..eef810ac44 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp @@ -29,194 +29,201 @@ #include "BC_OneDimWriter.h"
#include "BC_OnedCodaBarReader.h"
#include "BC_OnedCodaBarWriter.h"
-const FX_CHAR CBC_OnedCodaBarWriter::START_END_CHARS[] = {'A', 'B', 'C', 'D', 'T', 'N', '*', 'E', 'a', 'b', 'c', 'd', 't', 'n', 'e'};
-const FX_CHAR CBC_OnedCodaBarWriter::CONTENT_CHARS[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '$', '/', ':', '+', '.'};
-CBC_OnedCodaBarWriter::CBC_OnedCodaBarWriter()
-{
- m_chStart = 'A';
- m_chEnd = 'B';
- m_iWideNarrRatio = 2;
+const FX_CHAR CBC_OnedCodaBarWriter::START_END_CHARS[] = {
+ 'A', 'B', 'C', 'D', 'T', 'N', '*', 'E', 'a', 'b', 'c', 'd', 't', 'n', 'e'};
+const FX_CHAR CBC_OnedCodaBarWriter::CONTENT_CHARS[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', '-', '$', '/', ':', '+', '.'};
+CBC_OnedCodaBarWriter::CBC_OnedCodaBarWriter() {
+ m_chStart = 'A';
+ m_chEnd = 'B';
+ m_iWideNarrRatio = 2;
}
-CBC_OnedCodaBarWriter::~CBC_OnedCodaBarWriter()
-{
-}
-FX_BOOL CBC_OnedCodaBarWriter::SetStartChar(FX_CHAR start)
-{
- for (int32_t i = 0; i < sizeof(START_END_CHARS) / sizeof(FX_CHAR); i++) {
- if (START_END_CHARS[i] == start) {
- m_chStart = start;
- return TRUE;
- }
+CBC_OnedCodaBarWriter::~CBC_OnedCodaBarWriter() {}
+FX_BOOL CBC_OnedCodaBarWriter::SetStartChar(FX_CHAR start) {
+ for (int32_t i = 0; i < sizeof(START_END_CHARS) / sizeof(FX_CHAR); i++) {
+ if (START_END_CHARS[i] == start) {
+ m_chStart = start;
+ return TRUE;
}
- return FALSE;
+ }
+ return FALSE;
}
-FX_BOOL CBC_OnedCodaBarWriter::SetEndChar(FX_CHAR end)
-{
- for (int32_t i = 0; i < sizeof(START_END_CHARS) / sizeof(FX_CHAR); i++) {
- if (START_END_CHARS[i] == end) {
- m_chEnd = end;
- return TRUE;
- }
+FX_BOOL CBC_OnedCodaBarWriter::SetEndChar(FX_CHAR end) {
+ for (int32_t i = 0; i < sizeof(START_END_CHARS) / sizeof(FX_CHAR); i++) {
+ if (START_END_CHARS[i] == end) {
+ m_chEnd = end;
+ return TRUE;
}
+ }
+ return FALSE;
+}
+void CBC_OnedCodaBarWriter::SetDataLength(int32_t length) {
+ m_iDataLenth = length + 2;
+}
+FX_BOOL CBC_OnedCodaBarWriter::SetTextLocation(BC_TEXT_LOC location) {
+ if (location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) {
return FALSE;
+ }
+ m_locTextLoc = location;
+ return TRUE;
}
-void CBC_OnedCodaBarWriter::SetDataLength(int32_t length)
-{
- m_iDataLenth = length + 2;
+FX_BOOL CBC_OnedCodaBarWriter::SetWideNarrowRatio(int32_t ratio) {
+ if (ratio < 2 || ratio > 3) {
+ return FALSE;
+ }
+ m_iWideNarrRatio = ratio;
+ return TRUE;
}
-FX_BOOL CBC_OnedCodaBarWriter::SetTextLocation(BC_TEXT_LOC location)
-{
- if ( location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) {
- return FALSE;
+FX_BOOL CBC_OnedCodaBarWriter::FindChar(FX_WCHAR ch, FX_BOOL isContent) {
+ if (isContent) {
+ for (int32_t i = 0; i < sizeof(CONTENT_CHARS) / sizeof(FX_CHAR); i++) {
+ if (ch == (FX_WCHAR)CONTENT_CHARS[i]) {
+ return TRUE;
+ }
}
- m_locTextLoc = location;
- return TRUE;
-}
-FX_BOOL CBC_OnedCodaBarWriter::SetWideNarrowRatio(int32_t ratio)
-{
- if(ratio < 2 || ratio > 3) {
- return FALSE;
+ for (int32_t j = 0; j < sizeof(START_END_CHARS) / sizeof(FX_CHAR); j++) {
+ if (ch == (FX_WCHAR)START_END_CHARS[j]) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+ } else {
+ for (int32_t i = 0; i < sizeof(CONTENT_CHARS) / sizeof(FX_CHAR); i++) {
+ if (ch == (FX_WCHAR)CONTENT_CHARS[i]) {
+ return TRUE;
+ }
}
- m_iWideNarrRatio = ratio;
- return TRUE;
+ return FALSE;
+ }
}
-FX_BOOL CBC_OnedCodaBarWriter::FindChar(FX_WCHAR ch, FX_BOOL isContent)
-{
- if(isContent) {
- for(int32_t i = 0 ; i < sizeof(CONTENT_CHARS) / sizeof(FX_CHAR) ; i++) {
- if(ch == (FX_WCHAR)CONTENT_CHARS[i]) {
- return TRUE;
- }
- }
- for(int32_t j = 0 ; j < sizeof(START_END_CHARS) / sizeof(FX_CHAR) ; j++) {
- if(ch == (FX_WCHAR)START_END_CHARS[j]) {
- return TRUE;
- }
- }
- return FALSE;
+FX_BOOL CBC_OnedCodaBarWriter::CheckContentValidity(
+ const CFX_WideStringC& contents) {
+ FX_WCHAR ch;
+ int32_t index = 0;
+ for (index = 0; index < contents.GetLength(); index++) {
+ ch = contents.GetAt(index);
+ if (FindChar(ch, FALSE)) {
+ continue;
} else {
- for(int32_t i = 0 ; i < sizeof(CONTENT_CHARS) / sizeof(FX_CHAR) ; i++) {
- if(ch == (FX_WCHAR)CONTENT_CHARS[i]) {
- return TRUE;
- }
- }
- return FALSE;
+ return FALSE;
}
+ }
+ return TRUE;
}
-FX_BOOL CBC_OnedCodaBarWriter::CheckContentValidity(const CFX_WideStringC& contents)
-{
- FX_WCHAR ch;
- int32_t index = 0;
- for (index = 0; index < contents.GetLength(); index++) {
- ch = contents.GetAt(index);
- if (FindChar(ch, FALSE)) {
- continue;
- } else {
- return FALSE;
- }
+CFX_WideString CBC_OnedCodaBarWriter::FilterContents(
+ const CFX_WideStringC& contents) {
+ CFX_WideString filtercontents;
+ FX_WCHAR ch;
+ for (int32_t index = 0; index < contents.GetLength(); index++) {
+ ch = contents.GetAt(index);
+ if (ch > 175) {
+ index++;
+ continue;
}
- return TRUE;
-}
-CFX_WideString CBC_OnedCodaBarWriter::FilterContents(const CFX_WideStringC& contents)
-{
- CFX_WideString filtercontents;
- FX_WCHAR ch;
- for (int32_t index = 0; index < contents.GetLength(); index ++) {
- ch = contents.GetAt(index);
- if(ch > 175) {
- index++;
- continue;
- }
- if (FindChar(ch, TRUE)) {
- filtercontents += ch;
- } else {
- continue;
- }
+ if (FindChar(ch, TRUE)) {
+ filtercontents += ch;
+ } else {
+ continue;
}
- return filtercontents;
+ }
+ return filtercontents;
}
-uint8_t *CBC_OnedCodaBarWriter::Encode(const CFX_ByteString &contents, BCFORMAT format, int32_t &outWidth, int32_t &outHeight, int32_t &e)
-{
- uint8_t *ret = Encode(contents, format, outWidth, outHeight, 0 , e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return ret;
+uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents,
+ BCFORMAT format,
+ int32_t& outWidth,
+ int32_t& outHeight,
+ int32_t& e) {
+ uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return ret;
}
-uint8_t *CBC_OnedCodaBarWriter::Encode(const CFX_ByteString &contents, BCFORMAT format, int32_t &outWidth, int32_t &outHeight, int32_t hints, int32_t &e)
-{
- if(format != BCFORMAT_CODABAR) {
- e = BCExceptionOnlyEncodeCODEBAR;
- return NULL;
- }
- uint8_t *ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return ret;
+uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents,
+ BCFORMAT format,
+ int32_t& outWidth,
+ int32_t& outHeight,
+ int32_t hints,
+ int32_t& e) {
+ if (format != BCFORMAT_CODABAR) {
+ e = BCExceptionOnlyEncodeCODEBAR;
+ return NULL;
+ }
+ uint8_t* ret =
+ CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return ret;
}
-uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString &contents, int32_t &outLength, int32_t &e)
-{
- CBC_OnedCodaBarReader CodaBarR;
- CFX_ByteString data = m_chStart + contents + m_chEnd;
- m_iContentLen = data.GetLength();
- uint8_t *result = FX_Alloc(uint8_t, m_iWideNarrRatio * 7 * data.GetLength());
- FX_CHAR ch;
- int32_t position = 0;
- for (int32_t index = 0; index < data.GetLength(); index++) {
- ch = data.GetAt(index);
- if (((ch >= 'a') && (ch <= 'z'))) {
- ch = ch - 32;
- }
- switch (ch) {
- case 'T':
- ch = 'A';
- break;
- case 'N':
- ch = 'B';
- break;
- case '*':
- ch = 'C';
- break;
- case 'E':
- ch = 'D';
- break;
- default:
- break;
- }
- int32_t code = 0;
- int32_t len = (int32_t)strlen(CodaBarR.ALPHABET_STRING);
- for (int32_t i = 0; i < len; i++) {
- if (ch == CodaBarR.ALPHABET_STRING[i]) {
- code = CodaBarR.CHARACTER_ENCODINGS[i];
- break;
- }
- }
- uint8_t color = 1;
- int32_t counter = 0;
- int32_t bit = 0;
- while (bit < 7) {
- result[position] = color;
- position++;
- if (((code >> (6 - bit)) & 1) == 0 || counter == m_iWideNarrRatio - 1) {
- color = !color;
- bit++;
- counter = 0;
- } else {
- counter++;
- }
- }
- if (index < data.GetLength() - 1) {
- result[position] = 0;
- position ++;
- }
+uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents,
+ int32_t& outLength,
+ int32_t& e) {
+ CBC_OnedCodaBarReader CodaBarR;
+ CFX_ByteString data = m_chStart + contents + m_chEnd;
+ m_iContentLen = data.GetLength();
+ uint8_t* result = FX_Alloc(uint8_t, m_iWideNarrRatio * 7 * data.GetLength());
+ FX_CHAR ch;
+ int32_t position = 0;
+ for (int32_t index = 0; index < data.GetLength(); index++) {
+ ch = data.GetAt(index);
+ if (((ch >= 'a') && (ch <= 'z'))) {
+ ch = ch - 32;
+ }
+ switch (ch) {
+ case 'T':
+ ch = 'A';
+ break;
+ case 'N':
+ ch = 'B';
+ break;
+ case '*':
+ ch = 'C';
+ break;
+ case 'E':
+ ch = 'D';
+ break;
+ default:
+ break;
+ }
+ int32_t code = 0;
+ int32_t len = (int32_t)strlen(CodaBarR.ALPHABET_STRING);
+ for (int32_t i = 0; i < len; i++) {
+ if (ch == CodaBarR.ALPHABET_STRING[i]) {
+ code = CodaBarR.CHARACTER_ENCODINGS[i];
+ break;
+ }
+ }
+ uint8_t color = 1;
+ int32_t counter = 0;
+ int32_t bit = 0;
+ while (bit < 7) {
+ result[position] = color;
+ position++;
+ if (((code >> (6 - bit)) & 1) == 0 || counter == m_iWideNarrRatio - 1) {
+ color = !color;
+ bit++;
+ counter = 0;
+ } else {
+ counter++;
+ }
+ }
+ if (index < data.GetLength() - 1) {
+ result[position] = 0;
+ position++;
}
- outLength = position;
- return result;
+ }
+ outLength = position;
+ return result;
}
-CFX_WideString CBC_OnedCodaBarWriter::encodedContents(const CFX_WideStringC& contents)
-{
- CFX_WideString strStart(m_chStart);
- CFX_WideString strEnd(m_chEnd);
- return strStart + contents + strEnd;
+CFX_WideString CBC_OnedCodaBarWriter::encodedContents(
+ const CFX_WideStringC& contents) {
+ CFX_WideString strStart(m_chStart);
+ CFX_WideString strEnd(m_chEnd);
+ return strStart + contents + strEnd;
}
-void CBC_OnedCodaBarWriter::RenderResult(const CFX_WideStringC& contents, uint8_t* code, int32_t codeLength, FX_BOOL isDevice, int32_t &e)
-{
- CBC_OneDimWriter::RenderResult(encodedContents(contents), code, codeLength, isDevice, e);
+void CBC_OnedCodaBarWriter::RenderResult(const CFX_WideStringC& contents,
+ uint8_t* code,
+ int32_t codeLength,
+ FX_BOOL isDevice,
+ int32_t& e) {
+ CBC_OneDimWriter::RenderResult(encodedContents(contents), code, codeLength,
+ isDevice, e);
}
|