summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode')
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp10
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp22
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp21
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp29
4 files changed, 45 insertions, 37 deletions
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index ae1b237957..7b1cc50d72 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -201,6 +201,7 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
(FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix,
m_fontColor, FXTEXT_CLEARTYPE);
}
+
void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
const CFX_ByteString str,
FX_FLOAT geWidth,
@@ -211,7 +212,7 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
int32_t iFontSize = (int32_t)fabs(m_fFontSize);
int32_t iTextHeight = iFontSize + 1;
CFX_FxgeDevice ge;
- ge.Create((int)geWidth, iTextHeight, m_colorSpace);
+ ge.Create((int)geWidth, iTextHeight, m_colorSpace, nullptr);
FX_RECT geRect(0, 0, (int)geWidth, iTextHeight);
ge.FillRect(&geRect, m_backgroundColor);
CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
@@ -219,9 +220,10 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
(CFX_Matrix*)&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
CFX_FxgeDevice geBitmap;
- geBitmap.Attach(pOutBitmap);
+ geBitmap.Attach(pOutBitmap, false, nullptr, false);
geBitmap.SetDIBits(ge.GetBitmap(), (int)locX, (int)locY);
}
+
void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents,
CFX_DIBitmap* pOutBitmap,
CFX_RenderDevice* device,
@@ -229,11 +231,11 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents,
int32_t barWidth,
int32_t multiple,
int32_t& e) {
- if (device == NULL && pOutBitmap == NULL) {
+ if (!device && !pOutBitmap) {
e = BCExceptionIllegalArgument;
return;
}
- if (m_pFont == NULL) {
+ if (!m_pFont) {
e = BCExceptionNullPointer;
return;
}
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index bdc5e1f2c7..20b52774e8 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -153,6 +153,7 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents,
}
return result;
}
+
void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
CFX_DIBitmap* pOutBitmap,
CFX_RenderDevice* device,
@@ -160,7 +161,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
int32_t barWidth,
int32_t multiple,
int32_t& e) {
- if (device == NULL && pOutBitmap == NULL) {
+ if (!device && !pOutBitmap) {
e = BCExceptionIllegalArgument;
return;
}
@@ -171,14 +172,14 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen);
FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen);
CFX_FxgeDevice geBitmap;
- if (pOutBitmap) {
- geBitmap.Attach(pOutBitmap);
- }
+ if (pOutBitmap)
+ geBitmap.Attach(pOutBitmap, false, nullptr, false);
+
int32_t iFontSize = (int32_t)fabs(m_fFontSize);
int32_t iTextHeight = iFontSize + 1;
CFX_ByteString tempStr = str.Mid(1, 6);
int32_t strWidth = multiple * 42;
- if (pOutBitmap == NULL) {
+ if (!pOutBitmap) {
CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
CFX_FloatRect rect(
(FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight),
@@ -208,7 +209,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
}
FX_FLOAT blank = 0.0;
iLen = tempStr.GetLength();
- if (pOutBitmap == NULL) {
+ if (!pOutBitmap) {
strWidth = (int32_t)(strWidth * m_outputHScale);
}
CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize,
@@ -216,7 +217,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
CFX_FxgeDevice ge;
if (pOutBitmap) {
- ge.Create(strWidth, iTextHeight, FXDIB_Argb);
+ ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
FX_RECT rect(0, 0, strWidth, iTextHeight);
ge.FillRect(&rect, m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos + 1, m_pFont,
@@ -265,14 +266,14 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
tempStr = str.Mid(0, 1);
iLen = tempStr.GetLength();
strWidth = multiple * 7;
- if (pOutBitmap == NULL) {
+ if (!pOutBitmap)
strWidth = (int32_t)(strWidth * m_outputHScale);
- }
+
CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize,
blank);
if (pOutBitmap) {
delete ge.GetBitmap();
- ge.Create(strWidth, iTextHeight, FXDIB_Argb);
+ ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos, m_pFont,
CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
@@ -292,6 +293,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
}
FX_Free(pCharPos);
}
+
void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents,
uint8_t* code,
int32_t codeLength,
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 4427cb8970..2aa57d18d1 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -158,6 +158,7 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents,
}
return result;
}
+
void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
CFX_DIBitmap* pOutBitmap,
CFX_RenderDevice* device,
@@ -165,10 +166,11 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
int32_t barWidth,
int32_t multiple,
int32_t& e) {
- if (device == NULL && pOutBitmap == NULL) {
+ if (!device && !pOutBitmap) {
e = BCExceptionIllegalArgument;
return;
}
+
int32_t leftPosition = 3 * multiple;
CFX_ByteString str = FX_UTF8Encode(contents);
int32_t iLength = str.GetLength();
@@ -179,12 +181,12 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
int32_t strWidth = 7 * multiple * 4;
FX_FLOAT blank = 0.0;
CFX_FxgeDevice geBitmap;
- if (pOutBitmap) {
- geBitmap.Attach(pOutBitmap);
- }
+ if (pOutBitmap)
+ geBitmap.Attach(pOutBitmap, false, nullptr, false);
+
int32_t iFontSize = (int32_t)fabs(m_fFontSize);
int32_t iTextHeight = iFontSize + 1;
- if (pOutBitmap == NULL) {
+ if (!pOutBitmap) {
CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
CFX_FloatRect rect(
(FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight),
@@ -204,16 +206,16 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
re = rect1.GetOutterRect();
device->FillRect(&re, m_backgroundColor);
}
- if (pOutBitmap == NULL) {
+ if (!pOutBitmap)
strWidth = (int32_t)(strWidth * m_outputHScale);
- }
+
CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize,
blank);
CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
CFX_FxgeDevice ge;
if (pOutBitmap) {
delete ge.GetBitmap();
- ge.Create(strWidth, iTextHeight, FXDIB_Argb);
+ ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos, m_pFont,
CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
@@ -236,7 +238,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
blank);
if (pOutBitmap) {
delete ge.GetBitmap();
- ge.Create(strWidth, iTextHeight, FXDIB_Argb);
+ ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos + 4, m_pFont,
CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
@@ -259,6 +261,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
}
FX_Free(pCharPos);
}
+
void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents,
uint8_t* code,
int32_t codeLength,
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 943384d55c..f7900d4195 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -36,18 +36,16 @@ void CBC_OnedUPCAWriter::Init() {
CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {
delete m_subWriter;
}
+
FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity(
const CFX_WideStringC& contents) {
- int32_t i = 0;
- for (i = 0; i < contents.GetLength(); i++) {
- if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') {
- continue;
- } else {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) {
+ if (contents.GetAt(i) < '0' || contents.GetAt(i) > '9')
return FALSE;
- }
}
return TRUE;
}
+
CFX_WideString CBC_OnedUPCAWriter::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
@@ -106,6 +104,7 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents,
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return ret;
}
+
void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
CFX_DIBitmap* pOutBitmap,
CFX_RenderDevice* device,
@@ -113,10 +112,11 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
int32_t barWidth,
int32_t multiple,
int32_t& e) {
- if (device == NULL && pOutBitmap == NULL) {
+ if (!device && !pOutBitmap) {
e = BCExceptionIllegalArgument;
return;
}
+
int32_t leftPadding = 7 * multiple;
int32_t leftPosition = 10 * multiple + leftPadding;
CFX_ByteString str = FX_UTF8Encode(contents);
@@ -127,13 +127,13 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
FX_FLOAT strWidth = (FX_FLOAT)35 * multiple;
FX_FLOAT blank = 0.0;
CFX_FxgeDevice geBitmap;
- if (pOutBitmap) {
- geBitmap.Attach(pOutBitmap);
- }
+ if (pOutBitmap)
+ geBitmap.Attach(pOutBitmap, false, nullptr, false);
+
iLen = tempStr.GetLength();
int32_t iFontSize = (int32_t)fabs(m_fFontSize);
int32_t iTextHeight = iFontSize + 1;
- if (pOutBitmap == NULL) {
+ if (!pOutBitmap) {
CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
CFX_FloatRect rect(
(FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight),
@@ -178,7 +178,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
CFX_FxgeDevice ge;
if (pOutBitmap) {
- ge.Create((int)strWidth, iTextHeight, FXDIB_Argb);
+ ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos + 1, m_pFont,
CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
@@ -231,7 +231,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank);
if (pOutBitmap) {
delete ge.GetBitmap();
- ge.Create((int)strWidth, iTextHeight, FXDIB_Argb);
+ ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos, m_pFont,
CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
@@ -254,7 +254,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank);
if (pOutBitmap) {
delete ge.GetBitmap();
- ge.Create((int)strWidth, iTextHeight, FXDIB_Argb);
+ ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos + 11, m_pFont,
CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
@@ -277,6 +277,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
}
FX_Free(pCharPos);
}
+
void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents,
uint8_t* code,
int32_t codeLength,