OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
(...skipping 4556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4567 if (iCount > index) { | 4567 if (iCount > index) { |
4568 return pNode; | 4568 return pNode; |
4569 } | 4569 } |
4570 } | 4570 } |
4571 } | 4571 } |
4572 return NULL; | 4572 return NULL; |
4573 } | 4573 } |
4574 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { | 4574 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { |
4575 ASSERT(!pNode->m_pNext); | 4575 ASSERT(!pNode->m_pNext); |
4576 pNode->m_pParent = this; | 4576 pNode->m_pParent = this; |
4577 FX_BOOL bWasPurgeNode = m_pDocument->RemovePurgeNode(pNode); | 4577 ASSERT(m_pDocument->RemovePurgeNode(pNode)); |
4578 if (!bWasPurgeNode) | |
4579 ASSERT(false); | |
4580 | 4578 |
4581 if (m_pChild == NULL || index == 0) { | 4579 if (m_pChild == NULL || index == 0) { |
4582 if (index > 0) { | 4580 if (index > 0) { |
4583 return -1; | 4581 return -1; |
4584 } | 4582 } |
4585 pNode->m_pNext = m_pChild; | 4583 pNode->m_pNext = m_pChild; |
4586 m_pChild = pNode; | 4584 m_pChild = pNode; |
4587 index = 0; | 4585 index = 0; |
4588 } else if (index < 0) { | 4586 } else if (index < 0) { |
4589 m_pLastChild->m_pNext = pNode; | 4587 m_pLastChild->m_pNext = pNode; |
(...skipping 20 matching lines...) Expand all Loading... |
4610 if (pNotify) | 4608 if (pNotify) |
4611 pNotify->OnChildAdded(this); | 4609 pNotify->OnChildAdded(this); |
4612 | 4610 |
4613 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { | 4611 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
4614 ASSERT(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); | 4612 ASSERT(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); |
4615 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); | 4613 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); |
4616 pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode); | 4614 pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode); |
4617 } | 4615 } |
4618 return index; | 4616 return index; |
4619 } | 4617 } |
| 4618 |
4620 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { | 4619 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { |
4621 if (!pNode || pNode->m_pParent || | 4620 if (!pNode || pNode->m_pParent || |
4622 (pBeforeNode && pBeforeNode->m_pParent != this)) { | 4621 (pBeforeNode && pBeforeNode->m_pParent != this)) { |
4623 ASSERT(false); | 4622 ASSERT(false); |
4624 return FALSE; | 4623 return FALSE; |
4625 } | 4624 } |
4626 FX_BOOL bWasPurgeNode = m_pDocument->RemovePurgeNode(pNode); | 4625 ASSERT(m_pDocument->RemovePurgeNode(pNode)); |
4627 if (!bWasPurgeNode) | |
4628 ASSERT(false); | |
4629 | 4626 |
4630 int32_t nIndex = -1; | 4627 int32_t nIndex = -1; |
4631 pNode->m_pParent = this; | 4628 pNode->m_pParent = this; |
4632 if (m_pChild == NULL || pBeforeNode == m_pChild) { | 4629 if (m_pChild == NULL || pBeforeNode == m_pChild) { |
4633 pNode->m_pNext = m_pChild; | 4630 pNode->m_pNext = m_pChild; |
4634 m_pChild = pNode; | 4631 m_pChild = pNode; |
4635 nIndex = 0; | 4632 nIndex = 0; |
4636 } else if (!pBeforeNode) { | 4633 } else if (!pBeforeNode) { |
4637 pNode->m_pNext = m_pLastChild->m_pNext; | 4634 pNode->m_pNext = m_pLastChild->m_pNext; |
4638 m_pLastChild->m_pNext = pNode; | 4635 m_pLastChild->m_pNext = pNode; |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5380 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5377 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
5381 } | 5378 } |
5382 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5379 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
5383 return m_pAttachNode->RemoveChild(pNode); | 5380 return m_pAttachNode->RemoveChild(pNode); |
5384 } | 5381 } |
5385 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5382 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
5386 return m_pAttachNode->GetChild( | 5383 return m_pAttachNode->GetChild( |
5387 iIndex, XFA_ELEMENT_UNKNOWN, | 5384 iIndex, XFA_ELEMENT_UNKNOWN, |
5388 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5385 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
5389 } | 5386 } |
OLD | NEW |