summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-05-25 18:43:44 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-26 01:56:52 +0000
commit1bbcb35e4e5593998837c832eabf16a91a695387 (patch)
tree0e60ccf75924489907237e55fcd59c90d3be50e1
parent1c26a6e477c5eaebf8aaca0c65a3a06c22e9c527 (diff)
downloadpdfium-1bbcb35e4e5593998837c832eabf16a91a695387.tar.xz
Replace SymbolShapeHint with a boolean.
Delete BC_SymbolShapeHint.h since there is nothing left in it. Change-Id: Ic991064cd396f224966e5f3e8537fc62b5a9908a Reviewed-on: https://pdfium-review.googlesource.com/5835 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--BUILD.gn1
-rw-r--r--fxbarcode/datamatrix/BC_ASCIIEncoder.cpp1
-rw-r--r--fxbarcode/datamatrix/BC_Base256Encoder.cpp1
-rw-r--r--fxbarcode/datamatrix/BC_C40Encoder.cpp1
-rw-r--r--fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp1
-rw-r--r--fxbarcode/datamatrix/BC_DataMatrixWriter.cpp6
-rw-r--r--fxbarcode/datamatrix/BC_EdifactEncoder.cpp1
-rw-r--r--fxbarcode/datamatrix/BC_EncoderContext.cpp16
-rw-r--r--fxbarcode/datamatrix/BC_EncoderContext.h5
-rw-r--r--fxbarcode/datamatrix/BC_ErrorCorrection.cpp1
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.cpp13
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.h7
-rw-r--r--fxbarcode/datamatrix/BC_SymbolInfo.cpp8
-rw-r--r--fxbarcode/datamatrix/BC_SymbolInfo.h3
-rw-r--r--fxbarcode/datamatrix/BC_SymbolShapeHint.h16
-rw-r--r--fxbarcode/datamatrix/BC_TextEncoder.cpp1
-rw-r--r--fxbarcode/datamatrix/BC_X12Encoder.cpp1
17 files changed, 25 insertions, 58 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 4c3629784f..98189a09f5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1318,7 +1318,6 @@ if (pdf_enable_xfa) {
"fxbarcode/datamatrix/BC_HighLevelEncoder.h",
"fxbarcode/datamatrix/BC_SymbolInfo.cpp",
"fxbarcode/datamatrix/BC_SymbolInfo.h",
- "fxbarcode/datamatrix/BC_SymbolShapeHint.h",
"fxbarcode/datamatrix/BC_TextEncoder.cpp",
"fxbarcode/datamatrix/BC_TextEncoder.h",
"fxbarcode/datamatrix/BC_X12Encoder.cpp",
diff --git a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
index 7b277feb63..de57d81b71 100644
--- a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
@@ -26,7 +26,6 @@
#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() {}
diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
index c34ff02939..edcd411114 100644
--- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
@@ -26,7 +26,6 @@
#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() {}
diff --git a/fxbarcode/datamatrix/BC_C40Encoder.cpp b/fxbarcode/datamatrix/BC_C40Encoder.cpp
index 11d477c07d..e994774c4d 100644
--- a/fxbarcode/datamatrix/BC_C40Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_C40Encoder.cpp
@@ -27,7 +27,6 @@
#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 {
diff --git a/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp b/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp
index 122932179b..7a18d03839 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp
+++ b/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp
@@ -23,7 +23,6 @@
#include "fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h"
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
-#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
CBC_DataMatrixSymbolInfo144::CBC_DataMatrixSymbolInfo144()
: CBC_SymbolInfo(1558, 620, 22, 22, 36, -1, 62) {}
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
index 19b6346f0a..98af282f8f 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
+++ b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
@@ -40,7 +40,6 @@
#include "fxbarcode/datamatrix/BC_ErrorCorrection.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"
#include "fxbarcode/datamatrix/BC_X12Encoder.h"
#include "third_party/base/ptr_util.h"
@@ -115,15 +114,14 @@ uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents,
if (outWidth < 0 || outHeight < 0)
return nullptr;
- SymbolShapeHint shape = FORCE_SQUARE;
CFX_WideString ecLevel;
int32_t e = BCExceptionNO;
CFX_WideString encoded =
- CBC_HighLevelEncoder::encodeHighLevel(contents, ecLevel, shape, e);
+ CBC_HighLevelEncoder::encodeHighLevel(contents, ecLevel, false, e);
if (e != BCExceptionNO)
return nullptr;
CBC_SymbolInfo* symbolInfo =
- CBC_SymbolInfo::lookup(encoded.GetLength(), shape, e);
+ CBC_SymbolInfo::lookup(encoded.GetLength(), false, e);
if (e != BCExceptionNO)
return nullptr;
CFX_WideString codewords =
diff --git a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
index cc72a311c9..c7d6b317c1 100644
--- a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
@@ -29,7 +29,6 @@
#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 {
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp
index 1c39be1aec..40855fcbd8 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.cpp
+++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp
@@ -26,7 +26,6 @@
#include "fxbarcode/common/BC_CommonBitMatrix.h"
#include "fxbarcode/datamatrix/BC_Encoder.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,
@@ -44,16 +43,19 @@ CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString& msg,
sb += ch;
}
m_msg = sb;
- m_shape = FORCE_NONE;
+ m_allowRectangular = true;
m_newEncoding = -1;
m_pos = 0;
m_symbolInfo = nullptr;
m_skipAtEnd = 0;
}
+
CBC_EncoderContext::~CBC_EncoderContext() {}
-void CBC_EncoderContext::setSymbolShape(SymbolShapeHint shape) {
- m_shape = shape;
+
+void CBC_EncoderContext::setAllowRectangular(bool allow) {
+ m_allowRectangular = allow;
}
+
void CBC_EncoderContext::setSkipAtEnd(int32_t count) {
m_skipAtEnd = count;
}
@@ -91,14 +93,16 @@ void CBC_EncoderContext::updateSymbolInfo(int32_t& e) {
}
void CBC_EncoderContext::updateSymbolInfo(int32_t len, int32_t& e) {
if (!m_symbolInfo || len > m_symbolInfo->dataCapacity()) {
- m_symbolInfo = CBC_SymbolInfo::lookup(len, m_shape, e);
+ m_symbolInfo = CBC_SymbolInfo::lookup(len, m_allowRectangular, e);
if (e != BCExceptionNO)
return;
}
}
+
void CBC_EncoderContext::resetSymbolInfo() {
- m_shape = FORCE_NONE;
+ m_allowRectangular = true;
}
+
int32_t CBC_EncoderContext::getTotalMessageCharCount() {
return m_msg.GetLength() - m_skipAtEnd;
}
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.h b/fxbarcode/datamatrix/BC_EncoderContext.h
index 21ea695c3d..4931501c45 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.h
+++ b/fxbarcode/datamatrix/BC_EncoderContext.h
@@ -9,7 +9,6 @@
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/cfx_widestring.h"
-#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
class CBC_SymbolInfo;
@@ -20,7 +19,7 @@ class CBC_EncoderContext {
int32_t& e);
~CBC_EncoderContext();
- void setSymbolShape(SymbolShapeHint shape);
+ void setAllowRectangular(bool allow);
void setSkipAtEnd(int32_t count);
wchar_t getCurrentChar();
wchar_t getCurrent();
@@ -44,7 +43,7 @@ class CBC_EncoderContext {
private:
int32_t getTotalMessageCharCount();
- SymbolShapeHint m_shape;
+ bool m_allowRectangular; // Force square when false.
int32_t m_skipAtEnd;
};
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index cc6d1b320b..4071602303 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -26,7 +26,6 @@
#include "fxbarcode/datamatrix/BC_Encoder.h"
#include "fxbarcode/datamatrix/BC_SymbolInfo.h"
-#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
#include "fxbarcode/utils.h"
namespace {
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index dd92f5e2d5..ec527d29a8 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -35,7 +35,6 @@
#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/datamatrix/BC_TextEncoder.h"
#include "fxbarcode/datamatrix/BC_X12Encoder.h"
#include "fxbarcode/utils.h"
@@ -66,19 +65,17 @@ std::vector<uint8_t>& CBC_HighLevelEncoder::getBytesForMessage(
m_bytearray.insert(m_bytearray.end(), bytestr.begin(), bytestr.end());
return m_bytearray;
}
+
+// static
CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
CFX_WideString ecLevel,
- int32_t& e) {
- return encodeHighLevel(msg, ecLevel, FORCE_NONE, e);
-}
-CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
- CFX_WideString ecLevel,
- SymbolShapeHint shape,
+ bool allowRectangular,
int32_t& e) {
CBC_EncoderContext context(msg, ecLevel, e);
if (e != BCExceptionNO)
return CFX_WideString();
- context.setSymbolShape(shape);
+
+ context.setAllowRectangular(allowRectangular);
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 cfcca18e2b..0b7ff9bf0e 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.h
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.h
@@ -10,7 +10,6 @@
#include <vector>
#include "core/fxcrt/cfx_widestring.h"
-#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
#define ASCII_ENCODATION 0
#define C40_ENCODATION 1
@@ -25,12 +24,10 @@ class CBC_HighLevelEncoder {
~CBC_HighLevelEncoder();
std::vector<uint8_t>& getBytesForMessage(CFX_WideString msg);
+
static CFX_WideString encodeHighLevel(CFX_WideString msg,
CFX_WideString ecLevel,
- int32_t& e);
- static CFX_WideString encodeHighLevel(CFX_WideString msg,
- CFX_WideString ecLevel,
- SymbolShapeHint shape,
+ bool allowRectangular,
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 ac4815a71f..f4d99d2e1c 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.cpp
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -25,7 +25,6 @@
#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 {
@@ -112,14 +111,13 @@ CBC_SymbolInfo::CBC_SymbolInfo(int32_t dataCapacity,
CBC_SymbolInfo::~CBC_SymbolInfo() {}
CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
- SymbolShapeHint shape,
+ bool allowRectangular,
int32_t& e) {
for (size_t i = 0; i < kSymbolsCount; i++) {
CBC_SymbolInfo* symbol = g_symbols[i];
- if ((shape == FORCE_SQUARE && symbol->m_rectangular) ||
- (shape == FORCE_RECTANGLE && !symbol->m_rectangular)) {
+ if (symbol->m_rectangular && !allowRectangular)
continue;
- }
+
if (dataCodewords <= symbol->dataCapacity())
return symbol;
}
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.h b/fxbarcode/datamatrix/BC_SymbolInfo.h
index 55046f8fbe..fe3e24c817 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.h
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.h
@@ -9,7 +9,6 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
-#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
class CBC_SymbolInfo {
public:
@@ -24,7 +23,7 @@ class CBC_SymbolInfo {
static void Finalize();
static void overrideSymbolSet(CBC_SymbolInfo* override);
static CBC_SymbolInfo* lookup(int32_t dataCodewords,
- SymbolShapeHint shape,
+ bool allowRectangular,
int32_t& e);
int32_t getSymbolDataWidth() const;
diff --git a/fxbarcode/datamatrix/BC_SymbolShapeHint.h b/fxbarcode/datamatrix/BC_SymbolShapeHint.h
deleted file mode 100644
index 3e93988d27..0000000000
--- a/fxbarcode/datamatrix/BC_SymbolShapeHint.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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
-
-#ifndef FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_
-#define FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_
-
-enum SymbolShapeHint {
- FORCE_NONE,
- FORCE_SQUARE,
- FORCE_RECTANGLE,
-};
-
-#endif // FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_
diff --git a/fxbarcode/datamatrix/BC_TextEncoder.cpp b/fxbarcode/datamatrix/BC_TextEncoder.cpp
index ec7ff4751f..451c7b84d1 100644
--- a/fxbarcode/datamatrix/BC_TextEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_TextEncoder.cpp
@@ -26,7 +26,6 @@
#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_TextEncoder::CBC_TextEncoder() {}
diff --git a/fxbarcode/datamatrix/BC_X12Encoder.cpp b/fxbarcode/datamatrix/BC_X12Encoder.cpp
index 0d874b0de0..625ff90290 100644
--- a/fxbarcode/datamatrix/BC_X12Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_X12Encoder.cpp
@@ -28,7 +28,6 @@
#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_X12Encoder::CBC_X12Encoder() {}