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

Side by Side Diff: xfa/src/fxbarcode/src/BC_DataMatrixVersion.cpp

Issue 842043002: Organize barcode codes into modules. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 5 years, 11 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
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 // Original code is licensed as follows:
7 /*
8 * Copyright 2007 ZXing authors
9 *
10 * Licensed under the Apache License, Version 2.0 (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
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22
23 #include "barcode.h"
24 #include "include/BC_DataMatrixVersion.h"
25 CFX_PtrArray* CBC_DataMatrixVersion::VERSIONS = NULL;
26 void CBC_DataMatrixVersion::Initialize()
27 {
28 VERSIONS = FX_NEW CFX_PtrArray();
29 }
30 void CBC_DataMatrixVersion::Finalize()
31 {
32 for (FX_INT32 i = 0; i < VERSIONS->GetSize(); i++) {
33 delete ( (CBC_DataMatrixVersion*)(VERSIONS->GetAt(i)) );
34 }
35 VERSIONS->RemoveAll();
36 delete VERSIONS;
37 }
38 CBC_DataMatrixVersion::CBC_DataMatrixVersion(FX_INT32 versionNumber,
39 FX_INT32 symbolSizeRows,
40 FX_INT32 symbolSizeColumns,
41 FX_INT32 dataRegionSizeRows,
42 FX_INT32 dataRegionSizeColumns,
43 ECBlocks *ecBlocks)
44 {
45 m_versionNumber = versionNumber;
46 m_symbolSizeRows = symbolSizeRows;
47 m_symbolSizeColumns = symbolSizeColumns;
48 m_dataRegionSizeRows = dataRegionSizeRows;
49 m_dataRegionSizeColumns = dataRegionSizeColumns;
50 m_ecBlocks = ecBlocks;
51 FX_INT32 total = 0;
52 FX_INT32 ecCodewords = ecBlocks->GetECCodewords();
53 const CFX_PtrArray &ecbArray = ecBlocks->GetECBlocks();
54 for (FX_INT32 i = 0; i < ecbArray.GetSize(); i++) {
55 total += ((ECB*)ecbArray[i])->GetCount() * (((ECB*)ecbArray[i])->GetData Codewords() + ecCodewords);
56 }
57 m_totalCodewords = total;
58 }
59 CBC_DataMatrixVersion::~CBC_DataMatrixVersion()
60 {
61 if(m_ecBlocks != NULL) {
62 delete m_ecBlocks;
63 }
64 m_ecBlocks = NULL;
65 }
66 FX_INT32 CBC_DataMatrixVersion::GetVersionNumber()
67 {
68 return m_versionNumber;
69 }
70 FX_INT32 CBC_DataMatrixVersion::GetSymbolSizeRows()
71 {
72 return m_symbolSizeRows;
73 }
74 FX_INT32 CBC_DataMatrixVersion::GetSymbolSizeColumns()
75 {
76 return m_symbolSizeColumns;
77 }
78 FX_INT32 CBC_DataMatrixVersion::GetDataRegionSizeRows()
79 {
80 return m_dataRegionSizeRows;
81 }
82 FX_INT32 CBC_DataMatrixVersion::GetDataRegionSizeColumns()
83 {
84 return m_dataRegionSizeColumns;
85 }
86 FX_INT32 CBC_DataMatrixVersion::GetTotalCodewords()
87 {
88 return m_totalCodewords;
89 }
90 ECBlocks *CBC_DataMatrixVersion::GetECBlocks()
91 {
92 return m_ecBlocks;
93 }
94 void CBC_DataMatrixVersion::ReleaseAll()
95 {
96 for (FX_INT32 i = 0; i < VERSIONS->GetSize(); i++) {
97 delete (CBC_DataMatrixVersion*)VERSIONS->GetAt(i);
98 }
99 VERSIONS->RemoveAll();
100 }
101 CBC_DataMatrixVersion *CBC_DataMatrixVersion::GetVersionForDimensions(FX_INT32 n umRows, FX_INT32 numColumns, FX_INT32 &e)
102 {
103 if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) {
104 e = BCExceptionNotFound;
105 return NULL;
106 }
107 if(VERSIONS->GetSize() == 0) {
108 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(1, 10, 10, 8, 8, FX_NEW ECBlo cks(5, FX_NEW ECB(1, 3))));
109 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(2, 12, 12, 10, 10, FX_NEW ECB locks(7, FX_NEW ECB(1, 5))));
110 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(3, 14, 14, 12, 12, FX_NEW ECB locks(10, FX_NEW ECB(1, 8))));
111 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(4, 16, 16, 14, 14, FX_NEW ECB locks(12, FX_NEW ECB(1, 12))));
112 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(5, 18, 18, 16, 16, FX_NEW ECB locks(14, FX_NEW ECB(1, 18))));
113 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(6, 20, 20, 18, 18, FX_NEW ECB locks(18, FX_NEW ECB(1, 22))));
114 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(7, 22, 22, 20, 20, FX_NEW ECB locks(20, FX_NEW ECB(1, 30))));
115 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(8, 24, 24, 22, 22, FX_NEW ECB locks(24, FX_NEW ECB(1, 36))));
116 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(9, 26, 26, 24, 24, FX_NEW ECB locks(28, FX_NEW ECB(1, 44))));
117 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(10, 32, 32, 14, 14, FX_NEW EC Blocks(36, FX_NEW ECB(1, 62))));
118 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(11, 36, 36, 16, 16, FX_NEW EC Blocks(42, FX_NEW ECB(1, 86))));
119 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(12, 40, 40, 18, 18, FX_NEW EC Blocks(48, FX_NEW ECB(1, 114))));
120 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(13, 44, 44, 20, 20, FX_NEW EC Blocks(56, FX_NEW ECB(1, 144))));
121 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(14, 48, 48, 22, 22, FX_NEW EC Blocks(68, FX_NEW ECB(1, 174))));
122 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(15, 52, 52, 24, 24, FX_NEW EC Blocks(42, FX_NEW ECB(2, 102))));
123 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(16, 64, 64, 14, 14, FX_NEW EC Blocks(56, FX_NEW ECB(2, 140))));
124 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(17, 72, 72, 16, 16, FX_NEW EC Blocks(36, FX_NEW ECB(4, 92))));
125 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(18, 80, 80, 18, 18, FX_NEW EC Blocks(48, FX_NEW ECB(4, 114))));
126 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(19, 88, 88, 20, 20, FX_NEW EC Blocks(56, FX_NEW ECB(4, 144))));
127 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(20, 96, 96, 22, 22, FX_NEW EC Blocks(68, FX_NEW ECB(4, 174))));
128 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(21, 104, 104, 24, 24, FX_NEW ECBlocks(56, FX_NEW ECB(6, 136))));
129 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(22, 120, 120, 18, 18, FX_NEW ECBlocks(68, FX_NEW ECB(6, 175))));
130 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(23, 132, 132, 20, 20, FX_NEW ECBlocks(62, FX_NEW ECB(8, 163))));
131 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(24, 144, 144, 22, 22, FX_NEW ECBlocks(62, FX_NEW ECB(8, 156), FX_NEW ECB(2, 155))));
132 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(25, 8, 18, 6, 16, FX_NEW ECBl ocks(7, FX_NEW ECB(1, 5))));
133 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(26, 8, 32, 6, 14, FX_NEW ECBl ocks(11, FX_NEW ECB(1, 10))));
134 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(27, 12, 26, 10, 24, FX_NEW EC Blocks(14, FX_NEW ECB(1, 16))));
135 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(28, 12, 36, 10, 16, FX_NEW EC Blocks(18, FX_NEW ECB(1, 22))));
136 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(29, 16, 36, 14, 16, FX_NEW EC Blocks(24, FX_NEW ECB(1, 32))));
137 VERSIONS->Add(FX_NEW CBC_DataMatrixVersion(30, 16, 48, 14, 22, FX_NEW EC Blocks(28, FX_NEW ECB(1, 49))));
138 }
139 FX_INT32 numVersions = VERSIONS->GetSize();
140 for (FX_INT32 i = 0; i < numVersions; ++i) {
141 if (((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeRows == numR ows && ((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeColumns == numCol umns) {
142 return (CBC_DataMatrixVersion*)(*VERSIONS)[i];
143 }
144 }
145 e = BCExceptionNotFound;
146 return NULL;
147 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/src/BC_DataMatrixSymbolInfo144.cpp ('k') | xfa/src/fxbarcode/src/BC_DataMatrixWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698