summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp10
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h11
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp4
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp6
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h36
-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
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp42
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h19
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp26
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.h33
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp6
14 files changed, 138 insertions, 163 deletions
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 4d986cca26..00bd7811d8 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -37,8 +37,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
int32_t& e) {
if (degree >= m_cachedGenerators.GetSize()) {
CBC_ReedSolomonGF256Poly* lastGenerator =
- (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators
- [m_cachedGenerators.GetSize() - 1]);
+ m_cachedGenerators[m_cachedGenerators.GetSize() - 1];
for (int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) {
CFX_Int32Array temp;
temp.Add(1);
@@ -53,7 +52,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
lastGenerator = nextGenerator;
}
}
- return (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[degree]);
+ return m_cachedGenerators[degree];
}
void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
int32_t ecBytes,
@@ -98,7 +97,6 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
}
}
CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() {
- for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++) {
- delete (CBC_ReedSolomonGF256Poly*)m_cachedGenerators[i];
- }
+ for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++)
+ delete m_cachedGenerators[i];
}
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
index 0dfa37ddb7..695da46c79 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
@@ -13,17 +13,18 @@ class CBC_ReedSolomonGF256;
class CBC_ReedSolomonGF256Poly;
class CBC_ReedSolomonEncoder {
- private:
- CBC_ReedSolomonGF256* m_field;
- CFX_PtrArray m_cachedGenerators;
- CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t& e);
-
public:
CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field);
virtual ~CBC_ReedSolomonEncoder();
void Encode(CFX_Int32Array* toEncode, int32_t ecBytes, int32_t& e);
virtual void Init();
+
+ private:
+ CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t& e);
+
+ CBC_ReedSolomonGF256* m_field;
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*> m_cachedGenerators;
};
#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
index 89c09c22a8..c70f8b1fc9 100644
--- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
@@ -39,10 +39,10 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
int32_t& e) {
ECBlocks* ecBlocks = version->GetECBlocks();
int32_t totalBlocks = 0;
- const CFX_PtrArray& ecBlockArray = ecBlocks->GetECBlocks();
+ const CFX_ArrayTemplate<ECB*>& ecBlockArray = ecBlocks->GetECBlocks();
int32_t i;
for (i = 0; i < ecBlockArray.GetSize(); i++) {
- totalBlocks += ((ECB*)ecBlockArray[i])->GetCount();
+ totalBlocks += ecBlockArray[i]->GetCount();
}
std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray());
result->SetSize(totalBlocks);
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp
index 50131f3dc2..e441a29e44 100644
--- a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp
@@ -51,10 +51,10 @@ CBC_DataMatrixVersion::CBC_DataMatrixVersion(int32_t versionNumber,
m_ecBlocks = ecBlocks;
int32_t total = 0;
int32_t ecCodewords = ecBlocks->GetECCodewords();
- const CFX_PtrArray& ecbArray = ecBlocks->GetECBlocks();
+ const CFX_ArrayTemplate<ECB*>& ecbArray = ecBlocks->GetECBlocks();
for (int32_t i = 0; i < ecbArray.GetSize(); i++) {
- total += ((ECB*)ecbArray[i])->GetCount() *
- (((ECB*)ecbArray[i])->GetDataCodewords() + ecCodewords);
+ total += ecbArray[i]->GetCount() *
+ (ecbArray[i]->GetDataCodewords() + ecCodewords);
}
m_totalCodewords = total;
}
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h
index 9e8e801d8e..74433cc4f2 100644
--- a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h
+++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h
@@ -13,14 +13,11 @@ class CBC_DataMatrixVersion;
class ECB {
public:
- ECB(int32_t count, int32_t dataCodewords) {
- m_count = count;
- m_dataCodewords = dataCodewords;
- }
-
- int32_t GetCount() { return m_count; }
+ ECB(int32_t count, int32_t dataCodewords)
+ : m_count(count), m_dataCodewords(dataCodewords) {}
- int32_t GetDataCodewords() { return m_dataCodewords; }
+ int32_t GetCount() const { return m_count; }
+ int32_t GetDataCodewords() const { return m_dataCodewords; }
private:
int32_t m_count;
@@ -29,30 +26,27 @@ class ECB {
class ECBlocks {
public:
- ECBlocks(int32_t ecCodewords, ECB* ecBlocks) {
- m_ecCodewords = ecCodewords;
- m_ecBlocks.Add(ecBlocks);
+ ECBlocks(int32_t ecCodewords, ECB* ecBlocks) : m_ecCodewords(ecCodewords) {
+ m_ecBlocksArray.Add(ecBlocks);
}
- ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) {
- m_ecCodewords = ecCodewords;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
+ ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2)
+ : m_ecCodewords(ecCodewords) {
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
}
+
~ECBlocks() {
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- delete (ECB*)m_ecBlocks[i];
- }
- m_ecBlocks.RemoveAll();
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ delete m_ecBlocksArray[i];
}
int32_t GetECCodewords() { return m_ecCodewords; }
-
- const CFX_PtrArray& GetECBlocks() { return m_ecBlocks; }
+ const CFX_ArrayTemplate<ECB*>& GetECBlocks() { return m_ecBlocksArray; }
private:
int32_t m_ecCodewords;
- CFX_PtrArray m_ecBlocks;
+ CFX_ArrayTemplate<ECB*> m_ecBlocksArray;
};
class CBC_DataMatrixVersion {
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;
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
index eb6d194b55..507c91878e 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
@@ -24,36 +24,40 @@
#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h"
CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
- CBC_QRCoderECB* ecBlocks) {
- m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;
- m_ecBlocks.Add(ecBlocks);
+ CBC_QRCoderECB* ecBlocks)
+ : m_ecCodeWordsPerBlock(ecCodeWordsPerBlock) {
+ m_ecBlocksArray.Add(ecBlocks);
}
+
CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
CBC_QRCoderECB* ecBlocks1,
- CBC_QRCoderECB* ecBlocks2) {
- m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
+ CBC_QRCoderECB* ecBlocks2)
+ : m_ecCodeWordsPerBlock(ecCodeWordsPerBlock) {
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
}
+
CBC_QRCoderECBlocks::~CBC_QRCoderECBlocks() {
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- delete ((CBC_QRCoderECB*)(m_ecBlocks[i]));
- }
- m_ecBlocks.RemoveAll();
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ delete m_ecBlocksArray[i];
}
-int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() {
+
+int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() const {
return m_ecCodeWordsPerBlock;
}
-int32_t CBC_QRCoderECBlocks::GetNumBlocks() {
+
+int32_t CBC_QRCoderECBlocks::GetNumBlocks() const {
int32_t total = 0;
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- total += ((CBC_QRCoderECB*)(m_ecBlocks[i]))->GetCount();
- }
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ total += m_ecBlocksArray[i]->GetCount();
+
return total;
}
-int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() {
+
+int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() const {
return m_ecCodeWordsPerBlock * GetNumBlocks();
}
-CFX_PtrArray* CBC_QRCoderECBlocks::GetECBlocks() {
- return &m_ecBlocks;
+
+CFX_ArrayTemplate<CBC_QRCoderECB*>* CBC_QRCoderECBlocks::GetECBlocks() {
+ return &m_ecBlocksArray;
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
index 5209a5f8d8..cd1539a7b7 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
@@ -12,20 +12,21 @@
class CBC_QRCoderECB;
class CBC_QRCoderECBlocks {
- private:
- int32_t m_ecCodeWordsPerBlock;
- CFX_PtrArray m_ecBlocks;
-
public:
CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock, CBC_QRCoderECB* ecBlocks);
CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
CBC_QRCoderECB* ecBlocks1,
CBC_QRCoderECB* ecBlocks2);
- virtual ~CBC_QRCoderECBlocks();
- int32_t GetECCodeWordsPerBlock();
- int32_t GetNumBlocks();
- int32_t GetTotalECCodeWords();
- CFX_PtrArray* GetECBlocks();
+ ~CBC_QRCoderECBlocks();
+
+ int32_t GetECCodeWordsPerBlock() const;
+ int32_t GetNumBlocks() const;
+ int32_t GetTotalECCodeWords() const;
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* GetECBlocks();
+
+ private:
+ int32_t m_ecCodeWordsPerBlock;
+ CFX_ArrayTemplate<CBC_QRCoderECB*> m_ecBlocksArray;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
index 1ff557ede2..e92267819c 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
@@ -53,15 +53,15 @@ CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
CBC_QRCoderECBlocks* ecBlocks3,
CBC_QRCoderECBlocks* ecBlocks4) {
m_versionNumber = versionNumber;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
- m_ecBlocks.Add(ecBlocks3);
- m_ecBlocks.Add(ecBlocks4);
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
+ m_ecBlocksArray.Add(ecBlocks3);
+ m_ecBlocksArray.Add(ecBlocks4);
int32_t total = 0;
int32_t ecCodeWords = ecBlocks1->GetECCodeWordsPerBlock();
- CFX_PtrArray* ecbArray = ecBlocks1->GetECBlocks();
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* ecbArray = ecBlocks1->GetECBlocks();
for (int32_t i = 0; i < ecbArray->GetSize(); i++) {
- CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)((*ecbArray)[i]);
+ CBC_QRCoderECB* ecBlock = (*ecbArray)[i];
total += ecBlock->GetCount() * (ecBlock->GetDataCodeWords() + ecCodeWords);
}
m_totalCodeWords = total;
@@ -326,16 +326,12 @@ CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
break;
}
}
+
CBC_QRCoderVersion::~CBC_QRCoderVersion() {
- if (m_ecBlocks.GetSize() != 0) {
- int32_t itBeg = 0;
- int32_t itEnd = m_ecBlocks.GetSize();
- while (itBeg != itEnd) {
- delete ((CBC_QRCoderECBlocks*)(m_ecBlocks[itBeg]));
- itBeg++;
- }
- }
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); ++i)
+ delete m_ecBlocksArray[i];
}
+
int32_t CBC_QRCoderVersion::GetVersionNumber() {
return m_versionNumber;
}
@@ -350,7 +346,7 @@ int32_t CBC_QRCoderVersion::GetDimensionForVersion() {
}
CBC_QRCoderECBlocks* CBC_QRCoderVersion::GetECBlocksForLevel(
CBC_QRCoderErrorCorrectionLevel* ecLevel) {
- return (CBC_QRCoderECBlocks*)m_ecBlocks[ecLevel->Ordinal()];
+ return m_ecBlocksArray[ecLevel->Ordinal()];
}
CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension(
int32_t dimension,
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
index 0cbace0251..05bd71934d 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
@@ -9,26 +9,11 @@
#include "core/fxcrt/include/fx_basic.h"
-class CBC_QRCoderECBlocks;
class CBC_CommonBitMatrix;
+class CBC_QRCoderECBlocks;
class CBC_QRCoderErrorCorrectionLevel;
class CBC_QRCoderVersion {
- private:
- static const int32_t VERSION_DECODE_INFO[34];
- static CFX_PtrArray* VERSION;
- int32_t m_versionNumber;
- int32_t m_totalCodeWords;
- CFX_Int32Array m_alignmentPatternCenters;
- CFX_PtrArray m_ecBlocks;
-
- CBC_QRCoderVersion();
- CBC_QRCoderVersion(int32_t versionNumber,
- CBC_QRCoderECBlocks* ecBlocks1,
- CBC_QRCoderECBlocks* ecBlocks2,
- CBC_QRCoderECBlocks* ecBlocks3,
- CBC_QRCoderECBlocks* ecBlocks4);
-
public:
virtual ~CBC_QRCoderVersion();
static void Initialize();
@@ -49,6 +34,22 @@ class CBC_QRCoderVersion {
static CBC_QRCoderVersion* DecodeVersionInformation(int32_t versionBits,
int32_t& e);
static void Destroy();
+
+ private:
+ CBC_QRCoderVersion();
+ CBC_QRCoderVersion(int32_t versionNumber,
+ CBC_QRCoderECBlocks* ecBlocks1,
+ CBC_QRCoderECBlocks* ecBlocks2,
+ CBC_QRCoderECBlocks* ecBlocks3,
+ CBC_QRCoderECBlocks* ecBlocks4);
+
+ static const int32_t VERSION_DECODE_INFO[34];
+ static CFX_PtrArray* VERSION;
+
+ int32_t m_versionNumber;
+ int32_t m_totalCodeWords;
+ CFX_Int32Array m_alignmentPatternCenters;
+ CFX_ArrayTemplate<CBC_QRCoderECBlocks*> m_ecBlocksArray;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp b/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
index 9805ac9af8..721301cccc 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
@@ -52,16 +52,16 @@ CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks(
}
CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel);
int32_t totalBlocks = 0;
- CFX_PtrArray* ecBlockArray = ecBlocks->GetECBlocks();
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* ecBlockArray = ecBlocks->GetECBlocks();
int32_t i = 0;
for (i = 0; i < ecBlockArray->GetSize(); i++) {
- totalBlocks += ((CBC_QRCoderECB*)(*ecBlockArray)[i])->GetCount();
+ totalBlocks += (*ecBlockArray)[i]->GetCount();
}
std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray());
result->SetSize(totalBlocks);
int32_t numResultBlocks = 0;
for (int32_t j = 0; j < ecBlockArray->GetSize(); j++) {
- CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)(*ecBlockArray)[j];
+ CBC_QRCoderECB* ecBlock = (*ecBlockArray)[j];
for (int32_t k = 0; k < ecBlock->GetCount(); k++) {
int32_t numDataCodewords = ecBlock->GetDataCodeWords();
int32_t numBlockCodewords =