summaryrefslogtreecommitdiff
path: root/fxbarcode/oned/BC_OnedEAN13Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxbarcode/oned/BC_OnedEAN13Writer.cpp')
-rw-r--r--fxbarcode/oned/BC_OnedEAN13Writer.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index e7642de56d..2d9759b9eb 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -31,6 +31,7 @@
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "fxbarcode/BC_Writer.h"
#include "fxbarcode/oned/BC_OneDimWriter.h"
+#include "fxbarcode/oned/BC_OnedEANChecksum.h"
namespace {
@@ -76,19 +77,9 @@ CFX_WideString CBC_OnedEAN13Writer::FilterContents(
}
return filtercontents;
}
+
int32_t CBC_OnedEAN13Writer::CalcChecksum(const CFX_ByteString& contents) {
- int32_t odd = 0;
- int32_t even = 0;
- FX_STRSIZE parity = 1;
- for (FX_STRSIZE i = contents.GetLength(); i > 0; i--) {
- if (parity % 2) {
- odd += FXSYS_DecimalCharToInt(contents[i - 1]);
- } else {
- even += FXSYS_DecimalCharToInt(contents[i - 1]);
- }
- parity++;
- }
- return (10 - (odd * 3 + even) % 10) % 10;
+ return EANCalcChecksum(contents);
}
uint8_t* CBC_OnedEAN13Writer::EncodeWithHint(const CFX_ByteString& contents,