Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Unified Diff: xfa/fxbarcode/cbc_code39.cpp

Issue 2037573005: Clean up C-Style casts in CBC_CodeBase and subclasses (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fxbarcode/cbc_code128.cpp ('k') | xfa/fxbarcode/cbc_codebase.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxbarcode/cbc_code39.cpp
diff --git a/xfa/fxbarcode/cbc_code39.cpp b/xfa/fxbarcode/cbc_code39.cpp
index 5d00d772e4ecfce24122b9ade6d7ca7a36378003..03e618e188074a097437953198999383de9233d2 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;
}
« no previous file with comments | « xfa/fxbarcode/cbc_code128.cpp ('k') | xfa/fxbarcode/cbc_codebase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698