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_AttachNodeList(CXFA_Document * pDocument,CXFA_Node * pAttachNode)9CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, 10 CXFA_Node* pAttachNode) 11 : CXFA_NodeList(pDocument) { 12 m_pAttachNode = pAttachNode; 13 } 14 GetLength()15int32_t CXFA_AttachNodeList::GetLength() { 16 return m_pAttachNode->CountChildren( 17 XFA_Element::Unknown, 18 m_pAttachNode->GetElementType() == XFA_Element::Subform); 19 } 20 Append(CXFA_Node * pNode)21bool CXFA_AttachNodeList::Append(CXFA_Node* pNode) { 22 CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent); 23 if (pParent) { 24 pParent->RemoveChild(pNode); 25 } 26 return m_pAttachNode->InsertChild(pNode); 27 } 28 Insert(CXFA_Node * pNewNode,CXFA_Node * pBeforeNode)29bool CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { 30 CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent); 31 if (pParent) { 32 pParent->RemoveChild(pNewNode); 33 } 34 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); 35 } 36 Remove(CXFA_Node * pNode)37bool CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { 38 return m_pAttachNode->RemoveChild(pNode); 39 } 40 Item(int32_t iIndex)41CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { 42 return m_pAttachNode->GetChild( 43 iIndex, XFA_Element::Unknown, 44 m_pAttachNode->GetElementType() == XFA_Element::Subform); 45 } 46