summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/cbc_code128.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-06-06 12:57:44 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-06 12:57:44 -0700
commit52d78564a61fad5d435f3c95a3a6c0df142e50cf (patch)
tree209840b7f578c0e35722984b789a2e9e84d5d428 /xfa/fxbarcode/cbc_code128.cpp
parentfe433f15d60f92ccde7a928160c2e7cc77dcb8bf (diff)
downloadpdfium-52d78564a61fad5d435f3c95a3a6c0df142e50cf.tar.xz
Clean up C-Style casts in CBC_CodeBase and subclasses
Make the parent class own the reader/writer via unique_ptrs. De-virtualize some methods with no overrides. Review-Url: https://codereview.chromium.org/2037573005
Diffstat (limited to 'xfa/fxbarcode/cbc_code128.cpp')
-rw-r--r--xfa/fxbarcode/cbc_code128.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/xfa/fxbarcode/cbc_code128.cpp b/xfa/fxbarcode/cbc_code128.cpp
index 85d7afbbe8..c3614bee90 100644
--- a/xfa/fxbarcode/cbc_code128.cpp
+++ b/xfa/fxbarcode/cbc_code128.cpp
@@ -27,19 +27,15 @@
#include "xfa/fxbarcode/oned/BC_OnedCode128Reader.h"
#include "xfa/fxbarcode/oned/BC_OnedCode128Writer.h"
-CBC_Code128::CBC_Code128(BC_TYPE type) {
- m_pBCReader = (CBC_Reader*)new (CBC_OnedCode128Reader);
- m_pBCWriter = (CBC_Writer*)new CBC_OnedCode128Writer(type);
-}
+CBC_Code128::CBC_Code128(BC_TYPE type)
+ : CBC_OneCode(new CBC_OnedCode128Reader, new CBC_OnedCode128Writer(type)) {}
-CBC_Code128::~CBC_Code128() {
- delete (m_pBCReader);
- delete (m_pBCWriter);
-}
+CBC_Code128::~CBC_Code128() {}
FX_BOOL CBC_Code128::SetTextLocation(BC_TEXT_LOC location) {
if (m_pBCWriter)
- return ((CBC_OnedCode128Writer*)m_pBCWriter)->SetTextLocation(location);
+ return static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get())
+ ->SetTextLocation(location);
return FALSE;
}
@@ -55,17 +51,19 @@ FX_BOOL CBC_Code128::Encode(const CFX_WideStringC& contents,
int32_t outHeight = 0;
CFX_WideString content(contents);
if (contents.GetLength() % 2 &&
- ((CBC_OnedCode128Writer*)m_pBCWriter)->GetType() == BC_CODE128_C) {
+ static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get())->GetType() ==
+ BC_CODE128_C) {
content += '0';
}
- CFX_WideString encodeContents = ((CBC_OnedCode128Writer*)m_pBCWriter)
- ->FilterContents(content.AsStringC());
+ CFX_WideString encodeContents =
+ static_cast<CBC_OnedCode128Writer*>(m_pBCWriter.get())
+ ->FilterContents(content.AsStringC());
m_renderContents = encodeContents;
CFX_ByteString byteString = encodeContents.UTF8Encode();
- uint8_t* data = static_cast<CBC_OnedCode128Writer*>(m_pBCWriter)
+ uint8_t* data = static_cast<CBC_OnedCode128Writer*>(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);
@@ -75,14 +73,14 @@ FX_BOOL CBC_Code128::Encode(const CFX_WideStringC& contents,
FX_BOOL CBC_Code128::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_Code128::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;