From 1bbcb35e4e5593998837c832eabf16a91a695387 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 25 May 2017 18:43:44 -0700 Subject: 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 Reviewed-by: Tom Sepez --- fxbarcode/datamatrix/BC_ASCIIEncoder.cpp | 1 - fxbarcode/datamatrix/BC_Base256Encoder.cpp | 1 - fxbarcode/datamatrix/BC_C40Encoder.cpp | 1 - fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp | 1 - fxbarcode/datamatrix/BC_DataMatrixWriter.cpp | 6 ++---- fxbarcode/datamatrix/BC_EdifactEncoder.cpp | 1 - fxbarcode/datamatrix/BC_EncoderContext.cpp | 16 ++++++++++------ fxbarcode/datamatrix/BC_EncoderContext.h | 5 ++--- fxbarcode/datamatrix/BC_ErrorCorrection.cpp | 1 - fxbarcode/datamatrix/BC_HighLevelEncoder.cpp | 13 +++++-------- fxbarcode/datamatrix/BC_HighLevelEncoder.h | 7 ++----- fxbarcode/datamatrix/BC_SymbolInfo.cpp | 8 +++----- fxbarcode/datamatrix/BC_SymbolInfo.h | 3 +-- fxbarcode/datamatrix/BC_SymbolShapeHint.h | 16 ---------------- fxbarcode/datamatrix/BC_TextEncoder.cpp | 1 - fxbarcode/datamatrix/BC_X12Encoder.cpp | 1 - 16 files changed, 25 insertions(+), 57 deletions(-) delete mode 100644 fxbarcode/datamatrix/BC_SymbolShapeHint.h (limited to 'fxbarcode') 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& 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 #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& 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() {} -- cgit v1.2.3