summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/pdf417
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-28 14:56:27 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-28 14:56:27 -0700
commitaef780db30c434e1d681d81852fb13160e72ed1e (patch)
tree24810c630b3b27649c0dd856d795c0069ca5bcd6 /xfa/fxbarcode/pdf417
parent8e957baa851aed4b02511d04a66c0f95387d1e10 (diff)
downloadpdfium-aef780db30c434e1d681d81852fb13160e72ed1e.tar.xz
Replace CFX_PtrArray with typesafe CFX_ArrayTemplate, part 4
Review-Url: https://codereview.chromium.org/1932703003
Diffstat (limited to 'xfa/fxbarcode/pdf417')
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp16
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h3
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp85
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h4
4 files changed, 44 insertions, 64 deletions
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
index 47255fac71..a9d1fedef0 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
@@ -36,14 +36,13 @@ CBC_BarcodeMatrix::CBC_BarcodeMatrix(int32_t height, int32_t width) {
m_outWidth = 0;
}
CBC_BarcodeMatrix::~CBC_BarcodeMatrix() {
- for (int32_t i = 0; i < m_matrix.GetSize(); i++) {
- delete (CBC_BarcodeRow*)m_matrix.GetAt(i);
- }
- m_matrix.RemoveAll();
+ for (int32_t i = 0; i < m_matrix.GetSize(); i++)
+ delete m_matrix.GetAt(i);
+
m_matrixOut.RemoveAll();
}
void CBC_BarcodeMatrix::set(int32_t x, int32_t y, uint8_t value) {
- ((CBC_BarcodeRow*)m_matrix[y])->set(x, value);
+ m_matrix[y]->set(x, value);
}
void CBC_BarcodeMatrix::setMatrix(int32_t x, int32_t y, FX_BOOL black) {
set(x, y, (uint8_t)(black ? 1 : 0));
@@ -52,7 +51,7 @@ void CBC_BarcodeMatrix::startRow() {
++m_currentRow;
}
CBC_BarcodeRow* CBC_BarcodeMatrix::getCurrentRow() {
- return (CBC_BarcodeRow*)m_matrix[m_currentRow];
+ return m_matrix[m_currentRow];
}
int32_t CBC_BarcodeMatrix::getWidth() {
return m_outWidth;
@@ -70,7 +69,7 @@ CFX_ByteArray& CBC_BarcodeMatrix::getScaledMatrix(int32_t xScale,
int32_t yScale) {
int32_t yMax = m_height * yScale;
CFX_ByteArray bytearray;
- bytearray.Copy(((CBC_BarcodeRow*)m_matrix[0])->getScaledRow(xScale));
+ bytearray.Copy(m_matrix[0]->getScaledRow(xScale));
int32_t xMax = bytearray.GetSize();
m_matrixOut.SetSize(xMax * yMax);
m_outWidth = xMax;
@@ -78,8 +77,7 @@ CFX_ByteArray& CBC_BarcodeMatrix::getScaledMatrix(int32_t xScale,
int32_t k = 0;
for (int32_t i = 0; i < yMax; i++) {
if (i != 0) {
- bytearray.Copy(
- ((CBC_BarcodeRow*)m_matrix[i / yScale])->getScaledRow(xScale));
+ bytearray.Copy(m_matrix[i / yScale]->getScaledRow(xScale));
}
k = i * xMax;
for (int32_t l = 0; l < xMax; l++) {
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
index 793bf0acf2..c86f714fbb 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
@@ -10,6 +10,7 @@
#include "core/fxcrt/include/fx_basic.h"
class CBC_BarcodeRow;
+
class CBC_BarcodeMatrix {
public:
CBC_BarcodeMatrix();
@@ -26,7 +27,7 @@ class CBC_BarcodeMatrix {
int32_t getHeight();
private:
- CFX_PtrArray m_matrix;
+ CFX_ArrayTemplate<CBC_BarcodeRow*> m_matrix;
CFX_ByteArray m_matrixOut;
int32_t m_currentRow;
int32_t m_height;
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
index fa278bdea9..45e94f9306 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
@@ -36,21 +36,20 @@ CBC_DetectionResult::CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata,
m_barcodeColumnCount = barcodeMetadata->getColumnCount();
m_boundingBox = boundingBox;
m_detectionResultColumns.SetSize(m_barcodeColumnCount + 2);
- for (int32_t i = 0; i < m_barcodeColumnCount + 2; i++) {
- m_detectionResultColumns[i] = NULL;
- }
+ for (int32_t i = 0; i < m_barcodeColumnCount + 2; i++)
+ m_detectionResultColumns[i] = nullptr;
}
+
CBC_DetectionResult::~CBC_DetectionResult() {
delete m_boundingBox;
delete m_barcodeMetadata;
- m_detectionResultColumns.RemoveAll();
}
-CFX_PtrArray& CBC_DetectionResult::getDetectionResultColumns() {
- adjustIndicatorColumnRowNumbers(
- (CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(0));
+
+CFX_ArrayTemplate<CBC_DetectionResultColumn*>&
+CBC_DetectionResult::getDetectionResultColumns() {
+ adjustIndicatorColumnRowNumbers(m_detectionResultColumns.GetAt(0));
adjustIndicatorColumnRowNumbers(
- (CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(
- m_barcodeColumnCount + 1));
+ m_detectionResultColumns.GetAt(m_barcodeColumnCount + 1));
int32_t unadjustedCodewordCount = CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE;
int32_t previousUnadjustedCount;
do {
@@ -73,15 +72,13 @@ void CBC_DetectionResult::setDetectionResultColumn(
}
CBC_DetectionResultColumn* CBC_DetectionResult::getDetectionResultColumn(
int32_t barcodeColumn) {
- return (CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn];
+ return m_detectionResultColumns[barcodeColumn];
}
CFX_ByteString CBC_DetectionResult::toString() {
- CBC_DetectionResultColumn* rowIndicatorColumn =
- (CBC_DetectionResultColumn*)m_detectionResultColumns[0];
- if (rowIndicatorColumn == NULL) {
- rowIndicatorColumn = (CBC_DetectionResultColumn*)
- m_detectionResultColumns[m_barcodeColumnCount + 1];
- }
+ CBC_DetectionResultColumn* rowIndicatorColumn = m_detectionResultColumns[0];
+ if (!rowIndicatorColumn)
+ rowIndicatorColumn = m_detectionResultColumns[m_barcodeColumnCount + 1];
+
CFX_ByteString result;
for (int32_t codewordsRow = 0;
codewordsRow < rowIndicatorColumn->getCodewords()->GetSize();
@@ -89,16 +86,15 @@ CFX_ByteString CBC_DetectionResult::toString() {
result += (FX_CHAR)codewordsRow;
for (int32_t barcodeColumn = 0; barcodeColumn < m_barcodeColumnCount + 2;
barcodeColumn++) {
- if (m_detectionResultColumns[barcodeColumn] == NULL) {
+ if (!m_detectionResultColumns[barcodeColumn]) {
result += " | ";
continue;
}
CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn])
+ (CBC_Codeword*)m_detectionResultColumns[barcodeColumn]
->getCodewords()
->GetAt(codewordsRow);
- if (codeword == NULL) {
+ if (!codeword) {
result += " | ";
continue;
}
@@ -123,8 +119,7 @@ int32_t CBC_DetectionResult::adjustRowNumbers() {
for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1;
barcodeColumn++) {
CFX_PtrArray* codewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn])
- ->getCodewords();
+ m_detectionResultColumns[barcodeColumn]->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
@@ -144,16 +139,13 @@ int32_t CBC_DetectionResult::adjustRowNumbersByRow() {
return unadjustedCount + adjustRowNumbersFromRRI();
}
int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() {
- if (m_detectionResultColumns[0] == NULL ||
- m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) {
+ if (!m_detectionResultColumns[0] ||
+ !m_detectionResultColumns[m_barcodeColumnCount + 1]) {
return 0;
}
- CFX_PtrArray* LRIcodewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns[0])->getCodewords();
+ CFX_PtrArray* LRIcodewords = m_detectionResultColumns[0]->getCodewords();
CFX_PtrArray* RRIcodewords =
- ((CBC_DetectionResultColumn*)
- m_detectionResultColumns[m_barcodeColumnCount + 1])
- ->getCodewords();
+ m_detectionResultColumns[m_barcodeColumnCount + 1]->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < LRIcodewords->GetSize();
codewordsRow++) {
if (LRIcodewords->GetAt(codewordsRow) &&
@@ -164,19 +156,17 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() {
for (int32_t barcodeColumn = 1; barcodeColumn <= m_barcodeColumnCount;
barcodeColumn++) {
CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn])
+ (CBC_Codeword*)(m_detectionResultColumns[barcodeColumn])
->getCodewords()
->GetAt(codewordsRow);
- if (codeword == NULL) {
+ if (!codeword) {
continue;
}
codeword->setRowNumber(
((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber());
if (!codeword->hasValidRowNumber()) {
- ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn])
- ->getCodewords()
- ->SetAt(codewordsRow, NULL);
+ m_detectionResultColumns[barcodeColumn]->getCodewords()->SetAt(
+ codewordsRow, nullptr);
}
}
}
@@ -184,14 +174,12 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() {
return 0;
}
int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() {
- if (m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) {
+ if (!m_detectionResultColumns[m_barcodeColumnCount + 1]) {
return 0;
}
int32_t unadjustedCount = 0;
CFX_PtrArray* codewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(
- m_barcodeColumnCount + 1))
- ->getCodewords();
+ m_detectionResultColumns.GetAt(m_barcodeColumnCount + 1)->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
@@ -204,8 +192,7 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() {
barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn--) {
CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns.GetAt(barcodeColumn))
+ (CBC_Codeword*)m_detectionResultColumns.GetAt(barcodeColumn)
->getCodewords()
->GetAt(codewordsRow);
if (codeword) {
@@ -224,9 +211,7 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() {
return 0;
}
int32_t unadjustedCount = 0;
- CFX_PtrArray* codewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(0))
- ->getCodewords();
+ CFX_PtrArray* codewords = m_detectionResultColumns.GetAt(0)->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
@@ -239,8 +224,7 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() {
invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn++) {
CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn])
+ (CBC_Codeword*)(m_detectionResultColumns[barcodeColumn])
->getCodewords()
->GetAt(codewordsRow);
if (codeword) {
@@ -276,14 +260,11 @@ void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn,
CFX_PtrArray* codewords) {
CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow);
CFX_PtrArray* previousColumnCodewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(
- barcodeColumn - 1))
- ->getCodewords();
+ (m_detectionResultColumns.GetAt(barcodeColumn - 1))->getCodewords();
CFX_PtrArray* nextColumnCodewords = previousColumnCodewords;
if (m_detectionResultColumns[barcodeColumn + 1]) {
- nextColumnCodewords = ((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn + 1])
- ->getCodewords();
+ nextColumnCodewords =
+ m_detectionResultColumns[barcodeColumn + 1]->getCodewords();
}
CFX_PtrArray otherCodewords;
otherCodewords.SetSize(14);
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
index 8b7f91bfcd..9d6abb8c91 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
@@ -16,7 +16,7 @@ class CBC_DetectionResult {
CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata,
CBC_BoundingBox* boundingBox);
virtual ~CBC_DetectionResult();
- CFX_PtrArray& getDetectionResultColumns();
+ CFX_ArrayTemplate<CBC_DetectionResultColumn*>& getDetectionResultColumns();
void setBoundingBox(CBC_BoundingBox* boundingBox);
CBC_BoundingBox* getBoundingBox();
void setDetectionResultColumn(
@@ -32,7 +32,7 @@ class CBC_DetectionResult {
private:
static int32_t ADJUST_ROW_NUMBER_SKIP;
CBC_BarcodeMetadata* m_barcodeMetadata;
- CFX_PtrArray m_detectionResultColumns;
+ CFX_ArrayTemplate<CBC_DetectionResultColumn*> m_detectionResultColumns;
CBC_BoundingBox* m_boundingBox;
int32_t m_barcodeColumnCount;