diff options
Diffstat (limited to 'xfa/src/fxbarcode/datamatrix')
8 files changed, 62 insertions, 45 deletions
diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp index be13c8580f..9315b167e7 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp @@ -20,8 +20,11 @@ * limitations under the License. */ -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" + +#include <memory> + +#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" #include "xfa/src/fxbarcode/utils.h" @@ -63,7 +66,7 @@ CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::ReadVersion( return temp; } CFX_ByteArray* CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t& e) { - CBC_AutoPtr<CFX_ByteArray> result(new CFX_ByteArray()); + std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray()); result->SetSize(m_version->GetTotalCodewords()); int32_t resultOffset = 0; int32_t row = 4; diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp index 4728bb3572..6ccb2f75d9 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp @@ -21,6 +21,9 @@ */ #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" + +#include <memory> + #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" #include "xfa/src/fxbarcode/utils.h" @@ -41,7 +44,7 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( for (i = 0; i < ecBlockArray.GetSize(); i++) { totalBlocks += ((ECB*)ecBlockArray[i])->GetCount(); } - CBC_AutoPtr<CFX_PtrArray> result(new CFX_PtrArray()); + std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray()); result->SetSize(totalBlocks); int32_t numResultBlocks = 0; int32_t j; diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp index 49a1d1654a..423cefc65f 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp @@ -20,13 +20,16 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" + +#include <memory> + #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" CBC_DataMatrixDecoder::CBC_DataMatrixDecoder() { @@ -46,9 +49,8 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( parser.Init(bits, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_DataMatrixVersion* version = parser.GetVersion(); - CFX_ByteArray* byteTemp = parser.ReadCodewords(e); + std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CFX_ByteArray> codewords(byteTemp); CFX_PtrArray* dataBlocks = CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h index 011a8b8e72..d80a51247f 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h @@ -7,9 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ #define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_ReedSolomonDecoder; class CBC_CommonDecoderResult; class CBC_CommonBitMatrix; + class CBC_DataMatrixDecoder { public: CBC_DataMatrixDecoder(); diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp index b89ef7066b..c29c64862a 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp @@ -20,12 +20,14 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" + #include <algorithm> +#include <memory> #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" @@ -121,10 +123,10 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { } else { topRight = pointD; } - int32_t dimensionTop = CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + int32_t dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, topRight)) ->GetTransitions(); - int32_t dimensionRight = CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + int32_t dimensionRight = std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, topRight)) ->GetTransitions(); if ((dimensionTop & 0x01) == 1) { @@ -135,24 +137,24 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { dimensionRight++; } dimensionRight += 2; - CBC_AutoPtr<CBC_CommonBitMatrix> bits(NULL); - CBC_AutoPtr<CBC_ResultPoint> correctedTopRight(NULL); + std::unique_ptr<CBC_CommonBitMatrix> bits; + std::unique_ptr<CBC_ResultPoint> correctedTopRight; if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) { - correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>( + correctedTopRight.reset( CorrectTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight)); if (correctedTopRight.get() == NULL) { - correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>(topRight); + correctedTopRight.reset(topRight); } else { delete topRight; topRight = NULL; } - dimensionTop = CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, correctedTopRight.get())) ->GetTransitions(); dimensionRight = - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, correctedTopRight.get())) ->GetTransitions(); if ((dimensionTop & 0x01) == 1) { @@ -161,34 +163,34 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { if ((dimensionRight & 0x01) == 1) { dimensionRight++; } - bits = CBC_AutoPtr<CBC_CommonBitMatrix>( - SampleGrid(m_image, topLeft, bottomLeft, bottomRight, - correctedTopRight.get(), dimensionTop, dimensionRight, e)); + bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, + correctedTopRight.get(), dimensionTop, dimensionRight, + e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } else { int32_t dimension = std::min(dimensionRight, dimensionTop); - correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>( + correctedTopRight.reset( CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); if (correctedTopRight.get() == NULL) { - correctedTopRight = CBC_AutoPtr<CBC_ResultPoint>(topRight); + correctedTopRight.reset(topRight); } else { delete topRight; topRight = NULL; } int32_t dimensionCorrected = - std::max(CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::max(std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, correctedTopRight.get())) ->GetTransitions(), - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, correctedTopRight.get())) ->GetTransitions()); dimensionCorrected++; if ((dimensionCorrected & 0x01) == 1) { dimensionCorrected++; } - bits = CBC_AutoPtr<CBC_CommonBitMatrix>(SampleGrid( - m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), - dimensionCorrected, dimensionCorrected, e)); + bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, + correctedTopRight.get(), dimensionCorrected, + dimensionCorrected, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } CFX_PtrArray* result = new CFX_PtrArray; @@ -210,13 +212,13 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular( int32_t norm = Distance(topLeft, topRight); FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; - CBC_AutoPtr<CBC_ResultPoint> c1(new CBC_ResultPoint( + std::unique_ptr<CBC_ResultPoint> c1(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); corr = Distance(bottomLeft, topLeft) / (FX_FLOAT)dimensionRight; norm = Distance(bottomRight, topRight); cos = (topRight->GetX() - bottomRight->GetX()) / norm; sin = (topRight->GetY() - bottomRight->GetY()) / norm; - CBC_AutoPtr<CBC_ResultPoint> c2(new CBC_ResultPoint( + std::unique_ptr<CBC_ResultPoint> c2(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); if (!IsValid(c1.get())) { if (IsValid(c2.get())) { @@ -227,19 +229,19 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular( return c1.release(); } int32_t l1 = FXSYS_abs(dimensionTop - - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, c1.get())) ->GetTransitions()) + FXSYS_abs(dimensionRight - - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, c1.get())) ->GetTransitions()); int32_t l2 = FXSYS_abs(dimensionTop - - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, c2.get())) ->GetTransitions()) + FXSYS_abs(dimensionRight - - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, c2.get())) ->GetTransitions()); if (l1 <= l2) { @@ -257,13 +259,13 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight( int32_t norm = Distance(topLeft, topRight); FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; - CBC_AutoPtr<CBC_ResultPoint> c1(new CBC_ResultPoint( + std::unique_ptr<CBC_ResultPoint> c1(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimension; norm = Distance(bottomRight, topRight); cos = (topRight->GetX() - bottomRight->GetX()) / norm; sin = (topRight->GetY() - bottomRight->GetY()) / norm; - CBC_AutoPtr<CBC_ResultPoint> c2(new CBC_ResultPoint( + std::unique_ptr<CBC_ResultPoint> c2(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); if (!IsValid(c1.get())) { if (IsValid(c2.get())) { @@ -273,16 +275,16 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight( } else if (!IsValid(c2.get())) { return c1.release(); } - int32_t l1 = FXSYS_abs(CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + int32_t l1 = FXSYS_abs(std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, c1.get())) ->GetTransitions() - - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, c1.get())) ->GetTransitions()); - int32_t l2 = FXSYS_abs(CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + int32_t l2 = FXSYS_abs(std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(topLeft, c2.get())) ->GetTransitions() - - CBC_AutoPtr<CBC_ResultPointsAndTransitions>( + std::unique_ptr<CBC_ResultPointsAndTransitions>( TransitionsBetween(bottomRight, c2.get())) ->GetTransitions()); return l1 <= l2 ? c1.release() : c2.release(); diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h index 5ab8f9d060..123f75101b 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ #define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_WhiteRectangleDetector; class CBC_ResultPoint; diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp index 2586751107..36a238b007 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp @@ -20,12 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h" + +#include <memory> + #include "xfa/src/fxbarcode/BC_BinaryBitmap.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" #include "xfa/src/fxbarcode/utils.h" @@ -47,13 +50,11 @@ CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, CBC_DataMatrixDetector detector(cdr); detector.Init(e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_QRDetectorResult* ddr = detector.Detect(e); + std::unique_ptr<CBC_QRDetectorResult> detectorResult(detector.Detect(e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr<CBC_QRDetectorResult> detectorResult(ddr); - CBC_CommonDecoderResult* ResultTemp = - m_decoder->Decode(detectorResult->GetBits(), e); + std::unique_ptr<CBC_CommonDecoderResult> decodeResult( + m_decoder->Decode(detectorResult->GetBits(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr<CBC_CommonDecoderResult> decodeResult(ResultTemp); return decodeResult->GetText(); } CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h index 51d22588aa..5389c4857b 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h @@ -7,10 +7,11 @@ #ifndef XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ #define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ +#include "xfa/src/fxbarcode/BC_Reader.h" + class CBC_BinaryBitmap; class CBC_DataMatrixDecoder; -class CBC_Reader; -class CBC_DataMatrixReader; + class CBC_DataMatrixReader : public CBC_Reader { public: CBC_DataMatrixReader(); |