summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/oned
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode/oned')
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp19
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.h4
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp12
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.h8
4 files changed, 29 insertions, 14 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++) {
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.h b/xfa/fxbarcode/oned/BC_OneDimWriter.h
index 10eccf9eea..1480b82df1 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.h
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_
#define XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_
+#include <memory>
+
#include "core/fxge/include/fx_ge.h"
#include "xfa/fxbarcode/BC_Writer.h"
#include "xfa/fxbarcode/include/BC_Library.h"
@@ -107,7 +109,7 @@ class CBC_OneDimWriter : public CBC_Writer {
int32_t m_iContentLen;
FX_BOOL m_bLeftPadding;
FX_BOOL m_bRightPadding;
- CBC_CommonBitMatrix* m_output;
+ std::unique_ptr<CBC_CommonBitMatrix> m_output;
int32_t m_barWidth;
int32_t m_multiple;
FX_FLOAT m_outputHScale;
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 8ed5971e0e..8fd85fc6a1 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -27,17 +27,16 @@
#include "xfa/fxbarcode/oned/BC_OnedUPCAWriter.h"
CBC_OnedUPCAWriter::CBC_OnedUPCAWriter() {
- m_subWriter = nullptr;
m_bLeftPadding = TRUE;
m_bRightPadding = TRUE;
}
+
void CBC_OnedUPCAWriter::Init() {
- m_subWriter = new CBC_OnedEAN13Writer;
-}
-CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {
- delete m_subWriter;
+ m_subWriter.reset(new CBC_OnedEAN13Writer);
}
+CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {}
+
FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity(
const CFX_WideStringC& contents) {
for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) {
@@ -63,6 +62,7 @@ CFX_WideString CBC_OnedUPCAWriter::FilterContents(
}
return filtercontents;
}
+
int32_t CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString& contents) {
int32_t odd = 0;
int32_t even = 0;
@@ -79,6 +79,7 @@ int32_t CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString& contents) {
checksum = (10 - checksum) % 10;
return (checksum);
}
+
uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents,
BCFORMAT format,
int32_t& outWidth,
@@ -88,6 +89,7 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents,
BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return ret;
}
+
uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents,
BCFORMAT format,
int32_t& outWidth,
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h
index 8257dfa4b6..b38a235076 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_
#define XFA_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
#include "xfa/fxbarcode/oned/BC_OneDimWriter.h"
@@ -21,8 +23,6 @@ class CBC_OnedUPCAWriter : public CBC_OneDimWriter {
CBC_OnedUPCAWriter();
~CBC_OnedUPCAWriter() override;
- virtual void Init();
-
// CBC_OneDimWriter
uint8_t* Encode(const CFX_ByteString& contents,
BCFORMAT format,
@@ -46,6 +46,8 @@ class CBC_OnedUPCAWriter : public CBC_OneDimWriter {
int32_t& e) override;
FX_BOOL CheckContentValidity(const CFX_WideStringC& contents) override;
CFX_WideString FilterContents(const CFX_WideStringC& contents) override;
+
+ void Init();
int32_t CalcChecksum(const CFX_ByteString& contents);
protected:
@@ -58,7 +60,7 @@ class CBC_OnedUPCAWriter : public CBC_OneDimWriter {
int32_t& e) override;
private:
- CBC_OnedEAN13Writer* m_subWriter;
+ std::unique_ptr<CBC_OnedEAN13Writer> m_subWriter;
};
#endif // XFA_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_