Home | History | Annotate | Download | only in parser
      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_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument,
     10                                          CXFA_Node* pAttachNode)
     11     : CXFA_NodeList(pDocument) {
     12   m_pAttachNode = pAttachNode;
     13 }
     14 
     15 int32_t CXFA_AttachNodeList::GetLength() {
     16   return m_pAttachNode->CountChildren(
     17       XFA_Element::Unknown,
     18       m_pAttachNode->GetElementType() == XFA_Element::Subform);
     19 }
     20 
     21 bool 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 
     29 bool 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 
     37 bool CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
     38   return m_pAttachNode->RemoveChild(pNode);
     39 }
     40 
     41 CXFA_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