Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fxbarcode / src / BC_QRCoderECBlocks.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "barcode.h"\r
8 #include "include/BC_QRCoderECB.h"\r
9 #include "include/BC_QRCoderECBlocks.h"\r
10 CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(FX_INT32 ecCodeWordsPerBlock, CBC_QRCoderECB* ecBlocks)\r
11 {\r
12     m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;\r
13     m_ecBlocks.Add(ecBlocks);\r
14 }\r
15 CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(FX_INT32 ecCodeWordsPerBlock,\r
16         CBC_QRCoderECB* ecBlocks1,\r
17         CBC_QRCoderECB* ecBlocks2)\r
18 {\r
19     m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;\r
20     m_ecBlocks.Add(ecBlocks1);\r
21     m_ecBlocks.Add(ecBlocks2);\r
22 }\r
23 CBC_QRCoderECBlocks::~CBC_QRCoderECBlocks()\r
24 {\r
25     for (FX_INT32 i = 0 ; i < m_ecBlocks.GetSize(); i++) {\r
26         delete ( (CBC_QRCoderECB*)(m_ecBlocks[i]) ) ;\r
27     }\r
28     m_ecBlocks.RemoveAll();\r
29 }\r
30 FX_INT32 CBC_QRCoderECBlocks::GetECCodeWordsPerBlock()\r
31 {\r
32     return m_ecCodeWordsPerBlock;\r
33 }\r
34 FX_INT32 CBC_QRCoderECBlocks::GetNumBlocks()\r
35 {\r
36     FX_INT32 total = 0;\r
37     for(FX_INT32 i = 0; i < m_ecBlocks.GetSize(); i++) {\r
38         total += ( (CBC_QRCoderECB*)(m_ecBlocks[i]) )->GetCount();\r
39     }\r
40     return total;\r
41 }\r
42 FX_INT32 CBC_QRCoderECBlocks::GetTotalECCodeWords()\r
43 {\r
44     return m_ecCodeWordsPerBlock * GetNumBlocks();\r
45 }\r
46 CFX_PtrArray* CBC_QRCoderECBlocks::GetECBlocks()\r
47 {\r
48     return &m_ecBlocks;\r
49 }\r