Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: xfa/src/fxfa/parser/xfa_document_datadescription_imp.cpp

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
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/src/fxfa/fm2js/xfa_fm2jsapi.h"
8 #include "xfa/src/fxfa/parser/xfa_docdata.h"
9 #include "xfa/src/fxfa/parser/xfa_doclayout.h"
10 #include "xfa/src/fxfa/parser/xfa_document.h"
11 #include "xfa/src/fxfa/parser/xfa_localemgr.h"
12 #include "xfa/src/fxfa/parser/xfa_object.h"
13 #include "xfa/src/fxfa/parser/xfa_parser.h"
14 #include "xfa/src/fxfa/parser/xfa_script.h"
15 #include "xfa/src/fxfa/parser/xfa_utils.h"
16
17 #define XFA_HASHCODE_Group 0xf7f75fcd
18
19 class CXFA_TraverseStrategy_DDGroup {
20 public:
21 static inline CXFA_Node* GetFirstChild(CXFA_Node* pDDGroupNode) {
22 return pDDGroupNode->GetFirstChildByName(XFA_HASHCODE_Group);
23 }
24 static inline CXFA_Node* GetNextSibling(CXFA_Node* pDDGroupNode) {
25 return pDDGroupNode->GetNextSameNameSibling(XFA_HASHCODE_Group);
26 }
27 static inline CXFA_Node* GetParent(CXFA_Node* pDDGroupNode) {
28 return pDDGroupNode->GetNodeItem(XFA_NODEITEM_Parent);
29 }
30 };
31 void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode,
32 CXFA_Node* pDataDescriptionNode) {
33 FXSYS_assert(pDataDescriptionNode);
34 for (CXFA_Node* pDataChild = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild);
35 pDataChild;
36 pDataChild = pDataChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
37 FX_DWORD dwNameHash = pDataChild->GetNameHash();
38 XFA_ELEMENT eType = pDataChild->GetClassID();
39 if (!dwNameHash) {
40 continue;
41 }
42 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup>
43 sIterator(pDataDescriptionNode);
44 for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode;
45 pDDGroupNode = sIterator.MoveToNext()) {
46 if (pDDGroupNode != pDataDescriptionNode) {
47 if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) {
48 continue;
49 }
50 CFX_WideString wsNamespace;
51 if (!pDDGroupNode->TryNamespace(wsNamespace) ||
52 wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) {
53 continue;
54 }
55 }
56 CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(dwNameHash);
57 if (!pDDNode) {
58 continue;
59 }
60 if (pDDNode->GetClassID() != eType) {
61 break;
62 }
63 pDataChild->SetDataDescriptionNode(pDDNode);
64 XFA_DataDescription_UpdateDataRelation(pDataChild, pDDNode);
65 break;
66 }
67 }
68 }
69 CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
70 CXFA_Document* pDocument,
71 CXFA_Node* pDataParent,
72 XFA_ELEMENT eNodeType,
73 const CFX_WideStringC& wsName) {
74 if (!pDataParent) {
75 return NULL;
76 }
77 CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode();
78 if (!pParentDDNode) {
79 CXFA_Node* pDataNode =
80 pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
81 FXSYS_assert(pDataNode);
82 pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
83 pDataNode->CreateXMLMappingNode();
84 pDataParent->InsertChild(pDataNode);
85 pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
86 return pDataNode;
87 } else {
88 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup>
89 sIterator(pParentDDNode);
90 for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode;
91 pDDGroupNode = sIterator.MoveToNext()) {
92 if (pDDGroupNode != pParentDDNode) {
93 if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) {
94 continue;
95 }
96 CFX_WideString wsNamespace;
97 if (!pDDGroupNode->TryNamespace(wsNamespace) ||
98 wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) {
99 continue;
100 }
101 }
102 CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName);
103 if (!pDDNode) {
104 continue;
105 }
106 if (pDDNode->GetClassID() != eNodeType) {
107 break;
108 }
109 CXFA_Node* pDataNode =
110 pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
111 FXSYS_assert(pDataNode);
112 pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
113 pDataNode->CreateXMLMappingNode();
114 if (eNodeType == XFA_ELEMENT_DataValue &&
115 pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) ==
116 XFA_ATTRIBUTEENUM_MetaData) {
117 pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData);
118 }
119 pDataParent->InsertChild(pDataNode);
120 pDataNode->SetDataDescriptionNode(pDDNode);
121 pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
122 return pDataNode;
123 }
124 return NULL;
125 }
126 }
OLDNEW
« no previous file with comments | « xfa/src/fxfa/parser/xfa_document_datadescription_imp.h ('k') | xfa/src/fxfa/parser/xfa_document_datamerger_imp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698