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

Side by Side Diff: xfa/src/fxfa/parser/xfa_document_datamerger_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/parser/xfa_document_datamerger_imp.h"
8
9 #include "core/include/fxcrt/fx_ext.h"
10 #include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h"
11 #include "xfa/src/fxfa/parser/xfa_basic_imp.h"
12 #include "xfa/src/fxfa/parser/xfa_docdata.h"
13 #include "xfa/src/fxfa/parser/xfa_doclayout.h"
14 #include "xfa/src/fxfa/parser/xfa_document.h"
15 #include "xfa/src/fxfa/parser/xfa_document_datadescription_imp.h"
16 #include "xfa/src/fxfa/parser/xfa_document_layout_imp.h"
17 #include "xfa/src/fxfa/parser/xfa_localemgr.h"
18 #include "xfa/src/fxfa/parser/xfa_object.h"
19 #include "xfa/src/fxfa/parser/xfa_parser.h"
20 #include "xfa/src/fxfa/parser/xfa_script.h"
21 #include "xfa/src/fxfa/parser/xfa_utils.h"
22
23 static FX_BOOL XFA_GetOccurInfo(CXFA_Node* pOccurNode,
24 int32_t& iMin,
25 int32_t& iMax,
26 int32_t& iInit) {
27 if (!pOccurNode) {
28 return FALSE;
29 }
30 CXFA_Occur occur(pOccurNode);
31 return occur.GetOccurInfo(iMin, iMax, iInit);
32 }
33 struct XFA_DataMerge_RecurseRecord {
34 CXFA_Node* pTemplateChild;
35 CXFA_Node* pDataChild;
36 };
37 static CXFA_Node* XFA_DataMerge_FormValueNode_CreateChild(
38 CXFA_Node* pValueNode,
39 XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) {
40 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild);
41 if (!pChildNode) {
42 if (iType == XFA_ELEMENT_UNKNOWN) {
43 return FALSE;
44 }
45 pChildNode = pValueNode->GetProperty(0, iType);
46 }
47 return pChildNode;
48 }
49 static void XFA_DataMerge_FormValueNode_MatchNoneCreateChild(
50 CXFA_Node* pFormNode) {
51 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
52 FXSYS_assert(pWidgetData);
53 pWidgetData->GetUIType();
54 }
55 static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent(
56 CXFA_Node* pValueNode,
57 const CFX_WideString& wsContent,
58 XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) {
59 if (!pValueNode) {
60 return FALSE;
61 }
62 FXSYS_assert(pValueNode->GetPacketID() == XFA_XDPPACKET_Form);
63 CXFA_Node* pChildNode =
64 XFA_DataMerge_FormValueNode_CreateChild(pValueNode, iType);
65 if (!pChildNode) {
66 return FALSE;
67 }
68 XFA_OBJECTTYPE objectType = pChildNode->GetObjectType();
69 switch (objectType) {
70 case XFA_OBJECTTYPE_ContentNode: {
71 CXFA_Node* pContentRawDataNode =
72 pChildNode->GetNodeItem(XFA_NODEITEM_FirstChild);
73 if (!pContentRawDataNode) {
74 XFA_ELEMENT element = XFA_ELEMENT_Sharptext;
75 if (pChildNode->GetClassID() == XFA_ELEMENT_ExData) {
76 CFX_WideString wsContentType;
77 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType,
78 FALSE);
79 if (wsContentType.Equal(FX_WSTRC(L"text/html"))) {
80 element = XFA_ELEMENT_SharpxHTML;
81 } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) {
82 element = XFA_ELEMENT_Sharpxml;
83 }
84 }
85 pContentRawDataNode = pChildNode->CreateSamePacketNode(element);
86 pChildNode->InsertChild(pContentRawDataNode);
87 }
88 pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
89 } break;
90 case XFA_OBJECTTYPE_NodeC:
91 case XFA_OBJECTTYPE_TextNode:
92 case XFA_OBJECTTYPE_NodeV: {
93 pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
94 } break;
95 default:
96 FXSYS_assert(FALSE);
97 break;
98 }
99 return TRUE;
100 }
101 static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
102 CXFA_Node* pDataNode,
103 FX_BOOL bDataToForm = TRUE) {
104 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode);
105 pDataNode->AddBindItem(pFormNode);
106 XFA_ELEMENT eClass = pFormNode->GetClassID();
107 if (eClass != XFA_ELEMENT_Field && eClass != XFA_ELEMENT_ExclGroup) {
108 return;
109 }
110 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
111 FXSYS_assert(pWidgetData);
112 FX_BOOL bNotify = FALSE;
113 XFA_ELEMENT eUIType = pWidgetData->GetUIType();
114 CXFA_Value defValue(pFormNode->GetProperty(0, XFA_ELEMENT_Value));
115 if (!bDataToForm) {
116 CFX_WideString wsValue;
117 CFX_WideString wsFormatedValue;
118 switch (eUIType) {
119 case XFA_ELEMENT_ImageEdit: {
120 CXFA_Image image = defValue.GetImage();
121 CFX_WideString wsContentType;
122 CFX_WideString wsHref;
123 if (image) {
124 image.GetContent(wsValue);
125 image.GetContentType(wsContentType);
126 image.GetHref(wsHref);
127 }
128 IFDE_XMLElement* pXMLDataElement =
129 (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode());
130 FXSYS_assert(pXMLDataElement);
131 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
132 pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
133 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
134 if (!wsHref.IsEmpty()) {
135 pXMLDataElement->SetString(FX_WSTRC(L"href"), wsHref);
136 }
137 } break;
138 case XFA_ELEMENT_ChoiceList:
139 defValue.GetChildValueContent(wsValue);
140 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
141 CFX_WideStringArray wsSelTextArray;
142 pWidgetData->GetSelectedItemsValue(wsSelTextArray);
143 int32_t iSize = wsSelTextArray.GetSize();
144 if (iSize >= 1) {
145 CXFA_Node* pValue = NULL;
146 for (int32_t i = 0; i < iSize; i++) {
147 pValue = pDataNode->CreateSamePacketNode(XFA_ELEMENT_DataValue);
148 pValue->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"value"));
149 pValue->CreateXMLMappingNode();
150 pDataNode->InsertChild(pValue);
151 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]);
152 }
153 } else {
154 IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode();
155 FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element);
156 ((IFDE_XMLElement*)pXMLNode)
157 ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup"));
158 }
159 } else if (!wsValue.IsEmpty()) {
160 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
161 pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
162 }
163 break;
164 case XFA_ELEMENT_CheckButton:
165 defValue.GetChildValueContent(wsValue);
166 if (wsValue.IsEmpty()) {
167 break;
168 }
169 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
170 pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
171 break;
172 case XFA_ELEMENT_ExclGroup: {
173 CXFA_Node* pChecked = NULL;
174 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild);
175 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
176 if (pChild->GetClassID() != XFA_ELEMENT_Field) {
177 continue;
178 }
179 CXFA_Node* pValue = pChild->GetChild(0, XFA_ELEMENT_Value);
180 if (!pValue) {
181 continue;
182 }
183 CXFA_Value valueChild(pValue);
184 valueChild.GetChildValueContent(wsValue);
185 if (wsValue.IsEmpty()) {
186 continue;
187 }
188 CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items);
189 if (!pItems) {
190 continue;
191 }
192 CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
193 if (!pText) {
194 continue;
195 }
196 CFX_WideString wsContent;
197 if (pText->TryContent(wsContent) && (wsContent == wsValue)) {
198 pChecked = pChild;
199 wsFormatedValue = wsValue;
200 pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
201 pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
202 break;
203 }
204 }
205 if (!pChecked) {
206 break;
207 }
208 pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild);
209 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
210 if (pChild == pChecked) {
211 continue;
212 }
213 if (pChild->GetClassID() != XFA_ELEMENT_Field) {
214 continue;
215 }
216 CXFA_Node* pValue = pChild->GetProperty(0, XFA_ELEMENT_Value);
217 CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items);
218 CXFA_Node* pText =
219 pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL;
220 if (pText) {
221 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
222 }
223 CFX_WideString wsContent;
224 if (pText) {
225 pText->TryContent(wsContent);
226 }
227 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsContent,
228 XFA_ELEMENT_Text);
229 }
230 } break;
231 case XFA_ELEMENT_NumericEdit: {
232 defValue.GetChildValueContent(wsValue);
233 if (wsValue.IsEmpty()) {
234 break;
235 }
236 CFX_WideString wsOutput;
237 pWidgetData->NormalizeNumStr(wsValue, wsOutput);
238 wsValue = wsOutput;
239 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
240 pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
241 CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_ELEMENT_Value);
242 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue,
243 XFA_ELEMENT_Float);
244 } break;
245 default:
246 defValue.GetChildValueContent(wsValue);
247 if (wsValue.IsEmpty()) {
248 break;
249 }
250 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
251 pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
252 break;
253 }
254 } else {
255 CFX_WideString wsXMLValue;
256 pDataNode->TryContent(wsXMLValue);
257 CFX_WideString wsNormailizeValue;
258 pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormailizeValue);
259 pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue);
260 switch (eUIType) {
261 case XFA_ELEMENT_ImageEdit: {
262 XFA_DataMerge_FormValueNode_SetChildContent(
263 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Image);
264 CXFA_Image image = defValue.GetImage();
265 if (image) {
266 IFDE_XMLElement* pXMLDataElement =
267 (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode());
268 FXSYS_assert(pXMLDataElement);
269 CFX_WideString wsContentType;
270 CFX_WideString wsHref;
271 pXMLDataElement->GetString(L"xfa:contentType", wsContentType);
272 if (!wsContentType.IsEmpty()) {
273 pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
274 image.SetContentType(wsContentType);
275 }
276 pXMLDataElement->GetString(L"href", wsHref);
277 if (!wsHref.IsEmpty()) {
278 image.SetHref(wsHref);
279 }
280 }
281 } break;
282 case XFA_ELEMENT_ChoiceList:
283 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
284 CXFA_NodeArray items;
285 pDataNode->GetNodeList(items);
286 int32_t iCounts = items.GetSize();
287 if (iCounts > 0) {
288 wsNormailizeValue.Empty();
289 CFX_WideString wsItem;
290 for (int32_t i = 0; i < iCounts; i++) {
291 items[i]->TryContent(wsItem);
292 wsItem = (iCounts == 1) ? wsItem : wsItem + FX_WSTRC(L"\n");
293 wsNormailizeValue += wsItem;
294 }
295 CXFA_ExData exData = defValue.GetExData();
296 FXSYS_assert(exData);
297 exData.SetContentType((iCounts == 1) ? FX_WSTRC(L"text/plain")
298 : FX_WSTRC(L"text/xml"));
299 }
300 XFA_DataMerge_FormValueNode_SetChildContent(
301 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_ExData);
302 } else {
303 XFA_DataMerge_FormValueNode_SetChildContent(
304 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text);
305 }
306 break;
307 case XFA_ELEMENT_CheckButton:
308 XFA_DataMerge_FormValueNode_SetChildContent(
309 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text);
310 break;
311 case XFA_ELEMENT_ExclGroup: {
312 pWidgetData->SetSelectedMemberByValue(wsNormailizeValue, bNotify, FALSE,
313 FALSE);
314 } break;
315 case XFA_ELEMENT_DateTimeEdit:
316 XFA_DataMerge_FormValueNode_SetChildContent(
317 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_DateTime);
318 break;
319 case XFA_ELEMENT_NumericEdit: {
320 CFX_WideString wsPicture;
321 pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind);
322 if (wsPicture.IsEmpty()) {
323 CFX_WideString wsOutput;
324 pWidgetData->NormalizeNumStr(wsNormailizeValue, wsOutput);
325 wsNormailizeValue = wsOutput;
326 }
327 XFA_DataMerge_FormValueNode_SetChildContent(
328 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Float);
329 } break;
330 case XFA_ELEMENT_Barcode:
331 case XFA_ELEMENT_Button:
332 case XFA_ELEMENT_PasswordEdit:
333 case XFA_ELEMENT_Signature:
334 case XFA_ELEMENT_TextEdit:
335 default:
336 XFA_DataMerge_FormValueNode_SetChildContent(
337 defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text);
338 break;
339 }
340 }
341 }
342 static CXFA_Node* XFA_DataMerge_GetGlobalBinding(CXFA_Document* pDocument,
343 FX_DWORD dwNameHash) {
344 CXFA_Node* pNode = NULL;
345 pDocument->m_rgGlobalBinding.Lookup(dwNameHash, pNode);
346 return pNode;
347 }
348 static void XFA_DataMerge_RegisterGlobalBinding(CXFA_Document* pDocument,
349 FX_DWORD dwNameHash,
350 CXFA_Node* pDataNode) {
351 pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode);
352 }
353 static void XFA_DataMerge_ClearGlobalBinding(CXFA_Document* pDocument) {
354 pDocument->m_rgGlobalBinding.RemoveAll();
355 }
356 static CXFA_Node* XFA_DataMerge_ScopeMatchGlobalBinding(
357 CXFA_Node* pDataScope,
358 FX_DWORD dwNameHash,
359 XFA_ELEMENT eMatchDataNodeType,
360 FX_BOOL bUpLevel = TRUE) {
361 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL;
362 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets;
363 pLastDataScope = pCurDataScope,
364 pCurDataScope =
365 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) {
366 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash);
367 pDataChild;
368 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) {
369 if (pDataChild == pLastDataScope ||
370 (eMatchDataNodeType != XFA_ELEMENT_DataModel &&
371 pDataChild->GetClassID() != eMatchDataNodeType) ||
372 pDataChild->HasBindItem()) {
373 continue;
374 }
375 return pDataChild;
376 }
377 for (CXFA_Node* pDataChild =
378 pCurDataScope->GetFirstChildByClass(XFA_ELEMENT_DataGroup);
379 pDataChild; pDataChild = pDataChild->GetNextSameClassSibling(
380 XFA_ELEMENT_DataGroup)) {
381 CXFA_Node* pDataNode = XFA_DataMerge_ScopeMatchGlobalBinding(
382 pDataChild, dwNameHash, eMatchDataNodeType, FALSE);
383 if (pDataNode) {
384 return pDataNode;
385 }
386 }
387 if (!bUpLevel) {
388 break;
389 }
390 }
391 return NULL;
392 }
393 static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument,
394 CFX_WideStringC wsName,
395 CXFA_Node* pDataScope,
396 XFA_ELEMENT eMatchNodeType) {
397 FX_DWORD dwNameHash =
398 wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(),
399 wsName.GetLength());
400 if (dwNameHash != 0) {
401 CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash);
402 if (!pBounded) {
403 pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash,
404 eMatchNodeType);
405 if (pBounded) {
406 XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded);
407 }
408 }
409 return pBounded;
410 }
411 return NULL;
412 }
413 static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument,
414 CFX_WideStringC wsName,
415 CXFA_Node* pDataScope,
416 XFA_ELEMENT eMatchNodeType) {
417 FX_DWORD dwNameHash =
418 wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(),
419 wsName.GetLength());
420 if (dwNameHash != 0) {
421 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL;
422 pCurDataScope &&
423 pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets;
424 pLastDataScope = pCurDataScope,
425 pCurDataScope =
426 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) {
427 for (CXFA_Node* pDataChild =
428 pCurDataScope->GetFirstChildByName(dwNameHash);
429 pDataChild;
430 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) {
431 if (pDataChild == pLastDataScope ||
432 (eMatchNodeType != XFA_ELEMENT_DataModel &&
433 pDataChild->GetClassID() != eMatchNodeType) ||
434 pDataChild->HasBindItem()) {
435 continue;
436 }
437 return pDataChild;
438 }
439 }
440 }
441 return NULL;
442 }
443 static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument,
444 CFX_WideStringC wsRef,
445 CXFA_Node* pDataScope,
446 XFA_ELEMENT eMatchNodeType,
447 CXFA_Node* pTemplateNode,
448 FX_BOOL bForceBind,
449 FX_BOOL bUpLevel = TRUE) {
450 FX_DWORD dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew;
451 if (bUpLevel || wsRef != FX_WSTRC(L"name")) {
452 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
453 }
454 XFA_RESOLVENODE_RS rs;
455 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags,
456 pTemplateNode);
457 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll ||
458 rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll ||
459 rs.nodes.GetSize() > 1) {
460 return pDocument->GetNotBindNode(rs.nodes);
461 }
462 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) {
463 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL;
464 CXFA_Node* pNode = ToNode(pObject);
465 if (!bForceBind && pNode && pNode->HasBindItem()) {
466 pNode = NULL;
467 }
468 return pNode;
469 }
470 return NULL;
471 }
472 CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument,
473 XFA_ELEMENT eClassID,
474 FX_DWORD dwNameHash,
475 CXFA_Node* pFormParent) {
476 CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild);
477 for (; pFormChild;
478 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
479 if (pFormChild->GetClassID() == eClassID &&
480 pFormChild->GetNameHash() == dwNameHash &&
481 pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) {
482 return pFormChild;
483 }
484 }
485 return NULL;
486 }
487 static FX_BOOL XFA_NeedGenerateForm(CXFA_Node* pTemplateChild,
488 FX_BOOL bUseInstanceManager = TRUE) {
489 XFA_ELEMENT eType = pTemplateChild->GetClassID();
490 if (eType == XFA_ELEMENT_Variables) {
491 return TRUE;
492 }
493 if (pTemplateChild->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) {
494 return FALSE;
495 }
496 if (eType == XFA_ELEMENT_Proto ||
497 (bUseInstanceManager && eType == XFA_ELEMENT_Occur)) {
498 return FALSE;
499 }
500 return TRUE;
501 }
502 CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument,
503 CXFA_Node* pFormParent,
504 CXFA_Node* pTemplateNode,
505 FX_BOOL bRecursive,
506 CXFA_NodeArray* pSubformArray) {
507 CXFA_Node* pExistingNode = NULL;
508 if (pSubformArray == NULL) {
509 pExistingNode = XFA_DataMerge_FindFormDOMInstance(
510 pDocument, pTemplateNode->GetClassID(), pTemplateNode->GetNameHash(),
511 pFormParent);
512 } else if (pSubformArray->GetSize() > 0) {
513 pExistingNode = pSubformArray->GetAt(0);
514 pSubformArray->RemoveAt(0);
515 }
516 if (pExistingNode) {
517 if (pSubformArray) {
518 pFormParent->InsertChild(pExistingNode);
519 } else if (pExistingNode->IsContainerNode()) {
520 pFormParent->RemoveChild(pExistingNode);
521 pFormParent->InsertChild(pExistingNode);
522 }
523 pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
524 pExistingNode->SetTemplateNode(pTemplateNode);
525 if (bRecursive && pExistingNode->GetClassID() != XFA_ELEMENT_Items) {
526 for (CXFA_Node* pTemplateChild =
527 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
528 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
529 XFA_NODEITEM_NextSibling)) {
530 if (XFA_NeedGenerateForm(pTemplateChild)) {
531 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pExistingNode,
532 pTemplateChild, bRecursive);
533 }
534 }
535 }
536 pExistingNode->SetFlag(XFA_NODEFLAG_Initialized);
537 return pExistingNode;
538 }
539 CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(FALSE);
540 pFormParent->InsertChild(pNewNode, NULL);
541 if (bRecursive) {
542 for (CXFA_Node* pTemplateChild =
543 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
544 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
545 XFA_NODEITEM_NextSibling)) {
546 if (XFA_NeedGenerateForm(pTemplateChild)) {
547 CXFA_Node* pNewChild = pTemplateChild->CloneTemplateToForm(TRUE);
548 pNewNode->InsertChild(pNewChild, NULL);
549 }
550 }
551 }
552 return pNewNode;
553 }
554 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager(
555 CXFA_Document* pDocument,
556 CXFA_Node* pFormParent,
557 CXFA_Node* pTemplateNode,
558 CXFA_NodeArray& subforms) {
559 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
560 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName;
561 FX_DWORD dwInstNameHash =
562 FX_HashCode_String_GetW(wsInstMgrNodeName, wsInstMgrNodeName.GetLength());
563 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance(
564 pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent);
565 if (pExistingNode) {
566 FX_DWORD dwNameHash = pTemplateNode->GetNameHash();
567 for (CXFA_Node* pNode =
568 pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling);
569 pNode;) {
570 XFA_ELEMENT eCurType = pNode->GetClassID();
571 if (eCurType == XFA_ELEMENT_InstanceManager) {
572 break;
573 }
574 if ((eCurType != XFA_ELEMENT_Subform) &&
575 (eCurType != XFA_ELEMENT_SubformSet)) {
576 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling);
577 continue;
578 }
579 if (dwNameHash != pNode->GetNameHash()) {
580 break;
581 }
582 CXFA_Node* pNextNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling);
583 pFormParent->RemoveChild(pNode);
584 subforms.Add(pNode);
585 pNode = pNextNode;
586 }
587 pFormParent->RemoveChild(pExistingNode);
588 pFormParent->InsertChild(pExistingNode);
589 pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
590 pExistingNode->SetTemplateNode(pTemplateNode);
591 return pExistingNode;
592 }
593 CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode(
594 XFA_XDPPACKET_Form, XFA_ELEMENT_InstanceManager);
595 FXSYS_assert(pNewNode);
596 wsInstMgrNodeName =
597 FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
598 pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName);
599 pFormParent->InsertChild(pNewNode, NULL);
600 pNewNode->SetTemplateNode(pTemplateNode);
601 return pNewNode;
602 }
603 static CXFA_Node* XFA_DataMerge_FindMatchingDataNode(
604 CXFA_Document* pDocument,
605 CXFA_Node* pTemplateNode,
606 CXFA_Node* pDataScope,
607 FX_BOOL& bAccessedDataDOM,
608 FX_BOOL bForceBind,
609 CXFA_NodeIteratorTemplate<CXFA_Node,
610 CXFA_TraverseStrategy_XFAContainerNode>*
611 pIterator,
612 FX_BOOL& bSelfMatch,
613 XFA_ATTRIBUTEENUM& eBindMatch,
614 FX_BOOL bUpLevel = TRUE) {
615 FX_BOOL bOwnIterator = FALSE;
616 if (!pIterator) {
617 bOwnIterator = TRUE;
618 pIterator = new CXFA_NodeIteratorTemplate<
619 CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode);
620 }
621 CXFA_Node* pResult = NULL;
622 for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent();
623 pCurTemplateNode;) {
624 XFA_ELEMENT eMatchNodeType;
625 switch (pCurTemplateNode->GetClassID()) {
626 case XFA_ELEMENT_Subform:
627 eMatchNodeType = XFA_ELEMENT_DataGroup;
628 break;
629 case XFA_ELEMENT_Field: {
630 eMatchNodeType = XFA_FieldIsMultiListBox(pCurTemplateNode)
631 ? XFA_ELEMENT_DataGroup
632 : XFA_ELEMENT_DataValue;
633 } break;
634 case XFA_ELEMENT_ExclGroup:
635 eMatchNodeType = XFA_ELEMENT_DataValue;
636 break;
637 default:
638 pCurTemplateNode = pIterator->MoveToNext();
639 continue;
640 }
641 CXFA_Node* pTemplateNodeOccur =
642 pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur);
643 int32_t iMin, iMax, iInit;
644 if (pTemplateNodeOccur &&
645 XFA_GetOccurInfo(pTemplateNodeOccur, iMin, iMax, iInit) && iMax == 0) {
646 pCurTemplateNode = pIterator->MoveToNext();
647 continue;
648 }
649 CXFA_Node* pTemplateNodeBind =
650 pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind);
651 XFA_ATTRIBUTEENUM eMatch =
652 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match)
653 : XFA_ATTRIBUTEENUM_Once;
654 eBindMatch = eMatch;
655 switch (eMatch) {
656 case XFA_ATTRIBUTEENUM_None:
657 pCurTemplateNode = pIterator->MoveToNext();
658 continue;
659 case XFA_ATTRIBUTEENUM_Global:
660 bAccessedDataDOM = TRUE;
661 if (!bForceBind) {
662 pCurTemplateNode = pIterator->MoveToNext();
663 continue;
664 }
665 if (eMatchNodeType == XFA_ELEMENT_DataValue ||
666 (eMatchNodeType == XFA_ELEMENT_DataGroup &&
667 XFA_FieldIsMultiListBox(pTemplateNodeBind))) {
668 CXFA_Node* pGlobalBindNode = XFA_DataMerge_FindGlobalDataNode(
669 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name),
670 pDataScope, eMatchNodeType);
671 if (!pGlobalBindNode) {
672 pCurTemplateNode = pIterator->MoveToNext();
673 continue;
674 }
675 pResult = pGlobalBindNode;
676 break;
677 }
678 case XFA_ATTRIBUTEENUM_Once: {
679 bAccessedDataDOM = TRUE;
680 CXFA_Node* pOnceBindNode = XFA_DataMerge_FindOnceDataNode(
681 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name),
682 pDataScope, eMatchNodeType);
683 if (!pOnceBindNode) {
684 pCurTemplateNode = pIterator->MoveToNext();
685 continue;
686 }
687 pResult = pOnceBindNode;
688 } break;
689 case XFA_ATTRIBUTEENUM_DataRef: {
690 bAccessedDataDOM = TRUE;
691 CXFA_Node* pDataRefBindNode = XFA_DataMerge_FindDataRefDataNode(
692 pDocument, pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref),
693 pDataScope, eMatchNodeType, pTemplateNode, bForceBind, bUpLevel);
694 if (pDataRefBindNode &&
695 pDataRefBindNode->GetClassID() == eMatchNodeType) {
696 pResult = pDataRefBindNode;
697 }
698 if (!pResult) {
699 pCurTemplateNode = pIterator->SkipChildrenAndMoveToNext();
700 continue;
701 }
702 } break;
703 default:
704 break;
705 }
706 if (pCurTemplateNode == pTemplateNode && pResult) {
707 bSelfMatch = TRUE;
708 }
709 break;
710 }
711 if (bOwnIterator) {
712 delete pIterator;
713 }
714 return pResult;
715 }
716 static void XFA_DataMerge_SortRecurseRecord(
717 CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord>& rgRecords,
718 CXFA_Node* pDataScope,
719 FX_BOOL bChoiceMode = FALSE) {
720 int32_t iCount = rgRecords.GetSize();
721 CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord> rgResultRecord;
722 for (CXFA_Node* pChildNode = pDataScope->GetNodeItem(XFA_NODEITEM_FirstChild);
723 pChildNode;
724 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
725 for (int32_t i = 0; i < iCount; i++) {
726 CXFA_Node* pNode = rgRecords[i].pDataChild;
727 if (pChildNode == pNode) {
728 XFA_DataMerge_RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild,
729 pNode};
730 rgResultRecord.Add(sNewRecord);
731 rgRecords.RemoveAt(i);
732 iCount--;
733 break;
734 }
735 }
736 if (bChoiceMode && rgResultRecord.GetSize() > 0) {
737 break;
738 }
739 }
740 if (rgResultRecord.GetSize() > 0) {
741 if (!bChoiceMode) {
742 for (int32_t i = 0; i < iCount; i++) {
743 XFA_DataMerge_RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild,
744 rgRecords[i].pDataChild};
745 rgResultRecord.Add(sNewRecord);
746 }
747 }
748 rgRecords.RemoveAll();
749 rgRecords.Copy(rgResultRecord);
750 }
751 }
752 static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
753 CXFA_Document* pDocument,
754 CXFA_Node* pTemplateNode,
755 CXFA_Node* pFormParentNode,
756 CXFA_Node* pDataScope,
757 FX_BOOL bOneInstance,
758 FX_BOOL bDataMerge) {
759 XFA_ELEMENT eElement = pTemplateNode->GetClassID();
760 CXFA_Node* pOccurNode = NULL;
761 CXFA_Node* pFirstInstance = NULL;
762 FX_BOOL bUseInstanceManager =
763 pFormParentNode->GetClassID() != XFA_ELEMENT_Area;
764 CXFA_Node* pInstMgrNode = NULL;
765 CXFA_NodeArray subformArray;
766 CXFA_NodeArray* pSearchArray = NULL;
767 if (!bOneInstance &&
768 (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Subform)) {
769 pInstMgrNode =
770 bUseInstanceManager
771 ? XFA_NodeMerge_CloneOrMergeInstanceManager(
772 pDocument, pFormParentNode, pTemplateNode, subformArray)
773 : NULL;
774 if (CXFA_Node* pOccurTemplateNode =
775 pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur)) {
776 pOccurNode = pInstMgrNode
777 ? XFA_NodeMerge_CloneOrMergeContainer(
778 pDocument, pInstMgrNode, pOccurTemplateNode, FALSE)
779 : pOccurTemplateNode;
780 } else if (pInstMgrNode) {
781 pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_ELEMENT_Occur);
782 if (pOccurNode) {
783 pOccurNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
784 }
785 }
786 if (pInstMgrNode) {
787 pInstMgrNode->SetFlag(XFA_NODEFLAG_Initialized);
788 pSearchArray = &subformArray;
789 if (pFormParentNode->GetClassID() == XFA_ELEMENT_PageArea) {
790 bOneInstance = TRUE;
791 if (subformArray.GetSize() < 1) {
792 pSearchArray = NULL;
793 }
794 } else if ((pTemplateNode->GetNameHash() == 0) &&
795 (subformArray.GetSize() < 1)) {
796 pSearchArray = NULL;
797 }
798 }
799 }
800 int32_t iMax = 1, iInit = 1, iMin = 1;
801 if (!bOneInstance) {
802 XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit);
803 }
804 XFA_ATTRIBUTEENUM eRelation =
805 eElement == XFA_ELEMENT_SubformSet
806 ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation)
807 : XFA_ATTRIBUTEENUM_Ordered;
808 int32_t iCurRepeatIndex = 0;
809 XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None;
810 if (bDataMerge) {
811 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>
812 sNodeIterator(pTemplateNode);
813 FX_BOOL bAccessedDataDOM = FALSE;
814 if (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Area) {
815 sNodeIterator.MoveToNext();
816 } else {
817 CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray;
818 CXFA_NodeArray subformArray;
819 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) {
820 FX_BOOL bSelfMatch = FALSE;
821 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None;
822 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode(
823 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE,
824 &sNodeIterator, bSelfMatch, eBindMatch);
825 if (!pDataNode || sNodeIterator.GetCurrent() != pTemplateNode) {
826 break;
827 }
828 eParentBindMatch = eBindMatch;
829 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer(
830 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
831 if (!pFirstInstance) {
832 pFirstInstance = pSubformNode;
833 }
834 XFA_DataMerge_CreateDataBinding(pSubformNode, pDataNode);
835 FXSYS_assert(pSubformNode);
836 subformMapArray.SetAt(pSubformNode, pDataNode);
837 subformArray.Add(pSubformNode);
838 }
839 subformMapArray.GetStartPosition();
840 for (int32_t iIndex = 0; iIndex < subformArray.GetSize(); iIndex++) {
841 CXFA_Node* pSubform = subformArray[iIndex];
842 CXFA_Node* pDataNode =
843 reinterpret_cast<CXFA_Node*>(subformMapArray.GetValueAt(pSubform));
844 for (CXFA_Node* pTemplateChild =
845 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
846 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
847 XFA_NODEITEM_NextSibling)) {
848 if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
849 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubform,
850 pTemplateChild, TRUE);
851 } else if (pTemplateChild->GetObjectType() ==
852 XFA_OBJECTTYPE_ContainerNode) {
853 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubform,
854 pDataNode, FALSE, TRUE, FALSE);
855 }
856 }
857 }
858 subformMapArray.RemoveAll();
859 }
860 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) {
861 FX_BOOL bSelfMatch = FALSE;
862 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None;
863 if (!XFA_DataMerge_FindMatchingDataNode(
864 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE,
865 &sNodeIterator, bSelfMatch, eBindMatch)) {
866 break;
867 }
868 if (eBindMatch == XFA_ATTRIBUTEENUM_DataRef &&
869 eParentBindMatch == XFA_ATTRIBUTEENUM_DataRef) {
870 break;
871 }
872 if (eRelation == XFA_ATTRIBUTEENUM_Choice ||
873 eRelation == XFA_ATTRIBUTEENUM_Unordered) {
874 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
875 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
876 FXSYS_assert(pSubformSetNode);
877 if (!pFirstInstance) {
878 pFirstInstance = pSubformSetNode;
879 }
880 CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord> rgItemMatchList;
881 CFX_ArrayTemplate<CXFA_Node*> rgItemUnmatchList;
882 for (CXFA_Node* pTemplateChild =
883 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
884 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
885 XFA_NODEITEM_NextSibling)) {
886 if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
887 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode,
888 pTemplateChild, TRUE);
889 } else if (pTemplateChild->GetObjectType() ==
890 XFA_OBJECTTYPE_ContainerNode) {
891 CXFA_Node* pDataMatch;
892 bSelfMatch = FALSE;
893 eBindMatch = XFA_ATTRIBUTEENUM_None;
894 if (eRelation != XFA_ATTRIBUTEENUM_Ordered &&
895 (pDataMatch = XFA_DataMerge_FindMatchingDataNode(
896 pDocument, pTemplateChild, pDataScope, bAccessedDataDOM,
897 FALSE, NULL, bSelfMatch, eBindMatch))) {
898 XFA_DataMerge_RecurseRecord sNewRecord = {pTemplateChild,
899 pDataMatch};
900 if (bSelfMatch) {
901 rgItemMatchList.InsertAt(0, sNewRecord);
902 } else {
903 rgItemMatchList.Add(sNewRecord);
904 }
905 } else {
906 rgItemUnmatchList.Add(pTemplateChild);
907 }
908 }
909 }
910 switch (eRelation) {
911 case XFA_ATTRIBUTEENUM_Choice: {
912 FXSYS_assert(rgItemMatchList.GetSize());
913 XFA_DataMerge_SortRecurseRecord(rgItemMatchList, pDataScope, TRUE);
914 pDocument->DataMerge_CopyContainer(
915 rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope);
916 } break;
917 case XFA_ATTRIBUTEENUM_Unordered: {
918 if (rgItemMatchList.GetSize()) {
919 XFA_DataMerge_SortRecurseRecord(rgItemMatchList, pDataScope);
920 for (int32_t i = 0, count = rgItemMatchList.GetSize(); i < count;
921 i++) {
922 pDocument->DataMerge_CopyContainer(
923 rgItemMatchList[i].pTemplateChild, pSubformSetNode,
924 pDataScope);
925 }
926 }
927 for (int32_t i = 0, count = rgItemUnmatchList.GetSize(); i < count;
928 i++) {
929 pDocument->DataMerge_CopyContainer(rgItemUnmatchList[i],
930 pSubformSetNode, pDataScope);
931 }
932 } break;
933 default:
934 break;
935 }
936 } else {
937 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
938 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
939 FXSYS_assert(pSubformSetNode);
940 if (!pFirstInstance) {
941 pFirstInstance = pSubformSetNode;
942 }
943 for (CXFA_Node* pTemplateChild =
944 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
945 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
946 XFA_NODEITEM_NextSibling)) {
947 if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
948 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode,
949 pTemplateChild, TRUE);
950 } else if (pTemplateChild->GetObjectType() ==
951 XFA_OBJECTTYPE_ContainerNode) {
952 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode,
953 pDataScope);
954 }
955 }
956 }
957 }
958 if (iCurRepeatIndex == 0 && bAccessedDataDOM == FALSE) {
959 int32_t iLimit = iMax;
960 if (pInstMgrNode && pTemplateNode->GetNameHash() == 0) {
961 iLimit = subformArray.GetSize();
962 if (iLimit < iMin) {
963 iLimit = iInit;
964 }
965 }
966 for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) {
967 if (pInstMgrNode) {
968 if (pSearchArray && pSearchArray->GetSize() < 1) {
969 if (pTemplateNode->GetNameHash() != 0) {
970 break;
971 }
972 pSearchArray = NULL;
973 }
974 } else if (!XFA_DataMerge_FindFormDOMInstance(
975 pDocument, pTemplateNode->GetClassID(),
976 pTemplateNode->GetNameHash(), pFormParentNode)) {
977 break;
978 }
979 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer(
980 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
981 FXSYS_assert(pSubformNode);
982 if (!pFirstInstance) {
983 pFirstInstance = pSubformNode;
984 }
985 for (CXFA_Node* pTemplateChild =
986 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
987 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
988 XFA_NODEITEM_NextSibling)) {
989 if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
990 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformNode,
991 pTemplateChild, TRUE);
992 } else if (pTemplateChild->GetObjectType() ==
993 XFA_OBJECTTYPE_ContainerNode) {
994 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformNode,
995 pDataScope);
996 }
997 }
998 }
999 }
1000 }
1001 int32_t iMinimalLimit = iCurRepeatIndex == 0 ? iInit : iMin;
1002 for (; iCurRepeatIndex < iMinimalLimit; iCurRepeatIndex++) {
1003 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
1004 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
1005 FXSYS_assert(pSubformSetNode);
1006 if (!pFirstInstance) {
1007 pFirstInstance = pSubformSetNode;
1008 }
1009 FX_BOOL bFound = FALSE;
1010 for (CXFA_Node* pTemplateChild =
1011 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1012 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
1013 XFA_NODEITEM_NextSibling)) {
1014 if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
1015 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode,
1016 pTemplateChild, TRUE);
1017 } else if (pTemplateChild->GetObjectType() ==
1018 XFA_OBJECTTYPE_ContainerNode) {
1019 if (bFound && eRelation == XFA_ATTRIBUTEENUM_Choice) {
1020 continue;
1021 }
1022 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode,
1023 pDataScope, FALSE, bDataMerge);
1024 bFound = TRUE;
1025 }
1026 }
1027 }
1028 return pFirstInstance;
1029 }
1030 static CXFA_Node* XFA_DataMerge_CopyContainer_Field(CXFA_Document* pDocument,
1031 CXFA_Node* pTemplateNode,
1032 CXFA_Node* pFormNode,
1033 CXFA_Node* pDataScope,
1034 FX_BOOL bDataMerge,
1035 FX_BOOL bUpLevel = TRUE) {
1036 CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer(
1037 pDocument, pFormNode, pTemplateNode, FALSE);
1038 FXSYS_assert(pFieldNode);
1039 for (CXFA_Node* pTemplateChildNode =
1040 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1041 pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem(
1042 XFA_NODEITEM_NextSibling)) {
1043 if (XFA_NeedGenerateForm(pTemplateChildNode)) {
1044 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode,
1045 pTemplateChildNode, TRUE);
1046 } else if (pTemplateNode->GetClassID() == XFA_ELEMENT_ExclGroup &&
1047 pTemplateChildNode->IsContainerNode()) {
1048 if (pTemplateChildNode->GetClassID() == XFA_ELEMENT_Field) {
1049 XFA_DataMerge_CopyContainer_Field(pDocument, pTemplateChildNode,
1050 pFieldNode, NULL, FALSE);
1051 }
1052 }
1053 }
1054 if (bDataMerge) {
1055 FX_BOOL bAccessedDataDOM = FALSE;
1056 FX_BOOL bSelfMatch = FALSE;
1057 XFA_ATTRIBUTEENUM eBindMatch;
1058 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode(
1059 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, NULL,
1060 bSelfMatch, eBindMatch, bUpLevel);
1061 if (pDataNode) {
1062 XFA_DataMerge_CreateDataBinding(pFieldNode, pDataNode);
1063 }
1064 } else {
1065 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFieldNode);
1066 }
1067 return pFieldNode;
1068 }
1069 CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode,
1070 CXFA_Node* pFormNode,
1071 CXFA_Node* pDataScope,
1072 FX_BOOL bOneInstance,
1073 FX_BOOL bDataMerge,
1074 FX_BOOL bUpLevel) {
1075 switch (pTemplateNode->GetClassID()) {
1076 case XFA_ELEMENT_SubformSet:
1077 case XFA_ELEMENT_Subform:
1078 case XFA_ELEMENT_Area:
1079 case XFA_ELEMENT_PageArea:
1080 return XFA_DataMerge_CopyContainer_SubformSet(
1081 this, pTemplateNode, pFormNode, pDataScope, bOneInstance, bDataMerge);
1082 case XFA_ELEMENT_ExclGroup:
1083 case XFA_ELEMENT_Field:
1084 case XFA_ELEMENT_Draw:
1085 case XFA_ELEMENT_ContentArea:
1086 return XFA_DataMerge_CopyContainer_Field(
1087 this, pTemplateNode, pFormNode, pDataScope, bDataMerge, bUpLevel);
1088 case XFA_ELEMENT_PageSet:
1089 break;
1090 case XFA_ELEMENT_Variables:
1091 break;
1092 default:
1093 FXSYS_assert(FALSE);
1094 break;
1095 }
1096 return NULL;
1097 }
1098
1099 static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument,
1100 CXFA_Node* pFormNode,
1101 CXFA_Node* pDataScope,
1102 FX_BOOL bDataRef,
1103 FX_BOOL bParentDataRef) {
1104 FX_BOOL bMatchRef = TRUE;
1105 XFA_ELEMENT eClassID = pFormNode->GetClassID();
1106 CXFA_Node* pDataNode = pFormNode->GetBindData();
1107 if (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup ||
1108 eClassID == XFA_ELEMENT_Field) {
1109 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode();
1110 CXFA_Node* pTemplateNodeBind =
1111 pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind)
1112 : NULL;
1113 XFA_ATTRIBUTEENUM eMatch =
1114 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match)
1115 : XFA_ATTRIBUTEENUM_Once;
1116 switch (eMatch) {
1117 case XFA_ATTRIBUTEENUM_None:
1118 if (!bDataRef || bParentDataRef) {
1119 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode);
1120 }
1121 break;
1122 case XFA_ATTRIBUTEENUM_Once:
1123 if (!bDataRef || bParentDataRef) {
1124 if (!pDataNode) {
1125 if (pFormNode->GetNameHash() != 0 &&
1126 pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) !=
1127 XFA_ATTRIBUTEENUM_None) {
1128 XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform ||
1129 XFA_FieldIsMultiListBox(pFormNode))
1130 ? XFA_ELEMENT_DataGroup
1131 : XFA_ELEMENT_DataValue;
1132 pDataNode = XFA_DataDescription_MaybeCreateDataNode(
1133 pDocument, pDataScope, eDataNodeType,
1134 pFormNode->GetCData(XFA_ATTRIBUTE_Name));
1135 if (pDataNode) {
1136 XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE);
1137 }
1138 }
1139 if (!pDataNode) {
1140 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode);
1141 }
1142 } else {
1143 CXFA_Node* pDataParent =
1144 pDataNode->GetNodeItem(XFA_NODEITEM_Parent);
1145 if (pDataParent != pDataScope) {
1146 FXSYS_assert(pDataParent);
1147 pDataParent->RemoveChild(pDataNode);
1148 pDataScope->InsertChild(pDataNode);
1149 }
1150 }
1151 }
1152 break;
1153 case XFA_ATTRIBUTEENUM_Global:
1154 if (!bDataRef || bParentDataRef) {
1155 FX_DWORD dwNameHash = pFormNode->GetNameHash();
1156 if (dwNameHash != 0 && !pDataNode) {
1157 pDataNode = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash);
1158 if (!pDataNode) {
1159 XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform ||
1160 XFA_FieldIsMultiListBox(pFormNode))
1161 ? XFA_ELEMENT_DataGroup
1162 : XFA_ELEMENT_DataValue;
1163 CXFA_Node* pRecordNode =
1164 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
1165 pDataNode = XFA_DataDescription_MaybeCreateDataNode(
1166 pDocument, pRecordNode, eDataNodeType,
1167 pFormNode->GetCData(XFA_ATTRIBUTE_Name));
1168 if (pDataNode) {
1169 XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE);
1170 XFA_DataMerge_RegisterGlobalBinding(
1171 pDocument, pFormNode->GetNameHash(), pDataNode);
1172 }
1173 } else {
1174 XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode);
1175 }
1176 }
1177 if (!pDataNode) {
1178 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode);
1179 }
1180 }
1181 break;
1182 case XFA_ATTRIBUTEENUM_DataRef: {
1183 bMatchRef = bDataRef;
1184 bParentDataRef = TRUE;
1185 if (!pDataNode && bDataRef) {
1186 CFX_WideStringC wsRef =
1187 pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref);
1188 FX_DWORD dFlags =
1189 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode;
1190 XFA_RESOLVENODE_RS rs;
1191 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs,
1192 dFlags, pTemplateNode);
1193 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL;
1194 pDataNode = ToNode(pObject);
1195 if (pDataNode) {
1196 XFA_DataMerge_CreateDataBinding(
1197 pFormNode, pDataNode,
1198 rs.dwFlags == XFA_RESOVENODE_RSTYPE_ExistNodes);
1199 } else {
1200 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode);
1201 }
1202 }
1203 } break;
1204 default:
1205 break;
1206 }
1207 }
1208 if (bMatchRef &&
1209 (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_SubformSet ||
1210 eClassID == XFA_ELEMENT_Area || eClassID == XFA_ELEMENT_PageArea ||
1211 eClassID == XFA_ELEMENT_PageSet)) {
1212 for (CXFA_Node* pFormChild =
1213 pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1214 pFormChild;
1215 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1216 if (pFormChild->GetObjectType() != XFA_OBJECTTYPE_ContainerNode) {
1217 continue;
1218 }
1219 if (pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) {
1220 continue;
1221 }
1222 XFA_DataMerge_UpdateBindingRelations(pDocument, pFormChild,
1223 pDataNode ? pDataNode : pDataScope,
1224 bDataRef, bParentDataRef);
1225 }
1226 }
1227 }
1228 CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode) {
1229 for (CXFA_Node* pRootBoundNode = pParentFormNode;
1230 pRootBoundNode &&
1231 pRootBoundNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode;
1232 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) {
1233 CXFA_Node* pDataScope = pRootBoundNode->GetBindData();
1234 if (pDataScope) {
1235 return pDataScope;
1236 }
1237 }
1238 return ToNode(
1239 pParentFormNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Data));
1240 }
1241 void CXFA_Document::DataMerge_UpdateBindingRelations(
1242 CXFA_Node* pFormUpdateRoot) {
1243 CXFA_Node* pDataScope = XFA_DataMerge_FindDataScope(
1244 pFormUpdateRoot->GetNodeItem(XFA_NODEITEM_Parent));
1245 if (!pDataScope) {
1246 return;
1247 }
1248 XFA_DataMerge_UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, FALSE,
1249 FALSE);
1250 XFA_DataMerge_UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, TRUE,
1251 FALSE);
1252 }
1253 CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) {
1254 for (int32_t i = 0; i < arrayNodes.GetSize(); i++) {
1255 CXFA_Node* pNode = arrayNodes[i]->AsNode();
1256 if (pNode && !pNode->HasBindItem())
1257 return pNode;
1258 }
1259 return nullptr;
1260 }
1261 void CXFA_Document::DoDataMerge() {
1262 CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets));
1263 if (!pDatasetsRoot) {
1264 IFDE_XMLElement* pDatasetsXMLNode =
1265 IFDE_XMLElement::Create(FX_WSTRC(L"xfa:datasets"));
1266 FXSYS_assert(pDatasetsXMLNode);
1267 pDatasetsXMLNode->SetString(
1268 FX_WSTRC(L"xmlns:xfa"),
1269 FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/"));
1270 pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel);
1271 pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"datasets"));
1272 m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode);
1273 m_pRootNode->InsertChild(pDatasetsRoot);
1274 pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode);
1275 }
1276 CXFA_Node *pDataRoot = NULL, *pDDRoot = NULL;
1277 CFX_WideString wsDatasetsURI;
1278 pDatasetsRoot->TryNamespace(wsDatasetsURI);
1279 for (CXFA_Node* pChildNode =
1280 pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
1281 pChildNode;
1282 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1283 if (pChildNode->GetClassID() != XFA_ELEMENT_DataGroup) {
1284 continue;
1285 }
1286 CFX_WideString wsNamespaceURI;
1287 if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) {
1288 if (!pChildNode->TryNamespace(wsNamespaceURI)) {
1289 continue;
1290 }
1291 if (wsNamespaceURI ==
1292 FX_WSTRC(L"http://ns.adobe.com/data-description/")) {
1293 pDDRoot = pChildNode;
1294 }
1295 } else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) {
1296 if (!pChildNode->TryNamespace(wsNamespaceURI)) {
1297 continue;
1298 }
1299 if (wsNamespaceURI == wsDatasetsURI) {
1300 pDataRoot = pChildNode;
1301 }
1302 }
1303 if (pDataRoot && pDDRoot) {
1304 break;
1305 }
1306 }
1307 if (!pDataRoot) {
1308 IFDE_XMLElement* pDataRootXMLNode =
1309 IFDE_XMLElement::Create(FX_WSTRC(L"xfa:data"));
1310 FXSYS_assert(pDataRootXMLNode);
1311 pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup);
1312 pDataRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"data"));
1313 pDataRoot->SetXMLMappingNode(pDataRootXMLNode);
1314 pDatasetsRoot->InsertChild(pDataRoot);
1315 }
1316 CXFA_Node* pDataTopLevel =
1317 pDataRoot->GetFirstChildByClass(XFA_ELEMENT_DataGroup);
1318 FX_DWORD dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0;
1319 CXFA_Node* pTemplateRoot =
1320 m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template);
1321 if (!pTemplateRoot) {
1322 return;
1323 }
1324 CXFA_Node* pTemplateChosen =
1325 dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) : NULL;
1326 if (!pTemplateChosen ||
1327 pTemplateChosen->GetClassID() != XFA_ELEMENT_Subform) {
1328 pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform);
1329 }
1330 if (!pTemplateChosen) {
1331 return;
1332 }
1333 CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Form);
1334 FX_BOOL bEmptyForm = FALSE;
1335 if (!pFormRoot) {
1336 bEmptyForm = TRUE;
1337 pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form);
1338 FXSYS_assert(pFormRoot);
1339 pFormRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"form"));
1340 m_pRootNode->InsertChild(pFormRoot, NULL);
1341 } else {
1342 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
1343 sIterator(pFormRoot);
1344 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode;
1345 pNode = sIterator.MoveToNext()) {
1346 pNode->SetFlag(XFA_NODEFLAG_UnusedNode);
1347 }
1348 }
1349 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
1350 this, pFormRoot, pTemplateChosen, FALSE);
1351 FXSYS_assert(pSubformSetNode);
1352 if (!pDataTopLevel) {
1353 CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name);
1354 CFX_WideString wsDataTopLevelName =
1355 wsFormName.IsEmpty() ? FX_WSTRC(L"form") : wsFormName;
1356 IFDE_XMLElement* pDataTopLevelXMLNode =
1357 IFDE_XMLElement::Create(wsDataTopLevelName);
1358 FXSYS_assert(pDataTopLevelXMLNode);
1359 pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup);
1360 pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName);
1361 pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode);
1362 CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
1363 pDataRoot->InsertChild(pDataTopLevel, pBeforeNode);
1364 }
1365 FXSYS_assert(pDataTopLevel);
1366 XFA_DataMerge_CreateDataBinding(pSubformSetNode, pDataTopLevel);
1367 for (CXFA_Node* pTemplateChild =
1368 pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild);
1369 pTemplateChild;
1370 pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1371 if (XFA_NeedGenerateForm(pTemplateChild)) {
1372 XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild,
1373 TRUE);
1374 } else if (pTemplateChild->GetObjectType() ==
1375 XFA_OBJECTTYPE_ContainerNode) {
1376 DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel);
1377 }
1378 }
1379 if (pDDRoot) {
1380 XFA_DataDescription_UpdateDataRelation(pDataRoot, pDDRoot);
1381 }
1382 DataMerge_UpdateBindingRelations(pSubformSetNode);
1383 CXFA_Node* pPageSetNode =
1384 pSubformSetNode->GetFirstChildByClass(XFA_ELEMENT_PageSet);
1385 while (pPageSetNode) {
1386 m_pPendingPageSet.Add(pPageSetNode);
1387 CXFA_Node* pNextPageSetNode =
1388 pPageSetNode->GetNextSameClassSibling(XFA_ELEMENT_PageSet);
1389 pSubformSetNode->RemoveChild(pPageSetNode);
1390 pPageSetNode = pNextPageSetNode;
1391 }
1392 if (!bEmptyForm) {
1393 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
1394 sIterator(pFormRoot);
1395 CXFA_Node* pNode = sIterator.MoveToNext();
1396 while (pNode) {
1397 if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) {
1398 if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode ||
1399 pNode->GetClassID() == XFA_ELEMENT_InstanceManager) {
1400 CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext();
1401 pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode);
1402 pNode = pNext;
1403 } else {
1404 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
1405 pNode->SetFlag(XFA_NODEFLAG_Initialized);
1406 pNode = sIterator.MoveToNext();
1407 }
1408 } else {
1409 pNode->SetFlag(XFA_NODEFLAG_Initialized);
1410 pNode = sIterator.MoveToNext();
1411 }
1412 }
1413 }
1414 }
1415 void CXFA_Document::DoDataRemerge(FX_BOOL bDoDataMerge) {
1416 CXFA_Node* pFormRoot = ToNode(GetXFAObject(XFA_HASHCODE_Form));
1417 if (pFormRoot) {
1418 while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) {
1419 pFormRoot->RemoveChild(pNode);
1420 }
1421 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL);
1422 }
1423 XFA_DataMerge_ClearGlobalBinding(this);
1424 if (bDoDataMerge) {
1425 DoDataMerge();
1426 }
1427 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor();
1428 pLayoutProcessor->SetForceReLayout(TRUE);
1429 }
OLDNEW
« no previous file with comments | « xfa/src/fxfa/parser/xfa_document_datamerger_imp.h ('k') | xfa/src/fxfa/parser/xfa_document_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698