Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp

Issue 2048983002: Get rid of NULLs in xfa/fxbarcode/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2007 ZXing authors 8 * Copyright 2007 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 11 matching lines...) Expand all
22 22
23 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" 23 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h"
24 24
25 #include <memory> 25 #include <memory>
26 26
27 #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" 27 #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
28 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" 28 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h"
29 #include "xfa/fxbarcode/utils.h" 29 #include "xfa/fxbarcode/utils.h"
30 30
31 CBC_DataMatrixBitMatrixParser::CBC_DataMatrixBitMatrixParser() { 31 CBC_DataMatrixBitMatrixParser::CBC_DataMatrixBitMatrixParser() {
32 m_mappingBitMatrix = NULL; 32 m_mappingBitMatrix = nullptr;
33 m_version = NULL; 33 m_version = nullptr;
34 m_readMappingMatrix = NULL; 34 m_readMappingMatrix = nullptr;
35 } 35 }
36 void CBC_DataMatrixBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix, 36 void CBC_DataMatrixBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix,
37 int32_t& e) { 37 int32_t& e) {
38 int32_t dimension = bitMatrix->GetHeight(); 38 int32_t dimension = bitMatrix->GetHeight();
39 if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { 39 if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) {
40 e = BCExceptionFormatException; 40 e = BCExceptionFormatException;
41 return; 41 return;
42 } 42 }
43 m_version = ReadVersion(bitMatrix, e); 43 m_version = ReadVersion(bitMatrix, e);
44 BC_EXCEPTION_CHECK_ReturnVoid(e); 44 BC_EXCEPTION_CHECK_ReturnVoid(e);
(...skipping 10 matching lines...) Expand all
55 CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::GetVersion() { 55 CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::GetVersion() {
56 return m_version; 56 return m_version;
57 } 57 }
58 CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::ReadVersion( 58 CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::ReadVersion(
59 CBC_CommonBitMatrix* bitMatrix, 59 CBC_CommonBitMatrix* bitMatrix,
60 int32_t& e) { 60 int32_t& e) {
61 int32_t rows = bitMatrix->GetHeight(); 61 int32_t rows = bitMatrix->GetHeight();
62 int32_t columns = bitMatrix->GetWidth(); 62 int32_t columns = bitMatrix->GetWidth();
63 CBC_DataMatrixVersion* temp = 63 CBC_DataMatrixVersion* temp =
64 CBC_DataMatrixVersion::GetVersionForDimensions(rows, columns, e); 64 CBC_DataMatrixVersion::GetVersionForDimensions(rows, columns, e);
65 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 65 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
66 return temp; 66 return temp;
67 } 67 }
68 CFX_ByteArray* CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t& e) { 68 CFX_ByteArray* CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t& e) {
69 std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray()); 69 std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray());
70 result->SetSize(m_version->GetTotalCodewords()); 70 result->SetSize(m_version->GetTotalCodewords());
71 int32_t resultOffset = 0; 71 int32_t resultOffset = 0;
72 int32_t row = 4; 72 int32_t row = 4;
73 int32_t column = 0; 73 int32_t column = 0;
74 int32_t numRows = m_mappingBitMatrix->GetHeight(); 74 int32_t numRows = m_mappingBitMatrix->GetHeight();
75 int32_t numColumns = m_mappingBitMatrix->GetWidth(); 75 int32_t numColumns = m_mappingBitMatrix->GetWidth();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 row += 2; 126 row += 2;
127 column -= 2; 127 column -= 2;
128 } while ((row < numRows) && (column >= 0)); 128 } while ((row < numRows) && (column >= 0));
129 row += 3; 129 row += 3;
130 column += 1; 130 column += 1;
131 } 131 }
132 } while ((row < numRows) || (column < numColumns)); 132 } while ((row < numRows) || (column < numColumns));
133 if (resultOffset != m_version->GetTotalCodewords()) { 133 if (resultOffset != m_version->GetTotalCodewords()) {
134 e = BCExceptionFormatException; 134 e = BCExceptionFormatException;
135 return NULL; 135 return nullptr;
136 } 136 }
137 return result.release(); 137 return result.release();
138 } 138 }
139 FX_BOOL CBC_DataMatrixBitMatrixParser::ReadModule(int32_t row, 139 FX_BOOL CBC_DataMatrixBitMatrixParser::ReadModule(int32_t row,
140 int32_t column, 140 int32_t column,
141 int32_t numRows, 141 int32_t numRows,
142 int32_t numColumns) { 142 int32_t numColumns) {
143 if (row < 0) { 143 if (row < 0) {
144 row += numRows; 144 row += numRows;
145 column += 4 - ((numRows + 4) & 0x07); 145 column += 4 - ((numRows + 4) & 0x07);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 333 }
334 return currentByte; 334 return currentByte;
335 } 335 }
336 CBC_CommonBitMatrix* CBC_DataMatrixBitMatrixParser::ExtractDataRegion( 336 CBC_CommonBitMatrix* CBC_DataMatrixBitMatrixParser::ExtractDataRegion(
337 CBC_CommonBitMatrix* bitMatrix, 337 CBC_CommonBitMatrix* bitMatrix,
338 int32_t& e) { 338 int32_t& e) {
339 int32_t symbolSizeRows = m_version->GetSymbolSizeRows(); 339 int32_t symbolSizeRows = m_version->GetSymbolSizeRows();
340 int32_t symbolSizeColumns = m_version->GetSymbolSizeColumns(); 340 int32_t symbolSizeColumns = m_version->GetSymbolSizeColumns();
341 if (bitMatrix->GetHeight() != symbolSizeRows) { 341 if (bitMatrix->GetHeight() != symbolSizeRows) {
342 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; 342 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix;
343 return NULL; 343 return nullptr;
344 } 344 }
345 int32_t dataRegionSizeRows = m_version->GetDataRegionSizeRows(); 345 int32_t dataRegionSizeRows = m_version->GetDataRegionSizeRows();
346 int32_t dataRegionSizeColumns = m_version->GetDataRegionSizeColumns(); 346 int32_t dataRegionSizeColumns = m_version->GetDataRegionSizeColumns();
347 int32_t numDataRegionsRow = symbolSizeRows / dataRegionSizeRows; 347 int32_t numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
348 int32_t numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns; 348 int32_t numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;
349 int32_t sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; 349 int32_t sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
350 int32_t sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; 350 int32_t sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
351 CBC_CommonBitMatrix* bitMatrixWithoutAlignment = new CBC_CommonBitMatrix(); 351 CBC_CommonBitMatrix* bitMatrixWithoutAlignment = new CBC_CommonBitMatrix();
352 bitMatrixWithoutAlignment->Init(sizeDataRegionColumn, sizeDataRegionRow); 352 bitMatrixWithoutAlignment->Init(sizeDataRegionColumn, sizeDataRegionRow);
353 int32_t dataRegionRow; 353 int32_t dataRegionRow;
(...skipping 15 matching lines...) Expand all
369 if (bitMatrix->Get(readColumnOffset, readRowOffset)) { 369 if (bitMatrix->Get(readColumnOffset, readRowOffset)) {
370 int32_t writeColumnOffset = dataRegionColumnOffset + j; 370 int32_t writeColumnOffset = dataRegionColumnOffset + j;
371 bitMatrixWithoutAlignment->Set(writeColumnOffset, writeRowOffset); 371 bitMatrixWithoutAlignment->Set(writeColumnOffset, writeRowOffset);
372 } 372 }
373 } 373 }
374 } 374 }
375 } 375 }
376 } 376 }
377 return bitMatrixWithoutAlignment; 377 return bitMatrixWithoutAlignment;
378 } 378 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp ('k') | xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698