• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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 
7 #include "xfa/fxfa/parser/xfa_object.h"
8 
CXFA_ArrayNodeList(CXFA_Document * pDocument)9 CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument)
10     : CXFA_NodeList(pDocument) {}
11 
~CXFA_ArrayNodeList()12 CXFA_ArrayNodeList::~CXFA_ArrayNodeList() {}
13 
SetArrayNodeList(const CXFA_NodeArray & srcArray)14 void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) {
15   if (srcArray.GetSize() > 0) {
16     m_array.Copy(srcArray);
17   }
18 }
19 
GetLength()20 int32_t CXFA_ArrayNodeList::GetLength() {
21   return m_array.GetSize();
22 }
23 
Append(CXFA_Node * pNode)24 bool CXFA_ArrayNodeList::Append(CXFA_Node* pNode) {
25   m_array.Add(pNode);
26   return true;
27 }
28 
Insert(CXFA_Node * pNewNode,CXFA_Node * pBeforeNode)29 bool CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) {
30   if (!pBeforeNode) {
31     m_array.Add(pNewNode);
32   } else {
33     int32_t iSize = m_array.GetSize();
34     for (int32_t i = 0; i < iSize; ++i) {
35       if (m_array[i] == pBeforeNode) {
36         m_array.InsertAt(i, pNewNode);
37         break;
38       }
39     }
40   }
41   return true;
42 }
43 
Remove(CXFA_Node * pNode)44 bool CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) {
45   int32_t iSize = m_array.GetSize();
46   for (int32_t i = 0; i < iSize; ++i) {
47     if (m_array[i] == pNode) {
48       m_array.RemoveAt(i);
49       break;
50     }
51   }
52   return true;
53 }
54 
Item(int32_t iIndex)55 CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) {
56   int32_t iSize = m_array.GetSize();
57   if (iIndex >= 0 && iIndex < iSize) {
58     return m_array[iIndex];
59   }
60   return nullptr;
61 }
62