Index: xfa/fxbarcode/cbc_ean8.cpp |
diff --git a/xfa/fxbarcode/cbc_ean8.cpp b/xfa/fxbarcode/cbc_ean8.cpp |
index 418ef87c1f4d3e39ea1367f8cb1b39e3768078c3..3f32d2274c45fa00f48bf323fd46f482be5a36bf 100644 |
--- a/xfa/fxbarcode/cbc_ean8.cpp |
+++ b/xfa/fxbarcode/cbc_ean8.cpp |
@@ -27,27 +27,23 @@ |
#include "xfa/fxbarcode/oned/BC_OnedEAN8Reader.h" |
#include "xfa/fxbarcode/oned/BC_OnedEAN8Writer.h" |
-CBC_EAN8::CBC_EAN8() { |
- m_pBCReader = (CBC_Reader*)new (CBC_OnedEAN8Reader); |
- m_pBCWriter = (CBC_Writer*)new (CBC_OnedEAN8Writer); |
-} |
+CBC_EAN8::CBC_EAN8() |
+ : CBC_OneCode(new CBC_OnedEAN8Reader, new CBC_OnedEAN8Writer) {} |
-CBC_EAN8::~CBC_EAN8() { |
- delete (m_pBCReader); |
- delete (m_pBCWriter); |
-} |
+CBC_EAN8::~CBC_EAN8() {} |
CFX_WideString CBC_EAN8::Preprocess(const CFX_WideStringC& contents) { |
CFX_WideString encodeContents = |
- ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterContents(contents); |
+ static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) |
+ ->FilterContents(contents); |
int32_t length = encodeContents.GetLength(); |
if (length <= 7) { |
for (int32_t i = 0; i < 7 - length; i++) |
encodeContents = FX_WCHAR('0') + encodeContents; |
CFX_ByteString byteString = encodeContents.UTF8Encode(); |
- int32_t checksum = |
- ((CBC_OnedEAN8Writer*)m_pBCWriter)->CalcChecksum(byteString); |
+ int32_t checksum = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) |
+ ->CalcChecksum(byteString); |
encodeContents += FX_WCHAR(checksum - 0 + '0'); |
} |
if (length > 8) |
@@ -69,10 +65,10 @@ FX_BOOL CBC_EAN8::Encode(const CFX_WideStringC& contents, |
CFX_WideString encodeContents = Preprocess(contents); |
CFX_ByteString byteString = encodeContents.UTF8Encode(); |
m_renderContents = encodeContents; |
- uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter) |
+ uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) |
->Encode(byteString, format, outWidth, outHeight, e); |
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); |
- ((CBC_OneDimWriter*)m_pBCWriter) |
+ static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e); |
FX_Free(data); |
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); |
@@ -82,14 +78,14 @@ FX_BOOL CBC_EAN8::Encode(const CFX_WideStringC& contents, |
FX_BOOL CBC_EAN8::RenderDevice(CFX_RenderDevice* device, |
const CFX_Matrix* matrix, |
int32_t& e) { |
- ((CBC_OneDimWriter*)m_pBCWriter) |
+ static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e); |
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); |
return TRUE; |
} |
FX_BOOL CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { |
- ((CBC_OneDimWriter*)m_pBCWriter) |
+ static_cast<CBC_OneDimWriter*>(m_pBCWriter.get()) |
->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); |
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); |
return TRUE; |