Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_attachnodelist.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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/cxfa_attachnodelist.h"
8
9#include "xfa/fxfa/parser/cxfa_node.h"
10
11CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument,
12 CXFA_Node* pAttachNode)
13 : CXFA_TreeList(pDocument), m_pAttachNode(pAttachNode) {}
14
15CXFA_AttachNodeList::~CXFA_AttachNodeList() = default;
16
17void CXFA_AttachNodeList::Trace(cppgc::Visitor* visitor) const {
18 CXFA_TreeList::Trace(visitor);
19 visitor->Trace(m_pAttachNode);
20}
21
22size_t CXFA_AttachNodeList::GetLength() {
23 return m_pAttachNode->CountChildren(
24 XFA_Element::Unknown,
25 m_pAttachNode->GetElementType() == XFA_Element::Subform);
26}
27
28bool CXFA_AttachNodeList::Append(CXFA_Node* pNode) {
29 if (pNode->IsAncestorOf(m_pAttachNode))
30 return false;
31
32 CXFA_Node* pParent = pNode->GetParent();
33 if (pParent)
34 pParent->RemoveChildAndNotify(pNode, true);
35
36 m_pAttachNode->InsertChildAndNotify(pNode, nullptr);
37 return true;
38}
39
40bool CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) {
41 if (pNewNode->IsAncestorOf(m_pAttachNode))
42 return false;
43
44 if (pBeforeNode && pBeforeNode->GetParent() != m_pAttachNode)
45 return false;
46
47 CXFA_Node* pParent = pNewNode->GetParent();
48 if (pParent)
49 pParent->RemoveChildAndNotify(pNewNode, true);
50
51 m_pAttachNode->InsertChildAndNotify(pNewNode, pBeforeNode);
52 return true;
53}
54
55void CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
56 m_pAttachNode->RemoveChildAndNotify(pNode, true);
57}
58
59CXFA_Node* CXFA_AttachNodeList::Item(size_t index) {
60 return m_pAttachNode->GetChild<CXFA_Node>(
61 index, XFA_Element::Unknown,
62 m_pAttachNode->GetElementType() == XFA_Element::Subform);
63}
~CXFA_AttachNodeList() override
bool Insert(CXFA_Node *pNewNode, CXFA_Node *pBeforeNode) override
void Remove(CXFA_Node *pNode) override
CXFA_Node * Item(size_t iIndex) override
bool Append(CXFA_Node *pNode) override
size_t GetLength() override
void Trace(cppgc::Visitor *visitor) const override
void RemoveChildAndNotify(CXFA_Node *pNode, bool bNotify)
virtual void Trace(cppgc::Visitor *visitor) const
CXFA_TreeList(CXFA_Document *pDocument)
Definition heap.h:12