summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/cbc_code39.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode/cbc_code39.cpp')
-rw-r--r--xfa/fxbarcode/cbc_code39.cpp50
1 files changed, 23 insertions, 27 deletions
diff --git a/xfa/fxbarcode/cbc_code39.cpp b/xfa/fxbarcode/cbc_code39.cpp
index 5d00d772e4..03e618e188 100644
--- a/xfa/fxbarcode/cbc_code39.cpp
+++ b/xfa/fxbarcode/cbc_code39.cpp
@@ -27,26 +27,18 @@
#include "xfa/fxbarcode/oned/BC_OnedCode39Reader.h"
#include "xfa/fxbarcode/oned/BC_OnedCode39Writer.h"
-CBC_Code39::CBC_Code39() {
- m_pBCReader = (CBC_Reader*)new (CBC_OnedCode39Reader);
- m_pBCWriter = (CBC_Writer*)new (CBC_OnedCode39Writer);
-}
+CBC_Code39::CBC_Code39()
+ : CBC_OneCode(new CBC_OnedCode39Reader, new CBC_OnedCode39Writer) {}
-CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit) {
- m_pBCReader = (CBC_Reader*)new CBC_OnedCode39Reader(usingCheckDigit);
- m_pBCWriter = (CBC_Writer*)new CBC_OnedCode39Writer;
-}
+CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit)
+ : CBC_OneCode(new CBC_OnedCode39Reader(usingCheckDigit),
+ new CBC_OnedCode39Writer) {}
-CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit, FX_BOOL extendedMode) {
- m_pBCReader =
- (CBC_Reader*)new CBC_OnedCode39Reader(usingCheckDigit, extendedMode);
- m_pBCWriter = (CBC_Writer*)new CBC_OnedCode39Writer(extendedMode);
-}
+CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit, FX_BOOL extendedMode)
+ : CBC_OneCode(new CBC_OnedCode39Reader(usingCheckDigit, extendedMode),
+ new CBC_OnedCode39Writer(extendedMode)) {}
-CBC_Code39::~CBC_Code39() {
- delete (m_pBCReader);
- delete (m_pBCWriter);
-}
+CBC_Code39::~CBC_Code39() {}
FX_BOOL CBC_Code39::Encode(const CFX_WideStringC& contents,
FX_BOOL isDevice,
@@ -59,15 +51,17 @@ FX_BOOL CBC_Code39::Encode(const CFX_WideStringC& contents,
int32_t outWidth = 0;
int32_t outHeight = 0;
CFX_WideString filtercontents =
- ((CBC_OnedCode39Writer*)m_pBCWriter)->FilterContents(contents);
+ static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get())
+ ->FilterContents(contents);
CFX_WideString renderContents =
- ((CBC_OnedCode39Writer*)m_pBCWriter)->RenderTextContents(contents);
+ static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get())
+ ->RenderTextContents(contents);
m_renderContents = renderContents;
CFX_ByteString byteString = filtercontents.UTF8Encode();
- uint8_t* data = static_cast<CBC_OnedCode39Writer*>(m_pBCWriter)
+ uint8_t* data = static_cast<CBC_OnedCode39Writer*>(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(renderContents.AsStringC(), data, outWidth, isDevice, e);
FX_Free(data);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
@@ -78,9 +72,9 @@ FX_BOOL CBC_Code39::RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t& e) {
CFX_WideString renderCon =
- ((CBC_OnedCode39Writer*)m_pBCWriter)
+ static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get())
->encodedContents(m_renderContents.AsStringC(), e);
- ((CBC_OneDimWriter*)m_pBCWriter)
+ static_cast<CBC_OneDimWriter*>(m_pBCWriter.get())
->RenderDeviceResult(device, matrix, renderCon.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
@@ -88,9 +82,9 @@ FX_BOOL CBC_Code39::RenderDevice(CFX_RenderDevice* device,
FX_BOOL CBC_Code39::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString renderCon =
- ((CBC_OnedCode39Writer*)m_pBCWriter)
+ static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get())
->encodedContents(m_renderContents.AsStringC(), e);
- ((CBC_OneDimWriter*)m_pBCWriter)
+ static_cast<CBC_OneDimWriter*>(m_pBCWriter.get())
->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
@@ -115,12 +109,14 @@ CFX_WideString CBC_Code39::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
FX_BOOL CBC_Code39::SetTextLocation(BC_TEXT_LOC location) {
if (m_pBCWriter)
- return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetTextLocation(location);
+ return static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get())
+ ->SetTextLocation(location);
return FALSE;
}
FX_BOOL CBC_Code39::SetWideNarrowRatio(int32_t ratio) {
if (m_pBCWriter)
- return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetWideNarrowRatio(ratio);
+ return static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get())
+ ->SetWideNarrowRatio(ratio);
return FALSE;
}