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/datamatrix/BC_DefaultPlacement.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/datamatrix/BC_DefaultPlacement.cpp')
-rw-r--r-- | xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp | 254 |
1 files changed, 122 insertions, 132 deletions
diff --git a/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp b/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp index 57c6cc92d2..86c2a80210 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp @@ -23,152 +23,142 @@ #include "../barcode.h"
#include "BC_Encoder.h"
#include "BC_DefaultPlacement.h"
-CBC_DefaultPlacement::CBC_DefaultPlacement(CFX_WideString codewords, int32_t numcols, int32_t numrows)
-{
- m_codewords = codewords;
- m_numcols = numcols;
- m_numrows = numrows;
- m_bits.SetSize(numcols * numrows);
- for (int32_t i = 0; i < numcols * numrows; i++) {
- m_bits[i] = (uint8_t) 2;
- }
+CBC_DefaultPlacement::CBC_DefaultPlacement(CFX_WideString codewords,
+ int32_t numcols,
+ int32_t numrows) {
+ m_codewords = codewords;
+ m_numcols = numcols;
+ m_numrows = numrows;
+ m_bits.SetSize(numcols * numrows);
+ for (int32_t i = 0; i < numcols * numrows; i++) {
+ m_bits[i] = (uint8_t)2;
+ }
}
-CBC_DefaultPlacement::~CBC_DefaultPlacement()
-{
- m_bits.RemoveAll();
+CBC_DefaultPlacement::~CBC_DefaultPlacement() {
+ m_bits.RemoveAll();
}
-int32_t CBC_DefaultPlacement::getNumrows()
-{
- return m_numrows;
+int32_t CBC_DefaultPlacement::getNumrows() {
+ return m_numrows;
}
-int32_t CBC_DefaultPlacement::getNumcols()
-{
- return m_numcols;
+int32_t CBC_DefaultPlacement::getNumcols() {
+ return m_numcols;
}
-CFX_ByteArray& CBC_DefaultPlacement::getBits()
-{
- return m_bits;
+CFX_ByteArray& CBC_DefaultPlacement::getBits() {
+ return m_bits;
}
-FX_BOOL CBC_DefaultPlacement::getBit(int32_t col, int32_t row)
-{
- return m_bits[row * m_numcols + col] == 1;
+FX_BOOL CBC_DefaultPlacement::getBit(int32_t col, int32_t row) {
+ return m_bits[row * m_numcols + col] == 1;
}
-void CBC_DefaultPlacement::setBit(int32_t col, int32_t row, FX_BOOL bit)
-{
- m_bits[row * m_numcols + col] = bit ? (uint8_t) 1 : (uint8_t) 0;
+void CBC_DefaultPlacement::setBit(int32_t col, int32_t row, FX_BOOL bit) {
+ m_bits[row * m_numcols + col] = bit ? (uint8_t)1 : (uint8_t)0;
}
-FX_BOOL CBC_DefaultPlacement::hasBit(int32_t col, int32_t row)
-{
- return m_bits[row * m_numcols + col] != 2;
+FX_BOOL CBC_DefaultPlacement::hasBit(int32_t col, int32_t row) {
+ return m_bits[row * m_numcols + col] != 2;
}
-void CBC_DefaultPlacement::place()
-{
- int32_t pos = 0;
- int32_t row = 4;
- int32_t col = 0;
- do {
- if ((row == m_numrows) && (col == 0)) {
- corner1(pos++);
- }
- if ((row == m_numrows - 2) && (col == 0) && ((m_numcols % 4) != 0)) {
- corner2(pos++);
- }
- if ((row == m_numrows - 2) && (col == 0) && (m_numcols % 8 == 4)) {
- corner3(pos++);
- }
- if ((row == m_numrows + 4) && (col == 2) && ((m_numcols % 8) == 0)) {
- corner4(pos++);
- }
- do {
- if ((row < m_numrows) && (col >= 0) && !hasBit(col, row)) {
- utah(row, col, pos++);
- }
- row -= 2;
- col += 2;
- } while (row >= 0 && (col < m_numcols));
- row++;
- col += 3;
- do {
- if ((row >= 0) && (col < m_numcols) && !hasBit(col, row)) {
- utah(row, col, pos++);
- }
- row += 2;
- col -= 2;
- } while ((row < m_numrows) && (col >= 0));
- row += 3;
- col++;
- } while ((row < m_numrows) || (col < m_numcols));
- if (!hasBit(m_numcols - 1, m_numrows - 1)) {
- setBit(m_numcols - 1, m_numrows - 1, TRUE);
- setBit(m_numcols - 2, m_numrows - 2, TRUE);
+void CBC_DefaultPlacement::place() {
+ int32_t pos = 0;
+ int32_t row = 4;
+ int32_t col = 0;
+ do {
+ if ((row == m_numrows) && (col == 0)) {
+ corner1(pos++);
}
-}
-void CBC_DefaultPlacement::module(int32_t row, int32_t col, int32_t pos, int32_t bit)
-{
- if (row < 0) {
- row += m_numrows;
- col += 4 - ((m_numrows + 4) % 8);
+ if ((row == m_numrows - 2) && (col == 0) && ((m_numcols % 4) != 0)) {
+ corner2(pos++);
+ }
+ if ((row == m_numrows - 2) && (col == 0) && (m_numcols % 8 == 4)) {
+ corner3(pos++);
}
- if (col < 0) {
- col += m_numcols;
- row += 4 - ((m_numcols + 4) % 8);
+ if ((row == m_numrows + 4) && (col == 2) && ((m_numcols % 8) == 0)) {
+ corner4(pos++);
}
- int32_t v = m_codewords.GetAt(pos);
- v &= 1 << (8 - bit);
- setBit(col, row, v != 0);
+ do {
+ if ((row < m_numrows) && (col >= 0) && !hasBit(col, row)) {
+ utah(row, col, pos++);
+ }
+ row -= 2;
+ col += 2;
+ } while (row >= 0 && (col < m_numcols));
+ row++;
+ col += 3;
+ do {
+ if ((row >= 0) && (col < m_numcols) && !hasBit(col, row)) {
+ utah(row, col, pos++);
+ }
+ row += 2;
+ col -= 2;
+ } while ((row < m_numrows) && (col >= 0));
+ row += 3;
+ col++;
+ } while ((row < m_numrows) || (col < m_numcols));
+ if (!hasBit(m_numcols - 1, m_numrows - 1)) {
+ setBit(m_numcols - 1, m_numrows - 1, TRUE);
+ setBit(m_numcols - 2, m_numrows - 2, TRUE);
+ }
+}
+void CBC_DefaultPlacement::module(int32_t row,
+ int32_t col,
+ int32_t pos,
+ int32_t bit) {
+ if (row < 0) {
+ row += m_numrows;
+ col += 4 - ((m_numrows + 4) % 8);
+ }
+ if (col < 0) {
+ col += m_numcols;
+ row += 4 - ((m_numcols + 4) % 8);
+ }
+ int32_t v = m_codewords.GetAt(pos);
+ v &= 1 << (8 - bit);
+ setBit(col, row, v != 0);
}
-void CBC_DefaultPlacement::utah(int32_t row, int32_t col, int32_t pos)
-{
- module(row - 2, col - 2, pos, 1);
- module(row - 2, col - 1, pos, 2);
- module(row - 1, col - 2, pos, 3);
- module(row - 1, col - 1, pos, 4);
- module(row - 1, col, pos, 5);
- module(row, col - 2, pos, 6);
- module(row, col - 1, pos, 7);
- module(row, col, pos, 8);
+void CBC_DefaultPlacement::utah(int32_t row, int32_t col, int32_t pos) {
+ module(row - 2, col - 2, pos, 1);
+ module(row - 2, col - 1, pos, 2);
+ module(row - 1, col - 2, pos, 3);
+ module(row - 1, col - 1, pos, 4);
+ module(row - 1, col, pos, 5);
+ module(row, col - 2, pos, 6);
+ module(row, col - 1, pos, 7);
+ module(row, col, pos, 8);
}
-void CBC_DefaultPlacement::corner1(int32_t pos)
-{
- module(m_numrows - 1, 0, pos, 1);
- module(m_numrows - 1, 1, pos, 2);
- module(m_numrows - 1, 2, pos, 3);
- module(0, m_numcols - 2, pos, 4);
- module(0, m_numcols - 1, pos, 5);
- module(1, m_numcols - 1, pos, 6);
- module(2, m_numcols - 1, pos, 7);
- module(3, m_numcols - 1, pos, 8);
+void CBC_DefaultPlacement::corner1(int32_t pos) {
+ module(m_numrows - 1, 0, pos, 1);
+ module(m_numrows - 1, 1, pos, 2);
+ module(m_numrows - 1, 2, pos, 3);
+ module(0, m_numcols - 2, pos, 4);
+ module(0, m_numcols - 1, pos, 5);
+ module(1, m_numcols - 1, pos, 6);
+ module(2, m_numcols - 1, pos, 7);
+ module(3, m_numcols - 1, pos, 8);
}
-void CBC_DefaultPlacement::corner2(int32_t pos)
-{
- module(m_numrows - 3, 0, pos, 1);
- module(m_numrows - 2, 0, pos, 2);
- module(m_numrows - 1, 0, pos, 3);
- module(0, m_numcols - 4, pos, 4);
- module(0, m_numcols - 3, pos, 5);
- module(0, m_numcols - 2, pos, 6);
- module(0, m_numcols - 1, pos, 7);
- module(1, m_numcols - 1, pos, 8);
+void CBC_DefaultPlacement::corner2(int32_t pos) {
+ module(m_numrows - 3, 0, pos, 1);
+ module(m_numrows - 2, 0, pos, 2);
+ module(m_numrows - 1, 0, pos, 3);
+ module(0, m_numcols - 4, pos, 4);
+ module(0, m_numcols - 3, pos, 5);
+ module(0, m_numcols - 2, pos, 6);
+ module(0, m_numcols - 1, pos, 7);
+ module(1, m_numcols - 1, pos, 8);
}
-void CBC_DefaultPlacement::corner3(int32_t pos)
-{
- module(m_numrows - 3, 0, pos, 1);
- module(m_numrows - 2, 0, pos, 2);
- module(m_numrows - 1, 0, pos, 3);
- module(0, m_numcols - 2, pos, 4);
- module(0, m_numcols - 1, pos, 5);
- module(1, m_numcols - 1, pos, 6);
- module(2, m_numcols - 1, pos, 7);
- module(3, m_numcols - 1, pos, 8);
+void CBC_DefaultPlacement::corner3(int32_t pos) {
+ module(m_numrows - 3, 0, pos, 1);
+ module(m_numrows - 2, 0, pos, 2);
+ module(m_numrows - 1, 0, pos, 3);
+ module(0, m_numcols - 2, pos, 4);
+ module(0, m_numcols - 1, pos, 5);
+ module(1, m_numcols - 1, pos, 6);
+ module(2, m_numcols - 1, pos, 7);
+ module(3, m_numcols - 1, pos, 8);
}
-void CBC_DefaultPlacement::corner4(int32_t pos)
-{
- module(m_numrows - 1, 0, pos, 1);
- module(m_numrows - 1, m_numcols - 1, pos, 2);
- module(0, m_numcols - 3, pos, 3);
- module(0, m_numcols - 2, pos, 4);
- module(0, m_numcols - 1, pos, 5);
- module(1, m_numcols - 3, pos, 6);
- module(1, m_numcols - 2, pos, 7);
- module(1, m_numcols - 1, pos, 8);
+void CBC_DefaultPlacement::corner4(int32_t pos) {
+ module(m_numrows - 1, 0, pos, 1);
+ module(m_numrows - 1, m_numcols - 1, pos, 2);
+ module(0, m_numcols - 3, pos, 3);
+ module(0, m_numcols - 2, pos, 4);
+ module(0, m_numcols - 1, pos, 5);
+ module(1, m_numcols - 3, pos, 6);
+ module(1, m_numcols - 2, pos, 7);
+ module(1, m_numcols - 1, pos, 8);
}
|