diff options
author | Lei Zhang <thestig@chromium.org> | 2017-05-22 18:47:12 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-23 21:17:23 +0000 |
commit | abc83aa862050642a90ed109074a9cf1018fee9b (patch) | |
tree | b842d471c3cc49a0268a0647ca4c574248610ae9 /fxbarcode/datamatrix/BC_DataMatrixWriter.cpp | |
parent | e0f1310795f1cf886b9b2a134b28ace9e8fc25ba (diff) | |
download | pdfium-abc83aa862050642a90ed109074a9cf1018fee9b.tar.xz |
Clean up CBC_SymbolInfo.chromium/3109
- Remove rectangular ctor param. It can be derived from dimensions.
- Make members private and add accessors.
- Remove exceptions that cannot occur.
Change-Id: Iec113205241562a0559e594fe257f5b9064ed97e
Reviewed-on: https://pdfium-review.googlesource.com/5737
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxbarcode/datamatrix/BC_DataMatrixWriter.cpp')
-rw-r--r-- | fxbarcode/datamatrix/BC_DataMatrixWriter.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp index f45c338a7c..075449377f 100644 --- a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp +++ b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp @@ -50,50 +50,45 @@ namespace { std::unique_ptr<CBC_CommonByteMatrix> encodeLowLevel( CBC_DefaultPlacement* placement, CBC_SymbolInfo* symbolInfo) { - int32_t e = BCExceptionNO; - int32_t symbolWidth = symbolInfo->getSymbolDataWidth(e); - if (e != BCExceptionNO) - return nullptr; - int32_t symbolHeight = symbolInfo->getSymbolDataHeight(e); - if (e != BCExceptionNO) - return nullptr; - int32_t width = symbolInfo->getSymbolWidth(e); - if (e != BCExceptionNO) - return nullptr; - int32_t height = symbolInfo->getSymbolHeight(e); - if (e != BCExceptionNO) - return nullptr; + int32_t symbolWidth = symbolInfo->getSymbolDataWidth(); + ASSERT(symbolWidth); + int32_t symbolHeight = symbolInfo->getSymbolDataHeight(); + ASSERT(symbolHeight); + int32_t width = symbolInfo->getSymbolWidth(); + ASSERT(width); + int32_t height = symbolInfo->getSymbolHeight(); + ASSERT(height); auto matrix = pdfium::MakeUnique<CBC_CommonByteMatrix>(width, height); matrix->Init(); int32_t matrixY = 0; for (int32_t y = 0; y < symbolHeight; y++) { int32_t matrixX; - if ((y % symbolInfo->m_matrixHeight) == 0) { + if ((y % symbolInfo->matrixHeight()) == 0) { matrixX = 0; - for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) { - matrix->Set(matrixX, matrixY, (x % 2) == 0); + for (int32_t x = 0; x < width; x++) { + matrix->Set(matrixX, matrixY, x % 2 == 0); matrixX++; } matrixY++; } matrixX = 0; for (int32_t x = 0; x < symbolWidth; x++) { - if ((x % symbolInfo->m_matrixWidth) == 0) { + if (x % symbolInfo->matrixWidth() == 0) { matrix->Set(matrixX, matrixY, true); matrixX++; } matrix->Set(matrixX, matrixY, placement->getBit(x, y)); matrixX++; - if ((x % symbolInfo->m_matrixWidth) == symbolInfo->m_matrixWidth - 1) { - matrix->Set(matrixX, matrixY, (y % 2) == 0); + if (x % symbolInfo->matrixWidth() == symbolInfo->matrixWidth() - 1) { + matrix->Set(matrixX, matrixY, y % 2 == 0); matrixX++; } } matrixY++; - if ((y % symbolInfo->m_matrixHeight) == symbolInfo->m_matrixHeight - 1) { + if (y % symbolInfo->matrixHeight() == symbolInfo->matrixHeight() - 1) { matrixX = 0; - for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) { + for (int32_t x = 0; x < width; x++) { matrix->Set(matrixX, matrixY, true); matrixX++; } @@ -106,7 +101,9 @@ std::unique_ptr<CBC_CommonByteMatrix> encodeLowLevel( } // namespace CBC_DataMatrixWriter::CBC_DataMatrixWriter() {} + CBC_DataMatrixWriter::~CBC_DataMatrixWriter() {} + bool CBC_DataMatrixWriter::SetErrorCorrectionLevel(int32_t level) { m_iCorrectLevel = level; return true; @@ -135,13 +132,10 @@ uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents, if (e != BCExceptionNO) return nullptr; - int32_t width = symbolInfo->getSymbolDataWidth(e); - if (e != BCExceptionNO) - return nullptr; - - int32_t height = symbolInfo->getSymbolDataHeight(e); - if (e != BCExceptionNO) - return nullptr; + int32_t width = symbolInfo->getSymbolDataWidth(); + ASSERT(width); + int32_t height = symbolInfo->getSymbolDataHeight(); + ASSERT(height); auto placement = pdfium::MakeUnique<CBC_DefaultPlacement>(codewords, width, height); |