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