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/fm2js/xfa_fm2jsapi.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
8 #include "xfa/fxfa/parser/xfa_doclayout.h" | 8 #include "xfa/fxfa/parser/xfa_doclayout.h" |
9 #include "xfa/fxfa/parser/xfa_document.h" | 9 #include "xfa/fxfa/parser/xfa_document.h" |
10 #include "xfa/fxfa/parser/xfa_localemgr.h" | 10 #include "xfa/fxfa/parser/xfa_localemgr.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 pDataChild->SetDataDescriptionNode(pDDNode); | 62 pDataChild->SetDataDescriptionNode(pDDNode); |
63 XFA_DataDescription_UpdateDataRelation(pDataChild, pDDNode); | 63 XFA_DataDescription_UpdateDataRelation(pDataChild, pDDNode); |
64 break; | 64 break; |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 CXFA_Node* XFA_DataDescription_MaybeCreateDataNode( | 68 CXFA_Node* XFA_DataDescription_MaybeCreateDataNode( |
69 CXFA_Document* pDocument, | 69 CXFA_Document* pDocument, |
70 CXFA_Node* pDataParent, | 70 CXFA_Node* pDataParent, |
71 XFA_ELEMENT eNodeType, | 71 XFA_ELEMENT eNodeType, |
72 const CFX_WideStringC& wsName) { | 72 const CFX_WideString& wsName) { |
73 if (!pDataParent) { | 73 if (!pDataParent) { |
74 return NULL; | 74 return NULL; |
75 } | 75 } |
76 CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode(); | 76 CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode(); |
77 if (!pParentDDNode) { | 77 if (!pParentDDNode) { |
78 CXFA_Node* pDataNode = | 78 CXFA_Node* pDataNode = |
79 pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); | 79 pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); |
80 ASSERT(pDataNode); | 80 ASSERT(pDataNode); |
81 pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); | 81 pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); |
82 pDataNode->CreateXMLMappingNode(); | 82 pDataNode->CreateXMLMappingNode(); |
83 pDataParent->InsertChild(pDataNode); | 83 pDataParent->InsertChild(pDataNode); |
84 pDataNode->SetFlag(XFA_NODEFLAG_Initialized, false); | 84 pDataNode->SetFlag(XFA_NODEFLAG_Initialized, false); |
85 return pDataNode; | 85 return pDataNode; |
86 } else { | 86 } else { |
87 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup> | 87 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup> |
88 sIterator(pParentDDNode); | 88 sIterator(pParentDDNode); |
89 for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; | 89 for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; |
90 pDDGroupNode = sIterator.MoveToNext()) { | 90 pDDGroupNode = sIterator.MoveToNext()) { |
91 if (pDDGroupNode != pParentDDNode) { | 91 if (pDDGroupNode != pParentDDNode) { |
92 if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) { | 92 if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) { |
93 continue; | 93 continue; |
94 } | 94 } |
95 CFX_WideString wsNamespace; | 95 CFX_WideString wsNamespace; |
96 if (!pDDGroupNode->TryNamespace(wsNamespace) || | 96 if (!pDDGroupNode->TryNamespace(wsNamespace) || |
97 wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { | 97 wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { |
98 continue; | 98 continue; |
99 } | 99 } |
100 } | 100 } |
101 CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName); | 101 CXFA_Node* pDDNode = |
| 102 pDDGroupNode->GetFirstChildByName(wsName.AsStringC()); |
102 if (!pDDNode) { | 103 if (!pDDNode) { |
103 continue; | 104 continue; |
104 } | 105 } |
105 if (pDDNode->GetClassID() != eNodeType) { | 106 if (pDDNode->GetClassID() != eNodeType) { |
106 break; | 107 break; |
107 } | 108 } |
108 CXFA_Node* pDataNode = | 109 CXFA_Node* pDataNode = |
109 pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); | 110 pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); |
110 ASSERT(pDataNode); | 111 ASSERT(pDataNode); |
111 pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); | 112 pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); |
112 pDataNode->CreateXMLMappingNode(); | 113 pDataNode->CreateXMLMappingNode(); |
113 if (eNodeType == XFA_ELEMENT_DataValue && | 114 if (eNodeType == XFA_ELEMENT_DataValue && |
114 pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) == | 115 pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) == |
115 XFA_ATTRIBUTEENUM_MetaData) { | 116 XFA_ATTRIBUTEENUM_MetaData) { |
116 pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData); | 117 pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData); |
117 } | 118 } |
118 pDataParent->InsertChild(pDataNode); | 119 pDataParent->InsertChild(pDataNode); |
119 pDataNode->SetDataDescriptionNode(pDDNode); | 120 pDataNode->SetDataDescriptionNode(pDDNode); |
120 pDataNode->SetFlag(XFA_NODEFLAG_Initialized, false); | 121 pDataNode->SetFlag(XFA_NODEFLAG_Initialized, false); |
121 return pDataNode; | 122 return pDataNode; |
122 } | 123 } |
123 return NULL; | 124 return NULL; |
124 } | 125 } |
125 } | 126 } |
OLD | NEW |