summaryrefslogtreecommitdiff
path: root/fxbarcode/datamatrix
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-04-27 23:58:03 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-28 19:12:30 +0000
commit60cd033adf6c469ff47bdaf85a66b5817fdd188b (patch)
treea91b3cee7aaeb0dc650fd857bfd3476da848eacf /fxbarcode/datamatrix
parent7831f57f04ad3f581222b0a23eeb736601f98e96 (diff)
downloadpdfium-60cd033adf6c469ff47bdaf85a66b5817fdd188b.tar.xz
Remove dead dimensions code in fxbarcode.chromium/3084
Remove more exceptions. Change-Id: I3b8b8b9837b0010b1e0060ddd56e93c78f9f0fb5 Reviewed-on: https://pdfium-review.googlesource.com/4410 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxbarcode/datamatrix')
-rw-r--r--fxbarcode/datamatrix/BC_ASCIIEncoder.cpp3
-rw-r--r--fxbarcode/datamatrix/BC_Base256Encoder.cpp3
-rw-r--r--fxbarcode/datamatrix/BC_C40Encoder.cpp34
-rw-r--r--fxbarcode/datamatrix/BC_C40Encoder.h3
-rw-r--r--fxbarcode/datamatrix/BC_DataMatrixWriter.cpp11
-rw-r--r--fxbarcode/datamatrix/BC_EdifactEncoder.cpp197
-rw-r--r--fxbarcode/datamatrix/BC_EdifactEncoder.h9
-rw-r--r--fxbarcode/datamatrix/BC_Encoder.h2
-rw-r--r--fxbarcode/datamatrix/BC_EncoderContext.cpp26
-rw-r--r--fxbarcode/datamatrix/BC_EncoderContext.h12
-rw-r--r--fxbarcode/datamatrix/BC_ErrorCorrection.cpp4
-rw-r--r--fxbarcode/datamatrix/BC_ErrorCorrection.h2
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.cpp9
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.h3
-rw-r--r--fxbarcode/datamatrix/BC_SymbolInfo.cpp31
-rw-r--r--fxbarcode/datamatrix/BC_SymbolInfo.h8
-rw-r--r--fxbarcode/datamatrix/BC_TextEncoder.cpp4
-rw-r--r--fxbarcode/datamatrix/BC_X12Encoder.cpp2
18 files changed, 158 insertions, 205 deletions
diff --git a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
index 2d7b9d7995..7b277feb63 100644
--- a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
@@ -20,13 +20,14 @@
* limitations under the License.
*/
-#include "fxbarcode/BC_Dimension.h"
#include "fxbarcode/datamatrix/BC_ASCIIEncoder.h"
+
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_EncoderContext.h"
#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
CBC_ASCIIEncoder::CBC_ASCIIEncoder() {}
CBC_ASCIIEncoder::~CBC_ASCIIEncoder() {}
diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
index dd49c8e0f5..a360f6372e 100644
--- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
@@ -20,13 +20,14 @@
* limitations under the License.
*/
-#include "fxbarcode/BC_Dimension.h"
#include "fxbarcode/datamatrix/BC_Base256Encoder.h"
+
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_EncoderContext.h"
#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
CBC_Base256Encoder::CBC_Base256Encoder() {}
CBC_Base256Encoder::~CBC_Base256Encoder() {}
diff --git a/fxbarcode/datamatrix/BC_C40Encoder.cpp b/fxbarcode/datamatrix/BC_C40Encoder.cpp
index 7c3f4e7d7a..e8aa679e28 100644
--- a/fxbarcode/datamatrix/BC_C40Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_C40Encoder.cpp
@@ -20,14 +20,30 @@
* limitations under the License.
*/
-#include "fxbarcode/BC_Dimension.h"
-#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_C40Encoder.h"
+
+#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_EncoderContext.h"
#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
+
+namespace {
+
+CFX_WideString EncodeToCodewords(const CFX_WideString& sb, int32_t startPos) {
+ wchar_t c1 = sb.GetAt(startPos);
+ wchar_t c2 = sb.GetAt(startPos + 1);
+ wchar_t c3 = sb.GetAt(startPos + 2);
+ int32_t v = (1600 * c1) + (40 * c2) + c3 + 1;
+ wchar_t cw[2];
+ cw[0] = static_cast<wchar_t>(v / 256);
+ cw[1] = static_cast<wchar_t>(v % 256);
+ return CFX_WideString(cw);
+}
+
+} // namespace
CBC_C40Encoder::CBC_C40Encoder() {}
CBC_C40Encoder::~CBC_C40Encoder() {}
@@ -85,7 +101,7 @@ void CBC_C40Encoder::Encode(CBC_EncoderContext& context, int32_t& e) {
}
void CBC_C40Encoder::writeNextTriplet(CBC_EncoderContext& context,
CFX_WideString& buffer) {
- context.writeCodewords(encodeToCodewords(buffer, 0));
+ context.writeCodewords(EncodeToCodewords(buffer, 0));
buffer.Delete(0, 3);
}
void CBC_C40Encoder::handleEOD(CBC_EncoderContext& context,
@@ -186,15 +202,3 @@ int32_t CBC_C40Encoder::backtrackOneCharacter(CBC_EncoderContext& context,
context.resetSymbolInfo();
return lastCharSize;
}
-CFX_WideString CBC_C40Encoder::encodeToCodewords(CFX_WideString sb,
- int32_t startPos) {
- wchar_t c1 = sb.GetAt(startPos);
- wchar_t c2 = sb.GetAt(startPos + 1);
- wchar_t c3 = sb.GetAt(startPos + 2);
- int32_t v = (1600 * c1) + (40 * c2) + c3 + 1;
- wchar_t cw1 = (wchar_t)(v / 256);
- wchar_t cw2 = (wchar_t)(v % 256);
- CFX_WideString b1(cw1);
- CFX_WideString b2(cw2);
- return b1 + b2;
-}
diff --git a/fxbarcode/datamatrix/BC_C40Encoder.h b/fxbarcode/datamatrix/BC_C40Encoder.h
index 217404913e..ad8669d412 100644
--- a/fxbarcode/datamatrix/BC_C40Encoder.h
+++ b/fxbarcode/datamatrix/BC_C40Encoder.h
@@ -9,6 +9,8 @@
#include "fxbarcode/datamatrix/BC_Encoder.h"
+class CFX_WideString;
+
class CBC_C40Encoder : public CBC_Encoder {
public:
CBC_C40Encoder();
@@ -32,7 +34,6 @@ class CBC_C40Encoder : public CBC_Encoder {
CFX_WideString& removed,
int32_t lastCharSize,
int32_t& e);
- static CFX_WideString encodeToCodewords(CFX_WideString sb, int32_t startPos);
};
#endif // FXBARCODE_DATAMATRIX_BC_C40ENCODER_H_
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
index 54b7312abc..f45c338a7c 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
+++ b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
@@ -24,7 +24,6 @@
#include <memory>
-#include "fxbarcode/BC_Dimension.h"
#include "fxbarcode/BC_TwoDimWriter.h"
#include "fxbarcode/BC_UtilCodingConvert.h"
#include "fxbarcode/BC_Writer.h"
@@ -121,16 +120,14 @@ uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents,
CBC_SymbolShapeHint::SymbolShapeHint shape =
CBC_SymbolShapeHint::FORCE_SQUARE;
- CBC_Dimension* minSize = nullptr;
- CBC_Dimension* maxSize = nullptr;
CFX_WideString ecLevel;
int32_t e = BCExceptionNO;
- CFX_WideString encoded = CBC_HighLevelEncoder::encodeHighLevel(
- contents, ecLevel, shape, minSize, maxSize, e);
+ CFX_WideString encoded =
+ CBC_HighLevelEncoder::encodeHighLevel(contents, ecLevel, shape, e);
if (e != BCExceptionNO)
return nullptr;
- CBC_SymbolInfo* symbolInfo = CBC_SymbolInfo::lookup(
- encoded.GetLength(), shape, minSize, maxSize, true, e);
+ CBC_SymbolInfo* symbolInfo =
+ CBC_SymbolInfo::lookup(encoded.GetLength(), shape, true, e);
if (e != BCExceptionNO)
return nullptr;
CFX_WideString codewords =
diff --git a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
index 954dcbcba6..9231b1e293 100644
--- a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
@@ -22,134 +22,137 @@
#include "fxbarcode/datamatrix/BC_EdifactEncoder.h"
-#include "fxbarcode/BC_Dimension.h"
+#include <algorithm>
+
#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_EncoderContext.h"
#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
-CBC_EdifactEncoder::CBC_EdifactEncoder() {}
-CBC_EdifactEncoder::~CBC_EdifactEncoder() {}
-int32_t CBC_EdifactEncoder::getEncodingMode() {
- return EDIFACT_ENCODATION;
-}
-void CBC_EdifactEncoder::Encode(CBC_EncoderContext& context, int32_t& e) {
- CFX_WideString buffer;
- while (context.hasMoreCharacters()) {
- wchar_t c = context.getCurrentChar();
- encodeChar(c, buffer, e);
- if (e != BCExceptionNO) {
- return;
- }
- context.m_pos++;
- int32_t count = buffer.GetLength();
- if (count >= 4) {
- context.writeCodewords(encodeToCodewords(buffer, 0, e));
- if (e != BCExceptionNO) {
- return;
- }
- buffer.Delete(0, 4);
- int32_t newMode = CBC_HighLevelEncoder::lookAheadTest(
- context.m_msg, context.m_pos, getEncodingMode());
- if (newMode != getEncodingMode()) {
- context.signalEncoderChange(ASCII_ENCODATION);
- break;
- }
- }
- }
- buffer += (wchar_t)31;
- handleEOD(context, buffer, e);
+namespace {
+
+CFX_WideString EncodeToCodewords(const CFX_WideString& sb, int32_t startPos) {
+ int32_t len = sb.GetLength() - startPos;
+ if (len == 0)
+ return CFX_WideString();
+
+ wchar_t c1 = sb.GetAt(startPos);
+ wchar_t c2 = len >= 2 ? sb.GetAt(startPos + 1) : 0;
+ wchar_t c3 = len >= 3 ? sb.GetAt(startPos + 2) : 0;
+ wchar_t c4 = len >= 4 ? sb.GetAt(startPos + 3) : 0;
+ int32_t v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4;
+ constexpr int32_t kBuflen = 3;
+ wchar_t cw[kBuflen];
+ cw[0] = static_cast<wchar_t>((v >> 16) & 255);
+ cw[1] = static_cast<wchar_t>((v >> 8) & 255);
+ cw[2] = static_cast<wchar_t>(v & 255);
+ return CFX_WideString(cw, std::min(len, kBuflen));
}
-void CBC_EdifactEncoder::handleEOD(CBC_EncoderContext& context,
- CFX_WideString buffer,
- int32_t& e) {
+
+bool HandleEOD(CBC_EncoderContext* context, const CFX_WideString& buffer) {
int32_t count = buffer.GetLength();
- if (count == 0) {
- return;
- }
+ if (count == 0)
+ return true;
+ if (count > 4)
+ return false;
+
if (count == 1) {
- context.updateSymbolInfo(e);
- if (e != BCExceptionNO) {
- return;
- }
+ int32_t e = BCExceptionNO;
+ context->updateSymbolInfo(e);
+ if (e != BCExceptionNO)
+ return false;
+
int32_t available =
- context.m_symbolInfo->m_dataCapacity - context.getCodewordCount();
- int32_t remaining = context.getRemainingCharacters();
- if (remaining == 0 && available <= 2) {
- return;
- }
- }
- if (count > 4) {
- e = BCExceptionIllegalStateCountMustNotExceed4;
- return;
+ context->m_symbolInfo->m_dataCapacity - context->getCodewordCount();
+ int32_t remaining = context->getRemainingCharacters();
+ if (remaining == 0 && available <= 2)
+ return true;
}
+
int32_t restChars = count - 1;
- CFX_WideString encoded = encodeToCodewords(buffer, 0, e);
- if (e != BCExceptionNO) {
- return;
- }
- bool endOfSymbolReached = !context.hasMoreCharacters();
+ CFX_WideString encoded = EncodeToCodewords(buffer, 0);
+ if (encoded.IsEmpty())
+ return false;
+
+ bool endOfSymbolReached = !context->hasMoreCharacters();
bool restInAscii = endOfSymbolReached && restChars <= 2;
if (restChars <= 2) {
- context.updateSymbolInfo(context.getCodewordCount() + restChars, e);
- if (e != BCExceptionNO) {
- return;
- }
+ int32_t e = BCExceptionNO;
+ context->updateSymbolInfo(context->getCodewordCount() + restChars, e);
+ if (e != BCExceptionNO)
+ return false;
+
int32_t available =
- context.m_symbolInfo->m_dataCapacity - context.getCodewordCount();
+ context->m_symbolInfo->m_dataCapacity - context->getCodewordCount();
if (available >= 3) {
restInAscii = false;
- context.updateSymbolInfo(context.getCodewordCount() + encoded.GetLength(),
- e);
- if (e != BCExceptionNO) {
- return;
- }
+ context->updateSymbolInfo(
+ context->getCodewordCount() + encoded.GetLength(), e);
+ if (e != BCExceptionNO)
+ return false;
}
}
+
if (restInAscii) {
- context.resetSymbolInfo();
- context.m_pos -= restChars;
+ context->resetSymbolInfo();
+ context->m_pos -= restChars;
} else {
- context.writeCodewords(encoded);
+ context->writeCodewords(encoded);
}
- context.signalEncoderChange(ASCII_ENCODATION);
+ context->signalEncoderChange(ASCII_ENCODATION);
+ return true;
}
-void CBC_EdifactEncoder::encodeChar(wchar_t c, CFX_WideString& sb, int32_t& e) {
+void encodeChar(wchar_t c, CFX_WideString* sb, int32_t& e) {
if (c >= ' ' && c <= '?') {
- sb += c;
+ *sb += c;
} else if (c >= '@' && c <= '^') {
- sb += (wchar_t)(c - 64);
+ *sb += (wchar_t)(c - 64);
} else {
e = BCExceptionIllegalArgument;
}
}
-CFX_WideString CBC_EdifactEncoder::encodeToCodewords(CFX_WideString sb,
- int32_t startPos,
- int32_t& e) {
- int32_t len = sb.GetLength() - startPos;
- if (len == 0) {
- e = BCExceptionNoContents;
- return CFX_WideString();
- }
- wchar_t c1 = sb.GetAt(startPos);
- wchar_t c2 = len >= 2 ? sb.GetAt(startPos + 1) : 0;
- wchar_t c3 = len >= 3 ? sb.GetAt(startPos + 2) : 0;
- wchar_t c4 = len >= 4 ? sb.GetAt(startPos + 3) : 0;
- int32_t v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4;
- wchar_t cw1 = (wchar_t)((v >> 16) & 255);
- wchar_t cw2 = (wchar_t)((v >> 8) & 255);
- wchar_t cw3 = (wchar_t)(v & 255);
- CFX_WideString res;
- res += cw1;
- if (len >= 2) {
- res += cw2;
- }
- if (len >= 3) {
- res += cw3;
+} // namespace
+
+CBC_EdifactEncoder::CBC_EdifactEncoder() {}
+
+CBC_EdifactEncoder::~CBC_EdifactEncoder() {}
+
+int32_t CBC_EdifactEncoder::getEncodingMode() {
+ return EDIFACT_ENCODATION;
+}
+
+void CBC_EdifactEncoder::Encode(CBC_EncoderContext& context, int32_t& e) {
+ CFX_WideString buffer;
+ while (context.hasMoreCharacters()) {
+ wchar_t c = context.getCurrentChar();
+ encodeChar(c, &buffer, e);
+ if (e != BCExceptionNO) {
+ return;
+ }
+ context.m_pos++;
+ int32_t count = buffer.GetLength();
+ if (count >= 4) {
+ CFX_WideString encoded = EncodeToCodewords(buffer, 0);
+ if (encoded.IsEmpty()) {
+ e = BCExceptionGeneric;
+ return;
+ }
+ context.writeCodewords(encoded);
+ buffer.Delete(0, 4);
+ int32_t newMode = CBC_HighLevelEncoder::lookAheadTest(
+ context.m_msg, context.m_pos, getEncodingMode());
+ if (newMode != getEncodingMode()) {
+ context.signalEncoderChange(ASCII_ENCODATION);
+ break;
+ }
+ }
}
- return res;
+ buffer += static_cast<wchar_t>(31);
+ if (!HandleEOD(&context, buffer))
+ e = BCExceptionGeneric;
}
diff --git a/fxbarcode/datamatrix/BC_EdifactEncoder.h b/fxbarcode/datamatrix/BC_EdifactEncoder.h
index 6fe0934de1..eb59222d4f 100644
--- a/fxbarcode/datamatrix/BC_EdifactEncoder.h
+++ b/fxbarcode/datamatrix/BC_EdifactEncoder.h
@@ -17,15 +17,6 @@ class CBC_EdifactEncoder : public CBC_Encoder {
// CBC_Encoder
int32_t getEncodingMode() override;
void Encode(CBC_EncoderContext& context, int32_t& e) override;
-
- private:
- static void handleEOD(CBC_EncoderContext& context,
- CFX_WideString buffer,
- int32_t& e);
- static void encodeChar(wchar_t c, CFX_WideString& sb, int32_t& e);
- static CFX_WideString encodeToCodewords(CFX_WideString sb,
- int32_t startPos,
- int32_t& e);
};
#endif // FXBARCODE_DATAMATRIX_BC_EDIFACTENCODER_H_
diff --git a/fxbarcode/datamatrix/BC_Encoder.h b/fxbarcode/datamatrix/BC_Encoder.h
index 40d491c2cd..be1730f0c2 100644
--- a/fxbarcode/datamatrix/BC_Encoder.h
+++ b/fxbarcode/datamatrix/BC_Encoder.h
@@ -7,7 +7,7 @@
#ifndef FXBARCODE_DATAMATRIX_BC_ENCODER_H_
#define FXBARCODE_DATAMATRIX_BC_ENCODER_H_
-#include "fxbarcode/utils.h"
+#include <stdint.h>
class CBC_EncoderContext;
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp
index 8fe5bf5b26..0411d03b5d 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.cpp
+++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp
@@ -20,16 +20,17 @@
* limitations under the License.
*/
-#include "fxbarcode/BC_Dimension.h"
+#include "fxbarcode/datamatrix/BC_EncoderContext.h"
+
#include "fxbarcode/BC_UtilCodingConvert.h"
#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
-#include "fxbarcode/datamatrix/BC_EncoderContext.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
-CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg,
- CFX_WideString ecLevel,
+CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString& msg,
+ const CFX_WideString& ecLevel,
int32_t& e) {
CFX_ByteString dststr;
CBC_UtilCodingConvert::UnicodeToUTF8(msg, dststr);
@@ -48,21 +49,11 @@ CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg,
m_pos = 0;
m_symbolInfo = nullptr;
m_skipAtEnd = 0;
- m_maxSize = nullptr;
- m_minSize = nullptr;
}
CBC_EncoderContext::~CBC_EncoderContext() {}
void CBC_EncoderContext::setSymbolShape(SymbolShapeHint shape) {
m_shape = shape;
}
-void CBC_EncoderContext::setSizeConstraints(CBC_Dimension* minSize,
- CBC_Dimension* maxSize) {
- m_maxSize = maxSize;
- m_minSize = minSize;
-}
-CFX_WideString CBC_EncoderContext::getMessage() {
- return m_msg;
-}
void CBC_EncoderContext::setSkipAtEnd(int32_t count) {
m_skipAtEnd = count;
}
@@ -72,9 +63,11 @@ wchar_t CBC_EncoderContext::getCurrentChar() {
wchar_t CBC_EncoderContext::getCurrent() {
return m_msg.GetAt(m_pos);
}
-void CBC_EncoderContext::writeCodewords(CFX_WideString codewords) {
+
+void CBC_EncoderContext::writeCodewords(const CFX_WideString& codewords) {
m_codewords += codewords;
}
+
void CBC_EncoderContext::writeCodeword(wchar_t codeword) {
m_codewords += codeword;
}
@@ -98,8 +91,7 @@ void CBC_EncoderContext::updateSymbolInfo(int32_t& e) {
}
void CBC_EncoderContext::updateSymbolInfo(int32_t len, int32_t& e) {
if (!m_symbolInfo || len > m_symbolInfo->m_dataCapacity) {
- m_symbolInfo =
- CBC_SymbolInfo::lookup(len, m_shape, m_minSize, m_maxSize, true, e);
+ m_symbolInfo = CBC_SymbolInfo::lookup(len, m_shape, true, e);
if (e != BCExceptionNO)
return;
}
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.h b/fxbarcode/datamatrix/BC_EncoderContext.h
index 6be824116f..e2259334e8 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.h
+++ b/fxbarcode/datamatrix/BC_EncoderContext.h
@@ -7,25 +7,23 @@
#ifndef FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_
#define FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_
+#include "core/fxcrt/cfx_widestring.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
class CBC_SymbolInfo;
-class CBC_Dimension;
class CBC_EncoderContext : public CBC_SymbolShapeHint {
public:
- CBC_EncoderContext(const CFX_WideString msg,
- CFX_WideString ecLevel,
+ CBC_EncoderContext(const CFX_WideString& msg,
+ const CFX_WideString& ecLevel,
int32_t& e);
~CBC_EncoderContext() override;
void setSymbolShape(SymbolShapeHint shape);
- void setSizeConstraints(CBC_Dimension* minSize, CBC_Dimension* maxSize);
- CFX_WideString getMessage();
void setSkipAtEnd(int32_t count);
wchar_t getCurrentChar();
wchar_t getCurrent();
- void writeCodewords(CFX_WideString codewords);
+ void writeCodewords(const CFX_WideString& codewords);
void writeCodeword(wchar_t codeword);
int32_t getCodewordCount();
void signalEncoderChange(int32_t encoding);
@@ -48,8 +46,6 @@ class CBC_EncoderContext : public CBC_SymbolShapeHint {
private:
SymbolShapeHint m_shape;
- CBC_Dimension* m_minSize;
- CBC_Dimension* m_maxSize;
int32_t m_skipAtEnd;
};
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 43bdc24534..cd2355b8fe 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -20,12 +20,14 @@
* limitations under the License.
*/
+#include "fxbarcode/datamatrix/BC_ErrorCorrection.h"
+
#include <vector>
#include "fxbarcode/datamatrix/BC_Encoder.h"
-#include "fxbarcode/datamatrix/BC_ErrorCorrection.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
namespace {
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.h b/fxbarcode/datamatrix/BC_ErrorCorrection.h
index f09763da2b..97a2e48e2d 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.h
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.h
@@ -7,6 +7,8 @@
#ifndef FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_
#define FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_
+#include "core/fxcrt/cfx_widestring.h"
+
class CBC_SymbolInfo;
class CBC_ErrorCorrection {
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index f9fb080be3..cc85c838a3 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -20,11 +20,12 @@
* limitations under the License.
*/
+#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
+
#include <limits>
#include <memory>
#include <vector>
-#include "fxbarcode/BC_Dimension.h"
#include "fxbarcode/BC_UtilCodingConvert.h"
#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_ASCIIEncoder.h"
@@ -33,7 +34,6 @@
#include "fxbarcode/datamatrix/BC_EdifactEncoder.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_EncoderContext.h"
-#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
#include "fxbarcode/datamatrix/BC_TextEncoder.h"
@@ -69,19 +69,16 @@ std::vector<uint8_t>& CBC_HighLevelEncoder::getBytesForMessage(
CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
CFX_WideString ecLevel,
int32_t& e) {
- return encodeHighLevel(msg, ecLevel, FORCE_NONE, nullptr, nullptr, e);
+ return encodeHighLevel(msg, ecLevel, FORCE_NONE, e);
}
CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
CFX_WideString ecLevel,
SymbolShapeHint shape,
- CBC_Dimension* minSize,
- CBC_Dimension* maxSize,
int32_t& e) {
CBC_EncoderContext context(msg, ecLevel, e);
if (e != BCExceptionNO)
return CFX_WideString();
context.setSymbolShape(shape);
- context.setSizeConstraints(minSize, maxSize);
if ((msg.Mid(0, 6) == MACRO_05_HEADER) &&
(msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) {
context.writeCodeword(MACRO_05);
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.h b/fxbarcode/datamatrix/BC_HighLevelEncoder.h
index 12b8cab35a..6f0db292c9 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.h
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fxcrt/cfx_widestring.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
#define ASCII_ENCODATION 0
@@ -30,8 +31,6 @@ class CBC_HighLevelEncoder : public CBC_SymbolShapeHint {
static CFX_WideString encodeHighLevel(CFX_WideString msg,
CFX_WideString ecLevel,
SymbolShapeHint shape,
- CBC_Dimension* minSize,
- CBC_Dimension* maxSize,
int32_t& e);
static int32_t lookAheadTest(CFX_WideString msg,
int32_t startpos,
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
index f98370b90f..5d12f1c090 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.cpp
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -22,11 +22,11 @@
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
-#include "fxbarcode/BC_Dimension.h"
#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
namespace {
@@ -133,37 +133,14 @@ CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
SymbolShapeHint shape,
bool fail,
int32_t& e) {
- return lookup(dataCodewords, shape, nullptr, nullptr, fail, e);
-}
-CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
- SymbolShapeHint shape,
- CBC_Dimension* minSize,
- CBC_Dimension* maxSize,
- bool fail,
- int32_t& e) {
for (size_t i = 0; i < kSymbolsCount; i++) {
CBC_SymbolInfo* symbol = g_symbols[i];
- if (shape == FORCE_SQUARE && symbol->m_rectangular) {
- continue;
- }
- if (shape == FORCE_RECTANGLE && !symbol->m_rectangular) {
- continue;
- }
- if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() ||
- symbol->getSymbolHeight(e) < minSize->getHeight())) {
- if (e != BCExceptionNO)
- return nullptr;
+ if ((shape == FORCE_SQUARE && symbol->m_rectangular) ||
+ (shape == FORCE_RECTANGLE && !symbol->m_rectangular)) {
continue;
}
- if (maxSize && (symbol->getSymbolWidth(e) > maxSize->getWidth() ||
- symbol->getSymbolHeight(e) > maxSize->getHeight())) {
- if (e != BCExceptionNO)
- return nullptr;
- continue;
- }
- if (dataCodewords <= symbol->m_dataCapacity) {
+ if (dataCodewords <= symbol->m_dataCapacity)
return symbol;
- }
}
if (fail)
e = BCExceptionIllegalDataCodewords;
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.h b/fxbarcode/datamatrix/BC_SymbolInfo.h
index 36ed01d7e4..0a5cd20247 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.h
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.h
@@ -11,8 +11,6 @@
#include "core/fxcrt/fx_system.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
-class CBC_Dimension;
-
class CBC_SymbolInfo : public CBC_SymbolShapeHint {
public:
CBC_SymbolInfo(bool rectangular,
@@ -38,12 +36,6 @@ class CBC_SymbolInfo : public CBC_SymbolShapeHint {
SymbolShapeHint shape,
bool fail,
int32_t& e);
- static CBC_SymbolInfo* lookup(int32_t dataCodewords,
- SymbolShapeHint shape,
- CBC_Dimension* minSize,
- CBC_Dimension* maxSize,
- bool fail,
- int32_t& e);
int32_t getHorizontalDataRegions(int32_t& e);
int32_t getVerticalDataRegions(int32_t& e);
int32_t getSymbolDataWidth(int32_t& e);
diff --git a/fxbarcode/datamatrix/BC_TextEncoder.cpp b/fxbarcode/datamatrix/BC_TextEncoder.cpp
index 53f92c3d28..ec7ff4751f 100644
--- a/fxbarcode/datamatrix/BC_TextEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_TextEncoder.cpp
@@ -1,5 +1,3 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
@@ -22,7 +20,6 @@
#include "fxbarcode/datamatrix/BC_TextEncoder.h"
-#include "fxbarcode/BC_Dimension.h"
#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_C40Encoder.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
@@ -30,6 +27,7 @@
#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
CBC_TextEncoder::CBC_TextEncoder() {}
CBC_TextEncoder::~CBC_TextEncoder() {}
diff --git a/fxbarcode/datamatrix/BC_X12Encoder.cpp b/fxbarcode/datamatrix/BC_X12Encoder.cpp
index 9103908b1a..04bf958bf4 100644
--- a/fxbarcode/datamatrix/BC_X12Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_X12Encoder.cpp
@@ -22,7 +22,6 @@
#include "fxbarcode/datamatrix/BC_X12Encoder.h"
-#include "fxbarcode/BC_Dimension.h"
#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_C40Encoder.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
@@ -30,6 +29,7 @@
#include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
+#include "fxbarcode/utils.h"
CBC_X12Encoder::CBC_X12Encoder() {}
CBC_X12Encoder::~CBC_X12Encoder() {}