summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 14:14:16 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 14:14:16 -0400
commit1770c021cf998ff1b33855b1397f6ea8ff9f7cd7 (patch)
tree285e39abd4b5872d8cd632b9e331b0667fdc3eae /xfa/fxfa/parser/xfa_document_datadescription_imp.cpp
parentf766ad219f66543654520f6a1955836f519e26d1 (diff)
downloadpdfium-1770c021cf998ff1b33855b1397f6ea8ff9f7cd7.tar.xz
Move xfa/src up to xfa/.
This CL moves the xfa/src files up to the xfa/ directory and fixes the includes, include guards, and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1803723002 .
Diffstat (limited to 'xfa/fxfa/parser/xfa_document_datadescription_imp.cpp')
-rw-r--r--xfa/fxfa/parser/xfa_document_datadescription_imp.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp
new file mode 100644
index 0000000000..8cc8d01644
--- /dev/null
+++ b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp
@@ -0,0 +1,126 @@
+// Copyright 2014 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/fm2js/xfa_fm2jsapi.h"
+#include "xfa/fxfa/parser/xfa_docdata.h"
+#include "xfa/fxfa/parser/xfa_doclayout.h"
+#include "xfa/fxfa/parser/xfa_document.h"
+#include "xfa/fxfa/parser/xfa_localemgr.h"
+#include "xfa/fxfa/parser/xfa_object.h"
+#include "xfa/fxfa/parser/xfa_parser.h"
+#include "xfa/fxfa/parser/xfa_script.h"
+#include "xfa/fxfa/parser/xfa_utils.h"
+
+#define XFA_HASHCODE_Group 0xf7f75fcd
+
+class CXFA_TraverseStrategy_DDGroup {
+ public:
+ static inline CXFA_Node* GetFirstChild(CXFA_Node* pDDGroupNode) {
+ return pDDGroupNode->GetFirstChildByName(XFA_HASHCODE_Group);
+ }
+ static inline CXFA_Node* GetNextSibling(CXFA_Node* pDDGroupNode) {
+ return pDDGroupNode->GetNextSameNameSibling(XFA_HASHCODE_Group);
+ }
+ static inline CXFA_Node* GetParent(CXFA_Node* pDDGroupNode) {
+ return pDDGroupNode->GetNodeItem(XFA_NODEITEM_Parent);
+ }
+};
+void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode,
+ CXFA_Node* pDataDescriptionNode) {
+ FXSYS_assert(pDataDescriptionNode);
+ for (CXFA_Node* pDataChild = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ pDataChild;
+ pDataChild = pDataChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ FX_DWORD dwNameHash = pDataChild->GetNameHash();
+ XFA_ELEMENT eType = pDataChild->GetClassID();
+ if (!dwNameHash) {
+ continue;
+ }
+ CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup>
+ sIterator(pDataDescriptionNode);
+ for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode;
+ pDDGroupNode = sIterator.MoveToNext()) {
+ if (pDDGroupNode != pDataDescriptionNode) {
+ if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) {
+ continue;
+ }
+ CFX_WideString wsNamespace;
+ if (!pDDGroupNode->TryNamespace(wsNamespace) ||
+ wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) {
+ continue;
+ }
+ }
+ CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(dwNameHash);
+ if (!pDDNode) {
+ continue;
+ }
+ if (pDDNode->GetClassID() != eType) {
+ break;
+ }
+ pDataChild->SetDataDescriptionNode(pDDNode);
+ XFA_DataDescription_UpdateDataRelation(pDataChild, pDDNode);
+ break;
+ }
+ }
+}
+CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
+ CXFA_Document* pDocument,
+ CXFA_Node* pDataParent,
+ XFA_ELEMENT eNodeType,
+ const CFX_WideStringC& wsName) {
+ if (!pDataParent) {
+ return NULL;
+ }
+ CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode();
+ if (!pParentDDNode) {
+ CXFA_Node* pDataNode =
+ pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
+ FXSYS_assert(pDataNode);
+ pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
+ pDataNode->CreateXMLMappingNode();
+ pDataParent->InsertChild(pDataNode);
+ pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ return pDataNode;
+ } else {
+ CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup>
+ sIterator(pParentDDNode);
+ for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode;
+ pDDGroupNode = sIterator.MoveToNext()) {
+ if (pDDGroupNode != pParentDDNode) {
+ if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) {
+ continue;
+ }
+ CFX_WideString wsNamespace;
+ if (!pDDGroupNode->TryNamespace(wsNamespace) ||
+ wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) {
+ continue;
+ }
+ }
+ CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName);
+ if (!pDDNode) {
+ continue;
+ }
+ if (pDDNode->GetClassID() != eNodeType) {
+ break;
+ }
+ CXFA_Node* pDataNode =
+ pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
+ FXSYS_assert(pDataNode);
+ pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
+ pDataNode->CreateXMLMappingNode();
+ if (eNodeType == XFA_ELEMENT_DataValue &&
+ pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) ==
+ XFA_ATTRIBUTEENUM_MetaData) {
+ pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData);
+ }
+ pDataParent->InsertChild(pDataNode);
+ pDataNode->SetDataDescriptionNode(pDDNode);
+ pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ return pDataNode;
+ }
+ return NULL;
+ }
+}