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 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"); |
11 * you may not use this file except in compliance with the License. | 11 * you may not use this file except in compliance with the License. |
12 * You may obtain a copy of the License at | 12 * You may obtain a copy of the License at |
13 * | 13 * |
14 * http://www.apache.org/licenses/LICENSE-2.0 | 14 * http://www.apache.org/licenses/LICENSE-2.0 |
15 * | 15 * |
16 * Unless required by applicable law or agreed to in writing, software | 16 * Unless required by applicable law or agreed to in writing, software |
17 * distributed under the License is distributed on an "AS IS" BASIS, | 17 * distributed under the License is distributed on an "AS IS" BASIS, |
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 * See the License for the specific language governing permissions and | 19 * See the License for the specific language governing permissions and |
20 * limitations under the License. | 20 * limitations under the License. |
21 */ | 21 */ |
22 | 22 |
23 #include <stdint.h> | 23 #include <stdint.h> |
24 | 24 |
25 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" | 25 #include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" |
26 #include "xfa/fxbarcode/utils.h" | 26 #include "xfa/fxbarcode/utils.h" |
27 | 27 |
28 CFX_PtrArray* CBC_DataMatrixVersion::VERSIONS = NULL; | 28 CFX_ArrayTemplate<CBC_DataMatrixVersion*>* CBC_DataMatrixVersion::VERSIONS = |
| 29 nullptr; |
29 | 30 |
30 void CBC_DataMatrixVersion::Initialize() { | 31 void CBC_DataMatrixVersion::Initialize() { |
31 VERSIONS = new CFX_PtrArray(); | 32 VERSIONS = new CFX_ArrayTemplate<CBC_DataMatrixVersion*>(); |
32 } | 33 } |
33 void CBC_DataMatrixVersion::Finalize() { | 34 void CBC_DataMatrixVersion::Finalize() { |
34 for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { | 35 for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { |
35 delete ((CBC_DataMatrixVersion*)(VERSIONS->GetAt(i))); | 36 delete VERSIONS->GetAt(i); |
36 } | 37 } |
37 VERSIONS->RemoveAll(); | 38 VERSIONS->RemoveAll(); |
38 delete VERSIONS; | 39 delete VERSIONS; |
39 } | 40 } |
40 CBC_DataMatrixVersion::CBC_DataMatrixVersion(int32_t versionNumber, | 41 CBC_DataMatrixVersion::CBC_DataMatrixVersion(int32_t versionNumber, |
41 int32_t symbolSizeRows, | 42 int32_t symbolSizeRows, |
42 int32_t symbolSizeColumns, | 43 int32_t symbolSizeColumns, |
43 int32_t dataRegionSizeRows, | 44 int32_t dataRegionSizeRows, |
44 int32_t dataRegionSizeColumns, | 45 int32_t dataRegionSizeColumns, |
45 ECBlocks* ecBlocks) { | 46 ECBlocks* ecBlocks) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return m_dataRegionSizeColumns; | 78 return m_dataRegionSizeColumns; |
78 } | 79 } |
79 int32_t CBC_DataMatrixVersion::GetTotalCodewords() { | 80 int32_t CBC_DataMatrixVersion::GetTotalCodewords() { |
80 return m_totalCodewords; | 81 return m_totalCodewords; |
81 } | 82 } |
82 ECBlocks* CBC_DataMatrixVersion::GetECBlocks() { | 83 ECBlocks* CBC_DataMatrixVersion::GetECBlocks() { |
83 return m_ecBlocks; | 84 return m_ecBlocks; |
84 } | 85 } |
85 void CBC_DataMatrixVersion::ReleaseAll() { | 86 void CBC_DataMatrixVersion::ReleaseAll() { |
86 for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { | 87 for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { |
87 delete (CBC_DataMatrixVersion*)VERSIONS->GetAt(i); | 88 delete VERSIONS->GetAt(i); |
88 } | 89 } |
89 VERSIONS->RemoveAll(); | 90 VERSIONS->RemoveAll(); |
90 } | 91 } |
91 CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions( | 92 CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions( |
92 int32_t numRows, | 93 int32_t numRows, |
93 int32_t numColumns, | 94 int32_t numColumns, |
94 int32_t& e) { | 95 int32_t& e) { |
95 if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { | 96 if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { |
96 e = BCExceptionNotFound; | 97 e = BCExceptionNotFound; |
97 return NULL; | 98 return nullptr; |
98 } | 99 } |
99 if (VERSIONS->GetSize() == 0) { | 100 if (VERSIONS->GetSize() == 0) { |
100 VERSIONS->Add(new CBC_DataMatrixVersion(1, 10, 10, 8, 8, | 101 VERSIONS->Add(new CBC_DataMatrixVersion(1, 10, 10, 8, 8, |
101 new ECBlocks(5, new ECB(1, 3)))); | 102 new ECBlocks(5, new ECB(1, 3)))); |
102 VERSIONS->Add(new CBC_DataMatrixVersion(2, 12, 12, 10, 10, | 103 VERSIONS->Add(new CBC_DataMatrixVersion(2, 12, 12, 10, 10, |
103 new ECBlocks(7, new ECB(1, 5)))); | 104 new ECBlocks(7, new ECB(1, 5)))); |
104 VERSIONS->Add(new CBC_DataMatrixVersion(3, 14, 14, 12, 12, | 105 VERSIONS->Add(new CBC_DataMatrixVersion(3, 14, 14, 12, 12, |
105 new ECBlocks(10, new ECB(1, 8)))); | 106 new ECBlocks(10, new ECB(1, 8)))); |
106 VERSIONS->Add(new CBC_DataMatrixVersion(4, 16, 16, 14, 14, | 107 VERSIONS->Add(new CBC_DataMatrixVersion(4, 16, 16, 14, 14, |
107 new ECBlocks(12, new ECB(1, 12)))); | 108 new ECBlocks(12, new ECB(1, 12)))); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 new ECBlocks(14, new ECB(1, 16)))); | 155 new ECBlocks(14, new ECB(1, 16)))); |
155 VERSIONS->Add(new CBC_DataMatrixVersion(28, 12, 36, 10, 16, | 156 VERSIONS->Add(new CBC_DataMatrixVersion(28, 12, 36, 10, 16, |
156 new ECBlocks(18, new ECB(1, 22)))); | 157 new ECBlocks(18, new ECB(1, 22)))); |
157 VERSIONS->Add(new CBC_DataMatrixVersion(29, 16, 36, 14, 16, | 158 VERSIONS->Add(new CBC_DataMatrixVersion(29, 16, 36, 14, 16, |
158 new ECBlocks(24, new ECB(1, 32)))); | 159 new ECBlocks(24, new ECB(1, 32)))); |
159 VERSIONS->Add(new CBC_DataMatrixVersion(30, 16, 48, 14, 22, | 160 VERSIONS->Add(new CBC_DataMatrixVersion(30, 16, 48, 14, 22, |
160 new ECBlocks(28, new ECB(1, 49)))); | 161 new ECBlocks(28, new ECB(1, 49)))); |
161 } | 162 } |
162 int32_t numVersions = VERSIONS->GetSize(); | 163 int32_t numVersions = VERSIONS->GetSize(); |
163 for (int32_t i = 0; i < numVersions; ++i) { | 164 for (int32_t i = 0; i < numVersions; ++i) { |
164 if (((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeRows == | 165 if ((*VERSIONS)[i]->m_symbolSizeRows == numRows && |
165 numRows && | 166 (*VERSIONS)[i]->m_symbolSizeColumns == numColumns) { |
166 ((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeColumns == | 167 return (*VERSIONS)[i]; |
167 numColumns) { | |
168 return (CBC_DataMatrixVersion*)(*VERSIONS)[i]; | |
169 } | 168 } |
170 } | 169 } |
171 e = BCExceptionNotFound; | 170 e = BCExceptionNotFound; |
172 return NULL; | 171 return nullptr; |
173 } | 172 } |
OLD | NEW |