summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_attachnodelist.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-19 10:56:23 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-19 10:56:24 -0700
commit5b36f0a0eff7f3666a0e642640db3c89e4bb6748 (patch)
tree1c9c719ea55062ac7bf36dbee7dfb9e9753471dc /xfa/fxfa/parser/cxfa_attachnodelist.cpp
parenteea31b75a11215aa72a9845d47c38d2ce1edd4f7 (diff)
downloadpdfium-5b36f0a0eff7f3666a0e642640db3c89e4bb6748.tar.xz
Split xfa_object_imp into individual class files.
This CL splits the CXFA_Object, CXFA_NodeList, CXFA_ThisProxy, CXFA_ArrayNodeList and CXFA_AttachNodeList out of xfa_object_imp. xfa_object_imp is then renamed to CXFA_Node. Review-Url: https://codereview.chromium.org/2159973003
Diffstat (limited to 'xfa/fxfa/parser/cxfa_attachnodelist.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_attachnodelist.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_attachnodelist.cpp b/xfa/fxfa/parser/cxfa_attachnodelist.cpp
new file mode 100644
index 0000000000..fb8d026698
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_attachnodelist.cpp
@@ -0,0 +1,46 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument,
+ CXFA_Node* pAttachNode)
+ : CXFA_NodeList(pDocument) {
+ m_pAttachNode = pAttachNode;
+}
+
+int32_t CXFA_AttachNodeList::GetLength() {
+ return m_pAttachNode->CountChildren(
+ XFA_Element::Unknown,
+ m_pAttachNode->GetElementType() == XFA_Element::Subform);
+}
+
+FX_BOOL CXFA_AttachNodeList::Append(CXFA_Node* pNode) {
+ CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (pParent) {
+ pParent->RemoveChild(pNode);
+ }
+ return m_pAttachNode->InsertChild(pNode);
+}
+
+FX_BOOL CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode,
+ CXFA_Node* pBeforeNode) {
+ CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (pParent) {
+ pParent->RemoveChild(pNewNode);
+ }
+ return m_pAttachNode->InsertChild(pNewNode, pBeforeNode);
+}
+
+FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
+ return m_pAttachNode->RemoveChild(pNode);
+}
+
+CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) {
+ return m_pAttachNode->GetChild(
+ iIndex, XFA_Element::Unknown,
+ m_pAttachNode->GetElementType() == XFA_Element::Subform);
+}