summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/pdf417
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-29 13:45:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-29 13:45:14 -0700
commite801d4e064690fbe1815d25d220cfbca79976a4f (patch)
treec7955761755597d8430b70f2e477d7b7a272f46b /xfa/fxbarcode/pdf417
parente7ca8ba0f76d175eb89e4cc3aa3aa2743711414e (diff)
downloadpdfium-e801d4e064690fbe1815d25d220cfbca79976a4f.tar.xz
Replace CFX_PtrArray with typesafe CFX_ArrayTemplate, part 9
Converted one place to unique_ptr to avoid redundant cleanup. Review-Url: https://codereview.chromium.org/1937593002
Diffstat (limited to 'xfa/fxbarcode/pdf417')
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp63
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h2
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp13
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h7
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp16
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h7
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp8
7 files changed, 60 insertions, 56 deletions
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
index 45e94f9306..79754b020e 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
@@ -118,15 +118,14 @@ int32_t CBC_DetectionResult::adjustRowNumbers() {
}
for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1;
barcodeColumn++) {
- CFX_PtrArray* codewords =
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
m_detectionResultColumns[barcodeColumn]->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
- if (!((CBC_Codeword*)codewords->GetAt(codewordsRow))
- ->hasValidRowNumber()) {
+ if (!codewords->GetAt(codewordsRow)->hasValidRowNumber()) {
adjustRowNumbers(barcodeColumn, codewordsRow, codewords);
}
}
@@ -143,27 +142,26 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() {
!m_detectionResultColumns[m_barcodeColumnCount + 1]) {
return 0;
}
- CFX_PtrArray* LRIcodewords = m_detectionResultColumns[0]->getCodewords();
- CFX_PtrArray* RRIcodewords =
+ CFX_ArrayTemplate<CBC_Codeword*>* LRIcodewords =
+ m_detectionResultColumns[0]->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* RRIcodewords =
m_detectionResultColumns[m_barcodeColumnCount + 1]->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < LRIcodewords->GetSize();
codewordsRow++) {
if (LRIcodewords->GetAt(codewordsRow) &&
RRIcodewords->GetAt(codewordsRow) &&
- ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber() ==
- ((CBC_Codeword*)RRIcodewords->GetAt(codewordsRow))
- ->getRowNumber()) {
+ LRIcodewords->GetAt(codewordsRow)->getRowNumber() ==
+ RRIcodewords->GetAt(codewordsRow)->getRowNumber()) {
for (int32_t barcodeColumn = 1; barcodeColumn <= m_barcodeColumnCount;
barcodeColumn++) {
CBC_Codeword* codeword =
- (CBC_Codeword*)(m_detectionResultColumns[barcodeColumn])
- ->getCodewords()
- ->GetAt(codewordsRow);
+ m_detectionResultColumns[barcodeColumn]->getCodewords()->GetAt(
+ codewordsRow);
if (!codeword) {
continue;
}
codeword->setRowNumber(
- ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber());
+ LRIcodewords->GetAt(codewordsRow)->getRowNumber());
if (!codeword->hasValidRowNumber()) {
m_detectionResultColumns[barcodeColumn]->getCodewords()->SetAt(
codewordsRow, nullptr);
@@ -178,7 +176,7 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() {
return 0;
}
int32_t unadjustedCount = 0;
- CFX_PtrArray* codewords =
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
m_detectionResultColumns.GetAt(m_barcodeColumnCount + 1)->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
@@ -186,15 +184,14 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() {
continue;
}
int32_t rowIndicatorRowNumber =
- ((CBC_Codeword*)codewords->GetAt(codewordsRow))->getRowNumber();
+ codewords->GetAt(codewordsRow)->getRowNumber();
int32_t invalidRowCounts = 0;
for (int32_t barcodeColumn = m_barcodeColumnCount + 1;
barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn--) {
- CBC_Codeword* codeword =
- (CBC_Codeword*)m_detectionResultColumns.GetAt(barcodeColumn)
- ->getCodewords()
- ->GetAt(codewordsRow);
+ CBC_Codeword* codeword = m_detectionResultColumns.GetAt(barcodeColumn)
+ ->getCodewords()
+ ->GetAt(codewordsRow);
if (codeword) {
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword);
@@ -211,22 +208,22 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() {
return 0;
}
int32_t unadjustedCount = 0;
- CFX_PtrArray* codewords = m_detectionResultColumns.GetAt(0)->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
+ m_detectionResultColumns.GetAt(0)->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
int32_t rowIndicatorRowNumber =
- ((CBC_Codeword*)codewords->GetAt(codewordsRow))->getRowNumber();
+ codewords->GetAt(codewordsRow)->getRowNumber();
int32_t invalidRowCounts = 0;
for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1 &&
invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn++) {
CBC_Codeword* codeword =
- (CBC_Codeword*)(m_detectionResultColumns[barcodeColumn])
- ->getCodewords()
- ->GetAt(codewordsRow);
+ m_detectionResultColumns[barcodeColumn]->getCodewords()->GetAt(
+ codewordsRow);
if (codeword) {
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword);
@@ -255,18 +252,20 @@ int32_t CBC_DetectionResult::adjustRowNumberIfValid(
}
return invalidRowCounts;
}
-void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn,
- int32_t codewordsRow,
- CFX_PtrArray* codewords) {
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow);
- CFX_PtrArray* previousColumnCodewords =
- (m_detectionResultColumns.GetAt(barcodeColumn - 1))->getCodewords();
- CFX_PtrArray* nextColumnCodewords = previousColumnCodewords;
+void CBC_DetectionResult::adjustRowNumbers(
+ int32_t barcodeColumn,
+ int32_t codewordsRow,
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords) {
+ CBC_Codeword* codeword = codewords->GetAt(codewordsRow);
+ CFX_ArrayTemplate<CBC_Codeword*>* previousColumnCodewords =
+ m_detectionResultColumns.GetAt(barcodeColumn - 1)->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* nextColumnCodewords =
+ previousColumnCodewords;
if (m_detectionResultColumns[barcodeColumn + 1]) {
nextColumnCodewords =
m_detectionResultColumns[barcodeColumn + 1]->getCodewords();
}
- CFX_PtrArray otherCodewords;
+ CFX_ArrayTemplate<CBC_Codeword*> otherCodewords;
otherCodewords.SetSize(14);
otherCodewords[2] = previousColumnCodewords->GetAt(codewordsRow);
otherCodewords[3] = nextColumnCodewords->GetAt(codewordsRow);
@@ -291,7 +290,7 @@ void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn,
otherCodewords[13] = nextColumnCodewords->GetAt(codewordsRow + 2);
}
for (int32_t i = 0; i < otherCodewords.GetSize(); i++) {
- CBC_Codeword* otherCodeword = (CBC_Codeword*)otherCodewords.GetAt(i);
+ CBC_Codeword* otherCodeword = otherCodewords.GetAt(i);
if (adjustRowNumber(codeword, otherCodeword)) {
return;
}
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
index 9d6abb8c91..1590ce227a 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
@@ -49,7 +49,7 @@ class CBC_DetectionResult {
CBC_Codeword* codeword);
void adjustRowNumbers(int32_t barcodeColumn,
int32_t codewordsRow,
- CFX_PtrArray* codewords);
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords);
static FX_BOOL adjustRowNumber(CBC_Codeword* codeword,
CBC_Codeword* otherCodeword);
};
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp
index 24d81070f3..110a5f375e 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp
@@ -27,16 +27,16 @@
int32_t CBC_DetectionResultColumn::MAX_NEARBY_DISTANCE = 5;
CBC_DetectionResultColumn::CBC_DetectionResultColumn(
- CBC_BoundingBox* boundingBox) {
- m_boundingBox = boundingBox;
- m_codewords = new CFX_PtrArray;
+ CBC_BoundingBox* boundingBox)
+ : m_boundingBox(boundingBox),
+ m_codewords(new CFX_ArrayTemplate<CBC_Codeword*>()) {
m_codewords->SetSize(boundingBox->getMaxY() - boundingBox->getMinY() + 1);
}
+
CBC_DetectionResultColumn::~CBC_DetectionResultColumn() {
for (int32_t i = 0; i < m_codewords->GetSize(); i++) {
- delete (CBC_Codeword*)m_codewords->GetAt(i);
+ delete m_codewords->GetAt(i);
}
- m_codewords->RemoveAll();
delete m_codewords;
}
CBC_Codeword* CBC_DetectionResultColumn::getCodewordNearby(int32_t imageRow) {
@@ -79,7 +79,8 @@ CBC_Codeword* CBC_DetectionResultColumn::getCodeword(int32_t imageRow) {
CBC_BoundingBox* CBC_DetectionResultColumn::getBoundingBox() {
return m_boundingBox;
}
-CFX_PtrArray* CBC_DetectionResultColumn::getCodewords() {
+CFX_ArrayTemplate<CBC_Codeword*>* CBC_DetectionResultColumn::getCodewords()
+ const {
return m_codewords;
}
CFX_ByteString CBC_DetectionResultColumn::toString() {
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h
index ebe01a2a0c..949f8ac4aa 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h
@@ -9,22 +9,23 @@
class CBC_Codeword;
class CBC_BoundingBox;
+
class CBC_DetectionResultColumn {
public:
CBC_DetectionResultColumn(CBC_BoundingBox* boundingBox);
virtual ~CBC_DetectionResultColumn();
+
CBC_Codeword* getCodewordNearby(int32_t imageRow);
int32_t imageRowToCodewordIndex(int32_t imageRow);
int32_t codewordIndexToImageRow(int32_t codewordIndex);
void setCodeword(int32_t imageRow, CBC_Codeword* codeword);
CBC_Codeword* getCodeword(int32_t imageRow);
CBC_BoundingBox* getBoundingBox();
- CFX_PtrArray* getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* getCodewords() const;
CFX_ByteString toString();
- public:
CBC_BoundingBox* m_boundingBox;
- CFX_PtrArray* m_codewords;
+ CFX_ArrayTemplate<CBC_Codeword*>* m_codewords;
private:
static int32_t MAX_NEARBY_DISTANCE;
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp
index 3a6d73fd40..8783e87f1b 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp
@@ -50,7 +50,7 @@ void CBC_DetectionResultRowIndicatorColumn::setRowNumbers() {
int32_t
CBC_DetectionResultRowIndicatorColumn::adjustCompleteIndicatorColumnRowNumbers(
CBC_BarcodeMetadata barcodeMetadata) {
- CFX_PtrArray* codewords = getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords = getCodewords();
setRowNumbers();
removeIncorrectCodewords(codewords, barcodeMetadata);
CBC_BoundingBox* boundingBox = getBoundingBox();
@@ -70,7 +70,7 @@ CBC_DetectionResultRowIndicatorColumn::adjustCompleteIndicatorColumnRowNumbers(
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow);
+ CBC_Codeword* codeword = codewords->GetAt(codewordsRow);
int32_t rowDifference = codeword->getRowNumber() - barcodeRow;
if (rowDifference == 0) {
currentRowHeight++;
@@ -138,7 +138,7 @@ int32_t CBC_DetectionResultRowIndicatorColumn::
int32_t lastRow = imageRowToCodewordIndex((int32_t)bottom->GetY());
FX_FLOAT averageRowHeight =
(lastRow - firstRow) / (FX_FLOAT)barcodeMetadata.getRowCount();
- CFX_PtrArray* codewords = getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords = getCodewords();
int32_t barcodeRow = -1;
int32_t maxRowHeight = 1;
int32_t currentRowHeight = 0;
@@ -147,7 +147,7 @@ int32_t CBC_DetectionResultRowIndicatorColumn::
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow);
+ CBC_Codeword* codeword = codewords->GetAt(codewordsRow);
codeword->setRowNumberAsRowIndicatorColumn();
int32_t rowDifference = codeword->getRowNumber() - barcodeRow;
if (rowDifference == 0) {
@@ -168,13 +168,13 @@ int32_t CBC_DetectionResultRowIndicatorColumn::
}
CBC_BarcodeMetadata*
CBC_DetectionResultRowIndicatorColumn::getBarcodeMetadata() {
- CFX_PtrArray* codewords = getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords = getCodewords();
CBC_BarcodeValue barcodeColumnCount;
CBC_BarcodeValue barcodeRowCountUpperPart;
CBC_BarcodeValue barcodeRowCountLowerPart;
CBC_BarcodeValue barcodeECLevel;
for (int32_t i = 0; i < codewords->GetSize(); i++) {
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(i);
+ CBC_Codeword* codeword = codewords->GetAt(i);
if (codeword == NULL) {
continue;
}
@@ -226,11 +226,11 @@ CFX_ByteString CBC_DetectionResultRowIndicatorColumn::toString() {
CBC_DetectionResultColumn::toString();
}
void CBC_DetectionResultRowIndicatorColumn::removeIncorrectCodewords(
- CFX_PtrArray* codewords,
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords,
CBC_BarcodeMetadata barcodeMetadata) {
for (int32_t codewordRow = 0; codewordRow < codewords->GetSize();
codewordRow++) {
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordRow);
+ CBC_Codeword* codeword = codewords->GetAt(codewordRow);
if (codeword == NULL) {
continue;
}
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h
index dfe6a069d6..f914354124 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h
@@ -9,7 +9,7 @@
class CBC_BarcodeMetadata;
class CBC_BoundingBox;
-class CBC_DetectionResultRowIndicatorColumn;
+
class CBC_DetectionResultRowIndicatorColumn : public CBC_DetectionResultColumn {
public:
CBC_DetectionResultRowIndicatorColumn(CBC_BoundingBox* boundingBox,
@@ -26,9 +26,10 @@ class CBC_DetectionResultRowIndicatorColumn : public CBC_DetectionResultColumn {
CFX_ByteString toString();
private:
- FX_BOOL m_isLeft;
- void removeIncorrectCodewords(CFX_PtrArray* codewords,
+ void removeIncorrectCodewords(CFX_ArrayTemplate<CBC_Codeword*>* codewords,
CBC_BarcodeMetadata barcodeMetadata);
+
+ FX_BOOL m_isLeft;
};
#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp
index 6ae68d72f3..e0eaf3e91f 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp
@@ -229,7 +229,8 @@ CBC_BoundingBox* CBC_PDF417ScanningDecoder::adjustBoundingBox(
break;
}
}
- CFX_PtrArray* codewords = rowIndicatorColumn->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
+ rowIndicatorColumn->getCodewords();
for (int32_t row = 0; missingStartRows > 0 && codewords->GetAt(row) == NULL;
row++) {
missingStartRows--;
@@ -484,9 +485,10 @@ CFX_PtrArray* CBC_PDF417ScanningDecoder::createBarcodeMatrix(
if (detectionResultColumn == NULL) {
continue;
}
- CFX_PtrArray* temp = detectionResultColumn->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* temp =
+ detectionResultColumn->getCodewords();
for (int32_t l = 0; l < temp->GetSize(); l++) {
- CBC_Codeword* codeword = (CBC_Codeword*)temp->GetAt(l);
+ CBC_Codeword* codeword = temp->GetAt(l);
if (codeword == NULL || codeword->getRowNumber() == -1) {
continue;
}