diff options
author | dsinclair <dsinclair@chromium.org> | 2016-07-19 10:56:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-19 10:56:24 -0700 |
commit | 5b36f0a0eff7f3666a0e642640db3c89e4bb6748 (patch) | |
tree | 1c9c719ea55062ac7bf36dbee7dfb9e9753471dc /xfa/fxfa/parser/cxfa_arraynodelist.cpp | |
parent | eea31b75a11215aa72a9845d47c38d2ce1edd4f7 (diff) | |
download | pdfium-5b36f0a0eff7f3666a0e642640db3c89e4bb6748.tar.xz |
Split xfa_object_imp into individual class files.
This CL splits the CXFA_Object, CXFA_NodeList, CXFA_ThisProxy,
CXFA_ArrayNodeList and CXFA_AttachNodeList out of xfa_object_imp. xfa_object_imp
is then renamed to CXFA_Node.
Review-Url: https://codereview.chromium.org/2159973003
Diffstat (limited to 'xfa/fxfa/parser/cxfa_arraynodelist.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_arraynodelist.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.cpp b/xfa/fxfa/parser/cxfa_arraynodelist.cpp new file mode 100644 index 0000000000..06aab400f1 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_arraynodelist.cpp @@ -0,0 +1,62 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/parser/xfa_object.h" + +CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) + : CXFA_NodeList(pDocument) {} + +CXFA_ArrayNodeList::~CXFA_ArrayNodeList() {} + +void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { + if (srcArray.GetSize() > 0) { + m_array.Copy(srcArray); + } +} + +int32_t CXFA_ArrayNodeList::GetLength() { + return m_array.GetSize(); +} + +FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { + m_array.Add(pNode); + return TRUE; +} + +FX_BOOL CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, + CXFA_Node* pBeforeNode) { + if (!pBeforeNode) { + m_array.Add(pNewNode); + } else { + int32_t iSize = m_array.GetSize(); + for (int32_t i = 0; i < iSize; ++i) { + if (m_array[i] == pBeforeNode) { + m_array.InsertAt(i, pNewNode); + break; + } + } + } + return TRUE; +} + +FX_BOOL CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { + int32_t iSize = m_array.GetSize(); + for (int32_t i = 0; i < iSize; ++i) { + if (m_array[i] == pNode) { + m_array.RemoveAt(i); + break; + } + } + return TRUE; +} + +CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) { + int32_t iSize = m_array.GetSize(); + if (iIndex >= 0 && iIndex < iSize) { + return m_array[iIndex]; + } + return nullptr; +} |