OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/parser/xfa_object.h" | 7 #include "xfa/fxfa/parser/xfa_object.h" |
8 | 8 |
9 CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, | 9 CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, |
10 CXFA_Node* pAttachNode) | 10 CXFA_Node* pAttachNode) |
11 : CXFA_NodeList(pDocument) { | 11 : CXFA_NodeList(pDocument) { |
12 m_pAttachNode = pAttachNode; | 12 m_pAttachNode = pAttachNode; |
13 } | 13 } |
14 | 14 |
15 int32_t CXFA_AttachNodeList::GetLength() { | 15 int32_t CXFA_AttachNodeList::GetLength() { |
16 return m_pAttachNode->CountChildren( | 16 return m_pAttachNode->CountChildren( |
17 XFA_Element::Unknown, | 17 XFA_Element::Unknown, |
18 m_pAttachNode->GetElementType() == XFA_Element::Subform); | 18 m_pAttachNode->GetElementType() == XFA_Element::Subform); |
19 } | 19 } |
20 | 20 |
21 FX_BOOL CXFA_AttachNodeList::Append(CXFA_Node* pNode) { | 21 bool CXFA_AttachNodeList::Append(CXFA_Node* pNode) { |
22 CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent); | 22 CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent); |
23 if (pParent) { | 23 if (pParent) { |
24 pParent->RemoveChild(pNode); | 24 pParent->RemoveChild(pNode); |
25 } | 25 } |
26 return m_pAttachNode->InsertChild(pNode); | 26 return m_pAttachNode->InsertChild(pNode); |
27 } | 27 } |
28 | 28 |
29 FX_BOOL CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, | 29 bool CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { |
30 CXFA_Node* pBeforeNode) { | |
31 CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent); | 30 CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent); |
32 if (pParent) { | 31 if (pParent) { |
33 pParent->RemoveChild(pNewNode); | 32 pParent->RemoveChild(pNewNode); |
34 } | 33 } |
35 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 34 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
36 } | 35 } |
37 | 36 |
38 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 37 bool CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
39 return m_pAttachNode->RemoveChild(pNode); | 38 return m_pAttachNode->RemoveChild(pNode); |
40 } | 39 } |
41 | 40 |
42 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 41 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
43 return m_pAttachNode->GetChild( | 42 return m_pAttachNode->GetChild( |
44 iIndex, XFA_Element::Unknown, | 43 iIndex, XFA_Element::Unknown, |
45 m_pAttachNode->GetElementType() == XFA_Element::Subform); | 44 m_pAttachNode->GetElementType() == XFA_Element::Subform); |
46 } | 45 } |
OLD | NEW |