diff options
Diffstat (limited to 'xfa/fxbarcode/datamatrix')
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp | 35 | ||||
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h | 15 | ||||
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp | 29 | ||||
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp | 120 | ||||
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h | 17 | ||||
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp | 21 | ||||
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h | 2 |
7 files changed, 115 insertions, 124 deletions
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp index c70f8b1fc9..6b7680d1a8 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp @@ -33,10 +33,10 @@ CBC_DataMatrixDataBlock::CBC_DataMatrixDataBlock(int32_t numDataCodewords, m_codewords.Copy(*codewords); m_numDataCodewords = numDataCodewords; } -CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( - CFX_ByteArray* rawCodewords, - CBC_DataMatrixVersion* version, - int32_t& e) { +CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* +CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords, + CBC_DataMatrixVersion* version, + int32_t& e) { ECBlocks* ecBlocks = version->GetECBlocks(); int32_t totalBlocks = 0; const CFX_ArrayTemplate<ECB*>& ecBlockArray = ecBlocks->GetECBlocks(); @@ -44,7 +44,8 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( for (i = 0; i < ecBlockArray.GetSize(); i++) { totalBlocks += ecBlockArray[i]->GetCount(); } - std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray()); + std::unique_ptr<CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>> result( + new CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>()); result->SetSize(totalBlocks); int32_t numResultBlocks = 0; int32_t j; @@ -59,8 +60,7 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( codewords.SetSize(0); } } - int32_t longerBlocksTotalCodewords = - ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize(); + int32_t longerBlocksTotalCodewords = (*result)[0]->GetCodewords()->GetSize(); int32_t longerBlocksNumDataCodewords = longerBlocksTotalCodewords - ecBlocks->GetECCodewords(); int32_t shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; @@ -69,10 +69,8 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( int32_t j; for (j = 0; j < numResultBlocks; j++) { if (rawCodewordsOffset < rawCodewords->GetSize()) { - ((CBC_DataMatrixDataBlock*)(*result)[j]) - ->GetCodewords() - -> - operator[](i) = (*rawCodewords)[rawCodewordsOffset++]; + (*result)[j]->GetCodewords()->operator[](i) = + (*rawCodewords)[rawCodewordsOffset++]; } } } @@ -80,24 +78,19 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( int32_t numLongerBlocks = specialVersion ? 8 : numResultBlocks; for (j = 0; j < numLongerBlocks; j++) { if (rawCodewordsOffset < rawCodewords->GetSize()) { - ((CBC_DataMatrixDataBlock*)(*result)[j]) - ->GetCodewords() - -> - operator[](longerBlocksNumDataCodewords - 1) = + (*result)[j]->GetCodewords()->operator[](longerBlocksNumDataCodewords - + 1) = (*rawCodewords)[rawCodewordsOffset++]; } } - int32_t max = - ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize(); + int32_t max = (*result)[0]->GetCodewords()->GetSize(); for (i = longerBlocksNumDataCodewords; i < max; i++) { int32_t j; for (j = 0; j < numResultBlocks; j++) { int32_t iOffset = specialVersion && j > 7 ? i - 1 : i; if (rawCodewordsOffset < rawCodewords->GetSize()) { - ((CBC_DataMatrixDataBlock*)(*result)[j]) - ->GetCodewords() - -> - operator[](iOffset) = (*rawCodewords)[rawCodewordsOffset++]; + (*result)[j]->GetCodewords()->operator[](iOffset) = + (*rawCodewords)[rawCodewordsOffset++]; } } } diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h index 039255268f..782e5ed319 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h @@ -11,22 +11,23 @@ class CBC_DataMatrixVersion; -class CBC_DataMatrixDataBlock { +class CBC_DataMatrixDataBlock final { public: - virtual ~CBC_DataMatrixDataBlock(); + ~CBC_DataMatrixDataBlock(); int32_t GetNumDataCodewords(); CFX_ByteArray* GetCodewords(); - static CFX_PtrArray* GetDataBlocks(CFX_ByteArray* rawCodewords, - CBC_DataMatrixVersion* version, - int32_t& e); + static CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* GetDataBlocks( + CFX_ByteArray* rawCodewords, + CBC_DataMatrixVersion* version, + int32_t& e); private: + CBC_DataMatrixDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords); + int32_t m_numDataCodewords; CFX_ByteArray m_codewords; - - CBC_DataMatrixDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords); }; #endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDATABLOCK_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp index 3f765aa8f9..4276066444 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp @@ -42,40 +42,37 @@ void CBC_DataMatrixDecoder::Init() { CBC_DataMatrixDecoder::~CBC_DataMatrixDecoder() { delete m_rsDecoder; } + CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( CBC_CommonBitMatrix* bits, int32_t& e) { CBC_DataMatrixBitMatrixParser parser; parser.Init(bits, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); CBC_DataMatrixVersion* version = parser.GetVersion(); std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_PtrArray* dataBlocks = + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* dataBlocks = CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); int32_t dataBlocksCount = dataBlocks->GetSize(); int32_t totalBytes = 0; int32_t i, j; for (i = 0; i < dataBlocksCount; i++) { - totalBytes += - ((CBC_DataMatrixDataBlock*)(*dataBlocks)[i])->GetNumDataCodewords(); + totalBytes += (*dataBlocks)[i]->GetNumDataCodewords(); } CFX_ByteArray resultBytes; resultBytes.SetSize(totalBytes); for (j = 0; j < dataBlocksCount; j++) { - CFX_ByteArray* codewordBytes = - ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetCodewords(); - int32_t numDataCodewords = - ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetNumDataCodewords(); + CFX_ByteArray* codewordBytes = (*dataBlocks)[j]->GetCodewords(); + int32_t numDataCodewords = (*dataBlocks)[j]->GetNumDataCodewords(); CorrectErrors(*codewordBytes, numDataCodewords, e); if (e != BCExceptionNO) { for (int32_t i = 0; i < dataBlocks->GetSize(); i++) { - delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; + delete (*dataBlocks)[i]; } delete dataBlocks; - dataBlocks = NULL; - return NULL; + return nullptr; } int32_t i; for (i = 0; i < numDataCodewords; i++) { @@ -83,15 +80,15 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( } } for (i = 0; i < (dataBlocks->GetSize()); i++) { - delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; + delete (*dataBlocks)[i]; } delete dataBlocks; - dataBlocks = NULL; CBC_CommonDecoderResult* resultR = CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); return resultR; } + void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes, int32_t numDataCodewords, int32_t& e) { diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp index fd410097cc..9fd1bbc4a0 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp @@ -35,7 +35,7 @@ const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4}; CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image) - : m_image(image), m_rectangleDetector(NULL) {} + : m_image(image), m_rectangleDetector(nullptr) {} void CBC_DataMatrixDetector::Init(int32_t& e) { m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image); m_rectangleDetector->Init(e); @@ -44,42 +44,44 @@ void CBC_DataMatrixDetector::Init(int32_t& e) { CBC_DataMatrixDetector::~CBC_DataMatrixDetector() { delete m_rectangleDetector; } -inline FX_BOOL ResultPointsAndTransitionsComparator(void* a, void* b) { - return ((CBC_ResultPointsAndTransitions*)b)->GetTransitions() > - ((CBC_ResultPointsAndTransitions*)a)->GetTransitions(); -} + CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { - CFX_PtrArray* cornerPoints = m_rectangleDetector->Detect(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_ResultPoint* pointA = (CBC_ResultPoint*)(*cornerPoints)[0]; - CBC_ResultPoint* pointB = (CBC_ResultPoint*)(*cornerPoints)[1]; - CBC_ResultPoint* pointC = (CBC_ResultPoint*)(*cornerPoints)[2]; - CBC_ResultPoint* pointD = (CBC_ResultPoint*)(*cornerPoints)[3]; + CFX_ArrayTemplate<CBC_ResultPoint*>* cornerPoints = + m_rectangleDetector->Detect(e); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + CBC_ResultPoint* pointA = (*cornerPoints)[0]; + CBC_ResultPoint* pointB = (*cornerPoints)[1]; + CBC_ResultPoint* pointC = (*cornerPoints)[2]; + CBC_ResultPoint* pointD = (*cornerPoints)[3]; delete cornerPoints; - cornerPoints = NULL; - CFX_PtrArray transitions; + + CFX_ArrayTemplate<CBC_ResultPointsAndTransitions*> transitions; transitions.Add(TransitionsBetween(pointA, pointB)); transitions.Add(TransitionsBetween(pointA, pointC)); transitions.Add(TransitionsBetween(pointB, pointD)); transitions.Add(TransitionsBetween(pointC, pointD)); - BC_FX_PtrArray_Sort(transitions, &ResultPointsAndTransitionsComparator); - delete ((CBC_ResultPointsAndTransitions*)transitions[2]); - delete ((CBC_ResultPointsAndTransitions*)transitions[3]); - CBC_ResultPointsAndTransitions* lSideOne = - (CBC_ResultPointsAndTransitions*)transitions[0]; - CBC_ResultPointsAndTransitions* lSideTwo = - (CBC_ResultPointsAndTransitions*)transitions[1]; + std::sort(transitions.GetData(), + transitions.GetData() + transitions.GetSize(), + [](const CBC_ResultPointsAndTransitions* a, + const CBC_ResultPointsAndTransitions* b) { + return a->GetTransitions() < b->GetTransitions(); + }); + delete transitions[2]; + delete transitions[3]; + + CBC_ResultPointsAndTransitions* lSideOne = transitions[0]; + CBC_ResultPointsAndTransitions* lSideTwo = transitions[1]; CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t> pointCount; Increment(pointCount, lSideOne->GetFrom()); Increment(pointCount, lSideOne->GetTo()); Increment(pointCount, lSideTwo->GetFrom()); Increment(pointCount, lSideTwo->GetTo()); - delete ((CBC_ResultPointsAndTransitions*)transitions[1]); - delete ((CBC_ResultPointsAndTransitions*)transitions[0]); + delete transitions[1]; + delete transitions[0]; transitions.RemoveAll(); - CBC_ResultPoint* maybeTopLeft = NULL; - CBC_ResultPoint* bottomLeft = NULL; - CBC_ResultPoint* maybeBottomRight = NULL; + CBC_ResultPoint* maybeTopLeft = nullptr; + CBC_ResultPoint* bottomLeft = nullptr; + CBC_ResultPoint* maybeBottomRight = nullptr; FX_POSITION itBegin = pointCount.GetStartPosition(); while (itBegin) { CBC_ResultPoint* key = 0; @@ -88,31 +90,31 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { if (value == 2) { bottomLeft = key; } else { - if (maybeBottomRight == NULL) { - maybeBottomRight = key; - } else { + if (maybeBottomRight) { maybeTopLeft = key; + } else { + maybeBottomRight = key; } } } - if (maybeTopLeft == NULL || bottomLeft == NULL || maybeBottomRight == NULL) { + if (!maybeTopLeft || !bottomLeft || !maybeBottomRight) { delete pointA; delete pointB; delete pointC; delete pointD; e = BCExceptionNotFound; - return NULL; + return nullptr; } - CFX_PtrArray corners; + CFX_ArrayTemplate<CBC_ResultPoint*> corners; corners.SetSize(3); corners[0] = maybeTopLeft; corners[1] = bottomLeft; corners[2] = maybeBottomRight; OrderBestPatterns(&corners); - CBC_ResultPoint* bottomRight = (CBC_ResultPoint*)corners[0]; - bottomLeft = (CBC_ResultPoint*)corners[1]; - CBC_ResultPoint* topLeft = (CBC_ResultPoint*)corners[2]; - CBC_ResultPoint* topRight = NULL; + CBC_ResultPoint* bottomRight = corners[0]; + bottomLeft = corners[1]; + CBC_ResultPoint* topLeft = corners[2]; + CBC_ResultPoint* topRight = nullptr; int32_t value; if (!pointCount.Lookup(pointA, value)) { topRight = pointA; @@ -144,11 +146,11 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { correctedTopRight.reset( CorrectTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight)); - if (correctedTopRight.get() == NULL) { + if (!correctedTopRight.get()) { correctedTopRight.reset(topRight); } else { delete topRight; - topRight = NULL; + topRight = nullptr; } dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, correctedTopRight.get())) @@ -166,16 +168,16 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), dimensionTop, dimensionRight, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); } else { int32_t dimension = std::min(dimensionRight, dimensionTop); correctedTopRight.reset( CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); - if (correctedTopRight.get() == NULL) { + if (!correctedTopRight.get()) { correctedTopRight.reset(topRight); } else { delete topRight; - topRight = NULL; + topRight = nullptr; } int32_t dimensionCorrected = std::max(std::unique_ptr<CBC_ResultPointsAndTransitions>( @@ -191,7 +193,7 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), dimensionCorrected, dimensionCorrected, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); } CFX_PtrArray* result = new CFX_PtrArray; result->SetSize(4); @@ -224,7 +226,7 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular( if (IsValid(c2.get())) { return c2.release(); } - return NULL; + return nullptr; } else if (!IsValid(c2.get())) { return c1.release(); } @@ -271,7 +273,7 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight( if (IsValid(c2.get())) { return c2.release(); } - return NULL; + return nullptr; } else if (!IsValid(c2.get())) { return c1.release(); } @@ -328,7 +330,7 @@ CBC_CommonBitMatrix* CBC_DataMatrixDetector::SampleGrid( topLeft->GetX(), topLeft->GetY(), topRight->GetX(), topRight->GetY(), bottomRight->GetX(), bottomRight->GetY(), bottomLeft->GetX(), bottomLeft->GetY(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); return cbm; } CBC_ResultPointsAndTransitions* CBC_DataMatrixDetector::TransitionsBetween( @@ -371,26 +373,24 @@ CBC_ResultPointsAndTransitions* CBC_DataMatrixDetector::TransitionsBetween( } return new CBC_ResultPointsAndTransitions(from, to, transitions); } -void CBC_DataMatrixDetector::OrderBestPatterns(CFX_PtrArray* patterns) { - FX_FLOAT abDistance = (FX_FLOAT)Distance((CBC_ResultPoint*)(*patterns)[0], - (CBC_ResultPoint*)(*patterns)[1]); - FX_FLOAT bcDistance = (FX_FLOAT)Distance((CBC_ResultPoint*)(*patterns)[1], - (CBC_ResultPoint*)(*patterns)[2]); - FX_FLOAT acDistance = (FX_FLOAT)Distance((CBC_ResultPoint*)(*patterns)[0], - (CBC_ResultPoint*)(*patterns)[2]); +void CBC_DataMatrixDetector::OrderBestPatterns( + CFX_ArrayTemplate<CBC_ResultPoint*>* patterns) { + FX_FLOAT abDistance = (FX_FLOAT)Distance((*patterns)[0], (*patterns)[1]); + FX_FLOAT bcDistance = (FX_FLOAT)Distance((*patterns)[1], (*patterns)[2]); + FX_FLOAT acDistance = (FX_FLOAT)Distance((*patterns)[0], (*patterns)[2]); CBC_ResultPoint *topLeft, *topRight, *bottomLeft; if (bcDistance >= abDistance && bcDistance >= acDistance) { - topLeft = (CBC_ResultPoint*)(*patterns)[0]; - topRight = (CBC_ResultPoint*)(*patterns)[1]; - bottomLeft = (CBC_ResultPoint*)(*patterns)[2]; + topLeft = (*patterns)[0]; + topRight = (*patterns)[1]; + bottomLeft = (*patterns)[2]; } else if (acDistance >= bcDistance && acDistance >= abDistance) { - topLeft = (CBC_ResultPoint*)(*patterns)[1]; - topRight = (CBC_ResultPoint*)(*patterns)[0]; - bottomLeft = (CBC_ResultPoint*)(*patterns)[2]; + topLeft = (*patterns)[1]; + topRight = (*patterns)[0]; + bottomLeft = (*patterns)[2]; } else { - topLeft = (CBC_ResultPoint*)(*patterns)[2]; - topRight = (CBC_ResultPoint*)(*patterns)[0]; - bottomLeft = (CBC_ResultPoint*)(*patterns)[1]; + topLeft = (*patterns)[2]; + topRight = (*patterns)[0]; + bottomLeft = (*patterns)[1]; } if ((bottomLeft->GetY() - topLeft->GetY()) * (topRight->GetX() - topLeft->GetX()) < diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h index 589825fc38..8ef053b334 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h @@ -10,11 +10,11 @@ #include "core/fxcrt/include/fx_basic.h" class CBC_CommonBitMatrix; -class CBC_WhiteRectangleDetector; -class CBC_ResultPoint; -class CBC_QRDetectorResult; class CBC_DataMatrixDetector; -class ResultPointsAndTransitions; +class CBC_QRDetectorResult; +class CBC_ResultPoint; +class CBC_WhiteRectangleDetector; + class CBC_ResultPointsAndTransitions { public: CBC_ResultPointsAndTransitions(CBC_ResultPoint* from, @@ -25,15 +25,16 @@ class CBC_ResultPointsAndTransitions { m_transitions = transitions; } ~CBC_ResultPointsAndTransitions() {} - CBC_ResultPoint* GetFrom() { return m_from; } - CBC_ResultPoint* GetTo() { return m_to; } - int32_t GetTransitions() { return m_transitions; } + CBC_ResultPoint* GetFrom() const { return m_from; } + CBC_ResultPoint* GetTo() const { return m_to; } + int32_t GetTransitions() const { return m_transitions; } private: CBC_ResultPoint* m_from; CBC_ResultPoint* m_to; int32_t m_transitions; }; + class CBC_DataMatrixDetector { public: CBC_DataMatrixDetector(CBC_CommonBitMatrix* image); @@ -65,7 +66,7 @@ class CBC_DataMatrixDetector { void Increment(CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t>& table, CBC_ResultPoint* key); int32_t Round(FX_FLOAT d); - void OrderBestPatterns(CFX_PtrArray* patterns); + void OrderBestPatterns(CFX_ArrayTemplate<CBC_ResultPoint*>* patterns); virtual void Init(int32_t& e); private: diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp index e441a29e44..d1dcc23e7b 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp @@ -25,14 +25,15 @@ #include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" #include "xfa/fxbarcode/utils.h" -CFX_PtrArray* CBC_DataMatrixVersion::VERSIONS = NULL; +CFX_ArrayTemplate<CBC_DataMatrixVersion*>* CBC_DataMatrixVersion::VERSIONS = + nullptr; void CBC_DataMatrixVersion::Initialize() { - VERSIONS = new CFX_PtrArray(); + VERSIONS = new CFX_ArrayTemplate<CBC_DataMatrixVersion*>(); } void CBC_DataMatrixVersion::Finalize() { for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { - delete ((CBC_DataMatrixVersion*)(VERSIONS->GetAt(i))); + delete VERSIONS->GetAt(i); } VERSIONS->RemoveAll(); delete VERSIONS; @@ -84,7 +85,7 @@ ECBlocks* CBC_DataMatrixVersion::GetECBlocks() { } void CBC_DataMatrixVersion::ReleaseAll() { for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { - delete (CBC_DataMatrixVersion*)VERSIONS->GetAt(i); + delete VERSIONS->GetAt(i); } VERSIONS->RemoveAll(); } @@ -94,7 +95,7 @@ CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions( int32_t& e) { if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { e = BCExceptionNotFound; - return NULL; + return nullptr; } if (VERSIONS->GetSize() == 0) { VERSIONS->Add(new CBC_DataMatrixVersion(1, 10, 10, 8, 8, @@ -161,13 +162,11 @@ CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions( } int32_t numVersions = VERSIONS->GetSize(); for (int32_t i = 0; i < numVersions; ++i) { - if (((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeRows == - numRows && - ((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeColumns == - numColumns) { - return (CBC_DataMatrixVersion*)(*VERSIONS)[i]; + if ((*VERSIONS)[i]->m_symbolSizeRows == numRows && + (*VERSIONS)[i]->m_symbolSizeColumns == numColumns) { + return (*VERSIONS)[i]; } } e = BCExceptionNotFound; - return NULL; + return nullptr; } diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h index 74433cc4f2..b4585d20bc 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h @@ -80,7 +80,7 @@ class CBC_DataMatrixVersion { int32_t m_dataRegionSizeColumns; ECBlocks* m_ecBlocks; int32_t m_totalCodewords; - static CFX_PtrArray* VERSIONS; + static CFX_ArrayTemplate<CBC_DataMatrixVersion*>* VERSIONS; }; #endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_ |