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/parser/xfa_document_datamerger_imp.h" | 7 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 CXFA_Occur occur(pOccurNode); | 32 CXFA_Occur occur(pOccurNode); |
33 return occur.GetOccurInfo(iMin, iMax, iInit); | 33 return occur.GetOccurInfo(iMin, iMax, iInit); |
34 } | 34 } |
35 struct XFA_DataMerge_RecurseRecord { | 35 struct XFA_DataMerge_RecurseRecord { |
36 CXFA_Node* pTemplateChild; | 36 CXFA_Node* pTemplateChild; |
37 CXFA_Node* pDataChild; | 37 CXFA_Node* pDataChild; |
38 }; | 38 }; |
39 static CXFA_Node* XFA_DataMerge_FormValueNode_CreateChild( | 39 static CXFA_Node* XFA_DataMerge_FormValueNode_CreateChild( |
40 CXFA_Node* pValueNode, | 40 CXFA_Node* pValueNode, |
41 XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) { | 41 XFA_Element iType = XFA_Element::Unknown) { |
42 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 42 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
43 if (!pChildNode) { | 43 if (!pChildNode) { |
44 if (iType == XFA_ELEMENT_UNKNOWN) { | 44 if (iType == XFA_Element::Unknown) { |
45 return FALSE; | 45 return FALSE; |
46 } | 46 } |
47 pChildNode = pValueNode->GetProperty(0, iType); | 47 pChildNode = pValueNode->GetProperty(0, iType); |
48 } | 48 } |
49 return pChildNode; | 49 return pChildNode; |
50 } | 50 } |
51 static void XFA_DataMerge_FormValueNode_MatchNoneCreateChild( | 51 static void XFA_DataMerge_FormValueNode_MatchNoneCreateChild( |
52 CXFA_Node* pFormNode) { | 52 CXFA_Node* pFormNode) { |
53 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); | 53 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); |
54 ASSERT(pWidgetData); | 54 ASSERT(pWidgetData); |
55 pWidgetData->GetUIType(); | 55 pWidgetData->GetUIType(); |
56 } | 56 } |
57 static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent( | 57 static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent( |
58 CXFA_Node* pValueNode, | 58 CXFA_Node* pValueNode, |
59 const CFX_WideString& wsContent, | 59 const CFX_WideString& wsContent, |
60 XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) { | 60 XFA_Element iType = XFA_Element::Unknown) { |
61 if (!pValueNode) { | 61 if (!pValueNode) { |
62 return FALSE; | 62 return FALSE; |
63 } | 63 } |
64 ASSERT(pValueNode->GetPacketID() == XFA_XDPPACKET_Form); | 64 ASSERT(pValueNode->GetPacketID() == XFA_XDPPACKET_Form); |
65 CXFA_Node* pChildNode = | 65 CXFA_Node* pChildNode = |
66 XFA_DataMerge_FormValueNode_CreateChild(pValueNode, iType); | 66 XFA_DataMerge_FormValueNode_CreateChild(pValueNode, iType); |
67 if (!pChildNode) | 67 if (!pChildNode) |
68 return FALSE; | 68 return FALSE; |
69 | 69 |
70 switch (pChildNode->GetObjectType()) { | 70 switch (pChildNode->GetObjectType()) { |
71 case XFA_ObjectType::ContentNode: { | 71 case XFA_ObjectType::ContentNode: { |
72 CXFA_Node* pContentRawDataNode = | 72 CXFA_Node* pContentRawDataNode = |
73 pChildNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 73 pChildNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
74 if (!pContentRawDataNode) { | 74 if (!pContentRawDataNode) { |
75 XFA_ELEMENT element = XFA_ELEMENT_Sharptext; | 75 XFA_Element element = XFA_Element::Sharptext; |
76 if (pChildNode->GetClassID() == XFA_ELEMENT_ExData) { | 76 if (pChildNode->GetClassID() == XFA_Element::ExData) { |
77 CFX_WideString wsContentType; | 77 CFX_WideString wsContentType; |
78 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, | 78 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, |
79 FALSE); | 79 FALSE); |
80 if (wsContentType == FX_WSTRC(L"text/html")) { | 80 if (wsContentType == FX_WSTRC(L"text/html")) { |
81 element = XFA_ELEMENT_SharpxHTML; | 81 element = XFA_Element::SharpxHTML; |
82 } else if (wsContentType == FX_WSTRC(L"text/xml")) { | 82 } else if (wsContentType == FX_WSTRC(L"text/xml")) { |
83 element = XFA_ELEMENT_Sharpxml; | 83 element = XFA_Element::Sharpxml; |
84 } | 84 } |
85 } | 85 } |
86 pContentRawDataNode = pChildNode->CreateSamePacketNode(element); | 86 pContentRawDataNode = pChildNode->CreateSamePacketNode(element); |
87 pChildNode->InsertChild(pContentRawDataNode); | 87 pChildNode->InsertChild(pContentRawDataNode); |
88 } | 88 } |
89 pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); | 89 pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); |
90 } break; | 90 } break; |
91 case XFA_ObjectType::NodeC: | 91 case XFA_ObjectType::NodeC: |
92 case XFA_ObjectType::TextNode: | 92 case XFA_ObjectType::TextNode: |
93 case XFA_ObjectType::NodeV: { | 93 case XFA_ObjectType::NodeV: { |
94 pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); | 94 pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); |
95 } break; | 95 } break; |
96 default: | 96 default: |
97 ASSERT(FALSE); | 97 ASSERT(FALSE); |
98 break; | 98 break; |
99 } | 99 } |
100 return TRUE; | 100 return TRUE; |
101 } | 101 } |
102 static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, | 102 static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, |
103 CXFA_Node* pDataNode, | 103 CXFA_Node* pDataNode, |
104 FX_BOOL bDataToForm = TRUE) { | 104 FX_BOOL bDataToForm = TRUE) { |
105 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode); | 105 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode); |
106 pDataNode->AddBindItem(pFormNode); | 106 pDataNode->AddBindItem(pFormNode); |
107 XFA_ELEMENT eClass = pFormNode->GetClassID(); | 107 XFA_Element eClass = pFormNode->GetClassID(); |
108 if (eClass != XFA_ELEMENT_Field && eClass != XFA_ELEMENT_ExclGroup) { | 108 if (eClass != XFA_Element::Field && eClass != XFA_Element::ExclGroup) { |
109 return; | 109 return; |
110 } | 110 } |
111 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); | 111 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); |
112 ASSERT(pWidgetData); | 112 ASSERT(pWidgetData); |
113 XFA_ELEMENT eUIType = pWidgetData->GetUIType(); | 113 XFA_Element eUIType = pWidgetData->GetUIType(); |
114 CXFA_Value defValue(pFormNode->GetProperty(0, XFA_ELEMENT_Value)); | 114 CXFA_Value defValue(pFormNode->GetProperty(0, XFA_Element::Value)); |
115 if (!bDataToForm) { | 115 if (!bDataToForm) { |
116 CFX_WideString wsValue; | 116 CFX_WideString wsValue; |
117 CFX_WideString wsFormatedValue; | 117 CFX_WideString wsFormatedValue; |
118 switch (eUIType) { | 118 switch (eUIType) { |
119 case XFA_ELEMENT_ImageEdit: { | 119 case XFA_Element::ImageEdit: { |
120 CXFA_Image image = defValue.GetImage(); | 120 CXFA_Image image = defValue.GetImage(); |
121 CFX_WideString wsContentType; | 121 CFX_WideString wsContentType; |
122 CFX_WideString wsHref; | 122 CFX_WideString wsHref; |
123 if (image) { | 123 if (image) { |
124 image.GetContent(wsValue); | 124 image.GetContent(wsValue); |
125 image.GetContentType(wsContentType); | 125 image.GetContentType(wsContentType); |
126 image.GetHref(wsHref); | 126 image.GetHref(wsHref); |
127 } | 127 } |
128 CFDE_XMLElement* pXMLDataElement = | 128 CFDE_XMLElement* pXMLDataElement = |
129 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); | 129 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); |
130 ASSERT(pXMLDataElement); | 130 ASSERT(pXMLDataElement); |
131 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 131 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); |
132 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 132 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
133 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); | 133 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); |
134 if (!wsHref.IsEmpty()) { | 134 if (!wsHref.IsEmpty()) { |
135 pXMLDataElement->SetString(L"href", wsHref); | 135 pXMLDataElement->SetString(L"href", wsHref); |
136 } | 136 } |
137 } break; | 137 } break; |
138 case XFA_ELEMENT_ChoiceList: | 138 case XFA_Element::ChoiceList: |
139 defValue.GetChildValueContent(wsValue); | 139 defValue.GetChildValueContent(wsValue); |
140 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 140 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
141 CFX_WideStringArray wsSelTextArray; | 141 CFX_WideStringArray wsSelTextArray; |
142 pWidgetData->GetSelectedItemsValue(wsSelTextArray); | 142 pWidgetData->GetSelectedItemsValue(wsSelTextArray); |
143 int32_t iSize = wsSelTextArray.GetSize(); | 143 int32_t iSize = wsSelTextArray.GetSize(); |
144 if (iSize >= 1) { | 144 if (iSize >= 1) { |
145 CXFA_Node* pValue = NULL; | 145 CXFA_Node* pValue = NULL; |
146 for (int32_t i = 0; i < iSize; i++) { | 146 for (int32_t i = 0; i < iSize; i++) { |
147 pValue = pDataNode->CreateSamePacketNode(XFA_ELEMENT_DataValue); | 147 pValue = pDataNode->CreateSamePacketNode(XFA_Element::DataValue); |
148 pValue->SetCData(XFA_ATTRIBUTE_Name, L"value"); | 148 pValue->SetCData(XFA_ATTRIBUTE_Name, L"value"); |
149 pValue->CreateXMLMappingNode(); | 149 pValue->CreateXMLMappingNode(); |
150 pDataNode->InsertChild(pValue); | 150 pDataNode->InsertChild(pValue); |
151 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); | 151 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); |
152 } | 152 } |
153 } else { | 153 } else { |
154 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); | 154 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); |
155 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); | 155 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); |
156 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", | 156 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", |
157 L"dataGroup"); | 157 L"dataGroup"); |
158 } | 158 } |
159 } else if (!wsValue.IsEmpty()) { | 159 } else if (!wsValue.IsEmpty()) { |
160 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 160 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); |
161 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 161 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
162 } | 162 } |
163 break; | 163 break; |
164 case XFA_ELEMENT_CheckButton: | 164 case XFA_Element::CheckButton: |
165 defValue.GetChildValueContent(wsValue); | 165 defValue.GetChildValueContent(wsValue); |
166 if (wsValue.IsEmpty()) { | 166 if (wsValue.IsEmpty()) { |
167 break; | 167 break; |
168 } | 168 } |
169 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 169 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); |
170 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 170 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
171 break; | 171 break; |
172 case XFA_ELEMENT_ExclGroup: { | 172 case XFA_Element::ExclGroup: { |
173 CXFA_Node* pChecked = NULL; | 173 CXFA_Node* pChecked = NULL; |
174 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 174 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
175 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 175 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
176 if (pChild->GetClassID() != XFA_ELEMENT_Field) { | 176 if (pChild->GetClassID() != XFA_Element::Field) { |
177 continue; | 177 continue; |
178 } | 178 } |
179 CXFA_Node* pValue = pChild->GetChild(0, XFA_ELEMENT_Value); | 179 CXFA_Node* pValue = pChild->GetChild(0, XFA_Element::Value); |
180 if (!pValue) { | 180 if (!pValue) { |
181 continue; | 181 continue; |
182 } | 182 } |
183 CXFA_Value valueChild(pValue); | 183 CXFA_Value valueChild(pValue); |
184 valueChild.GetChildValueContent(wsValue); | 184 valueChild.GetChildValueContent(wsValue); |
185 if (wsValue.IsEmpty()) { | 185 if (wsValue.IsEmpty()) { |
186 continue; | 186 continue; |
187 } | 187 } |
188 CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); | 188 CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); |
189 if (!pItems) { | 189 if (!pItems) { |
190 continue; | 190 continue; |
191 } | 191 } |
192 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); | 192 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); |
193 if (!pText) { | 193 if (!pText) { |
194 continue; | 194 continue; |
195 } | 195 } |
196 CFX_WideString wsContent; | 196 CFX_WideString wsContent; |
197 if (pText->TryContent(wsContent) && (wsContent == wsValue)) { | 197 if (pText->TryContent(wsContent) && (wsContent == wsValue)) { |
198 pChecked = pChild; | 198 pChecked = pChild; |
199 wsFormatedValue = wsValue; | 199 wsFormatedValue = wsValue; |
200 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 200 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
201 pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); | 201 pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); |
202 break; | 202 break; |
203 } | 203 } |
204 } | 204 } |
205 if (!pChecked) { | 205 if (!pChecked) { |
206 break; | 206 break; |
207 } | 207 } |
208 pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 208 pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
209 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 209 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
210 if (pChild == pChecked) { | 210 if (pChild == pChecked) { |
211 continue; | 211 continue; |
212 } | 212 } |
213 if (pChild->GetClassID() != XFA_ELEMENT_Field) { | 213 if (pChild->GetClassID() != XFA_Element::Field) { |
214 continue; | 214 continue; |
215 } | 215 } |
216 CXFA_Node* pValue = pChild->GetProperty(0, XFA_ELEMENT_Value); | 216 CXFA_Node* pValue = pChild->GetProperty(0, XFA_Element::Value); |
217 CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); | 217 CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); |
218 CXFA_Node* pText = | 218 CXFA_Node* pText = |
219 pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; | 219 pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; |
220 if (pText) { | 220 if (pText) { |
221 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); | 221 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); |
222 } | 222 } |
223 CFX_WideString wsContent; | 223 CFX_WideString wsContent; |
224 if (pText) { | 224 if (pText) { |
225 pText->TryContent(wsContent); | 225 pText->TryContent(wsContent); |
226 } | 226 } |
227 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsContent, | 227 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsContent, |
228 XFA_ELEMENT_Text); | 228 XFA_Element::Text); |
229 } | 229 } |
230 } break; | 230 } break; |
231 case XFA_ELEMENT_NumericEdit: { | 231 case XFA_Element::NumericEdit: { |
232 defValue.GetChildValueContent(wsValue); | 232 defValue.GetChildValueContent(wsValue); |
233 if (wsValue.IsEmpty()) { | 233 if (wsValue.IsEmpty()) { |
234 break; | 234 break; |
235 } | 235 } |
236 CFX_WideString wsOutput; | 236 CFX_WideString wsOutput; |
237 pWidgetData->NormalizeNumStr(wsValue, wsOutput); | 237 pWidgetData->NormalizeNumStr(wsValue, wsOutput); |
238 wsValue = wsOutput; | 238 wsValue = wsOutput; |
239 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 239 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); |
240 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 240 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
241 CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_ELEMENT_Value); | 241 CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_Element::Value); |
242 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue, | 242 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue, |
243 XFA_ELEMENT_Float); | 243 XFA_Element::Float); |
244 } break; | 244 } break; |
245 default: | 245 default: |
246 defValue.GetChildValueContent(wsValue); | 246 defValue.GetChildValueContent(wsValue); |
247 if (wsValue.IsEmpty()) { | 247 if (wsValue.IsEmpty()) { |
248 break; | 248 break; |
249 } | 249 } |
250 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 250 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); |
251 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 251 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
252 break; | 252 break; |
253 } | 253 } |
254 } else { | 254 } else { |
255 CFX_WideString wsXMLValue; | 255 CFX_WideString wsXMLValue; |
256 pDataNode->TryContent(wsXMLValue); | 256 pDataNode->TryContent(wsXMLValue); |
257 CFX_WideString wsNormailizeValue; | 257 CFX_WideString wsNormailizeValue; |
258 pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormailizeValue); | 258 pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormailizeValue); |
259 pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue); | 259 pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue); |
260 switch (eUIType) { | 260 switch (eUIType) { |
261 case XFA_ELEMENT_ImageEdit: { | 261 case XFA_Element::ImageEdit: { |
262 XFA_DataMerge_FormValueNode_SetChildContent( | 262 XFA_DataMerge_FormValueNode_SetChildContent( |
263 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Image); | 263 defValue.GetNode(), wsNormailizeValue, XFA_Element::Image); |
264 CXFA_Image image = defValue.GetImage(); | 264 CXFA_Image image = defValue.GetImage(); |
265 if (image) { | 265 if (image) { |
266 CFDE_XMLElement* pXMLDataElement = | 266 CFDE_XMLElement* pXMLDataElement = |
267 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); | 267 static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode()); |
268 ASSERT(pXMLDataElement); | 268 ASSERT(pXMLDataElement); |
269 CFX_WideString wsContentType; | 269 CFX_WideString wsContentType; |
270 CFX_WideString wsHref; | 270 CFX_WideString wsHref; |
271 pXMLDataElement->GetString(L"xfa:contentType", wsContentType); | 271 pXMLDataElement->GetString(L"xfa:contentType", wsContentType); |
272 if (!wsContentType.IsEmpty()) { | 272 if (!wsContentType.IsEmpty()) { |
273 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); | 273 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); |
274 image.SetContentType(wsContentType); | 274 image.SetContentType(wsContentType); |
275 } | 275 } |
276 pXMLDataElement->GetString(L"href", wsHref); | 276 pXMLDataElement->GetString(L"href", wsHref); |
277 if (!wsHref.IsEmpty()) { | 277 if (!wsHref.IsEmpty()) { |
278 image.SetHref(wsHref); | 278 image.SetHref(wsHref); |
279 } | 279 } |
280 } | 280 } |
281 } break; | 281 } break; |
282 case XFA_ELEMENT_ChoiceList: | 282 case XFA_Element::ChoiceList: |
283 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 283 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
284 CXFA_NodeArray items; | 284 CXFA_NodeArray items; |
285 pDataNode->GetNodeList(items); | 285 pDataNode->GetNodeList(items); |
286 int32_t iCounts = items.GetSize(); | 286 int32_t iCounts = items.GetSize(); |
287 if (iCounts > 0) { | 287 if (iCounts > 0) { |
288 wsNormailizeValue.clear(); | 288 wsNormailizeValue.clear(); |
289 CFX_WideString wsItem; | 289 CFX_WideString wsItem; |
290 for (int32_t i = 0; i < iCounts; i++) { | 290 for (int32_t i = 0; i < iCounts; i++) { |
291 items[i]->TryContent(wsItem); | 291 items[i]->TryContent(wsItem); |
292 wsItem = (iCounts == 1) ? wsItem : wsItem + FX_WSTRC(L"\n"); | 292 wsItem = (iCounts == 1) ? wsItem : wsItem + FX_WSTRC(L"\n"); |
293 wsNormailizeValue += wsItem; | 293 wsNormailizeValue += wsItem; |
294 } | 294 } |
295 CXFA_ExData exData = defValue.GetExData(); | 295 CXFA_ExData exData = defValue.GetExData(); |
296 ASSERT(exData); | 296 ASSERT(exData); |
297 exData.SetContentType(iCounts == 1 ? L"text/plain" : L"text/xml"); | 297 exData.SetContentType(iCounts == 1 ? L"text/plain" : L"text/xml"); |
298 } | 298 } |
299 XFA_DataMerge_FormValueNode_SetChildContent( | 299 XFA_DataMerge_FormValueNode_SetChildContent( |
300 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_ExData); | 300 defValue.GetNode(), wsNormailizeValue, XFA_Element::ExData); |
301 } else { | 301 } else { |
302 XFA_DataMerge_FormValueNode_SetChildContent( | 302 XFA_DataMerge_FormValueNode_SetChildContent( |
303 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); | 303 defValue.GetNode(), wsNormailizeValue, XFA_Element::Text); |
304 } | 304 } |
305 break; | 305 break; |
306 case XFA_ELEMENT_CheckButton: | 306 case XFA_Element::CheckButton: |
307 XFA_DataMerge_FormValueNode_SetChildContent( | 307 XFA_DataMerge_FormValueNode_SetChildContent( |
308 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); | 308 defValue.GetNode(), wsNormailizeValue, XFA_Element::Text); |
309 break; | 309 break; |
310 case XFA_ELEMENT_ExclGroup: { | 310 case XFA_Element::ExclGroup: { |
311 pWidgetData->SetSelectedMemberByValue(wsNormailizeValue.AsStringC(), | 311 pWidgetData->SetSelectedMemberByValue(wsNormailizeValue.AsStringC(), |
312 false, FALSE, FALSE); | 312 false, FALSE, FALSE); |
313 } break; | 313 } break; |
314 case XFA_ELEMENT_DateTimeEdit: | 314 case XFA_Element::DateTimeEdit: |
315 XFA_DataMerge_FormValueNode_SetChildContent( | 315 XFA_DataMerge_FormValueNode_SetChildContent( |
316 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_DateTime); | 316 defValue.GetNode(), wsNormailizeValue, XFA_Element::DateTime); |
317 break; | 317 break; |
318 case XFA_ELEMENT_NumericEdit: { | 318 case XFA_Element::NumericEdit: { |
319 CFX_WideString wsPicture; | 319 CFX_WideString wsPicture; |
320 pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); | 320 pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); |
321 if (wsPicture.IsEmpty()) { | 321 if (wsPicture.IsEmpty()) { |
322 CFX_WideString wsOutput; | 322 CFX_WideString wsOutput; |
323 pWidgetData->NormalizeNumStr(wsNormailizeValue, wsOutput); | 323 pWidgetData->NormalizeNumStr(wsNormailizeValue, wsOutput); |
324 wsNormailizeValue = wsOutput; | 324 wsNormailizeValue = wsOutput; |
325 } | 325 } |
326 XFA_DataMerge_FormValueNode_SetChildContent( | 326 XFA_DataMerge_FormValueNode_SetChildContent( |
327 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Float); | 327 defValue.GetNode(), wsNormailizeValue, XFA_Element::Float); |
328 } break; | 328 } break; |
329 case XFA_ELEMENT_Barcode: | 329 case XFA_Element::Barcode: |
330 case XFA_ELEMENT_Button: | 330 case XFA_Element::Button: |
331 case XFA_ELEMENT_PasswordEdit: | 331 case XFA_Element::PasswordEdit: |
332 case XFA_ELEMENT_Signature: | 332 case XFA_Element::Signature: |
333 case XFA_ELEMENT_TextEdit: | 333 case XFA_Element::TextEdit: |
334 default: | 334 default: |
335 XFA_DataMerge_FormValueNode_SetChildContent( | 335 XFA_DataMerge_FormValueNode_SetChildContent( |
336 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); | 336 defValue.GetNode(), wsNormailizeValue, XFA_Element::Text); |
337 break; | 337 break; |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 static CXFA_Node* XFA_DataMerge_GetGlobalBinding(CXFA_Document* pDocument, | 341 static CXFA_Node* XFA_DataMerge_GetGlobalBinding(CXFA_Document* pDocument, |
342 uint32_t dwNameHash) { | 342 uint32_t dwNameHash) { |
343 CXFA_Node* pNode = NULL; | 343 CXFA_Node* pNode = NULL; |
344 pDocument->m_rgGlobalBinding.Lookup(dwNameHash, pNode); | 344 pDocument->m_rgGlobalBinding.Lookup(dwNameHash, pNode); |
345 return pNode; | 345 return pNode; |
346 } | 346 } |
347 static void XFA_DataMerge_RegisterGlobalBinding(CXFA_Document* pDocument, | 347 static void XFA_DataMerge_RegisterGlobalBinding(CXFA_Document* pDocument, |
348 uint32_t dwNameHash, | 348 uint32_t dwNameHash, |
349 CXFA_Node* pDataNode) { | 349 CXFA_Node* pDataNode) { |
350 pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode); | 350 pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode); |
351 } | 351 } |
352 static void XFA_DataMerge_ClearGlobalBinding(CXFA_Document* pDocument) { | 352 static void XFA_DataMerge_ClearGlobalBinding(CXFA_Document* pDocument) { |
353 pDocument->m_rgGlobalBinding.RemoveAll(); | 353 pDocument->m_rgGlobalBinding.RemoveAll(); |
354 } | 354 } |
355 static CXFA_Node* XFA_DataMerge_ScopeMatchGlobalBinding( | 355 static CXFA_Node* XFA_DataMerge_ScopeMatchGlobalBinding( |
356 CXFA_Node* pDataScope, | 356 CXFA_Node* pDataScope, |
357 uint32_t dwNameHash, | 357 uint32_t dwNameHash, |
358 XFA_ELEMENT eMatchDataNodeType, | 358 XFA_Element eMatchDataNodeType, |
359 FX_BOOL bUpLevel = TRUE) { | 359 FX_BOOL bUpLevel = TRUE) { |
360 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL; | 360 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL; |
361 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; | 361 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; |
362 pLastDataScope = pCurDataScope, | 362 pLastDataScope = pCurDataScope, |
363 pCurDataScope = | 363 pCurDataScope = |
364 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { | 364 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { |
365 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); | 365 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); |
366 pDataChild; | 366 pDataChild; |
367 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { | 367 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { |
368 if (pDataChild == pLastDataScope || | 368 if (pDataChild == pLastDataScope || |
369 (eMatchDataNodeType != XFA_ELEMENT_DataModel && | 369 (eMatchDataNodeType != XFA_Element::DataModel && |
370 pDataChild->GetClassID() != eMatchDataNodeType) || | 370 pDataChild->GetClassID() != eMatchDataNodeType) || |
371 pDataChild->HasBindItem()) { | 371 pDataChild->HasBindItem()) { |
372 continue; | 372 continue; |
373 } | 373 } |
374 return pDataChild; | 374 return pDataChild; |
375 } | 375 } |
376 for (CXFA_Node* pDataChild = | 376 for (CXFA_Node* pDataChild = |
377 pCurDataScope->GetFirstChildByClass(XFA_ELEMENT_DataGroup); | 377 pCurDataScope->GetFirstChildByClass(XFA_Element::DataGroup); |
378 pDataChild; pDataChild = pDataChild->GetNextSameClassSibling( | 378 pDataChild; pDataChild = pDataChild->GetNextSameClassSibling( |
379 XFA_ELEMENT_DataGroup)) { | 379 XFA_Element::DataGroup)) { |
380 CXFA_Node* pDataNode = XFA_DataMerge_ScopeMatchGlobalBinding( | 380 CXFA_Node* pDataNode = XFA_DataMerge_ScopeMatchGlobalBinding( |
381 pDataChild, dwNameHash, eMatchDataNodeType, FALSE); | 381 pDataChild, dwNameHash, eMatchDataNodeType, FALSE); |
382 if (pDataNode) { | 382 if (pDataNode) { |
383 return pDataNode; | 383 return pDataNode; |
384 } | 384 } |
385 } | 385 } |
386 if (!bUpLevel) { | 386 if (!bUpLevel) { |
387 break; | 387 break; |
388 } | 388 } |
389 } | 389 } |
390 return NULL; | 390 return NULL; |
391 } | 391 } |
392 static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, | 392 static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, |
393 CFX_WideStringC wsName, | 393 CFX_WideStringC wsName, |
394 CXFA_Node* pDataScope, | 394 CXFA_Node* pDataScope, |
395 XFA_ELEMENT eMatchNodeType) { | 395 XFA_Element eMatchNodeType) { |
396 if (wsName.IsEmpty()) | 396 if (wsName.IsEmpty()) |
397 return nullptr; | 397 return nullptr; |
398 | 398 |
399 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); | 399 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); |
400 CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); | 400 CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); |
401 if (!pBounded) { | 401 if (!pBounded) { |
402 pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash, | 402 pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash, |
403 eMatchNodeType); | 403 eMatchNodeType); |
404 if (pBounded) { | 404 if (pBounded) { |
405 XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded); | 405 XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded); |
406 } | 406 } |
407 } | 407 } |
408 return pBounded; | 408 return pBounded; |
409 } | 409 } |
410 | 410 |
411 static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument, | 411 static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument, |
412 CFX_WideStringC wsName, | 412 CFX_WideStringC wsName, |
413 CXFA_Node* pDataScope, | 413 CXFA_Node* pDataScope, |
414 XFA_ELEMENT eMatchNodeType) { | 414 XFA_Element eMatchNodeType) { |
415 if (wsName.IsEmpty()) | 415 if (wsName.IsEmpty()) |
416 return nullptr; | 416 return nullptr; |
417 | 417 |
418 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); | 418 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); |
419 CXFA_Node* pLastDataScope = nullptr; | 419 CXFA_Node* pLastDataScope = nullptr; |
420 for (CXFA_Node* pCurDataScope = pDataScope; | 420 for (CXFA_Node* pCurDataScope = pDataScope; |
421 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; | 421 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; |
422 pCurDataScope = pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { | 422 pCurDataScope = pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { |
423 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); | 423 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); |
424 pDataChild; | 424 pDataChild; |
425 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { | 425 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { |
426 if (pDataChild == pLastDataScope || pDataChild->HasBindItem() || | 426 if (pDataChild == pLastDataScope || pDataChild->HasBindItem() || |
427 (eMatchNodeType != XFA_ELEMENT_DataModel && | 427 (eMatchNodeType != XFA_Element::DataModel && |
428 pDataChild->GetClassID() != eMatchNodeType)) { | 428 pDataChild->GetClassID() != eMatchNodeType)) { |
429 continue; | 429 continue; |
430 } | 430 } |
431 return pDataChild; | 431 return pDataChild; |
432 } | 432 } |
433 pLastDataScope = pCurDataScope; | 433 pLastDataScope = pCurDataScope; |
434 } | 434 } |
435 return nullptr; | 435 return nullptr; |
436 } | 436 } |
437 | 437 |
438 static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, | 438 static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, |
439 CFX_WideStringC wsRef, | 439 CFX_WideStringC wsRef, |
440 CXFA_Node* pDataScope, | 440 CXFA_Node* pDataScope, |
441 XFA_ELEMENT eMatchNodeType, | 441 XFA_Element eMatchNodeType, |
442 CXFA_Node* pTemplateNode, | 442 CXFA_Node* pTemplateNode, |
443 FX_BOOL bForceBind, | 443 FX_BOOL bForceBind, |
444 FX_BOOL bUpLevel = TRUE) { | 444 FX_BOOL bUpLevel = TRUE) { |
445 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; | 445 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; |
446 if (bUpLevel || wsRef != FX_WSTRC(L"name")) { | 446 if (bUpLevel || wsRef != FX_WSTRC(L"name")) { |
447 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); | 447 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); |
448 } | 448 } |
449 XFA_RESOLVENODE_RS rs; | 449 XFA_RESOLVENODE_RS rs; |
450 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags, | 450 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags, |
451 pTemplateNode); | 451 pTemplateNode); |
452 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll || | 452 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll || |
453 rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll || | 453 rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll || |
454 rs.nodes.GetSize() > 1) { | 454 rs.nodes.GetSize() > 1) { |
455 return pDocument->GetNotBindNode(rs.nodes); | 455 return pDocument->GetNotBindNode(rs.nodes); |
456 } | 456 } |
457 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { | 457 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { |
458 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; | 458 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; |
459 CXFA_Node* pNode = ToNode(pObject); | 459 CXFA_Node* pNode = ToNode(pObject); |
460 if (!bForceBind && pNode && pNode->HasBindItem()) { | 460 if (!bForceBind && pNode && pNode->HasBindItem()) { |
461 pNode = NULL; | 461 pNode = NULL; |
462 } | 462 } |
463 return pNode; | 463 return pNode; |
464 } | 464 } |
465 return NULL; | 465 return NULL; |
466 } | 466 } |
467 CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, | 467 CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, |
468 XFA_ELEMENT eClassID, | 468 XFA_Element eClassID, |
469 uint32_t dwNameHash, | 469 uint32_t dwNameHash, |
470 CXFA_Node* pFormParent) { | 470 CXFA_Node* pFormParent) { |
471 CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild); | 471 CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild); |
472 for (; pFormChild; | 472 for (; pFormChild; |
473 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 473 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
474 if (pFormChild->GetClassID() == eClassID && | 474 if (pFormChild->GetClassID() == eClassID && |
475 pFormChild->GetNameHash() == dwNameHash && pFormChild->IsUnusedNode()) { | 475 pFormChild->GetNameHash() == dwNameHash && pFormChild->IsUnusedNode()) { |
476 return pFormChild; | 476 return pFormChild; |
477 } | 477 } |
478 } | 478 } |
479 return NULL; | 479 return NULL; |
480 } | 480 } |
481 static FX_BOOL XFA_NeedGenerateForm(CXFA_Node* pTemplateChild, | 481 static FX_BOOL XFA_NeedGenerateForm(CXFA_Node* pTemplateChild, |
482 FX_BOOL bUseInstanceManager = TRUE) { | 482 FX_BOOL bUseInstanceManager = TRUE) { |
483 XFA_ELEMENT eType = pTemplateChild->GetClassID(); | 483 XFA_Element eType = pTemplateChild->GetClassID(); |
484 if (eType == XFA_ELEMENT_Variables) { | 484 if (eType == XFA_Element::Variables) { |
485 return TRUE; | 485 return TRUE; |
486 } | 486 } |
487 if (pTemplateChild->IsContainerNode()) { | 487 if (pTemplateChild->IsContainerNode()) { |
488 return FALSE; | 488 return FALSE; |
489 } | 489 } |
490 if (eType == XFA_ELEMENT_Proto || | 490 if (eType == XFA_Element::Proto || |
491 (bUseInstanceManager && eType == XFA_ELEMENT_Occur)) { | 491 (bUseInstanceManager && eType == XFA_Element::Occur)) { |
492 return FALSE; | 492 return FALSE; |
493 } | 493 } |
494 return TRUE; | 494 return TRUE; |
495 } | 495 } |
496 CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument, | 496 CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument, |
497 CXFA_Node* pFormParent, | 497 CXFA_Node* pFormParent, |
498 CXFA_Node* pTemplateNode, | 498 CXFA_Node* pTemplateNode, |
499 FX_BOOL bRecursive, | 499 FX_BOOL bRecursive, |
500 CXFA_NodeArray* pSubformArray) { | 500 CXFA_NodeArray* pSubformArray) { |
501 CXFA_Node* pExistingNode = NULL; | 501 CXFA_Node* pExistingNode = NULL; |
502 if (pSubformArray == NULL) { | 502 if (pSubformArray == NULL) { |
503 pExistingNode = XFA_DataMerge_FindFormDOMInstance( | 503 pExistingNode = XFA_DataMerge_FindFormDOMInstance( |
504 pDocument, pTemplateNode->GetClassID(), pTemplateNode->GetNameHash(), | 504 pDocument, pTemplateNode->GetClassID(), pTemplateNode->GetNameHash(), |
505 pFormParent); | 505 pFormParent); |
506 } else if (pSubformArray->GetSize() > 0) { | 506 } else if (pSubformArray->GetSize() > 0) { |
507 pExistingNode = pSubformArray->GetAt(0); | 507 pExistingNode = pSubformArray->GetAt(0); |
508 pSubformArray->RemoveAt(0); | 508 pSubformArray->RemoveAt(0); |
509 } | 509 } |
510 if (pExistingNode) { | 510 if (pExistingNode) { |
511 if (pSubformArray) { | 511 if (pSubformArray) { |
512 pFormParent->InsertChild(pExistingNode); | 512 pFormParent->InsertChild(pExistingNode); |
513 } else if (pExistingNode->IsContainerNode()) { | 513 } else if (pExistingNode->IsContainerNode()) { |
514 pFormParent->RemoveChild(pExistingNode); | 514 pFormParent->RemoveChild(pExistingNode); |
515 pFormParent->InsertChild(pExistingNode); | 515 pFormParent->InsertChild(pExistingNode); |
516 } | 516 } |
517 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode); | 517 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode); |
518 pExistingNode->SetTemplateNode(pTemplateNode); | 518 pExistingNode->SetTemplateNode(pTemplateNode); |
519 if (bRecursive && pExistingNode->GetClassID() != XFA_ELEMENT_Items) { | 519 if (bRecursive && pExistingNode->GetClassID() != XFA_Element::Items) { |
520 for (CXFA_Node* pTemplateChild = | 520 for (CXFA_Node* pTemplateChild = |
521 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 521 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
522 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( | 522 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( |
523 XFA_NODEITEM_NextSibling)) { | 523 XFA_NODEITEM_NextSibling)) { |
524 if (XFA_NeedGenerateForm(pTemplateChild)) { | 524 if (XFA_NeedGenerateForm(pTemplateChild)) { |
525 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pExistingNode, | 525 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pExistingNode, |
526 pTemplateChild, bRecursive); | 526 pTemplateChild, bRecursive); |
527 } | 527 } |
528 } | 528 } |
529 } | 529 } |
(...skipping 18 matching lines...) Expand all Loading... |
548 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( | 548 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( |
549 CXFA_Document* pDocument, | 549 CXFA_Document* pDocument, |
550 CXFA_Node* pFormParent, | 550 CXFA_Node* pFormParent, |
551 CXFA_Node* pTemplateNode, | 551 CXFA_Node* pTemplateNode, |
552 CXFA_NodeArray& subforms) { | 552 CXFA_NodeArray& subforms) { |
553 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); | 553 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); |
554 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; | 554 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; |
555 uint32_t dwInstNameHash = | 555 uint32_t dwInstNameHash = |
556 FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false); | 556 FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false); |
557 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( | 557 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( |
558 pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent); | 558 pDocument, XFA_Element::InstanceManager, dwInstNameHash, pFormParent); |
559 if (pExistingNode) { | 559 if (pExistingNode) { |
560 uint32_t dwNameHash = pTemplateNode->GetNameHash(); | 560 uint32_t dwNameHash = pTemplateNode->GetNameHash(); |
561 for (CXFA_Node* pNode = | 561 for (CXFA_Node* pNode = |
562 pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 562 pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
563 pNode;) { | 563 pNode;) { |
564 XFA_ELEMENT eCurType = pNode->GetClassID(); | 564 XFA_Element eCurType = pNode->GetClassID(); |
565 if (eCurType == XFA_ELEMENT_InstanceManager) { | 565 if (eCurType == XFA_Element::InstanceManager) { |
566 break; | 566 break; |
567 } | 567 } |
568 if ((eCurType != XFA_ELEMENT_Subform) && | 568 if ((eCurType != XFA_Element::Subform) && |
569 (eCurType != XFA_ELEMENT_SubformSet)) { | 569 (eCurType != XFA_Element::SubformSet)) { |
570 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 570 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
571 continue; | 571 continue; |
572 } | 572 } |
573 if (dwNameHash != pNode->GetNameHash()) { | 573 if (dwNameHash != pNode->GetNameHash()) { |
574 break; | 574 break; |
575 } | 575 } |
576 CXFA_Node* pNextNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 576 CXFA_Node* pNextNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
577 pFormParent->RemoveChild(pNode); | 577 pFormParent->RemoveChild(pNode); |
578 subforms.Add(pNode); | 578 subforms.Add(pNode); |
579 pNode = pNextNode; | 579 pNode = pNextNode; |
580 } | 580 } |
581 pFormParent->RemoveChild(pExistingNode); | 581 pFormParent->RemoveChild(pExistingNode); |
582 pFormParent->InsertChild(pExistingNode); | 582 pFormParent->InsertChild(pExistingNode); |
583 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode); | 583 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode); |
584 pExistingNode->SetTemplateNode(pTemplateNode); | 584 pExistingNode->SetTemplateNode(pTemplateNode); |
585 return pExistingNode; | 585 return pExistingNode; |
586 } | 586 } |
587 CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode( | 587 CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode( |
588 XFA_XDPPACKET_Form, XFA_ELEMENT_InstanceManager); | 588 XFA_XDPPACKET_Form, XFA_Element::InstanceManager); |
589 ASSERT(pNewNode); | 589 ASSERT(pNewNode); |
590 wsInstMgrNodeName = | 590 wsInstMgrNodeName = |
591 FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); | 591 FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); |
592 pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName); | 592 pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName); |
593 pFormParent->InsertChild(pNewNode, NULL); | 593 pFormParent->InsertChild(pNewNode, NULL); |
594 pNewNode->SetTemplateNode(pTemplateNode); | 594 pNewNode->SetTemplateNode(pTemplateNode); |
595 return pNewNode; | 595 return pNewNode; |
596 } | 596 } |
597 static CXFA_Node* XFA_DataMerge_FindMatchingDataNode( | 597 static CXFA_Node* XFA_DataMerge_FindMatchingDataNode( |
598 CXFA_Document* pDocument, | 598 CXFA_Document* pDocument, |
599 CXFA_Node* pTemplateNode, | 599 CXFA_Node* pTemplateNode, |
600 CXFA_Node* pDataScope, | 600 CXFA_Node* pDataScope, |
601 FX_BOOL& bAccessedDataDOM, | 601 FX_BOOL& bAccessedDataDOM, |
602 FX_BOOL bForceBind, | 602 FX_BOOL bForceBind, |
603 CXFA_NodeIteratorTemplate<CXFA_Node, | 603 CXFA_NodeIteratorTemplate<CXFA_Node, |
604 CXFA_TraverseStrategy_XFAContainerNode>* | 604 CXFA_TraverseStrategy_XFAContainerNode>* |
605 pIterator, | 605 pIterator, |
606 FX_BOOL& bSelfMatch, | 606 FX_BOOL& bSelfMatch, |
607 XFA_ATTRIBUTEENUM& eBindMatch, | 607 XFA_ATTRIBUTEENUM& eBindMatch, |
608 FX_BOOL bUpLevel = TRUE) { | 608 FX_BOOL bUpLevel = TRUE) { |
609 FX_BOOL bOwnIterator = FALSE; | 609 FX_BOOL bOwnIterator = FALSE; |
610 if (!pIterator) { | 610 if (!pIterator) { |
611 bOwnIterator = TRUE; | 611 bOwnIterator = TRUE; |
612 pIterator = new CXFA_NodeIteratorTemplate< | 612 pIterator = new CXFA_NodeIteratorTemplate< |
613 CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); | 613 CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); |
614 } | 614 } |
615 CXFA_Node* pResult = NULL; | 615 CXFA_Node* pResult = NULL; |
616 for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); | 616 for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); |
617 pCurTemplateNode;) { | 617 pCurTemplateNode;) { |
618 XFA_ELEMENT eMatchNodeType; | 618 XFA_Element eMatchNodeType; |
619 switch (pCurTemplateNode->GetClassID()) { | 619 switch (pCurTemplateNode->GetClassID()) { |
620 case XFA_ELEMENT_Subform: | 620 case XFA_Element::Subform: |
621 eMatchNodeType = XFA_ELEMENT_DataGroup; | 621 eMatchNodeType = XFA_Element::DataGroup; |
622 break; | 622 break; |
623 case XFA_ELEMENT_Field: { | 623 case XFA_Element::Field: { |
624 eMatchNodeType = XFA_FieldIsMultiListBox(pCurTemplateNode) | 624 eMatchNodeType = XFA_FieldIsMultiListBox(pCurTemplateNode) |
625 ? XFA_ELEMENT_DataGroup | 625 ? XFA_Element::DataGroup |
626 : XFA_ELEMENT_DataValue; | 626 : XFA_Element::DataValue; |
627 } break; | 627 } break; |
628 case XFA_ELEMENT_ExclGroup: | 628 case XFA_Element::ExclGroup: |
629 eMatchNodeType = XFA_ELEMENT_DataValue; | 629 eMatchNodeType = XFA_Element::DataValue; |
630 break; | 630 break; |
631 default: | 631 default: |
632 pCurTemplateNode = pIterator->MoveToNext(); | 632 pCurTemplateNode = pIterator->MoveToNext(); |
633 continue; | 633 continue; |
634 } | 634 } |
635 CXFA_Node* pTemplateNodeOccur = | 635 CXFA_Node* pTemplateNodeOccur = |
636 pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur); | 636 pCurTemplateNode->GetFirstChildByClass(XFA_Element::Occur); |
637 int32_t iMin, iMax, iInit; | 637 int32_t iMin, iMax, iInit; |
638 if (pTemplateNodeOccur && | 638 if (pTemplateNodeOccur && |
639 XFA_GetOccurInfo(pTemplateNodeOccur, iMin, iMax, iInit) && iMax == 0) { | 639 XFA_GetOccurInfo(pTemplateNodeOccur, iMin, iMax, iInit) && iMax == 0) { |
640 pCurTemplateNode = pIterator->MoveToNext(); | 640 pCurTemplateNode = pIterator->MoveToNext(); |
641 continue; | 641 continue; |
642 } | 642 } |
643 CXFA_Node* pTemplateNodeBind = | 643 CXFA_Node* pTemplateNodeBind = |
644 pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind); | 644 pCurTemplateNode->GetFirstChildByClass(XFA_Element::Bind); |
645 XFA_ATTRIBUTEENUM eMatch = | 645 XFA_ATTRIBUTEENUM eMatch = |
646 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) | 646 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) |
647 : XFA_ATTRIBUTEENUM_Once; | 647 : XFA_ATTRIBUTEENUM_Once; |
648 eBindMatch = eMatch; | 648 eBindMatch = eMatch; |
649 switch (eMatch) { | 649 switch (eMatch) { |
650 case XFA_ATTRIBUTEENUM_None: | 650 case XFA_ATTRIBUTEENUM_None: |
651 pCurTemplateNode = pIterator->MoveToNext(); | 651 pCurTemplateNode = pIterator->MoveToNext(); |
652 continue; | 652 continue; |
653 case XFA_ATTRIBUTEENUM_Global: | 653 case XFA_ATTRIBUTEENUM_Global: |
654 bAccessedDataDOM = TRUE; | 654 bAccessedDataDOM = TRUE; |
655 if (!bForceBind) { | 655 if (!bForceBind) { |
656 pCurTemplateNode = pIterator->MoveToNext(); | 656 pCurTemplateNode = pIterator->MoveToNext(); |
657 continue; | 657 continue; |
658 } | 658 } |
659 if (eMatchNodeType == XFA_ELEMENT_DataValue || | 659 if (eMatchNodeType == XFA_Element::DataValue || |
660 (eMatchNodeType == XFA_ELEMENT_DataGroup && | 660 (eMatchNodeType == XFA_Element::DataGroup && |
661 XFA_FieldIsMultiListBox(pTemplateNodeBind))) { | 661 XFA_FieldIsMultiListBox(pTemplateNodeBind))) { |
662 CXFA_Node* pGlobalBindNode = XFA_DataMerge_FindGlobalDataNode( | 662 CXFA_Node* pGlobalBindNode = XFA_DataMerge_FindGlobalDataNode( |
663 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), | 663 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), |
664 pDataScope, eMatchNodeType); | 664 pDataScope, eMatchNodeType); |
665 if (!pGlobalBindNode) { | 665 if (!pGlobalBindNode) { |
666 pCurTemplateNode = pIterator->MoveToNext(); | 666 pCurTemplateNode = pIterator->MoveToNext(); |
667 continue; | 667 continue; |
668 } | 668 } |
669 pResult = pGlobalBindNode; | 669 pResult = pGlobalBindNode; |
670 break; | 670 break; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 rgRecords.Copy(rgResultRecord); | 743 rgRecords.Copy(rgResultRecord); |
744 } | 744 } |
745 } | 745 } |
746 static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( | 746 static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( |
747 CXFA_Document* pDocument, | 747 CXFA_Document* pDocument, |
748 CXFA_Node* pTemplateNode, | 748 CXFA_Node* pTemplateNode, |
749 CXFA_Node* pFormParentNode, | 749 CXFA_Node* pFormParentNode, |
750 CXFA_Node* pDataScope, | 750 CXFA_Node* pDataScope, |
751 FX_BOOL bOneInstance, | 751 FX_BOOL bOneInstance, |
752 FX_BOOL bDataMerge) { | 752 FX_BOOL bDataMerge) { |
753 XFA_ELEMENT eElement = pTemplateNode->GetClassID(); | 753 XFA_Element eElement = pTemplateNode->GetClassID(); |
754 CXFA_Node* pOccurNode = NULL; | 754 CXFA_Node* pOccurNode = NULL; |
755 CXFA_Node* pFirstInstance = NULL; | 755 CXFA_Node* pFirstInstance = NULL; |
756 FX_BOOL bUseInstanceManager = | 756 FX_BOOL bUseInstanceManager = |
757 pFormParentNode->GetClassID() != XFA_ELEMENT_Area; | 757 pFormParentNode->GetClassID() != XFA_Element::Area; |
758 CXFA_Node* pInstMgrNode = NULL; | 758 CXFA_Node* pInstMgrNode = NULL; |
759 CXFA_NodeArray subformArray; | 759 CXFA_NodeArray subformArray; |
760 CXFA_NodeArray* pSearchArray = NULL; | 760 CXFA_NodeArray* pSearchArray = NULL; |
761 if (!bOneInstance && | 761 if (!bOneInstance && (eElement == XFA_Element::SubformSet || |
762 (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Subform)) { | 762 eElement == XFA_Element::Subform)) { |
763 pInstMgrNode = | 763 pInstMgrNode = |
764 bUseInstanceManager | 764 bUseInstanceManager |
765 ? XFA_NodeMerge_CloneOrMergeInstanceManager( | 765 ? XFA_NodeMerge_CloneOrMergeInstanceManager( |
766 pDocument, pFormParentNode, pTemplateNode, subformArray) | 766 pDocument, pFormParentNode, pTemplateNode, subformArray) |
767 : NULL; | 767 : NULL; |
768 if (CXFA_Node* pOccurTemplateNode = | 768 if (CXFA_Node* pOccurTemplateNode = |
769 pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur)) { | 769 pTemplateNode->GetFirstChildByClass(XFA_Element::Occur)) { |
770 pOccurNode = pInstMgrNode | 770 pOccurNode = pInstMgrNode |
771 ? XFA_NodeMerge_CloneOrMergeContainer( | 771 ? XFA_NodeMerge_CloneOrMergeContainer( |
772 pDocument, pInstMgrNode, pOccurTemplateNode, FALSE) | 772 pDocument, pInstMgrNode, pOccurTemplateNode, FALSE) |
773 : pOccurTemplateNode; | 773 : pOccurTemplateNode; |
774 } else if (pInstMgrNode) { | 774 } else if (pInstMgrNode) { |
775 pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_ELEMENT_Occur); | 775 pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_Element::Occur); |
776 if (pOccurNode) { | 776 if (pOccurNode) { |
777 pOccurNode->ClearFlag(XFA_NodeFlag_UnusedNode); | 777 pOccurNode->ClearFlag(XFA_NodeFlag_UnusedNode); |
778 } | 778 } |
779 } | 779 } |
780 if (pInstMgrNode) { | 780 if (pInstMgrNode) { |
781 pInstMgrNode->SetFlag(XFA_NodeFlag_Initialized, true); | 781 pInstMgrNode->SetFlag(XFA_NodeFlag_Initialized, true); |
782 pSearchArray = &subformArray; | 782 pSearchArray = &subformArray; |
783 if (pFormParentNode->GetClassID() == XFA_ELEMENT_PageArea) { | 783 if (pFormParentNode->GetClassID() == XFA_Element::PageArea) { |
784 bOneInstance = TRUE; | 784 bOneInstance = TRUE; |
785 if (subformArray.GetSize() < 1) { | 785 if (subformArray.GetSize() < 1) { |
786 pSearchArray = NULL; | 786 pSearchArray = NULL; |
787 } | 787 } |
788 } else if ((pTemplateNode->GetNameHash() == 0) && | 788 } else if ((pTemplateNode->GetNameHash() == 0) && |
789 (subformArray.GetSize() < 1)) { | 789 (subformArray.GetSize() < 1)) { |
790 pSearchArray = NULL; | 790 pSearchArray = NULL; |
791 } | 791 } |
792 } | 792 } |
793 } | 793 } |
794 int32_t iMax = 1, iInit = 1, iMin = 1; | 794 int32_t iMax = 1, iInit = 1, iMin = 1; |
795 if (!bOneInstance) { | 795 if (!bOneInstance) { |
796 XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit); | 796 XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit); |
797 } | 797 } |
798 XFA_ATTRIBUTEENUM eRelation = | 798 XFA_ATTRIBUTEENUM eRelation = |
799 eElement == XFA_ELEMENT_SubformSet | 799 eElement == XFA_Element::SubformSet |
800 ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) | 800 ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) |
801 : XFA_ATTRIBUTEENUM_Ordered; | 801 : XFA_ATTRIBUTEENUM_Ordered; |
802 int32_t iCurRepeatIndex = 0; | 802 int32_t iCurRepeatIndex = 0; |
803 XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None; | 803 XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None; |
804 if (bDataMerge) { | 804 if (bDataMerge) { |
805 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> | 805 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> |
806 sNodeIterator(pTemplateNode); | 806 sNodeIterator(pTemplateNode); |
807 FX_BOOL bAccessedDataDOM = FALSE; | 807 FX_BOOL bAccessedDataDOM = FALSE; |
808 if (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Area) { | 808 if (eElement == XFA_Element::SubformSet || eElement == XFA_Element::Area) { |
809 sNodeIterator.MoveToNext(); | 809 sNodeIterator.MoveToNext(); |
810 } else { | 810 } else { |
811 CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray; | 811 CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray; |
812 CXFA_NodeArray nodeArray; | 812 CXFA_NodeArray nodeArray; |
813 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { | 813 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { |
814 FX_BOOL bSelfMatch = FALSE; | 814 FX_BOOL bSelfMatch = FALSE; |
815 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; | 815 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; |
816 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( | 816 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( |
817 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE, | 817 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE, |
818 &sNodeIterator, bSelfMatch, eBindMatch); | 818 &sNodeIterator, bSelfMatch, eBindMatch); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer( | 1025 CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer( |
1026 pDocument, pFormNode, pTemplateNode, FALSE); | 1026 pDocument, pFormNode, pTemplateNode, FALSE); |
1027 ASSERT(pFieldNode); | 1027 ASSERT(pFieldNode); |
1028 for (CXFA_Node* pTemplateChildNode = | 1028 for (CXFA_Node* pTemplateChildNode = |
1029 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1029 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
1030 pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem( | 1030 pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem( |
1031 XFA_NODEITEM_NextSibling)) { | 1031 XFA_NODEITEM_NextSibling)) { |
1032 if (XFA_NeedGenerateForm(pTemplateChildNode)) { | 1032 if (XFA_NeedGenerateForm(pTemplateChildNode)) { |
1033 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode, | 1033 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode, |
1034 pTemplateChildNode, TRUE); | 1034 pTemplateChildNode, TRUE); |
1035 } else if (pTemplateNode->GetClassID() == XFA_ELEMENT_ExclGroup && | 1035 } else if (pTemplateNode->GetClassID() == XFA_Element::ExclGroup && |
1036 pTemplateChildNode->IsContainerNode()) { | 1036 pTemplateChildNode->IsContainerNode()) { |
1037 if (pTemplateChildNode->GetClassID() == XFA_ELEMENT_Field) { | 1037 if (pTemplateChildNode->GetClassID() == XFA_Element::Field) { |
1038 XFA_DataMerge_CopyContainer_Field(pDocument, pTemplateChildNode, | 1038 XFA_DataMerge_CopyContainer_Field(pDocument, pTemplateChildNode, |
1039 pFieldNode, NULL, FALSE); | 1039 pFieldNode, NULL, FALSE); |
1040 } | 1040 } |
1041 } | 1041 } |
1042 } | 1042 } |
1043 if (bDataMerge) { | 1043 if (bDataMerge) { |
1044 FX_BOOL bAccessedDataDOM = FALSE; | 1044 FX_BOOL bAccessedDataDOM = FALSE; |
1045 FX_BOOL bSelfMatch = FALSE; | 1045 FX_BOOL bSelfMatch = FALSE; |
1046 XFA_ATTRIBUTEENUM eBindMatch; | 1046 XFA_ATTRIBUTEENUM eBindMatch; |
1047 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( | 1047 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( |
1048 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, NULL, | 1048 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, NULL, |
1049 bSelfMatch, eBindMatch, bUpLevel); | 1049 bSelfMatch, eBindMatch, bUpLevel); |
1050 if (pDataNode) { | 1050 if (pDataNode) { |
1051 XFA_DataMerge_CreateDataBinding(pFieldNode, pDataNode); | 1051 XFA_DataMerge_CreateDataBinding(pFieldNode, pDataNode); |
1052 } | 1052 } |
1053 } else { | 1053 } else { |
1054 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFieldNode); | 1054 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFieldNode); |
1055 } | 1055 } |
1056 return pFieldNode; | 1056 return pFieldNode; |
1057 } | 1057 } |
1058 CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode, | 1058 CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode, |
1059 CXFA_Node* pFormNode, | 1059 CXFA_Node* pFormNode, |
1060 CXFA_Node* pDataScope, | 1060 CXFA_Node* pDataScope, |
1061 FX_BOOL bOneInstance, | 1061 FX_BOOL bOneInstance, |
1062 FX_BOOL bDataMerge, | 1062 FX_BOOL bDataMerge, |
1063 FX_BOOL bUpLevel) { | 1063 FX_BOOL bUpLevel) { |
1064 switch (pTemplateNode->GetClassID()) { | 1064 switch (pTemplateNode->GetClassID()) { |
1065 case XFA_ELEMENT_SubformSet: | 1065 case XFA_Element::SubformSet: |
1066 case XFA_ELEMENT_Subform: | 1066 case XFA_Element::Subform: |
1067 case XFA_ELEMENT_Area: | 1067 case XFA_Element::Area: |
1068 case XFA_ELEMENT_PageArea: | 1068 case XFA_Element::PageArea: |
1069 return XFA_DataMerge_CopyContainer_SubformSet( | 1069 return XFA_DataMerge_CopyContainer_SubformSet( |
1070 this, pTemplateNode, pFormNode, pDataScope, bOneInstance, bDataMerge); | 1070 this, pTemplateNode, pFormNode, pDataScope, bOneInstance, bDataMerge); |
1071 case XFA_ELEMENT_ExclGroup: | 1071 case XFA_Element::ExclGroup: |
1072 case XFA_ELEMENT_Field: | 1072 case XFA_Element::Field: |
1073 case XFA_ELEMENT_Draw: | 1073 case XFA_Element::Draw: |
1074 case XFA_ELEMENT_ContentArea: | 1074 case XFA_Element::ContentArea: |
1075 return XFA_DataMerge_CopyContainer_Field( | 1075 return XFA_DataMerge_CopyContainer_Field( |
1076 this, pTemplateNode, pFormNode, pDataScope, bDataMerge, bUpLevel); | 1076 this, pTemplateNode, pFormNode, pDataScope, bDataMerge, bUpLevel); |
1077 case XFA_ELEMENT_PageSet: | 1077 case XFA_Element::PageSet: |
1078 break; | 1078 break; |
1079 case XFA_ELEMENT_Variables: | 1079 case XFA_Element::Variables: |
1080 break; | 1080 break; |
1081 default: | 1081 default: |
1082 ASSERT(FALSE); | 1082 ASSERT(FALSE); |
1083 break; | 1083 break; |
1084 } | 1084 } |
1085 return NULL; | 1085 return NULL; |
1086 } | 1086 } |
1087 | 1087 |
1088 static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, | 1088 static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, |
1089 CXFA_Node* pFormNode, | 1089 CXFA_Node* pFormNode, |
1090 CXFA_Node* pDataScope, | 1090 CXFA_Node* pDataScope, |
1091 FX_BOOL bDataRef, | 1091 FX_BOOL bDataRef, |
1092 FX_BOOL bParentDataRef) { | 1092 FX_BOOL bParentDataRef) { |
1093 FX_BOOL bMatchRef = TRUE; | 1093 FX_BOOL bMatchRef = TRUE; |
1094 XFA_ELEMENT eClassID = pFormNode->GetClassID(); | 1094 XFA_Element eClassID = pFormNode->GetClassID(); |
1095 CXFA_Node* pDataNode = pFormNode->GetBindData(); | 1095 CXFA_Node* pDataNode = pFormNode->GetBindData(); |
1096 if (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup || | 1096 if (eClassID == XFA_Element::Subform || eClassID == XFA_Element::ExclGroup || |
1097 eClassID == XFA_ELEMENT_Field) { | 1097 eClassID == XFA_Element::Field) { |
1098 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); | 1098 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); |
1099 CXFA_Node* pTemplateNodeBind = | 1099 CXFA_Node* pTemplateNodeBind = |
1100 pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind) | 1100 pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind) |
1101 : NULL; | 1101 : NULL; |
1102 XFA_ATTRIBUTEENUM eMatch = | 1102 XFA_ATTRIBUTEENUM eMatch = |
1103 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) | 1103 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) |
1104 : XFA_ATTRIBUTEENUM_Once; | 1104 : XFA_ATTRIBUTEENUM_Once; |
1105 switch (eMatch) { | 1105 switch (eMatch) { |
1106 case XFA_ATTRIBUTEENUM_None: | 1106 case XFA_ATTRIBUTEENUM_None: |
1107 if (!bDataRef || bParentDataRef) { | 1107 if (!bDataRef || bParentDataRef) { |
1108 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); | 1108 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); |
1109 } | 1109 } |
1110 break; | 1110 break; |
1111 case XFA_ATTRIBUTEENUM_Once: | 1111 case XFA_ATTRIBUTEENUM_Once: |
1112 if (!bDataRef || bParentDataRef) { | 1112 if (!bDataRef || bParentDataRef) { |
1113 if (!pDataNode) { | 1113 if (!pDataNode) { |
1114 if (pFormNode->GetNameHash() != 0 && | 1114 if (pFormNode->GetNameHash() != 0 && |
1115 pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) != | 1115 pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) != |
1116 XFA_ATTRIBUTEENUM_None) { | 1116 XFA_ATTRIBUTEENUM_None) { |
1117 XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform || | 1117 XFA_Element eDataNodeType = (eClassID == XFA_Element::Subform || |
1118 XFA_FieldIsMultiListBox(pFormNode)) | 1118 XFA_FieldIsMultiListBox(pFormNode)) |
1119 ? XFA_ELEMENT_DataGroup | 1119 ? XFA_Element::DataGroup |
1120 : XFA_ELEMENT_DataValue; | 1120 : XFA_Element::DataValue; |
1121 pDataNode = XFA_DataDescription_MaybeCreateDataNode( | 1121 pDataNode = XFA_DataDescription_MaybeCreateDataNode( |
1122 pDocument, pDataScope, eDataNodeType, | 1122 pDocument, pDataScope, eDataNodeType, |
1123 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name))); | 1123 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name))); |
1124 if (pDataNode) { | 1124 if (pDataNode) { |
1125 XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); | 1125 XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); |
1126 } | 1126 } |
1127 } | 1127 } |
1128 if (!pDataNode) { | 1128 if (!pDataNode) { |
1129 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); | 1129 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); |
1130 } | 1130 } |
1131 } else { | 1131 } else { |
1132 CXFA_Node* pDataParent = | 1132 CXFA_Node* pDataParent = |
1133 pDataNode->GetNodeItem(XFA_NODEITEM_Parent); | 1133 pDataNode->GetNodeItem(XFA_NODEITEM_Parent); |
1134 if (pDataParent != pDataScope) { | 1134 if (pDataParent != pDataScope) { |
1135 ASSERT(pDataParent); | 1135 ASSERT(pDataParent); |
1136 pDataParent->RemoveChild(pDataNode); | 1136 pDataParent->RemoveChild(pDataNode); |
1137 pDataScope->InsertChild(pDataNode); | 1137 pDataScope->InsertChild(pDataNode); |
1138 } | 1138 } |
1139 } | 1139 } |
1140 } | 1140 } |
1141 break; | 1141 break; |
1142 case XFA_ATTRIBUTEENUM_Global: | 1142 case XFA_ATTRIBUTEENUM_Global: |
1143 if (!bDataRef || bParentDataRef) { | 1143 if (!bDataRef || bParentDataRef) { |
1144 uint32_t dwNameHash = pFormNode->GetNameHash(); | 1144 uint32_t dwNameHash = pFormNode->GetNameHash(); |
1145 if (dwNameHash != 0 && !pDataNode) { | 1145 if (dwNameHash != 0 && !pDataNode) { |
1146 pDataNode = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); | 1146 pDataNode = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); |
1147 if (!pDataNode) { | 1147 if (!pDataNode) { |
1148 XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform || | 1148 XFA_Element eDataNodeType = (eClassID == XFA_Element::Subform || |
1149 XFA_FieldIsMultiListBox(pFormNode)) | 1149 XFA_FieldIsMultiListBox(pFormNode)) |
1150 ? XFA_ELEMENT_DataGroup | 1150 ? XFA_Element::DataGroup |
1151 : XFA_ELEMENT_DataValue; | 1151 : XFA_Element::DataValue; |
1152 CXFA_Node* pRecordNode = | 1152 CXFA_Node* pRecordNode = |
1153 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); | 1153 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); |
1154 pDataNode = XFA_DataDescription_MaybeCreateDataNode( | 1154 pDataNode = XFA_DataDescription_MaybeCreateDataNode( |
1155 pDocument, pRecordNode, eDataNodeType, | 1155 pDocument, pRecordNode, eDataNodeType, |
1156 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name))); | 1156 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name))); |
1157 if (pDataNode) { | 1157 if (pDataNode) { |
1158 XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); | 1158 XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); |
1159 XFA_DataMerge_RegisterGlobalBinding( | 1159 XFA_DataMerge_RegisterGlobalBinding( |
1160 pDocument, pFormNode->GetNameHash(), pDataNode); | 1160 pDocument, pFormNode->GetNameHash(), pDataNode); |
1161 } | 1161 } |
(...skipping 26 matching lines...) Expand all Loading... |
1188 } else { | 1188 } else { |
1189 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); | 1189 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); |
1190 } | 1190 } |
1191 } | 1191 } |
1192 } break; | 1192 } break; |
1193 default: | 1193 default: |
1194 break; | 1194 break; |
1195 } | 1195 } |
1196 } | 1196 } |
1197 if (bMatchRef && | 1197 if (bMatchRef && |
1198 (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_SubformSet || | 1198 (eClassID == XFA_Element::Subform || |
1199 eClassID == XFA_ELEMENT_Area || eClassID == XFA_ELEMENT_PageArea || | 1199 eClassID == XFA_Element::SubformSet || eClassID == XFA_Element::Area || |
1200 eClassID == XFA_ELEMENT_PageSet)) { | 1200 eClassID == XFA_Element::PageArea || eClassID == XFA_Element::PageSet)) { |
1201 for (CXFA_Node* pFormChild = | 1201 for (CXFA_Node* pFormChild = |
1202 pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1202 pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
1203 pFormChild; | 1203 pFormChild; |
1204 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1204 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
1205 if (!pFormChild->IsContainerNode()) | 1205 if (!pFormChild->IsContainerNode()) |
1206 continue; | 1206 continue; |
1207 if (pFormChild->IsUnusedNode()) | 1207 if (pFormChild->IsUnusedNode()) |
1208 continue; | 1208 continue; |
1209 | 1209 |
1210 XFA_DataMerge_UpdateBindingRelations(pDocument, pFormChild, | 1210 XFA_DataMerge_UpdateBindingRelations(pDocument, pFormChild, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 return pNode; | 1244 return pNode; |
1245 } | 1245 } |
1246 return nullptr; | 1246 return nullptr; |
1247 } | 1247 } |
1248 void CXFA_Document::DoDataMerge() { | 1248 void CXFA_Document::DoDataMerge() { |
1249 CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); | 1249 CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); |
1250 if (!pDatasetsRoot) { | 1250 if (!pDatasetsRoot) { |
1251 CFDE_XMLElement* pDatasetsXMLNode = new CFDE_XMLElement(L"xfa:datasets"); | 1251 CFDE_XMLElement* pDatasetsXMLNode = new CFDE_XMLElement(L"xfa:datasets"); |
1252 pDatasetsXMLNode->SetString(L"xmlns:xfa", | 1252 pDatasetsXMLNode->SetString(L"xmlns:xfa", |
1253 L"http://www.xfa.org/schema/xfa-data/1.0/"); | 1253 L"http://www.xfa.org/schema/xfa-data/1.0/"); |
1254 pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel); | 1254 pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel); |
1255 pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, L"datasets"); | 1255 pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, L"datasets"); |
1256 m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode); | 1256 m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode); |
1257 m_pRootNode->InsertChild(pDatasetsRoot); | 1257 m_pRootNode->InsertChild(pDatasetsRoot); |
1258 pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode); | 1258 pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode); |
1259 } | 1259 } |
1260 CXFA_Node *pDataRoot = NULL, *pDDRoot = NULL; | 1260 CXFA_Node *pDataRoot = NULL, *pDDRoot = NULL; |
1261 CFX_WideString wsDatasetsURI; | 1261 CFX_WideString wsDatasetsURI; |
1262 pDatasetsRoot->TryNamespace(wsDatasetsURI); | 1262 pDatasetsRoot->TryNamespace(wsDatasetsURI); |
1263 for (CXFA_Node* pChildNode = | 1263 for (CXFA_Node* pChildNode = |
1264 pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild); | 1264 pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild); |
1265 pChildNode; | 1265 pChildNode; |
1266 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1266 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
1267 if (pChildNode->GetClassID() != XFA_ELEMENT_DataGroup) { | 1267 if (pChildNode->GetClassID() != XFA_Element::DataGroup) { |
1268 continue; | 1268 continue; |
1269 } | 1269 } |
1270 CFX_WideString wsNamespaceURI; | 1270 CFX_WideString wsNamespaceURI; |
1271 if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) { | 1271 if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) { |
1272 if (!pChildNode->TryNamespace(wsNamespaceURI)) { | 1272 if (!pChildNode->TryNamespace(wsNamespaceURI)) { |
1273 continue; | 1273 continue; |
1274 } | 1274 } |
1275 if (wsNamespaceURI == | 1275 if (wsNamespaceURI == |
1276 FX_WSTRC(L"http://ns.adobe.com/data-description/")) { | 1276 FX_WSTRC(L"http://ns.adobe.com/data-description/")) { |
1277 pDDRoot = pChildNode; | 1277 pDDRoot = pChildNode; |
1278 } | 1278 } |
1279 } else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) { | 1279 } else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) { |
1280 if (!pChildNode->TryNamespace(wsNamespaceURI)) { | 1280 if (!pChildNode->TryNamespace(wsNamespaceURI)) { |
1281 continue; | 1281 continue; |
1282 } | 1282 } |
1283 if (wsNamespaceURI == wsDatasetsURI) { | 1283 if (wsNamespaceURI == wsDatasetsURI) { |
1284 pDataRoot = pChildNode; | 1284 pDataRoot = pChildNode; |
1285 } | 1285 } |
1286 } | 1286 } |
1287 if (pDataRoot && pDDRoot) { | 1287 if (pDataRoot && pDDRoot) { |
1288 break; | 1288 break; |
1289 } | 1289 } |
1290 } | 1290 } |
1291 if (!pDataRoot) { | 1291 if (!pDataRoot) { |
1292 CFDE_XMLElement* pDataRootXMLNode = new CFDE_XMLElement(L"xfa:data"); | 1292 CFDE_XMLElement* pDataRootXMLNode = new CFDE_XMLElement(L"xfa:data"); |
1293 pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); | 1293 pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup); |
1294 pDataRoot->SetCData(XFA_ATTRIBUTE_Name, L"data"); | 1294 pDataRoot->SetCData(XFA_ATTRIBUTE_Name, L"data"); |
1295 pDataRoot->SetXMLMappingNode(pDataRootXMLNode); | 1295 pDataRoot->SetXMLMappingNode(pDataRootXMLNode); |
1296 pDatasetsRoot->InsertChild(pDataRoot); | 1296 pDatasetsRoot->InsertChild(pDataRoot); |
1297 } | 1297 } |
1298 CXFA_Node* pDataTopLevel = | 1298 CXFA_Node* pDataTopLevel = |
1299 pDataRoot->GetFirstChildByClass(XFA_ELEMENT_DataGroup); | 1299 pDataRoot->GetFirstChildByClass(XFA_Element::DataGroup); |
1300 uint32_t dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0; | 1300 uint32_t dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0; |
1301 CXFA_Node* pTemplateRoot = | 1301 CXFA_Node* pTemplateRoot = |
1302 m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template); | 1302 m_pRootNode->GetFirstChildByClass(XFA_Element::Template); |
1303 if (!pTemplateRoot) { | 1303 if (!pTemplateRoot) { |
1304 return; | 1304 return; |
1305 } | 1305 } |
1306 CXFA_Node* pTemplateChosen = | 1306 CXFA_Node* pTemplateChosen = |
1307 dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) : NULL; | 1307 dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) : NULL; |
1308 if (!pTemplateChosen || | 1308 if (!pTemplateChosen || |
1309 pTemplateChosen->GetClassID() != XFA_ELEMENT_Subform) { | 1309 pTemplateChosen->GetClassID() != XFA_Element::Subform) { |
1310 pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform); | 1310 pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform); |
1311 } | 1311 } |
1312 if (!pTemplateChosen) { | 1312 if (!pTemplateChosen) { |
1313 return; | 1313 return; |
1314 } | 1314 } |
1315 CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Form); | 1315 CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_Element::Form); |
1316 FX_BOOL bEmptyForm = FALSE; | 1316 FX_BOOL bEmptyForm = FALSE; |
1317 if (!pFormRoot) { | 1317 if (!pFormRoot) { |
1318 bEmptyForm = TRUE; | 1318 bEmptyForm = TRUE; |
1319 pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form); | 1319 pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form); |
1320 ASSERT(pFormRoot); | 1320 ASSERT(pFormRoot); |
1321 pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form"); | 1321 pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form"); |
1322 m_pRootNode->InsertChild(pFormRoot, NULL); | 1322 m_pRootNode->InsertChild(pFormRoot, NULL); |
1323 } else { | 1323 } else { |
1324 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1324 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
1325 sIterator(pFormRoot); | 1325 sIterator(pFormRoot); |
1326 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; | 1326 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; |
1327 pNode = sIterator.MoveToNext()) { | 1327 pNode = sIterator.MoveToNext()) { |
1328 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); | 1328 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); |
1329 } | 1329 } |
1330 } | 1330 } |
1331 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( | 1331 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( |
1332 this, pFormRoot, pTemplateChosen, FALSE); | 1332 this, pFormRoot, pTemplateChosen, FALSE); |
1333 ASSERT(pSubformSetNode); | 1333 ASSERT(pSubformSetNode); |
1334 if (!pDataTopLevel) { | 1334 if (!pDataTopLevel) { |
1335 CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name); | 1335 CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name); |
1336 CFX_WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form" | 1336 CFX_WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form" |
1337 : wsFormName); | 1337 : wsFormName); |
1338 CFDE_XMLElement* pDataTopLevelXMLNode = | 1338 CFDE_XMLElement* pDataTopLevelXMLNode = |
1339 new CFDE_XMLElement(wsDataTopLevelName); | 1339 new CFDE_XMLElement(wsDataTopLevelName); |
1340 | 1340 |
1341 pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); | 1341 pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup); |
1342 pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName); | 1342 pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName); |
1343 pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode); | 1343 pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode); |
1344 CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild); | 1344 CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild); |
1345 pDataRoot->InsertChild(pDataTopLevel, pBeforeNode); | 1345 pDataRoot->InsertChild(pDataTopLevel, pBeforeNode); |
1346 } | 1346 } |
1347 ASSERT(pDataTopLevel); | 1347 ASSERT(pDataTopLevel); |
1348 XFA_DataMerge_CreateDataBinding(pSubformSetNode, pDataTopLevel); | 1348 XFA_DataMerge_CreateDataBinding(pSubformSetNode, pDataTopLevel); |
1349 for (CXFA_Node* pTemplateChild = | 1349 for (CXFA_Node* pTemplateChild = |
1350 pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild); | 1350 pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild); |
1351 pTemplateChild; | 1351 pTemplateChild; |
1352 pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1352 pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
1353 if (XFA_NeedGenerateForm(pTemplateChild)) { | 1353 if (XFA_NeedGenerateForm(pTemplateChild)) { |
1354 XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild, | 1354 XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild, |
1355 TRUE); | 1355 TRUE); |
1356 } else if (pTemplateChild->IsContainerNode()) { | 1356 } else if (pTemplateChild->IsContainerNode()) { |
1357 DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel); | 1357 DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel); |
1358 } | 1358 } |
1359 } | 1359 } |
1360 if (pDDRoot) { | 1360 if (pDDRoot) { |
1361 XFA_DataDescription_UpdateDataRelation(pDataRoot, pDDRoot); | 1361 XFA_DataDescription_UpdateDataRelation(pDataRoot, pDDRoot); |
1362 } | 1362 } |
1363 DataMerge_UpdateBindingRelations(pSubformSetNode); | 1363 DataMerge_UpdateBindingRelations(pSubformSetNode); |
1364 CXFA_Node* pPageSetNode = | 1364 CXFA_Node* pPageSetNode = |
1365 pSubformSetNode->GetFirstChildByClass(XFA_ELEMENT_PageSet); | 1365 pSubformSetNode->GetFirstChildByClass(XFA_Element::PageSet); |
1366 while (pPageSetNode) { | 1366 while (pPageSetNode) { |
1367 m_pPendingPageSet.Add(pPageSetNode); | 1367 m_pPendingPageSet.Add(pPageSetNode); |
1368 CXFA_Node* pNextPageSetNode = | 1368 CXFA_Node* pNextPageSetNode = |
1369 pPageSetNode->GetNextSameClassSibling(XFA_ELEMENT_PageSet); | 1369 pPageSetNode->GetNextSameClassSibling(XFA_Element::PageSet); |
1370 pSubformSetNode->RemoveChild(pPageSetNode); | 1370 pSubformSetNode->RemoveChild(pPageSetNode); |
1371 pPageSetNode = pNextPageSetNode; | 1371 pPageSetNode = pNextPageSetNode; |
1372 } | 1372 } |
1373 if (!bEmptyForm) { | 1373 if (!bEmptyForm) { |
1374 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1374 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
1375 sIterator(pFormRoot); | 1375 sIterator(pFormRoot); |
1376 CXFA_Node* pNode = sIterator.MoveToNext(); | 1376 CXFA_Node* pNode = sIterator.MoveToNext(); |
1377 while (pNode) { | 1377 while (pNode) { |
1378 if (pNode->IsUnusedNode()) { | 1378 if (pNode->IsUnusedNode()) { |
1379 if (pNode->IsContainerNode() || | 1379 if (pNode->IsContainerNode() || |
1380 pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { | 1380 pNode->GetClassID() == XFA_Element::InstanceManager) { |
1381 CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); | 1381 CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); |
1382 pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); | 1382 pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); |
1383 pNode = pNext; | 1383 pNode = pNext; |
1384 } else { | 1384 } else { |
1385 pNode->ClearFlag(XFA_NodeFlag_UnusedNode); | 1385 pNode->ClearFlag(XFA_NodeFlag_UnusedNode); |
1386 pNode->SetFlag(XFA_NodeFlag_Initialized, true); | 1386 pNode->SetFlag(XFA_NodeFlag_Initialized, true); |
1387 pNode = sIterator.MoveToNext(); | 1387 pNode = sIterator.MoveToNext(); |
1388 } | 1388 } |
1389 } else { | 1389 } else { |
1390 pNode->SetFlag(XFA_NodeFlag_Initialized, true); | 1390 pNode->SetFlag(XFA_NodeFlag_Initialized, true); |
(...skipping 10 matching lines...) Expand all Loading... |
1401 } | 1401 } |
1402 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 1402 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); |
1403 } | 1403 } |
1404 XFA_DataMerge_ClearGlobalBinding(this); | 1404 XFA_DataMerge_ClearGlobalBinding(this); |
1405 if (bDoDataMerge) { | 1405 if (bDoDataMerge) { |
1406 DoDataMerge(); | 1406 DoDataMerge(); |
1407 } | 1407 } |
1408 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); | 1408 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); |
1409 pLayoutProcessor->SetForceReLayout(TRUE); | 1409 pLayoutProcessor->SetForceReLayout(TRUE); |
1410 } | 1410 } |
OLD | NEW |