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

Unified Diff: xfa/fxbarcode/cbc_ean13.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_datamatrix.cpp ('k') | xfa/fxbarcode/cbc_ean8.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxbarcode/cbc_ean13.cpp
diff --git a/xfa/fxbarcode/cbc_ean13.cpp b/xfa/fxbarcode/cbc_ean13.cpp
index ea67c9f64b7ce920049a910d241b591c706fbc9a..589af5b090497f4f2e5f380f4bef3f8e22640436 100644
--- a/xfa/fxbarcode/cbc_ean13.cpp
+++ b/xfa/fxbarcode/cbc_ean13.cpp
@@ -27,27 +27,23 @@
#include "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h"
#include "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h"
-CBC_EAN13::CBC_EAN13() {
- m_pBCReader = (CBC_Reader*)new (CBC_OnedEAN13Reader);
- m_pBCWriter = (CBC_Writer*)new (CBC_OnedEAN13Writer);
-}
+CBC_EAN13::CBC_EAN13()
+ : CBC_OneCode(new CBC_OnedEAN13Reader, new CBC_OnedEAN13Writer) {}
-CBC_EAN13::~CBC_EAN13() {
- delete (m_pBCReader);
- delete (m_pBCWriter);
-}
+CBC_EAN13::~CBC_EAN13() {}
CFX_WideString CBC_EAN13::Preprocess(const CFX_WideStringC& contents) {
CFX_WideString encodeContents =
- ((CBC_OnedEAN13Writer*)m_pBCWriter)->FilterContents(contents);
+ static_cast<CBC_OnedEAN13Writer*>(m_pBCWriter.get())
+ ->FilterContents(contents);
int32_t length = encodeContents.GetLength();
if (length <= 12) {
for (int32_t i = 0; i < 12 - length; i++)
encodeContents = FX_WCHAR('0') + encodeContents;
CFX_ByteString byteString = encodeContents.UTF8Encode();
- int32_t checksum =
- ((CBC_OnedEAN13Writer*)m_pBCWriter)->CalcChecksum(byteString);
+ int32_t checksum = static_cast<CBC_OnedEAN13Writer*>(m_pBCWriter.get())
+ ->CalcChecksum(byteString);
byteString += checksum - 0 + '0';
encodeContents = byteString.UTF8Decode();
}
@@ -70,10 +66,10 @@ FX_BOOL CBC_EAN13::Encode(const CFX_WideStringC& contents,
CFX_WideString encodeContents = Preprocess(contents);
CFX_ByteString byteString = encodeContents.UTF8Encode();
m_renderContents = encodeContents;
- uint8_t* data = static_cast<CBC_OnedEAN13Writer*>(m_pBCWriter)
+ uint8_t* data = static_cast<CBC_OnedEAN13Writer*>(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);
@@ -83,14 +79,14 @@ FX_BOOL CBC_EAN13::Encode(const CFX_WideStringC& contents,
FX_BOOL CBC_EAN13::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_EAN13::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;
« no previous file with comments | « xfa/fxbarcode/cbc_datamatrix.cpp ('k') | xfa/fxbarcode/cbc_ean8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698