| OLD | NEW |
| 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 2006 Jeremias Maerki | 8 * Copyright 2006 Jeremias Maerki |
| 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 12 matching lines...) Expand all Loading... |
| 23 #include "xfa/fxbarcode/BC_Dimension.h" | 23 #include "xfa/fxbarcode/BC_Dimension.h" |
| 24 #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" | 24 #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" |
| 25 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" | 25 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" |
| 26 #include "xfa/fxbarcode/datamatrix/BC_Encoder.h" | 26 #include "xfa/fxbarcode/datamatrix/BC_Encoder.h" |
| 27 #include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" | 27 #include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" |
| 28 #include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" | 28 #include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" |
| 29 | 29 |
| 30 #define SYMBOLS_COUNT 30 | 30 #define SYMBOLS_COUNT 30 |
| 31 | 31 |
| 32 CBC_SymbolInfo* CBC_SymbolInfo::m_PROD_SYMBOLS[30] = { | 32 CBC_SymbolInfo* CBC_SymbolInfo::m_PROD_SYMBOLS[30] = { |
| 33 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 33 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 34 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 34 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 35 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; | 35 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 36 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; |
| 36 CBC_SymbolInfo* CBC_SymbolInfo::m_symbols[30] = { | 37 CBC_SymbolInfo* CBC_SymbolInfo::m_symbols[30] = { |
| 37 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 38 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 38 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 39 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 39 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; | 40 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 41 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; |
| 40 void CBC_SymbolInfo::Initialize() { | 42 void CBC_SymbolInfo::Initialize() { |
| 41 m_PROD_SYMBOLS[0] = new CBC_SymbolInfo(FALSE, 3, 5, 8, 8, 1); | 43 m_PROD_SYMBOLS[0] = new CBC_SymbolInfo(FALSE, 3, 5, 8, 8, 1); |
| 42 m_PROD_SYMBOLS[1] = new CBC_SymbolInfo(FALSE, 5, 7, 10, 10, 1); | 44 m_PROD_SYMBOLS[1] = new CBC_SymbolInfo(FALSE, 5, 7, 10, 10, 1); |
| 43 m_PROD_SYMBOLS[2] = new CBC_SymbolInfo(TRUE, 5, 7, 16, 6, 1); | 45 m_PROD_SYMBOLS[2] = new CBC_SymbolInfo(TRUE, 5, 7, 16, 6, 1); |
| 44 m_PROD_SYMBOLS[3] = new CBC_SymbolInfo(FALSE, 8, 10, 12, 12, 1); | 46 m_PROD_SYMBOLS[3] = new CBC_SymbolInfo(FALSE, 8, 10, 12, 12, 1); |
| 45 m_PROD_SYMBOLS[4] = new CBC_SymbolInfo(TRUE, 10, 11, 14, 6, 2); | 47 m_PROD_SYMBOLS[4] = new CBC_SymbolInfo(TRUE, 10, 11, 14, 6, 2); |
| 46 m_PROD_SYMBOLS[5] = new CBC_SymbolInfo(FALSE, 12, 12, 14, 14, 1); | 48 m_PROD_SYMBOLS[5] = new CBC_SymbolInfo(FALSE, 12, 12, 14, 14, 1); |
| 47 m_PROD_SYMBOLS[6] = new CBC_SymbolInfo(TRUE, 16, 14, 24, 10, 1); | 49 m_PROD_SYMBOLS[6] = new CBC_SymbolInfo(TRUE, 16, 14, 24, 10, 1); |
| 48 m_PROD_SYMBOLS[7] = new CBC_SymbolInfo(FALSE, 18, 14, 16, 16, 1); | 50 m_PROD_SYMBOLS[7] = new CBC_SymbolInfo(FALSE, 18, 14, 16, 16, 1); |
| 49 m_PROD_SYMBOLS[8] = new CBC_SymbolInfo(FALSE, 22, 18, 18, 18, 1); | 51 m_PROD_SYMBOLS[8] = new CBC_SymbolInfo(FALSE, 22, 18, 18, 18, 1); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 70 m_PROD_SYMBOLS[28] = | 72 m_PROD_SYMBOLS[28] = |
| 71 new CBC_SymbolInfo(FALSE, 1304, 496, 20, 20, 36, 163, 62); | 73 new CBC_SymbolInfo(FALSE, 1304, 496, 20, 20, 36, 163, 62); |
| 72 m_PROD_SYMBOLS[29] = new CBC_DataMatrixSymbolInfo144(); | 74 m_PROD_SYMBOLS[29] = new CBC_DataMatrixSymbolInfo144(); |
| 73 for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { | 75 for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { |
| 74 m_symbols[i] = m_PROD_SYMBOLS[i]; | 76 m_symbols[i] = m_PROD_SYMBOLS[i]; |
| 75 } | 77 } |
| 76 } | 78 } |
| 77 void CBC_SymbolInfo::Finalize() { | 79 void CBC_SymbolInfo::Finalize() { |
| 78 for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { | 80 for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { |
| 79 delete m_PROD_SYMBOLS[i]; | 81 delete m_PROD_SYMBOLS[i]; |
| 80 m_PROD_SYMBOLS[i] = NULL; | 82 m_PROD_SYMBOLS[i] = nullptr; |
| 81 m_symbols[i] = NULL; | 83 m_symbols[i] = nullptr; |
| 82 } | 84 } |
| 83 } | 85 } |
| 84 CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, | 86 CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, |
| 85 int32_t dataCapacity, | 87 int32_t dataCapacity, |
| 86 int32_t errorCodewords, | 88 int32_t errorCodewords, |
| 87 int32_t matrixWidth, | 89 int32_t matrixWidth, |
| 88 int32_t matrixHeight, | 90 int32_t matrixHeight, |
| 89 int32_t dataRegions) { | 91 int32_t dataRegions) { |
| 90 m_rectangular = rectangular; | 92 m_rectangular = rectangular; |
| 91 m_dataCapacity = dataCapacity; | 93 m_dataCapacity = dataCapacity; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 FX_BOOL allowRectangular, | 129 FX_BOOL allowRectangular, |
| 128 FX_BOOL fail, | 130 FX_BOOL fail, |
| 129 int32_t& e) { | 131 int32_t& e) { |
| 130 SymbolShapeHint shape = allowRectangular ? FORCE_NONE : FORCE_SQUARE; | 132 SymbolShapeHint shape = allowRectangular ? FORCE_NONE : FORCE_SQUARE; |
| 131 return lookup(dataCodewords, shape, fail, e); | 133 return lookup(dataCodewords, shape, fail, e); |
| 132 } | 134 } |
| 133 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, | 135 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, |
| 134 SymbolShapeHint shape, | 136 SymbolShapeHint shape, |
| 135 FX_BOOL fail, | 137 FX_BOOL fail, |
| 136 int32_t& e) { | 138 int32_t& e) { |
| 137 return lookup(dataCodewords, shape, NULL, NULL, fail, e); | 139 return lookup(dataCodewords, shape, nullptr, nullptr, fail, e); |
| 138 } | 140 } |
| 139 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, | 141 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, |
| 140 SymbolShapeHint shape, | 142 SymbolShapeHint shape, |
| 141 CBC_Dimension* minSize, | 143 CBC_Dimension* minSize, |
| 142 CBC_Dimension* maxSize, | 144 CBC_Dimension* maxSize, |
| 143 FX_BOOL fail, | 145 FX_BOOL fail, |
| 144 int32_t& e) { | 146 int32_t& e) { |
| 145 for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { | 147 for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { |
| 146 CBC_SymbolInfo* symbol = m_symbols[i]; | 148 CBC_SymbolInfo* symbol = m_symbols[i]; |
| 147 if (shape == FORCE_SQUARE && symbol->m_rectangular) { | 149 if (shape == FORCE_SQUARE && symbol->m_rectangular) { |
| 148 continue; | 150 continue; |
| 149 } | 151 } |
| 150 if (shape == FORCE_RECTANGLE && !symbol->m_rectangular) { | 152 if (shape == FORCE_RECTANGLE && !symbol->m_rectangular) { |
| 151 continue; | 153 continue; |
| 152 } | 154 } |
| 153 if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() || | 155 if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() || |
| 154 symbol->getSymbolHeight(e) < minSize->getHeight())) { | 156 symbol->getSymbolHeight(e) < minSize->getHeight())) { |
| 155 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 157 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 156 continue; | 158 continue; |
| 157 } | 159 } |
| 158 if (maxSize && (symbol->getSymbolWidth(e) > maxSize->getWidth() || | 160 if (maxSize && (symbol->getSymbolWidth(e) > maxSize->getWidth() || |
| 159 symbol->getSymbolHeight(e) > maxSize->getHeight())) { | 161 symbol->getSymbolHeight(e) > maxSize->getHeight())) { |
| 160 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 162 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 161 continue; | 163 continue; |
| 162 } | 164 } |
| 163 if (dataCodewords <= symbol->m_dataCapacity) { | 165 if (dataCodewords <= symbol->m_dataCapacity) { |
| 164 return symbol; | 166 return symbol; |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 if (fail) { | 169 if (fail) { |
| 168 e = BCExceptionIllegalDataCodewords; | 170 e = BCExceptionIllegalDataCodewords; |
| 169 return NULL; | 171 return nullptr; |
| 170 } | 172 } |
| 171 return NULL; | 173 return nullptr; |
| 172 } | 174 } |
| 173 int32_t CBC_SymbolInfo::getHorizontalDataRegions(int32_t& e) { | 175 int32_t CBC_SymbolInfo::getHorizontalDataRegions(int32_t& e) { |
| 174 switch (m_dataRegions) { | 176 switch (m_dataRegions) { |
| 175 case 1: | 177 case 1: |
| 176 return 1; | 178 return 1; |
| 177 case 2: | 179 case 2: |
| 178 return 2; | 180 return 2; |
| 179 case 4: | 181 case 4: |
| 180 return 2; | 182 return 2; |
| 181 case 16: | 183 case 16: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 223 } |
| 222 int32_t CBC_SymbolInfo::getInterleavedBlockCount() { | 224 int32_t CBC_SymbolInfo::getInterleavedBlockCount() { |
| 223 return m_dataCapacity / m_rsBlockData; | 225 return m_dataCapacity / m_rsBlockData; |
| 224 } | 226 } |
| 225 int32_t CBC_SymbolInfo::getDataLengthForInterleavedBlock(int32_t index) { | 227 int32_t CBC_SymbolInfo::getDataLengthForInterleavedBlock(int32_t index) { |
| 226 return m_rsBlockData; | 228 return m_rsBlockData; |
| 227 } | 229 } |
| 228 int32_t CBC_SymbolInfo::getErrorLengthForInterleavedBlock(int32_t index) { | 230 int32_t CBC_SymbolInfo::getErrorLengthForInterleavedBlock(int32_t index) { |
| 229 return m_rsBlockError; | 231 return m_rsBlockError; |
| 230 } | 232 } |
| OLD | NEW |