summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-08-09 13:45:03 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-09 13:45:03 -0700
commite76203dbefd1df075a063ee019c3908513f6bee5 (patch)
tree2a763852e1d1de3eee6a67285ea96be2874bfb00 /xfa/fxbarcode/oned/BC_OneDimWriter.cpp
parentad5ac7584844b03c5ceed082e5f5158a632405cc (diff)
downloadpdfium-e76203dbefd1df075a063ee019c3908513f6bee5.tar.xz
Use smart pointers for class owned pointers in xfa/fxbarcode
For classes under xfa/fxbarcode, use smart pointers instead of raw pointer to make memory management easier. Also fix some styling issues along the changes. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2221023003
Diffstat (limited to 'xfa/fxbarcode/oned/BC_OneDimWriter.cpp')
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index ea2f3f9f89..9ab1aeb53e 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -42,20 +42,22 @@ CBC_OneDimWriter::CBC_OneDimWriter() {
m_iContentLen = 0;
m_bLeftPadding = FALSE;
m_bRightPadding = FALSE;
- m_output = nullptr;
-}
-CBC_OneDimWriter::~CBC_OneDimWriter() {
- delete m_output;
}
+
+CBC_OneDimWriter::~CBC_OneDimWriter() {}
+
void CBC_OneDimWriter::SetPrintChecksum(FX_BOOL checksum) {
m_bPrintChecksum = checksum;
}
+
void CBC_OneDimWriter::SetDataLength(int32_t length) {
m_iDataLenth = length;
}
+
void CBC_OneDimWriter::SetCalcChecksum(int32_t state) {
m_bCalcChecksum = state;
}
+
FX_BOOL CBC_OneDimWriter::SetFont(CFX_Font* cFont) {
if (!cFont)
return FALSE;
@@ -63,21 +65,26 @@ FX_BOOL CBC_OneDimWriter::SetFont(CFX_Font* cFont) {
m_pFont = cFont;
return TRUE;
}
+
void CBC_OneDimWriter::SetFontSize(FX_FLOAT size) {
m_fFontSize = size;
}
+
void CBC_OneDimWriter::SetFontStyle(int32_t style) {
m_iFontStyle = style;
}
+
void CBC_OneDimWriter::SetFontColor(FX_ARGB color) {
m_fontColor = color;
}
+
FX_WCHAR CBC_OneDimWriter::Upper(FX_WCHAR ch) {
if (ch >= 'a' && ch <= 'z') {
ch = ch - ('a' - 'A');
}
return ch;
}
+
uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents,
BCFORMAT format,
int32_t& outWidth,
@@ -94,6 +101,7 @@ uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents,
BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return ret;
}
+
uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents,
BCFORMAT format,
int32_t& outWidth,
@@ -183,6 +191,7 @@ void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text,
}
FX_Free(pCharCode);
}
+
void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
const CFX_Matrix* matrix,
const CFX_ByteString str,
@@ -429,7 +438,7 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents,
if (!isDevice) {
m_barWidth = codeLength * m_multiple;
}
- m_output = new CBC_CommonBitMatrix;
+ m_output.reset(new CBC_CommonBitMatrix);
m_output->Init(outputWidth, outputHeight);
int32_t outputX = leftPadding * m_multiple;
for (int32_t inputX = 0; inputX < codeOldLength; inputX++) {