summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp3
-rw-r--r--xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp44
-rw-r--r--xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp41
-rw-r--r--xfa/fxbarcode/oned/BC_OnedCode128Writer.h6
-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
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetector.cpp18
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp24
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetectorResult.h24
14 files changed, 142 insertions, 134 deletions
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp
index 9fd1bbc4a0..a4ca4e228c 100644
--- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp
@@ -195,7 +195,8 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) {
dimensionCorrected, e));
BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
- CFX_PtrArray* result = new CFX_PtrArray;
+ CFX_ArrayTemplate<CBC_ResultPoint*>* result =
+ new CFX_ArrayTemplate<CBC_ResultPoint*>();
result->SetSize(4);
result->Add(topLeft);
result->Add(bottomLeft);
diff --git a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 1f7c4c3453..15f288be63 100644
--- a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -21,6 +21,8 @@
*/
#include <limits>
+#include <memory>
+#include <vector>
#include "xfa/fxbarcode/BC_Dimension.h"
#include "xfa/fxbarcode/BC_UtilCodingConvert.h"
@@ -55,6 +57,7 @@ const wchar_t CBC_HighLevelEncoder::MACRO_TRAILER = 0x0004;
CBC_HighLevelEncoder::CBC_HighLevelEncoder() {}
CBC_HighLevelEncoder::~CBC_HighLevelEncoder() {}
+
CFX_ByteArray& CBC_HighLevelEncoder::getBytesForMessage(CFX_WideString msg) {
CFX_ByteString bytestr;
CBC_UtilCodingConvert::UnicodeToUTF8(msg, bytestr);
@@ -89,23 +92,20 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
context.setSkipAtEnd(2);
context.m_pos += 6;
}
- CFX_PtrArray encoders;
- encoders.Add(new CBC_ASCIIEncoder());
- encoders.Add(new CBC_C40Encoder());
- encoders.Add(new CBC_TextEncoder());
- encoders.Add(new CBC_X12Encoder());
- encoders.Add(new CBC_EdifactEncoder());
- encoders.Add(new CBC_Base256Encoder());
+
+ std::vector<std::unique_ptr<CBC_Encoder>> encoders;
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_ASCIIEncoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_C40Encoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_TextEncoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_X12Encoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_EdifactEncoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_Base256Encoder()));
int32_t encodingMode = ASCII_ENCODATION;
while (context.hasMoreCharacters()) {
- ((CBC_Encoder*)encoders.GetAt(encodingMode))->Encode(context, e);
- if (e != BCExceptionNO) {
- for (int32_t i = 0; i < encoders.GetSize(); i++) {
- delete (CBC_Encoder*)encoders.GetAt(i);
- }
- encoders.RemoveAll();
- return (FX_WCHAR*)"";
- }
+ encoders[encodingMode]->Encode(context, e);
+ if (e != BCExceptionNO)
+ return L"";
+
if (context.m_newEncoding >= 0) {
encodingMode = context.m_newEncoding;
context.resetEncoderSignal();
@@ -113,13 +113,9 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
}
int32_t len = context.m_codewords.GetLength();
context.updateSymbolInfo(e);
- if (e != BCExceptionNO) {
- for (int32_t i = 0; i < encoders.GetSize(); i++) {
- delete (CBC_Encoder*)encoders.GetAt(i);
- }
- encoders.RemoveAll();
- return (FX_WCHAR*)"";
- }
+ if (e != BCExceptionNO)
+ return L"";
+
int32_t capacity = context.m_symbolInfo->m_dataCapacity;
if (len < capacity) {
if (encodingMode != ASCII_ENCODATION &&
@@ -134,10 +130,6 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
while (codewords.GetLength() < capacity) {
codewords += (randomize253State(PAD, codewords.GetLength() + 1));
}
- for (int32_t i = 0; i < encoders.GetSize(); i++) {
- delete (CBC_Encoder*)encoders.GetAt(i);
- }
- encoders.RemoveAll();
return codewords;
}
int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg,
diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
index 98ec75ac2f..5806b3d09d 100644
--- a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
@@ -137,30 +137,31 @@ FX_BOOL CBC_OnedCode128Writer::IsDigits(const CFX_ByteString& contents,
}
return TRUE;
}
+
uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents,
int32_t& outLength,
int32_t& e) {
if (contents.GetLength() < 1 || contents.GetLength() > 80) {
e = BCExceptionContentsLengthShouldBetween1and80;
- return NULL;
+ return nullptr;
}
- CFX_PtrArray patterns;
+ CFX_ArrayTemplate<const int32_t*> patterns;
int32_t checkSum = 0;
if (m_codeFormat == BC_CODE128_B) {
- checkSum = Encode128B(contents, patterns);
+ checkSum = Encode128B(contents, &patterns);
} else if (m_codeFormat == BC_CODE128_C) {
- checkSum = Encode128C(contents, patterns);
+ checkSum = Encode128C(contents, &patterns);
} else {
e = BCExceptionFormatException;
- return NULL;
+ return nullptr;
}
checkSum %= 103;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[checkSum]);
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_STOP]);
+ patterns.Add(CBC_OnedCode128Reader::CODE_PATTERNS[checkSum]);
+ patterns.Add(CBC_OnedCode128Reader::CODE_PATTERNS[CODE_STOP]);
m_iContentLen = contents.GetLength() + 3;
int32_t codeWidth = 0;
for (int32_t k = 0; k < patterns.GetSize(); k++) {
- int32_t* pattern = (int32_t*)patterns[k];
+ const int32_t* pattern = patterns[k];
for (int32_t j = 0; j < 7; j++) {
codeWidth += pattern[j];
}
@@ -169,27 +170,29 @@ uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents,
uint8_t* result = FX_Alloc(uint8_t, outLength);
int32_t pos = 0;
for (int32_t j = 0; j < patterns.GetSize(); j++) {
- int32_t* pattern = (int32_t*)patterns[j];
+ const int32_t* pattern = patterns[j];
pos += AppendPattern(result, pos, pattern, 7, 1, e);
if (e != BCExceptionNO) {
FX_Free(result);
- return NULL;
+ return nullptr;
}
}
return result;
}
-int32_t CBC_OnedCode128Writer::Encode128B(const CFX_ByteString& contents,
- CFX_PtrArray& patterns) {
+
+int32_t CBC_OnedCode128Writer::Encode128B(
+ const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns) {
int32_t checkSum = 0;
int32_t checkWeight = 1;
int32_t position = 0;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_B]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_B]);
checkSum += CODE_START_B * checkWeight;
while (position < contents.GetLength()) {
int32_t patternIndex = 0;
patternIndex = contents[position] - ' ';
position += 1;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
checkSum += patternIndex * checkWeight;
if (position != 0) {
checkWeight++;
@@ -197,12 +200,14 @@ int32_t CBC_OnedCode128Writer::Encode128B(const CFX_ByteString& contents,
}
return checkSum;
}
-int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents,
- CFX_PtrArray& patterns) {
+
+int32_t CBC_OnedCode128Writer::Encode128C(
+ const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns) {
int32_t checkSum = 0;
int32_t checkWeight = 1;
int32_t position = 0;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_C]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_C]);
checkSum += CODE_START_C * checkWeight;
while (position < contents.GetLength()) {
int32_t patternIndex = 0;
@@ -219,7 +224,7 @@ int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents,
position += 2;
}
}
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
checkSum += patternIndex * checkWeight;
if (position != 0) {
checkWeight++;
diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Writer.h b/xfa/fxbarcode/oned/BC_OnedCode128Writer.h
index aa6bd90f17..b2530642af 100644
--- a/xfa/fxbarcode/oned/BC_OnedCode128Writer.h
+++ b/xfa/fxbarcode/oned/BC_OnedCode128Writer.h
@@ -47,8 +47,10 @@ class CBC_OnedCode128Writer : public CBC_OneDimWriter {
FX_BOOL IsDigits(const CFX_ByteString& contents,
int32_t start,
int32_t length);
- int32_t Encode128B(const CFX_ByteString& contents, CFX_PtrArray& patterns);
- int32_t Encode128C(const CFX_ByteString& contents, CFX_PtrArray& patterns);
+ int32_t Encode128B(const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns);
+ int32_t Encode128C(const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns);
BC_TYPE m_codeFormat;
};
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;
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
index 030ee43c20..15ae3e26f1 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
@@ -28,6 +28,7 @@
#include "xfa/fxbarcode/BC_ResultPoint.h"
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h"
+#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h"
#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
@@ -90,17 +91,14 @@ CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo(
SampleGrid(m_image, topLeft.get(), topRight.get(), bottomLeft.get(),
(CBC_ResultPoint*)(alignmentPattern), dimension, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* points = new CFX_PtrArray;
- if (alignmentPattern == NULL) {
- points->Add(bottomLeft.release());
- points->Add(topLeft.release());
- points->Add(topRight.release());
- } else {
- points->Add(bottomLeft.release());
- points->Add(topLeft.release());
- points->Add(topRight.release());
+
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points =
+ new CFX_ArrayTemplate<CBC_ResultPoint*>();
+ points->Add(bottomLeft.release());
+ points->Add(topLeft.release());
+ points->Add(topRight.release());
+ if (alignmentPattern)
points->Add(alignmentPattern);
- }
return new CBC_QRDetectorResult(bits, points);
}
CBC_CommonBitMatrix* CBC_QRDetector::SampleGrid(
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
index 18e5d9ad4c..5ce2e75762 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
@@ -24,20 +24,20 @@
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
-CBC_QRDetectorResult::CBC_QRDetectorResult(CBC_CommonBitMatrix* bits,
- CFX_PtrArray* points)
+CBC_QRDetectorResult::CBC_QRDetectorResult(
+ CBC_CommonBitMatrix* bits,
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points)
: m_bits(bits), m_points(points) {}
+
CBC_QRDetectorResult::~CBC_QRDetectorResult() {
- for (int32_t i = 0; i < m_points->GetSize(); i++) {
- delete (CBC_ResultPoint*)(*m_points)[i];
- }
- m_points->RemoveAll();
- delete m_points;
- delete m_bits;
+ for (int32_t i = 0; i < m_points->GetSize(); i++)
+ delete (*m_points)[i];
}
-CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() {
- return m_bits;
+
+CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() const {
+ return m_bits.get();
}
-CFX_PtrArray* CBC_QRDetectorResult::GetPoints() {
- return m_points;
+
+CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_QRDetectorResult::GetPoints() const {
+ return m_points.get();
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
index 1570777afe..5948c2a01c 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
+++ b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
@@ -7,20 +7,26 @@
#ifndef XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
#define XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_basic.h"
class CBC_CommonBitMatrix;
+class CBC_ResultPoint;
-class CBC_QRDetectorResult {
- private:
- CBC_CommonBitMatrix* m_bits;
- CFX_PtrArray* m_points;
-
+class CBC_QRDetectorResult final {
public:
- CBC_QRDetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points);
- virtual ~CBC_QRDetectorResult();
- CBC_CommonBitMatrix* GetBits();
- CFX_PtrArray* GetPoints();
+ // Takes ownership of |bits| and |points|.
+ CBC_QRDetectorResult(CBC_CommonBitMatrix* bits,
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points);
+ ~CBC_QRDetectorResult();
+
+ CBC_CommonBitMatrix* GetBits() const;
+ CFX_ArrayTemplate<CBC_ResultPoint*>* GetPoints() const;
+
+ private:
+ std::unique_ptr<CBC_CommonBitMatrix> m_bits;
+ std::unique_ptr<CFX_ArrayTemplate<CBC_ResultPoint*>> m_points;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_