diff options
Diffstat (limited to 'xfa')
38 files changed, 269 insertions, 272 deletions
diff --git a/xfa/src/fxbarcode/BC_UtilRSS.cpp b/xfa/src/fxbarcode/BC_UtilRSS.cpp index 958f192358..dcc12e2268 100644 --- a/xfa/src/fxbarcode/BC_UtilRSS.cpp +++ b/xfa/src/fxbarcode/BC_UtilRSS.cpp @@ -22,6 +22,8 @@ #include "xfa/src/fxbarcode/BC_UtilRSS.h" +#include <memory> + #include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/utils.h" @@ -32,9 +34,8 @@ CFX_Int32Array* CBC_UtilRSS::GetRssWidths(int32_t val, int32_t elements, int32_t maxWidth, FX_BOOL noNarrow) { - CFX_Int32Array* iTemp = new CFX_Int32Array; - iTemp->SetSize(elements); - CBC_AutoPtr<CFX_Int32Array> widths(iTemp); + std::unique_ptr<CFX_Int32Array> widths(new CFX_Int32Array); + widths->SetSize(elements); int32_t bar; int32_t narrowMask = 0; for (bar = 0; bar < elements - 1; bar++) { diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp index c0e982cb63..897d9537fd 100644 --- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp +++ b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp @@ -20,8 +20,11 @@ * limitations under the License. */ -#include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h" + +#include <memory> + +#include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/utils.h" CBC_CommonPerspectiveTransform::CBC_CommonPerspectiveTransform(FX_FLOAT a11, @@ -61,9 +64,9 @@ CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(FX_FLOAT x0, FX_FLOAT y2p, FX_FLOAT x3p, FX_FLOAT y3p) { - CBC_AutoPtr<CBC_CommonPerspectiveTransform> qToS( + std::unique_ptr<CBC_CommonPerspectiveTransform> qToS( QuadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3)); - CBC_AutoPtr<CBC_CommonPerspectiveTransform> sToQ( + std::unique_ptr<CBC_CommonPerspectiveTransform> sToQ( SquareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p)); return sToQ->Times(*(qToS.get())); } @@ -123,7 +126,7 @@ CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0, FX_FLOAT y2, FX_FLOAT x3, FX_FLOAT y3) { - CBC_AutoPtr<CBC_CommonPerspectiveTransform> temp1( + std::unique_ptr<CBC_CommonPerspectiveTransform> temp1( SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)); return temp1->BuildAdjoint(); } diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp index 6c3920483c..8babc9c78f 100644 --- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp +++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp @@ -20,11 +20,14 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" + +#include <memory> + #include "xfa/src/fxbarcode/BC_Binarizer.h" #include "xfa/src/fxbarcode/BC_LuminanceSource.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" #include "xfa/src/fxbarcode/utils.h" const int32_t LUMINANCE_BITS = 5; @@ -41,7 +44,7 @@ CBC_CommonBitArray* CBC_GlobalHistogramBinarizer::GetBlackRow( int32_t& e) { CBC_LuminanceSource* source = GetLuminanceSource(); int32_t width = source->GetWidth(); - CBC_AutoPtr<CBC_CommonBitArray> result(new CBC_CommonBitArray(width)); + std::unique_ptr<CBC_CommonBitArray> result(new CBC_CommonBitArray(width)); InitArrays(width); CFX_ByteArray* localLuminances = source->GetRow(y, m_luminance, e); if (e != BCExceptionNO) { @@ -75,9 +78,8 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) { CBC_LuminanceSource* source = GetLuminanceSource(); int32_t width = source->GetWidth(); int32_t height = source->GetHeight(); - CBC_CommonBitMatrix* BitMatrixTemp = new CBC_CommonBitMatrix(); - BitMatrixTemp->Init(width, height); - CBC_AutoPtr<CBC_CommonBitMatrix> matrix(BitMatrixTemp); + std::unique_ptr<CBC_CommonBitMatrix> matrix(new CBC_CommonBitMatrix()); + matrix->Init(width, height); InitArrays(width); CFX_Int32Array localBuckets; localBuckets.Copy(m_buckets); @@ -95,7 +97,7 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) { } int32_t blackPoint = EstimateBlackPoint(localBuckets, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CFX_ByteArray> localLuminances(source->GetMatrix()); + std::unique_ptr<CFX_ByteArray> localLuminances(source->GetMatrix()); for (y = 0; y < height; y++) { int32_t offset = y * width; for (int32_t x = 0; x < width; x++) { diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h index a74187e767..c0ffaaa28d 100644 --- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h +++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h @@ -8,6 +8,7 @@ #define XFA_SRC_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ #include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/BC_Binarizer.h" class CBC_CommonBinarizer; class CBC_CommonBitArray; diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp index ed5899da37..cc1b435f00 100644 --- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp +++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp @@ -20,9 +20,12 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" + +#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/utils.h" const int32_t CBC_WhiteRectangleDetector::INIT_SIZE = 30; @@ -124,53 +127,45 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) { } if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) { int32_t maxSize = right - left; - CBC_AutoPtr<CBC_ResultPoint> z(NULL); + std::unique_ptr<CBC_ResultPoint> z; for (int32_t i = 1; i < maxSize; i++) { - z = CBC_AutoPtr<CBC_ResultPoint>( - GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i), - (FX_FLOAT)(left + i), (FX_FLOAT)(down))); - if (z.get()) { + z.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i), + (FX_FLOAT)(left + i), (FX_FLOAT)(down))); + if (z) break; - } } if (z.get() == NULL) { e = BCExceptionNotFound; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_AutoPtr<CBC_ResultPoint> t(NULL); + std::unique_ptr<CBC_ResultPoint> t; for (int32_t j = 1; j < maxSize; j++) { - t = CBC_AutoPtr<CBC_ResultPoint>( - GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j), - (FX_FLOAT)(left + j), (FX_FLOAT)up)); - if (t.get()) { + t.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j), + (FX_FLOAT)(left + j), (FX_FLOAT)up)); + if (t) break; - } } if (t.get() == NULL) { e = BCExceptionNotFound; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_AutoPtr<CBC_ResultPoint> x(NULL); + std::unique_ptr<CBC_ResultPoint> x; for (int32_t k = 1; k < maxSize; k++) { - x = CBC_AutoPtr<CBC_ResultPoint>( - GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k), - (FX_FLOAT)(right - k), (FX_FLOAT)up)); - if (x.get()) { + x.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k), + (FX_FLOAT)(right - k), (FX_FLOAT)up)); + if (x) break; - } } if (x.get() == NULL) { e = BCExceptionNotFound; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_AutoPtr<CBC_ResultPoint> y(NULL); + std::unique_ptr<CBC_ResultPoint> y; for (int32_t m = 1; m < maxSize; m++) { - y = CBC_AutoPtr<CBC_ResultPoint>( - GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m), - (FX_FLOAT)(right - m), (FX_FLOAT)down)); - if (y.get()) { + y.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m), + (FX_FLOAT)(right - m), (FX_FLOAT)down)); + if (y) break; - } } if (y.get() == NULL) { e = BCExceptionNotFound; diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp index 78c5bdc5e2..3e6de6ef06 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp @@ -21,6 +21,9 @@ */ #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" + +#include <memory> + #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" @@ -74,12 +77,11 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode, CBC_ReedSolomonGF256Poly info; info.Init(m_field, &infoCoefficients, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_ReedSolomonGF256Poly* rsg = info.MultiplyByMonomial(ecBytes, 1, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> infoTemp( + info.MultiplyByMonomial(ecBytes, 1, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> infoTemp(rsg); - CFX_PtrArray* pa = infoTemp->Divide(generator, e); + std::unique_ptr<CFX_PtrArray> temp(infoTemp->Divide(generator, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr<CFX_PtrArray> temp(pa); CBC_ReedSolomonGF256Poly* remainder = (CBC_ReedSolomonGF256Poly*)(temp->operator[](1)); CFX_Int32Array* coefficients = remainder->GetCoefficients(); diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp index 86c8a60c39..abdcaf0c88 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp @@ -21,6 +21,10 @@ */ #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" + +#include <memory> +#include <utility> + #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" @@ -51,23 +55,22 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, CBC_ReedSolomonGF256Poly syndrome; syndrome.Init(m_field, &syndromeCoefficients, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_ReedSolomonGF256Poly* rsg = m_field->BuildMonomial(twoS, 1, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> temp( + m_field->BuildMonomial(twoS, 1, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg); - CFX_PtrArray* pa = RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e); + std::unique_ptr<CFX_PtrArray> sigmaOmega( + RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr<CFX_PtrArray> sigmaOmega(pa); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma( + std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma( (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega( + std::unique_ptr<CBC_ReedSolomonGF256Poly> omega( (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]); - CFX_Int32Array* ia1 = FindErrorLocations(sigma.get(), e); + std::unique_ptr<CFX_Int32Array> errorLocations( + FindErrorLocations(sigma.get(), e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr<CFX_Int32Array> errorLocations(ia1); - CFX_Int32Array* ia2 = - FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e); + std::unique_ptr<CFX_Int32Array> errorMagnitudes( + FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr<CFX_Int32Array> errorMagnitudes(ia2); for (int32_t k = 0; k < errorLocations->GetSize(); k++) { int32_t position = received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e); @@ -90,42 +93,33 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm( a = b; b = temp; } - CBC_ReedSolomonGF256Poly* rsg1 = a->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> rLast(a->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLast(rsg1); - CBC_ReedSolomonGF256Poly* rsg2 = b->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> r(b->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> r(rsg2); - CBC_ReedSolomonGF256Poly* rsg3 = m_field->GetOne()->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> sLast(m_field->GetOne()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLast(rsg3); - CBC_ReedSolomonGF256Poly* rsg4 = m_field->GetZero()->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> s(m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> s(rsg4); - CBC_ReedSolomonGF256Poly* rsg5 = m_field->GetZero()->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> tLast(m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLast(rsg5); - CBC_ReedSolomonGF256Poly* rsg6 = m_field->GetOne()->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> t(m_field->GetOne()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> t(rsg6); while (r->GetDegree() >= R / 2) { - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLastLast = rLast; - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLastLast = sLast; - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLastlast = tLast; - rLast = r; - sLast = s; - tLast = t; + std::unique_ptr<CBC_ReedSolomonGF256Poly> rLastLast = std::move(rLast); + std::unique_ptr<CBC_ReedSolomonGF256Poly> sLastLast = std::move(sLast); + std::unique_ptr<CBC_ReedSolomonGF256Poly> tLastlast = std::move(tLast); + rLast = std::move(r); + sLast = std::move(s); + tLast = std::move(t); if (rLast->IsZero()) { e = BCExceptionR_I_1IsZero; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_ReedSolomonGF256Poly* rsg7 = rLastLast->Clone(e); + r.reset(rLastLast->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rTemp(rsg7); - r = rTemp; - CBC_ReedSolomonGF256Poly* rsg8 = m_field->GetZero()->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> q(m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> q(rsg8); int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree()); int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); @@ -133,37 +127,27 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm( int32_t degreeDiff = r->GetDegree() - rLast->GetDegree(); int32_t scale = m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse); - CBC_ReedSolomonGF256Poly* rsgp1 = - m_field->BuildMonomial(degreeDiff, scale, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> build( + m_field->BuildMonomial(degreeDiff, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> build(rsgp1); - CBC_ReedSolomonGF256Poly* rsgp2 = q->AddOrSubtract(build.get(), e); + q.reset(q->AddOrSubtract(build.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsgp2); - q = temp; - CBC_ReedSolomonGF256Poly* rsgp3 = - rLast->MultiplyByMonomial(degreeDiff, scale, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> multiply( + rLast->MultiplyByMonomial(degreeDiff, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> multiply(rsgp3); - CBC_ReedSolomonGF256Poly* rsgp4 = r->AddOrSubtract(multiply.get(), e); + r.reset(r->AddOrSubtract(multiply.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp3(rsgp4); - r = temp3; } - CBC_ReedSolomonGF256Poly* rsg9 = q->Multiply(sLast.get(), e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> temp1( + q->Multiply(sLast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg9); - CBC_ReedSolomonGF256Poly* rsg10 = temp1->AddOrSubtract(sLastLast.get(), e); + s.reset(temp1->AddOrSubtract(sLastLast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp2(rsg10); - s = temp2; - CBC_ReedSolomonGF256Poly* rsg11 = q->Multiply(tLast.get(), e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> temp5( + q->Multiply(tLast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp5(rsg11); - CBC_ReedSolomonGF256Poly* rsg12 = temp5->AddOrSubtract(tLastlast.get(), e); + t.reset(temp5->AddOrSubtract(tLastlast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp6(rsg12); - t = temp6; } int32_t sigmaTildeAtZero = t->GetCoefficients(0); if (sigmaTildeAtZero == 0) { @@ -172,12 +156,10 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm( } int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_ReedSolomonGF256Poly* rsg13 = t->Multiply(inverse, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(t->Multiply(inverse, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(rsg13); - CBC_ReedSolomonGF256Poly* rsg14 = r->Multiply(inverse, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(r->Multiply(inverse, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(rsg14); CFX_PtrArray* temp = new CFX_PtrArray; temp->Add(sigma.release()); temp->Add(omega.release()); @@ -188,13 +170,13 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations( int32_t& e) { int32_t numErrors = errorLocator->GetDegree(); if (numErrors == 1) { - CBC_AutoPtr<CFX_Int32Array> temp(new CFX_Int32Array); + std::unique_ptr<CFX_Int32Array> temp(new CFX_Int32Array); temp->Add(errorLocator->GetCoefficients(1)); return temp.release(); } CFX_Int32Array* tempT = new CFX_Int32Array; tempT->SetSize(numErrors); - CBC_AutoPtr<CFX_Int32Array> result(tempT); + std::unique_ptr<CFX_Int32Array> result(tempT); int32_t ie = 0; for (int32_t i = 1; i < 256 && ie < numErrors; i++) { if (errorLocator->EvaluateAt(i) == 0) { @@ -217,7 +199,7 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes( int32_t s = errorLocations->GetSize(); CFX_Int32Array* temp = new CFX_Int32Array; temp->SetSize(s); - CBC_AutoPtr<CFX_Int32Array> result(temp); + std::unique_ptr<CFX_Int32Array> result(temp); for (int32_t i = 0; i < s; i++) { int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp index baafde023a..f138009ffa 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp @@ -20,9 +20,12 @@ * limitations under the License. */ -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" +#include <memory> + +#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" + CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients) { if (field == NULL) { @@ -216,12 +219,11 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, e = BCExceptionDivideByZero; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient( + m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> quotient(rsg1); - CBC_ReedSolomonGF256Poly* rsg2 = Clone(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2); int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); int32_t inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeadingTerm, e); @@ -231,23 +233,16 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, int32_t scale = m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), inverseDenominatorLeadingTeam); - CBC_ReedSolomonGF256Poly* rsg3 = - other->MultiplyByMonomial(degreeDifference, scale, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> term( + other->MultiplyByMonomial(degreeDifference, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> term(rsg3); - CBC_ReedSolomonGF256Poly* rsg4 = - m_field->BuildMonomial(degreeDifference, scale, e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient( + m_field->BuildMonomial(degreeDifference, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> iteratorQuotient(rsg4); - CBC_ReedSolomonGF256Poly* rsg5 = - quotient->AddOrSubtract(iteratorQuotient.get(), e); + quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg5); - quotient = temp; - CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e); + remainder.reset(remainder->AddOrSubtract(term.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg6); - remainder = temp1; } CFX_PtrArray* tempPtrA = new CFX_PtrArray; tempPtrA->Add(quotient.release()); diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h index 8f2642dd87..71e4a09dd3 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h @@ -7,7 +7,10 @@ #ifndef XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ #define XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_ReedSolomonGF256; + class CBC_ReedSolomonGF256Poly { public: CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients); 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(); diff --git a/xfa/src/fxbarcode/oned/BC_OneDReader.h b/xfa/src/fxbarcode/oned/BC_OneDReader.h index 5a55d1f5e2..27a1a3d7ee 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDReader.h +++ b/xfa/src/fxbarcode/oned/BC_OneDReader.h @@ -7,9 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDREADER_H_ #define XFA_SRC_FXBARCODE_ONED_BC_ONEDREADER_H_ -#include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/BC_Reader.h" -class CBC_Reader; class CBC_BinaryBitmap; class CBC_CommonBitArray; diff --git a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp b/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp index 74f0db4068..da1f47bfe8 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp @@ -20,10 +20,13 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" + +#include <memory> + #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" #include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" #include "xfa/src/fxbarcode/utils.h" const int32_t CBC_OneDimReader::MAX_AVG_VARIANCE = (int32_t)(256 * 0.48f); @@ -73,9 +76,8 @@ CFX_ByteString CBC_OneDimReader::DecodeRow(int32_t rowNumber, CBC_CommonBitArray* row, int32_t hints, int32_t& e) { - CFX_Int32Array* StartPattern = FindStartGuardPattern(row, e); + std::unique_ptr<CFX_Int32Array> result(FindStartGuardPattern(row, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr<CFX_Int32Array> result(StartPattern); CFX_ByteString temp = DecodeRow(rowNumber, row, result.get(), hints, e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); return temp; diff --git a/xfa/src/fxbarcode/oned/BC_OneDimReader.h b/xfa/src/fxbarcode/oned/BC_OneDimReader.h index 0a3e3c3d5d..3374bec63a 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimReader.h +++ b/xfa/src/fxbarcode/oned/BC_OneDimReader.h @@ -7,9 +7,11 @@ #ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDIMREADER_H_ #define XFA_SRC_FXBARCODE_ONED_BC_ONEDIMREADER_H_ -class CBC_OneDReader; +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" + class CBC_CommonBitArray; -class CBC_OneDimReader; + class CBC_OneDimReader : public CBC_OneDReader { private: const static int32_t MAX_AVG_VARIANCE; diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp index d7caf68226..3cbad1eade 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp @@ -20,13 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" + #include <algorithm> +#include <memory> #include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" #include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" #include "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h" #include "xfa/src/fxbarcode/utils.h" @@ -46,9 +48,8 @@ CFX_ByteString CBC_OnedCodaBarReader::DecodeRow(int32_t rowNumber, CBC_CommonBitArray* row, int32_t hints, int32_t& e) { - CFX_Int32Array* int32Ptr = FindAsteriskPattern(row, e); + std::unique_ptr<CFX_Int32Array> start(FindAsteriskPattern(row, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr<CFX_Int32Array> start(int32Ptr); (*start)[1] = 0; int32_t nextStart = (*start)[1]; int32_t end = row->GetSize(); diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h index e1cf9d8698..cbb47fb554 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h +++ b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h @@ -7,9 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ #define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" + class CBC_CommonBitArray; class CBC_OneDReader; -class CBC_OnedCodaBarReader; + class CBC_OnedCodaBarReader : public CBC_OneDReader { public: CBC_OnedCodaBarReader(); diff --git a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp b/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp index d44995385a..7426d95d4c 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp @@ -20,8 +20,11 @@ * limitations under the License. */ -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h" + +#include <memory> + +#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h" @@ -140,13 +143,12 @@ CFX_ByteArray* CBC_QRBitMatrixParser::ReadCodewords(int32_t& e) { int32_t dimension = m_bitMatrix->GetDimension(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); dataMask->UnmaskBitMatirx(m_bitMatrix, dimension); - CBC_CommonBitMatrix* cbm = version->BuildFunctionPattern(e); + std::unique_ptr<CBC_CommonBitMatrix> functionPattern( + version->BuildFunctionPattern(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_CommonBitMatrix> functionPattern(cbm); FX_BOOL readingUp = TRUE; - CFX_ByteArray* temp = new CFX_ByteArray; - temp->SetSize(version->GetTotalCodeWords()); - CBC_AutoPtr<CFX_ByteArray> result(temp); + std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray); + result->SetSize(version->GetTotalCodeWords()); int32_t resultOffset = 0; int32_t currentByte = 0; int32_t bitsRead = 0; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp index c594230428..896a3a107b 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp @@ -20,6 +20,10 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" + +#include <memory> + #include "xfa/src/fxbarcode/BC_Binarizer.h" #include "xfa/src/fxbarcode/BC_BinaryBitmap.h" #include "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h" @@ -29,9 +33,6 @@ #include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" #include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" @@ -54,13 +55,12 @@ CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, CBC_CommonBitMatrix* matrix = image->GetMatrix(e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); CBC_QRDetector detector(matrix); - CBC_QRDetectorResult* qdr = detector.Detect(hints, e); + std::unique_ptr<CBC_QRDetectorResult> detectorResult( + detector.Detect(hints, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr<CBC_QRDetectorResult> detectorResult(qdr); - CBC_CommonDecoderResult* qdr2 = - m_decoder->Decode(detectorResult->GetBits(), 0, e); + std::unique_ptr<CBC_CommonDecoderResult> decodeResult( + m_decoder->Decode(detectorResult->GetBits(), 0, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr<CBC_CommonDecoderResult> decodeResult(qdr2); return (decodeResult->GetText()); } CFX_ByteString CBC_QRCodeReader::Decode(const CFX_WideString& filename, diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h index 98bf976e06..bcb08fa21e 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h @@ -7,6 +7,11 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ +#include <stdint.h> + +#include "core/include/fxcrt/fx_string.h" +#include "xfa/src/fxbarcode/BC_Reader.h" + class CBC_QRDetector; class CBC_BinaryBitmap; class CBC_QRCoderDecoder; @@ -18,7 +23,8 @@ class CBC_QRDetectorResult; class CBC_QRCoderErrorCorrectionLevel; class CBC_QRCoderMode; class CBC_QRDataMask; -class CBC_QRCodeReader; +class CFX_DIBitmap; + class CBC_QRCodeReader : public CBC_Reader { private: CBC_QRCoderDecoder* m_decoder; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp index ebaa40fd12..dd310217d4 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp @@ -20,12 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" + +#include <memory> + #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" @@ -69,9 +72,8 @@ CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(CBC_CommonBitMatrix* bits, CBC_QRCoderFormatInformation* temp = parser.ReadFormatInformation(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_QRCoderErrorCorrectionLevel* ecLevel = temp->GetErrorCorrectionLevel(); - CFX_ByteArray* ba = parser.ReadCodewords(e); + std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CFX_ByteArray> codewords(ba); CFX_PtrArray* dataBlocks = CBC_QRDataBlock::GetDataBlocks(codewords.get(), version, ecLevel, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h index 26952ee9e0..e2e53a796c 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h @@ -7,12 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_ReedSolomonDecoder; class CBC_CommonDecoderResult; -class CBC_QRBitMatrixParser; -class CBC_QRCoderVersion; -class CBC_QRDataBlock; + class CBC_QRCoderDecoder { private: CBC_ReedSolomonDecoder* m_rsDecoder; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index a451ab50b8..eb31ddc301 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -20,7 +20,10 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" + #include <algorithm> +#include <memory> #include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" #include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" @@ -31,8 +34,6 @@ #include "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" @@ -408,10 +409,9 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion( qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), &finalBits, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()); - pDecoder->Init(); - CBC_AutoPtr<CBC_CommonByteMatrix> matrix(pDecoder); + std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); int32_t maskPattern = ChooseMaskPattern( &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); BC_EXCEPTION_CHECK_ReturnVoid(e); @@ -499,10 +499,9 @@ catchException: qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), &finalBits, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()); - pDecoder->Init(); - CBC_AutoPtr<CBC_CommonByteMatrix> matrix(pDecoder); + std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); int32_t maskPattern = ChooseMaskPattern( &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); BC_EXCEPTION_CHECK_ReturnVoid(e); @@ -550,10 +549,9 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content, qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), &finalBits, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()); - pDecoder->Init(); - CBC_AutoPtr<CBC_CommonByteMatrix> matrix(pDecoder); + std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); int32_t maskPattern = ChooseMaskPattern( &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); BC_EXCEPTION_CHECK_ReturnVoid(e); diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h index 05fc2f8551..27e5b65494 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h @@ -7,6 +7,9 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_string.h" + class Make_Pair; class CBC_QRCoder; class CBC_QRCoderErrorCorrectionLevel; @@ -14,7 +17,7 @@ class CBC_QRCoderMode; class CBC_QRCoderBitVector; class CBC_CommonByteArray; class CBC_CommonByteMatrix; -class CBC_QRCoderEncoder; + class CBC_QRCoderEncoder { private: const static int32_t m_alphaNumbericTable[96]; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp index 75ad077521..185e16c5b7 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp @@ -20,10 +20,13 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" + +#include <memory> + #include "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" #include "xfa/src/fxbarcode/utils.h" CBC_QRDataBlock::CBC_QRDataBlock(int32_t numDataCodewords, @@ -54,9 +57,8 @@ CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks( for (i = 0; i < ecBlockArray->GetSize(); i++) { totalBlocks += ((CBC_QRCoderECB*)(*ecBlockArray)[i])->GetCount(); } - CFX_PtrArray* datablock = new CFX_PtrArray(); - datablock->SetSize(totalBlocks); - CBC_AutoPtr<CFX_PtrArray> result(datablock); + 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]; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h index 63ee10ef06..6146c41465 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_QRCoderVersion; class CBC_QRCoderECBlocks; class CBC_QRCoderECB; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp index 1fd8742690..72ce42fc4c 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp @@ -20,14 +20,16 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRDetector.h" + #include <algorithm> +#include <memory> #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h" #include "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetector.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" @@ -37,9 +39,8 @@ CBC_QRDetector::CBC_QRDetector(CBC_CommonBitMatrix* image) : m_image(image) {} CBC_QRDetector::~CBC_QRDetector() {} CBC_QRDetectorResult* CBC_QRDetector::Detect(int32_t hints, int32_t& e) { CBC_QRFinderPatternFinder finder(m_image); - CBC_QRFinderPatternInfo* qpi = finder.Find(hints, e); + std::unique_ptr<CBC_QRFinderPatternInfo> info(finder.Find(hints, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CBC_QRFinderPatternInfo> info(qpi); CBC_QRDetectorResult* qdr = ProcessFinderPatternInfo(info.get(), e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); return qdr; @@ -47,9 +48,9 @@ CBC_QRDetectorResult* CBC_QRDetector::Detect(int32_t hints, int32_t& e) { CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo( CBC_QRFinderPatternInfo* info, int32_t& e) { - CBC_AutoPtr<CBC_QRFinderPattern> topLeft(info->GetTopLeft()); - CBC_AutoPtr<CBC_QRFinderPattern> topRight(info->GetTopRight()); - CBC_AutoPtr<CBC_QRFinderPattern> bottomLeft(info->GetBottomLeft()); + std::unique_ptr<CBC_QRFinderPattern> topLeft(info->GetTopLeft()); + std::unique_ptr<CBC_QRFinderPattern> topRight(info->GetTopRight()); + std::unique_ptr<CBC_QRFinderPattern> bottomLeft(info->GetBottomLeft()); FX_FLOAT moduleSize = CalculateModuleSize(topLeft.get(), topRight.get(), bottomLeft.get()); if (moduleSize < 1.0f) { diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetector.h b/xfa/src/fxbarcode/qrcode/BC_QRDetector.h index 45d2f5345f..b76a656f07 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetector.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRDetector.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_ResultPoint; class CBC_CommonBitMatrix; class CBC_QRDetectorResult; @@ -17,7 +19,7 @@ class CBC_QRCoderVersion; class CBC_QRGridSampler; class CBC_QRAlignmentPatternFinder; class CBC_QRAlignmentPattern; -class CBC_QRDetector; + class CBC_QRDetector { private: CBC_CommonBitMatrix* m_image; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp index d143e276bb..f5a3c7aead 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp @@ -20,12 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" + +#include <memory> + #include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" #include "xfa/src/fxbarcode/utils.h" const int32_t CBC_QRFinderPatternFinder::CENTER_QUORUM = 2; @@ -158,9 +161,8 @@ CBC_QRFinderPatternInfo* CBC_QRFinderPatternFinder::Find(int32_t hint, } } } - CFX_PtrArray* ptr = SelectBestpatterns(e); + std::unique_ptr<CFX_PtrArray> patternInfo(SelectBestpatterns(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr<CFX_PtrArray> patternInfo(ptr); OrderBestPatterns(patternInfo.get()); return new CBC_QRFinderPatternInfo(patternInfo.get()); } diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h index 7f9209d214..aa731b6cdb 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_QRFinderPattern; class CBC_ResultPoint; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp index 7b9fe7b4f3..87f0fd072e 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp @@ -20,9 +20,12 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" + +#include <memory> + #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" #include "xfa/src/fxbarcode/utils.h" CBC_QRGridSampler CBC_QRGridSampler::m_gridSampler; @@ -107,13 +110,12 @@ CBC_CommonBitMatrix* CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix* image, FX_FLOAT p4FromX, FX_FLOAT p4FromY, int32_t& e) { - CBC_AutoPtr<CBC_CommonPerspectiveTransform> transform( + std::unique_ptr<CBC_CommonPerspectiveTransform> transform( CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral( p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)); - CBC_CommonBitMatrix* tempBitM = new CBC_CommonBitMatrix(); - tempBitM->Init(dimensionX, dimensionY); - CBC_AutoPtr<CBC_CommonBitMatrix> bits(tempBitM); + std::unique_ptr<CBC_CommonBitMatrix> bits(new CBC_CommonBitMatrix()); + bits->Init(dimensionX, dimensionY); CFX_FloatArray points; points.SetSize(dimensionX << 1); for (int32_t y = 0; y < dimensionY; y++) { diff --git a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h index a3f412435d..8d6b96a2b2 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h @@ -7,10 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_CommonPerspectiveTransform; class CBC_CommonDefaultGridSampler; -class CBC_QRGridSampler; + class CBC_QRGridSampler { private: static CBC_QRGridSampler m_gridSampler; diff --git a/xfa/src/fxbarcode/utils.h b/xfa/src/fxbarcode/utils.h index 37d2ce775b..23830d5656 100644 --- a/xfa/src/fxbarcode/utils.h +++ b/xfa/src/fxbarcode/utils.h @@ -19,44 +19,7 @@ void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, FX_CHAR c); void BC_FX_ByteString_Append(CFX_ByteString& dst, const CFX_ByteArray& ba); typedef FX_BOOL (*BC_PtrArrayCompareCallback)(void* l, void* r); void BC_FX_PtrArray_Sort(CFX_PtrArray& src, BC_PtrArrayCompareCallback fun); -template <class _Ty> -class CBC_AutoPtr { - public: - typedef _Ty element_type; - explicit CBC_AutoPtr(_Ty* _P = 0) : _Owns(_P != 0), _Ptr(_P) {} - CBC_AutoPtr(const CBC_AutoPtr<_Ty>& _Y) - : _Owns(_Y._Owns), _Ptr(_Y.release()) {} - CBC_AutoPtr<_Ty>& operator=(const CBC_AutoPtr<_Ty>& _Y) { - if (this != &_Y) { - if (_Ptr != _Y.get()) { - if (_Owns) { - delete _Ptr; - } - _Owns = _Y._Owns; - } else if (_Y._Owns) { - _Owns = TRUE; - } - _Ptr = _Y.release(); - } - return (*this); - } - ~CBC_AutoPtr() { - if (_Owns) { - delete _Ptr; - } - } - _Ty& operator*() const { return (*get()); } - _Ty* operator->() const { return (get()); } - _Ty* get() const { return (_Ptr); } - _Ty* release() const { - ((CBC_AutoPtr<_Ty>*)this)->_Owns = FALSE; - return (_Ptr); - } - private: - FX_BOOL _Owns; - _Ty* _Ptr; -}; #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) #include <limits> #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ |