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

Side by Side Diff: xfa/src/fxbarcode/src/BC_DataMatrixDataBlock.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 2008 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 #include "include/BC_DataMatrixDataBlock.h"
26 CBC_DataMatrixDataBlock::~CBC_DataMatrixDataBlock()
27 {
28 }
29 CBC_DataMatrixDataBlock::CBC_DataMatrixDataBlock(FX_INT32 numDataCodewords, CFX_ ByteArray *codewords)
30 {
31 m_codewords.Copy(*codewords);
32 m_numDataCodewords = numDataCodewords;
33 }
34 CFX_PtrArray *CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords , CBC_DataMatrixVersion *version, FX_INT32 &e)
35 {
36 ECBlocks *ecBlocks = version->GetECBlocks();
37 FX_INT32 totalBlocks = 0;
38 const CFX_PtrArray &ecBlockArray = ecBlocks->GetECBlocks();
39 FX_INT32 i;
40 for (i = 0; i < ecBlockArray.GetSize(); i++) {
41 totalBlocks += ((ECB*)ecBlockArray[i])->GetCount();
42 }
43 CBC_AutoPtr<CFX_PtrArray>result(FX_NEW CFX_PtrArray());
44 result->SetSize(totalBlocks);
45 FX_INT32 numResultBlocks = 0;
46 FX_INT32 j;
47 for (j = 0; j < ecBlockArray.GetSize(); j++) {
48 for (i = 0; i < ((ECB*)ecBlockArray[j])->GetCount(); i++) {
49 FX_INT32 numDataCodewords = ((ECB*)ecBlockArray[j])->GetDataCodeword s();
50 FX_INT32 numBlockCodewords = ecBlocks->GetECCodewords() + numDataCod ewords;
51 CFX_ByteArray codewords;
52 codewords.SetSize(numBlockCodewords);
53 (*result)[numResultBlocks++] = FX_NEW CBC_DataMatrixDataBlock(numDat aCodewords, &codewords);
54 codewords.SetSize(0);
55 }
56 }
57 FX_INT32 longerBlocksTotalCodewords = ((CBC_DataMatrixDataBlock*)(*result)[0 ])->GetCodewords()->GetSize();
58 FX_INT32 longerBlocksNumDataCodewords = longerBlocksTotalCodewords - ecBlock s->GetECCodewords();
59 FX_INT32 shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1;
60 FX_INT32 rawCodewordsOffset = 0;
61 for (i = 0; i < shorterBlocksNumDataCodewords; i++) {
62 FX_INT32 j;
63 for (j = 0; j < numResultBlocks; j++) {
64 if (rawCodewordsOffset < rawCodewords->GetSize()) {
65 ((CBC_DataMatrixDataBlock*)(*result)[j])->GetCodewords()->operat or [](i) = (*rawCodewords)[rawCodewordsOffset++];
66 }
67 }
68 }
69 FX_BOOL specialVersion = version->GetVersionNumber() == 24;
70 FX_INT32 numLongerBlocks = specialVersion ? 8 : numResultBlocks;
71 for (j = 0; j < numLongerBlocks; j++) {
72 if (rawCodewordsOffset < rawCodewords->GetSize()) {
73 ((CBC_DataMatrixDataBlock*)(*result)[j])->GetCodewords()->operator [ ](longerBlocksNumDataCodewords - 1) = (*rawCodewords)[rawCodewordsOffset++];
74 }
75 }
76 FX_INT32 max = ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->Get Size();
77 for (i = longerBlocksNumDataCodewords; i < max; i++) {
78 FX_INT32 j;
79 for (j = 0; j < numResultBlocks; j++) {
80 FX_INT32 iOffset = specialVersion && j > 7 ? i - 1 : i;
81 if (rawCodewordsOffset < rawCodewords->GetSize()) {
82 ((CBC_DataMatrixDataBlock*)(*result)[j])->GetCodewords()->operat or [](iOffset) = (*rawCodewords)[rawCodewordsOffset++];
83 }
84 }
85 }
86 if (rawCodewordsOffset != rawCodewords->GetSize()) {
87 e = BCExceptionIllegalArgument;
88 return NULL;
89 }
90 return result.release();
91 }
92 FX_INT32 CBC_DataMatrixDataBlock::GetNumDataCodewords()
93 {
94 return m_numDataCodewords;
95 }
96 CFX_ByteArray *CBC_DataMatrixDataBlock::GetCodewords()
97 {
98 return &m_codewords;
99 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/src/BC_DataMatrixBitMatrixParser.cpp ('k') | xfa/src/fxbarcode/src/BC_DataMatrixDecodedBitStreamParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698