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

Side by Side Diff: xfa/fxfa/parser/cxfa_node.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « xfa/fxfa/parser/cxfa_measurement.cpp ('k') | xfa/fxfa/parser/cxfa_nodehelper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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_object.h" 7 #include "xfa/fxfa/parser/xfa_object.h"
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get(); 121 CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get();
122 if (!(*pNodeSetPairMap)[dwNameHash]) 122 if (!(*pNodeSetPairMap)[dwNameHash])
123 (*pNodeSetPairMap)[dwNameHash].reset(new CXFA_NodeSetPair); 123 (*pNodeSetPairMap)[dwNameHash].reset(new CXFA_NodeSetPair);
124 124
125 return (*pNodeSetPairMap)[dwNameHash].get(); 125 return (*pNodeSetPairMap)[dwNameHash].get();
126 } 126 }
127 127
128 void ReorderDataNodes(const CXFA_NodeSet& sSet1, 128 void ReorderDataNodes(const CXFA_NodeSet& sSet1,
129 const CXFA_NodeSet& sSet2, 129 const CXFA_NodeSet& sSet2,
130 FX_BOOL bInsertBefore) { 130 bool bInsertBefore) {
131 CXFA_NodeSetPairMapMap rgMap; 131 CXFA_NodeSetPairMapMap rgMap;
132 for (CXFA_Node* pNode : sSet1) { 132 for (CXFA_Node* pNode : sSet1) {
133 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); 133 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap);
134 if (pNodeSetPair) 134 if (pNodeSetPair)
135 pNodeSetPair->first.insert(pNode); 135 pNodeSetPair->first.insert(pNode);
136 } 136 }
137 for (CXFA_Node* pNode : sSet2) { 137 for (CXFA_Node* pNode : sSet2) {
138 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap); 138 CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap);
139 if (pNodeSetPair) { 139 if (pNodeSetPair) {
140 if (pdfium::ContainsValue(pNodeSetPair->first, pNode)) 140 if (pdfium::ContainsValue(pNodeSetPair->first, pNode))
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (iCount > iIndex) 211 if (iCount > iIndex)
212 return pNode; 212 return pNode;
213 } 213 }
214 return nullptr; 214 return nullptr;
215 } 215 }
216 216
217 void InsertItem(CXFA_Node* pInstMgrNode, 217 void InsertItem(CXFA_Node* pInstMgrNode,
218 CXFA_Node* pNewInstance, 218 CXFA_Node* pNewInstance,
219 int32_t iPos, 219 int32_t iPos,
220 int32_t iCount = -1, 220 int32_t iCount = -1,
221 FX_BOOL bMoveDataBindingNodes = TRUE) { 221 bool bMoveDataBindingNodes = true) {
222 if (iCount < 0) 222 if (iCount < 0)
223 iCount = GetCount(pInstMgrNode); 223 iCount = GetCount(pInstMgrNode);
224 if (iPos < 0) 224 if (iPos < 0)
225 iPos = iCount; 225 iPos = iCount;
226 if (iPos == iCount) { 226 if (iPos == iCount) {
227 CXFA_Node* pNextSibling = 227 CXFA_Node* pNextSibling =
228 iCount > 0 228 iCount > 0
229 ? GetItem(pInstMgrNode, iCount - 1) 229 ? GetItem(pInstMgrNode, iCount - 1)
230 ->GetNodeItem(XFA_NODEITEM_NextSibling) 230 ->GetNodeItem(XFA_NODEITEM_NextSibling)
231 : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); 231 : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling);
(...skipping 17 matching lines...) Expand all
249 CXFA_TraverseStrategy_XFAContainerNode> 249 CXFA_TraverseStrategy_XFAContainerNode>
250 sIteratorAfter(pNextSibling); 250 sIteratorAfter(pNextSibling);
251 for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode; 251 for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode;
252 pNode = sIteratorAfter.MoveToNext()) { 252 pNode = sIteratorAfter.MoveToNext()) {
253 CXFA_Node* pDataNode = pNode->GetBindData(); 253 CXFA_Node* pDataNode = pNode->GetBindData();
254 if (!pDataNode) 254 if (!pDataNode)
255 continue; 255 continue;
256 256
257 sAfter.insert(pDataNode); 257 sAfter.insert(pDataNode);
258 } 258 }
259 ReorderDataNodes(sNew, sAfter, FALSE); 259 ReorderDataNodes(sNew, sAfter, false);
260 } 260 }
261 } else { 261 } else {
262 CXFA_Node* pBeforeInstance = GetItem(pInstMgrNode, iPos); 262 CXFA_Node* pBeforeInstance = GetItem(pInstMgrNode, iPos);
263 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) 263 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)
264 ->InsertChild(pNewInstance, pBeforeInstance); 264 ->InsertChild(pNewInstance, pBeforeInstance);
265 if (bMoveDataBindingNodes) { 265 if (bMoveDataBindingNodes) {
266 CXFA_NodeSet sNew; 266 CXFA_NodeSet sNew;
267 CXFA_NodeSet sBefore; 267 CXFA_NodeSet sBefore;
268 CXFA_NodeIteratorTemplate<CXFA_Node, 268 CXFA_NodeIteratorTemplate<CXFA_Node,
269 CXFA_TraverseStrategy_XFAContainerNode> 269 CXFA_TraverseStrategy_XFAContainerNode>
(...skipping 10 matching lines...) Expand all
280 CXFA_TraverseStrategy_XFAContainerNode> 280 CXFA_TraverseStrategy_XFAContainerNode>
281 sIteratorBefore(pBeforeInstance); 281 sIteratorBefore(pBeforeInstance);
282 for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode; 282 for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode;
283 pNode = sIteratorBefore.MoveToNext()) { 283 pNode = sIteratorBefore.MoveToNext()) {
284 CXFA_Node* pDataNode = pNode->GetBindData(); 284 CXFA_Node* pDataNode = pNode->GetBindData();
285 if (!pDataNode) 285 if (!pDataNode)
286 continue; 286 continue;
287 287
288 sBefore.insert(pDataNode); 288 sBefore.insert(pDataNode);
289 } 289 }
290 ReorderDataNodes(sNew, sBefore, TRUE); 290 ReorderDataNodes(sNew, sBefore, true);
291 } 291 }
292 } 292 }
293 } 293 }
294 294
295 void RemoveItem(CXFA_Node* pInstMgrNode, 295 void RemoveItem(CXFA_Node* pInstMgrNode,
296 CXFA_Node* pRemoveInstance, 296 CXFA_Node* pRemoveInstance,
297 FX_BOOL bRemoveDataBinding = TRUE) { 297 bool bRemoveDataBinding = true) {
298 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance); 298 pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance);
299 if (!bRemoveDataBinding) 299 if (!bRemoveDataBinding)
300 return; 300 return;
301 301
302 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> 302 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>
303 sIterator(pRemoveInstance); 303 sIterator(pRemoveInstance);
304 for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode; 304 for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode;
305 pFormNode = sIterator.MoveToNext()) { 305 pFormNode = sIterator.MoveToNext()) {
306 CXFA_Node* pDataNode = pFormNode->GetBindData(); 306 CXFA_Node* pDataNode = pFormNode->GetBindData();
307 if (!pDataNode) 307 if (!pDataNode)
308 continue; 308 continue;
309 309
310 if (pDataNode->RemoveBindItem(pFormNode) == 0) { 310 if (pDataNode->RemoveBindItem(pFormNode) == 0) {
311 if (CXFA_Node* pDataParent = 311 if (CXFA_Node* pDataParent =
312 pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) { 312 pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) {
313 pDataParent->RemoveChild(pDataNode); 313 pDataParent->RemoveChild(pDataNode);
314 } 314 }
315 } 315 }
316 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); 316 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
317 } 317 }
318 } 318 }
319 319
320 CXFA_Node* CreateInstance(CXFA_Node* pInstMgrNode, FX_BOOL bDataMerge) { 320 CXFA_Node* CreateInstance(CXFA_Node* pInstMgrNode, bool bDataMerge) {
321 CXFA_Document* pDocument = pInstMgrNode->GetDocument(); 321 CXFA_Document* pDocument = pInstMgrNode->GetDocument();
322 CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode(); 322 CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode();
323 CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent); 323 CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent);
324 CXFA_Node* pDataScope = nullptr; 324 CXFA_Node* pDataScope = nullptr;
325 for (CXFA_Node* pRootBoundNode = pFormParent; 325 for (CXFA_Node* pRootBoundNode = pFormParent;
326 pRootBoundNode && pRootBoundNode->IsContainerNode(); 326 pRootBoundNode && pRootBoundNode->IsContainerNode();
327 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { 327 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) {
328 pDataScope = pRootBoundNode->GetBindData(); 328 pDataScope = pRootBoundNode->GetBindData();
329 if (pDataScope) 329 if (pDataScope)
330 break; 330 break;
331 } 331 }
332 if (!pDataScope) { 332 if (!pDataScope) {
333 pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); 333 pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
334 ASSERT(pDataScope); 334 ASSERT(pDataScope);
335 } 335 }
336 CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer( 336 CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer(
337 pTemplateNode, pFormParent, pDataScope, TRUE, bDataMerge, TRUE); 337 pTemplateNode, pFormParent, pDataScope, true, bDataMerge, true);
338 if (pInstance) { 338 if (pInstance) {
339 pDocument->DataMerge_UpdateBindingRelations(pInstance); 339 pDocument->DataMerge_UpdateBindingRelations(pInstance);
340 pFormParent->RemoveChild(pInstance); 340 pFormParent->RemoveChild(pInstance);
341 } 341 }
342 return pInstance; 342 return pInstance;
343 } 343 }
344 344
345 struct XFA_ExecEventParaInfo { 345 struct XFA_ExecEventParaInfo {
346 public: 346 public:
347 uint32_t m_uHash; 347 uint32_t m_uHash;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 while (pNode) { 504 while (pNode) {
505 CXFA_Node* pNext = pNode->m_pNext; 505 CXFA_Node* pNext = pNode->m_pNext;
506 pNode->m_pParent = nullptr; 506 pNode->m_pParent = nullptr;
507 delete pNode; 507 delete pNode;
508 pNode = pNext; 508 pNode = pNext;
509 } 509 }
510 if (m_pXMLNode && IsOwnXMLNode()) 510 if (m_pXMLNode && IsOwnXMLNode())
511 m_pXMLNode->Release(); 511 m_pXMLNode->Release();
512 } 512 }
513 513
514 CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { 514 CXFA_Node* CXFA_Node::Clone(bool bRecursive) {
515 CXFA_Node* pClone = m_pDocument->CreateNode(m_ePacket, m_elementType); 515 CXFA_Node* pClone = m_pDocument->CreateNode(m_ePacket, m_elementType);
516 if (!pClone) 516 if (!pClone)
517 return nullptr; 517 return nullptr;
518 518
519 MergeAllData(pClone); 519 MergeAllData(pClone);
520 pClone->UpdateNameHash(); 520 pClone->UpdateNameHash();
521 if (IsNeedSavingXMLNode()) { 521 if (IsNeedSavingXMLNode()) {
522 CFDE_XMLNode* pCloneXML = nullptr; 522 CFDE_XMLNode* pCloneXML = nullptr;
523 if (IsAttributeInXML()) { 523 if (IsAttributeInXML()) {
524 CFX_WideString wsName; 524 CFX_WideString wsName;
525 GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); 525 GetAttribute(XFA_ATTRIBUTE_Name, wsName, false);
526 CFDE_XMLElement* pCloneXMLElement = new CFDE_XMLElement(wsName); 526 CFDE_XMLElement* pCloneXMLElement = new CFDE_XMLElement(wsName);
527 CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); 527 CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value);
528 if (!wsValue.IsEmpty()) { 528 if (!wsValue.IsEmpty()) {
529 pCloneXMLElement->SetTextData(CFX_WideString(wsValue)); 529 pCloneXMLElement->SetTextData(CFX_WideString(wsValue));
530 } 530 }
531 pCloneXML = pCloneXMLElement; 531 pCloneXML = pCloneXMLElement;
532 pCloneXMLElement = nullptr; 532 pCloneXMLElement = nullptr;
533 pClone->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); 533 pClone->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown);
534 } else { 534 } else {
535 pCloneXML = m_pXMLNode->Clone(FALSE); 535 pCloneXML = m_pXMLNode->Clone(false);
536 } 536 }
537 pClone->SetXMLMappingNode(pCloneXML); 537 pClone->SetXMLMappingNode(pCloneXML);
538 pClone->SetFlag(XFA_NodeFlag_OwnXMLNode, false); 538 pClone->SetFlag(XFA_NodeFlag_OwnXMLNode, false);
539 } 539 }
540 if (bRecursive) { 540 if (bRecursive) {
541 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; 541 for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild;
542 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 542 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
543 pClone->InsertChild(pChild->Clone(bRecursive)); 543 pClone->InsertChild(pChild->Clone(bRecursive));
544 } 544 }
545 } 545 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 return nodes.GetSize(); 686 return nodes.GetSize();
687 } 687 }
688 688
689 CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_Element eType, 689 CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_Element eType,
690 uint32_t dwFlags) { 690 uint32_t dwFlags) {
691 CXFA_Node* pNode = m_pDocument->CreateNode(m_ePacket, eType); 691 CXFA_Node* pNode = m_pDocument->CreateNode(m_ePacket, eType);
692 pNode->SetFlag(dwFlags, true); 692 pNode->SetFlag(dwFlags, true);
693 return pNode; 693 return pNode;
694 } 694 }
695 695
696 CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) { 696 CXFA_Node* CXFA_Node::CloneTemplateToForm(bool bRecursive) {
697 ASSERT(m_ePacket == XFA_XDPPACKET_Template); 697 ASSERT(m_ePacket == XFA_XDPPACKET_Template);
698 CXFA_Node* pClone = 698 CXFA_Node* pClone =
699 m_pDocument->CreateNode(XFA_XDPPACKET_Form, m_elementType); 699 m_pDocument->CreateNode(XFA_XDPPACKET_Form, m_elementType);
700 if (!pClone) 700 if (!pClone)
701 return nullptr; 701 return nullptr;
702 702
703 pClone->SetTemplateNode(this); 703 pClone->SetTemplateNode(this);
704 pClone->UpdateNameHash(); 704 pClone->UpdateNameHash();
705 pClone->SetXMLMappingNode(GetXMLMappingNode()); 705 pClone->SetXMLMappingNode(GetXMLMappingNode());
706 if (bRecursive) { 706 if (bRecursive) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 789 }
790 CXFA_Node* pOldFormItem = 790 CXFA_Node* pOldFormItem =
791 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); 791 static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
792 if (pOldFormItem == pFormNode) { 792 if (pOldFormItem == pFormNode) {
793 SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); 793 SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
794 pOldFormItem = nullptr; 794 pOldFormItem = nullptr;
795 } 795 }
796 return pOldFormItem ? 1 : 0; 796 return pOldFormItem ? 1 : 0;
797 } 797 }
798 798
799 FX_BOOL CXFA_Node::HasBindItem() { 799 bool CXFA_Node::HasBindItem() {
800 return GetPacketID() == XFA_XDPPACKET_Datasets && 800 return GetPacketID() == XFA_XDPPACKET_Datasets &&
801 GetObject(XFA_ATTRIBUTE_BindingNode); 801 GetObject(XFA_ATTRIBUTE_BindingNode);
802 } 802 }
803 803
804 CXFA_WidgetData* CXFA_Node::GetWidgetData() { 804 CXFA_WidgetData* CXFA_Node::GetWidgetData() {
805 return (CXFA_WidgetData*)GetObject(XFA_ATTRIBUTE_WidgetData); 805 return (CXFA_WidgetData*)GetObject(XFA_ATTRIBUTE_WidgetData);
806 } 806 }
807 807
808 CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() { 808 CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
809 if (GetPacketID() != XFA_XDPPACKET_Form) 809 if (GetPacketID() != XFA_XDPPACKET_Form)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 (pGrandNode && pGrandNode->GetElementType() == XFA_Element::Value) 862 (pGrandNode && pGrandNode->GetElementType() == XFA_Element::Value)
863 ? pGrandNode 863 ? pGrandNode
864 : nullptr; 864 : nullptr;
865 } 865 }
866 CXFA_Node* pParentOfValueNode = 866 CXFA_Node* pParentOfValueNode =
867 pValueNode ? pValueNode->GetNodeItem(XFA_NODEITEM_Parent) : nullptr; 867 pValueNode ? pValueNode->GetNodeItem(XFA_NODEITEM_Parent) : nullptr;
868 return pParentOfValueNode ? pParentOfValueNode->GetContainerWidgetData() 868 return pParentOfValueNode ? pParentOfValueNode->GetContainerWidgetData()
869 : nullptr; 869 : nullptr;
870 } 870 }
871 871
872 FX_BOOL CXFA_Node::GetLocaleName(CFX_WideString& wsLocaleName) { 872 bool CXFA_Node::GetLocaleName(CFX_WideString& wsLocaleName) {
873 CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode(); 873 CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode();
874 CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_Element::Subform); 874 CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_Element::Subform);
875 ASSERT(pTopSubform); 875 ASSERT(pTopSubform);
876 CXFA_Node* pLocaleNode = this; 876 CXFA_Node* pLocaleNode = this;
877 FX_BOOL bLocale = FALSE; 877 bool bLocale = false;
878 do { 878 do {
879 bLocale = pLocaleNode->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); 879 bLocale = pLocaleNode->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, false);
880 if (!bLocale) { 880 if (!bLocale) {
881 pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent); 881 pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent);
882 } 882 }
883 } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale); 883 } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale);
884 if (bLocale) 884 if (bLocale)
885 return TRUE; 885 return true;
886 CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); 886 CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config));
887 wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig); 887 wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig);
888 if (!wsLocaleName.IsEmpty()) 888 if (!wsLocaleName.IsEmpty())
889 return TRUE; 889 return true;
890 if (pTopSubform && 890 if (pTopSubform &&
891 pTopSubform->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE)) { 891 pTopSubform->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, false)) {
892 return TRUE; 892 return true;
893 } 893 }
894 IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale(); 894 IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale();
895 if (pLocale) { 895 if (pLocale) {
896 wsLocaleName = pLocale->GetName(); 896 wsLocaleName = pLocale->GetName();
897 return TRUE; 897 return true;
898 } 898 }
899 return FALSE; 899 return false;
900 } 900 }
901 901
902 XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { 902 XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
903 CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep); 903 CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep);
904 XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout); 904 XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout);
905 if (pKeep) { 905 if (pKeep) {
906 XFA_ATTRIBUTEENUM eIntact; 906 XFA_ATTRIBUTEENUM eIntact;
907 if (pKeep->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, FALSE)) { 907 if (pKeep->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, false)) {
908 if (eIntact == XFA_ATTRIBUTEENUM_None && 908 if (eIntact == XFA_ATTRIBUTEENUM_None &&
909 eLayoutType == XFA_ATTRIBUTEENUM_Row && 909 eLayoutType == XFA_ATTRIBUTEENUM_Row &&
910 m_pDocument->GetCurVersionMode() < XFA_VERSION_208) { 910 m_pDocument->GetCurVersionMode() < XFA_VERSION_208) {
911 CXFA_Node* pPreviewRow = GetNodeItem(XFA_NODEITEM_PrevSibling, 911 CXFA_Node* pPreviewRow = GetNodeItem(XFA_NODEITEM_PrevSibling,
912 XFA_ObjectType::ContainerNode); 912 XFA_ObjectType::ContainerNode);
913 if (pPreviewRow && 913 if (pPreviewRow &&
914 pPreviewRow->GetEnum(XFA_ATTRIBUTE_Layout) == 914 pPreviewRow->GetEnum(XFA_ATTRIBUTE_Layout) ==
915 XFA_ATTRIBUTEENUM_Row) { 915 XFA_ATTRIBUTEENUM_Row) {
916 XFA_ATTRIBUTEENUM eValue; 916 XFA_ATTRIBUTEENUM eValue;
917 if (pKeep->TryEnum(XFA_ATTRIBUTE_Previous, eValue, FALSE) && 917 if (pKeep->TryEnum(XFA_ATTRIBUTE_Previous, eValue, false) &&
918 (eValue == XFA_ATTRIBUTEENUM_ContentArea || 918 (eValue == XFA_ATTRIBUTEENUM_ContentArea ||
919 eValue == XFA_ATTRIBUTEENUM_PageArea)) { 919 eValue == XFA_ATTRIBUTEENUM_PageArea)) {
920 return XFA_ATTRIBUTEENUM_ContentArea; 920 return XFA_ATTRIBUTEENUM_ContentArea;
921 } 921 }
922 CXFA_Node* pNode = 922 CXFA_Node* pNode =
923 pPreviewRow->GetFirstChildByClass(XFA_Element::Keep); 923 pPreviewRow->GetFirstChildByClass(XFA_Element::Keep);
924 if (pNode && pNode->TryEnum(XFA_ATTRIBUTE_Next, eValue, FALSE) && 924 if (pNode && pNode->TryEnum(XFA_ATTRIBUTE_Next, eValue, false) &&
925 (eValue == XFA_ATTRIBUTEENUM_ContentArea || 925 (eValue == XFA_ATTRIBUTEENUM_ContentArea ||
926 eValue == XFA_ATTRIBUTEENUM_PageArea)) { 926 eValue == XFA_ATTRIBUTEENUM_PageArea)) {
927 return XFA_ATTRIBUTEENUM_ContentArea; 927 return XFA_ATTRIBUTEENUM_ContentArea;
928 } 928 }
929 } 929 }
930 } 930 }
931 return eIntact; 931 return eIntact;
932 } 932 }
933 } 933 }
934 switch (GetElementType()) { 934 switch (GetElementType()) {
(...skipping 20 matching lines...) Expand all
955 XFA_ATTRIBUTEENUM eParLayout = 955 XFA_ATTRIBUTEENUM eParLayout =
956 pParentNode->GetEnum(XFA_ATTRIBUTE_Layout); 956 pParentNode->GetEnum(XFA_ATTRIBUTE_Layout);
957 if (eParLayout == XFA_ATTRIBUTEENUM_Position || 957 if (eParLayout == XFA_ATTRIBUTEENUM_Position ||
958 eParLayout == XFA_ATTRIBUTEENUM_Row || 958 eParLayout == XFA_ATTRIBUTEENUM_Row ||
959 eParLayout == XFA_ATTRIBUTEENUM_Table) { 959 eParLayout == XFA_ATTRIBUTEENUM_Table) {
960 return XFA_ATTRIBUTEENUM_None; 960 return XFA_ATTRIBUTEENUM_None;
961 } 961 }
962 XFA_VERSION version = m_pDocument->GetCurVersionMode(); 962 XFA_VERSION version = m_pDocument->GetCurVersionMode();
963 if (eParLayout == XFA_ATTRIBUTEENUM_Tb && version < XFA_VERSION_208) { 963 if (eParLayout == XFA_ATTRIBUTEENUM_Tb && version < XFA_VERSION_208) {
964 CXFA_Measurement measureH; 964 CXFA_Measurement measureH;
965 if (TryMeasure(XFA_ATTRIBUTE_H, measureH, FALSE)) 965 if (TryMeasure(XFA_ATTRIBUTE_H, measureH, false))
966 return XFA_ATTRIBUTEENUM_ContentArea; 966 return XFA_ATTRIBUTEENUM_ContentArea;
967 } 967 }
968 return XFA_ATTRIBUTEENUM_None; 968 return XFA_ATTRIBUTEENUM_None;
969 } 969 }
970 return XFA_ATTRIBUTEENUM_ContentArea; 970 return XFA_ATTRIBUTEENUM_ContentArea;
971 } 971 }
972 case XFA_Element::Draw: 972 case XFA_Element::Draw:
973 return XFA_ATTRIBUTEENUM_ContentArea; 973 return XFA_ATTRIBUTEENUM_ContentArea;
974 default: 974 default:
975 break; 975 break;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 CXFA_Object* pNode = resoveNodeRS.nodes[0]; 1016 CXFA_Object* pNode = resoveNodeRS.nodes[0];
1017 pArguments->GetReturnValue()->Assign( 1017 pArguments->GetReturnValue()->Assign(
1018 pScriptContext->GetJSValueFromMap(pNode)); 1018 pScriptContext->GetJSValueFromMap(pNode));
1019 } else { 1019 } else {
1020 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = 1020 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
1021 resoveNodeRS.pScriptAttribute; 1021 resoveNodeRS.pScriptAttribute;
1022 if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) { 1022 if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) {
1023 std::unique_ptr<CFXJSE_Value> pValue( 1023 std::unique_ptr<CFXJSE_Value> pValue(
1024 new CFXJSE_Value(pScriptContext->GetRuntime())); 1024 new CFXJSE_Value(pScriptContext->GetRuntime()));
1025 (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))( 1025 (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))(
1026 pValue.get(), FALSE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); 1026 pValue.get(), false, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
1027 pArguments->GetReturnValue()->Assign(pValue.get()); 1027 pArguments->GetReturnValue()->Assign(pValue.get());
1028 } else { 1028 } else {
1029 pArguments->GetReturnValue()->SetNull(); 1029 pArguments->GetReturnValue()->SetNull();
1030 } 1030 }
1031 } 1031 }
1032 } 1032 }
1033 1033
1034 void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { 1034 void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) {
1035 int32_t iLength = pArguments->GetLength(); 1035 int32_t iLength = pArguments->GetLength();
1036 if (iLength != 1) { 1036 if (iLength != 1) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 for (int32_t i = 0; i < objectArray.GetSize(); i++) { 1077 for (int32_t i = 0; i < objectArray.GetSize(); i++) {
1078 if (objectArray[i]->IsNode()) 1078 if (objectArray[i]->IsNode())
1079 pNodeList->Append(objectArray[i]->AsNode()); 1079 pNodeList->Append(objectArray[i]->AsNode());
1080 } 1080 }
1081 } 1081 }
1082 } 1082 }
1083 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass()); 1083 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
1084 } 1084 }
1085 1085
1086 void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue, 1086 void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue,
1087 FX_BOOL bSetting, 1087 bool bSetting,
1088 XFA_ATTRIBUTE eAttribute) { 1088 XFA_ATTRIBUTE eAttribute) {
1089 if (bSetting) { 1089 if (bSetting) {
1090 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1090 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1091 } else { 1091 } else {
1092 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; 1092 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
1093 CFX_WideString wsName; 1093 CFX_WideString wsName;
1094 GetAttribute(XFA_ATTRIBUTE_Name, wsName); 1094 GetAttribute(XFA_ATTRIBUTE_Name, wsName);
1095 CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]"); 1095 CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]");
1096 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); 1096 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue, 1100 void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue,
1101 FX_BOOL bSetting, 1101 bool bSetting,
1102 XFA_ATTRIBUTE eAttribute) { 1102 XFA_ATTRIBUTE eAttribute) {
1103 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 1103 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
1104 if (!pScriptContext) 1104 if (!pScriptContext)
1105 return; 1105 return;
1106 if (bSetting) { 1106 if (bSetting) {
1107 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); 1107 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
1108 ASSERT(pAppProvider); 1108 ASSERT(pAppProvider);
1109 CFX_WideString wsMessage; 1109 CFX_WideString wsMessage;
1110 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); 1110 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage);
1111 FXJSE_ThrowMessage( 1111 FXJSE_ThrowMessage(
1112 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 1112 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
1113 } else { 1113 } else {
1114 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); 1114 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this);
1115 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass()); 1115 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
1116 } 1116 }
1117 } 1117 }
1118 1118
1119 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, 1119 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue,
1120 FX_BOOL bSetting, 1120 bool bSetting,
1121 XFA_ATTRIBUTE eAttribute) { 1121 XFA_ATTRIBUTE eAttribute) {
1122 if (bSetting) { 1122 if (bSetting) {
1123 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1123 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1124 } else { 1124 } else {
1125 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; 1125 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
1126 CFX_WideString wsExpression = 1126 CFX_WideString wsExpression =
1127 FX_WSTRC(L"#") + GetClassName() + FX_WSTRC(L"[*]"); 1127 FX_WSTRC(L"#") + GetClassName() + FX_WSTRC(L"[*]");
1128 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); 1128 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
1129 } 1129 }
1130 } 1130 }
1131 1131
1132 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, 1132 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue,
1133 FX_BOOL bSetting, 1133 bool bSetting,
1134 XFA_ATTRIBUTE eAttribute) { 1134 XFA_ATTRIBUTE eAttribute) {
1135 if (bSetting) { 1135 if (bSetting) {
1136 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1136 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1137 } else { 1137 } else {
1138 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); 1138 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent);
1139 if (pParent) { 1139 if (pParent) {
1140 pValue->Assign( 1140 pValue->Assign(
1141 m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent)); 1141 m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent));
1142 } else { 1142 } else {
1143 pValue->SetNull(); 1143 pValue->SetNull();
1144 } 1144 }
1145 } 1145 }
1146 } 1146 }
1147 1147
1148 void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue, 1148 void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue,
1149 FX_BOOL bSetting, 1149 bool bSetting,
1150 XFA_ATTRIBUTE eAttribute) { 1150 XFA_ATTRIBUTE eAttribute) {
1151 if (bSetting) 1151 if (bSetting)
1152 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1152 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1153 else 1153 else
1154 pValue->SetInteger(GetNodeSameNameIndex()); 1154 pValue->SetInteger(GetNodeSameNameIndex());
1155 } 1155 }
1156 1156
1157 void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, 1157 void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue,
1158 FX_BOOL bSetting, 1158 bool bSetting,
1159 XFA_ATTRIBUTE eAttribute) { 1159 XFA_ATTRIBUTE eAttribute) {
1160 if (bSetting) 1160 if (bSetting)
1161 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1161 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1162 else 1162 else
1163 pValue->SetInteger(GetNodeSameClassIndex()); 1163 pValue->SetInteger(GetNodeSameClassIndex());
1164 } 1164 }
1165 1165
1166 void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, 1166 void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue,
1167 FX_BOOL bSetting, 1167 bool bSetting,
1168 XFA_ATTRIBUTE eAttribute) { 1168 XFA_ATTRIBUTE eAttribute) {
1169 if (bSetting) { 1169 if (bSetting) {
1170 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1170 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1171 } else { 1171 } else {
1172 CFX_WideString wsSOMExpression; 1172 CFX_WideString wsSOMExpression;
1173 GetSOMExpression(wsSOMExpression); 1173 GetSOMExpression(wsSOMExpression);
1174 pValue->SetString(FX_UTF8Encode(wsSOMExpression).AsStringC()); 1174 pValue->SetString(FX_UTF8Encode(wsSOMExpression).AsStringC());
1175 } 1175 }
1176 } 1176 }
1177 1177
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 } 1266 }
1267 CFX_WideString wsExpression; 1267 CFX_WideString wsExpression;
1268 bool bParent = true; 1268 bool bParent = true;
1269 int32_t iIndex = 0; 1269 int32_t iIndex = 0;
1270 wsExpression = 1270 wsExpression =
1271 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); 1271 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
1272 if (iLength >= 2) 1272 if (iLength >= 2)
1273 bParent = !!pArguments->GetInt32(1); 1273 bParent = !!pArguments->GetInt32(1);
1274 if (iLength >= 3) 1274 if (iLength >= 3)
1275 iIndex = pArguments->GetInt32(2); 1275 iIndex = pArguments->GetInt32(2);
1276 FX_BOOL bHas = FALSE; 1276 bool bHas = false;
1277 const XFA_ATTRIBUTEINFO* pAttributeInfo = 1277 const XFA_ATTRIBUTEINFO* pAttributeInfo =
1278 XFA_GetAttributeByName(wsExpression.AsStringC()); 1278 XFA_GetAttributeByName(wsExpression.AsStringC());
1279 CFX_WideString wsValue; 1279 CFX_WideString wsValue;
1280 if (pAttributeInfo) 1280 if (pAttributeInfo)
1281 bHas = HasAttribute(pAttributeInfo->eName); 1281 bHas = HasAttribute(pAttributeInfo->eName);
1282 if (!bHas) { 1282 if (!bHas) {
1283 XFA_Element eType = XFA_GetElementTypeForName(wsExpression.AsStringC()); 1283 XFA_Element eType = XFA_GetElementTypeForName(wsExpression.AsStringC());
1284 bHas = !!GetProperty(iIndex, eType); 1284 bHas = !!GetProperty(iIndex, eType);
1285 if (!bHas && bParent && m_pParent) { 1285 if (!bHas && bParent && m_pParent) {
1286 // Also check on the parent. 1286 // Also check on the parent.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 CFDE_XMLNode* pXMLNode = nullptr; 1318 CFDE_XMLNode* pXMLNode = nullptr;
1319 int32_t iParserStatus = 1319 int32_t iParserStatus =
1320 pParser->ParseXMLData(wsExpression, pXMLNode, nullptr); 1320 pParser->ParseXMLData(wsExpression, pXMLNode, nullptr);
1321 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) 1321 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode)
1322 return; 1322 return;
1323 if (bIgnoreRoot && 1323 if (bIgnoreRoot &&
1324 (pXMLNode->GetType() != FDE_XMLNODE_Element || 1324 (pXMLNode->GetType() != FDE_XMLNODE_Element ||
1325 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) { 1325 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) {
1326 bIgnoreRoot = false; 1326 bIgnoreRoot = false;
1327 } 1327 }
1328 CXFA_Node* pFakeRoot = Clone(FALSE); 1328 CXFA_Node* pFakeRoot = Clone(false);
1329 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); 1329 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType);
1330 if (!wsContentType.IsEmpty()) { 1330 if (!wsContentType.IsEmpty()) {
1331 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, 1331 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType,
1332 CFX_WideString(wsContentType)); 1332 CFX_WideString(wsContentType));
1333 } 1333 }
1334 CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); 1334 CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode();
1335 if (!pFakeXMLRoot) { 1335 if (!pFakeXMLRoot) {
1336 CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); 1336 CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode();
1337 pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : nullptr; 1337 pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(false) : nullptr;
1338 } 1338 }
1339 if (!pFakeXMLRoot) 1339 if (!pFakeXMLRoot)
1340 pFakeXMLRoot = new CFDE_XMLElement(CFX_WideString(GetClassName())); 1340 pFakeXMLRoot = new CFDE_XMLElement(CFX_WideString(GetClassName()));
1341 1341
1342 if (bIgnoreRoot) { 1342 if (bIgnoreRoot) {
1343 CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); 1343 CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild);
1344 while (pXMLChild) { 1344 while (pXMLChild) {
1345 CFDE_XMLNode* pXMLSibling = 1345 CFDE_XMLNode* pXMLSibling =
1346 pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling); 1346 pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling);
1347 pXMLNode->RemoveChildNode(pXMLChild); 1347 pXMLNode->RemoveChildNode(pXMLChild);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 GetElementType() == XFA_Element::ExData) { 1379 GetElementType() == XFA_Element::ExData) {
1380 CFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); 1380 CFDE_XMLNode* pTempXMLNode = GetXMLMappingNode();
1381 SetXMLMappingNode(pFakeXMLRoot); 1381 SetXMLMappingNode(pFakeXMLRoot);
1382 SetFlag(XFA_NodeFlag_OwnXMLNode, false); 1382 SetFlag(XFA_NodeFlag_OwnXMLNode, false);
1383 if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFDE_XMLNode::Parent)) { 1383 if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFDE_XMLNode::Parent)) {
1384 pFakeXMLRoot = pTempXMLNode; 1384 pFakeXMLRoot = pTempXMLNode;
1385 } else { 1385 } else {
1386 pFakeXMLRoot = nullptr; 1386 pFakeXMLRoot = nullptr;
1387 } 1387 }
1388 } 1388 }
1389 MoveBufferMapData(pFakeRoot, this, XFA_CalcData, TRUE); 1389 MoveBufferMapData(pFakeRoot, this, XFA_CalcData, true);
1390 } else { 1390 } else {
1391 CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); 1391 CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
1392 while (pChild) { 1392 while (pChild) {
1393 CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); 1393 CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
1394 pFakeRoot->RemoveChild(pChild); 1394 pFakeRoot->RemoveChild(pChild);
1395 InsertChild(pChild); 1395 InsertChild(pChild);
1396 pChild->SetFlag(XFA_NodeFlag_Initialized, true); 1396 pChild->SetFlag(XFA_NodeFlag_Initialized, true);
1397 pChild = pItem; 1397 pChild = pItem;
1398 } 1398 }
1399 } 1399 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 CFDE_XMLNode* pElement = nullptr; 1434 CFDE_XMLNode* pElement = nullptr;
1435 if (GetPacketID() == XFA_XDPPACKET_Datasets) { 1435 if (GetPacketID() == XFA_XDPPACKET_Datasets) {
1436 pElement = GetXMLMappingNode(); 1436 pElement = GetXMLMappingNode();
1437 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { 1437 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) {
1438 pArguments->GetReturnValue()->SetString(bsXMLHeader); 1438 pArguments->GetReturnValue()->SetString(bsXMLHeader);
1439 return; 1439 return;
1440 } 1440 }
1441 XFA_DataExporter_DealWithDataGroupNode(this); 1441 XFA_DataExporter_DealWithDataGroupNode(this);
1442 } 1442 }
1443 std::unique_ptr<IFX_MemoryStream, ReleaseDeleter<IFX_MemoryStream>> 1443 std::unique_ptr<IFX_MemoryStream, ReleaseDeleter<IFX_MemoryStream>>
1444 pMemoryStream(FX_CreateMemoryStream(TRUE)); 1444 pMemoryStream(FX_CreateMemoryStream(true));
1445 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> pStream( 1445 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> pStream(
1446 IFX_Stream::CreateStream( 1446 IFX_Stream::CreateStream(
1447 static_cast<IFX_SeekableWriteStream*>(pMemoryStream.get()), 1447 static_cast<IFX_SeekableWriteStream*>(pMemoryStream.get()),
1448 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | 1448 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write |
1449 FX_STREAMACCESS_Append)); 1449 FX_STREAMACCESS_Append));
1450 if (!pStream) { 1450 if (!pStream) {
1451 pArguments->GetReturnValue()->SetString(bsXMLHeader); 1451 pArguments->GetReturnValue()->SetString(bsXMLHeader);
1452 return; 1452 return;
1453 } 1453 }
1454 pStream->SetCodePage(FX_CODEPAGE_UTF8); 1454 pStream->SetCodePage(FX_CODEPAGE_UTF8);
1455 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength()); 1455 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength());
1456 if (GetPacketID() == XFA_XDPPACKET_Form) 1456 if (GetPacketID() == XFA_XDPPACKET_Form)
1457 XFA_DataExporter_RegenerateFormFile(this, pStream.get(), nullptr, TRUE); 1457 XFA_DataExporter_RegenerateFormFile(this, pStream.get(), nullptr, true);
1458 else 1458 else
1459 pElement->SaveXMLNode(pStream.get()); 1459 pElement->SaveXMLNode(pStream.get());
1460 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. 1460 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
1461 // For now, just put it here to avoid unused variable warning. 1461 // For now, just put it here to avoid unused variable warning.
1462 (void)bPrettyMode; 1462 (void)bPrettyMode;
1463 pArguments->GetReturnValue()->SetString( 1463 pArguments->GetReturnValue()->SetString(
1464 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); 1464 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize()));
1465 return; 1465 return;
1466 } 1466 }
1467 pArguments->GetReturnValue()->SetString(""); 1467 pArguments->GetReturnValue()->SetString("");
(...skipping 23 matching lines...) Expand all
1491 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 1491 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
1492 if (iLength == 2) 1492 if (iLength == 2)
1493 wsName = CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC()); 1493 wsName = CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC());
1494 // TODO(weili): check whether we need to implement this, pdfium:501. 1494 // TODO(weili): check whether we need to implement this, pdfium:501.
1495 // For now, just put the variables here to avoid unused variable warning. 1495 // For now, just put the variables here to avoid unused variable warning.
1496 (void)pNode; 1496 (void)pNode;
1497 (void)wsName; 1497 (void)wsName;
1498 } 1498 }
1499 1499
1500 void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, 1500 void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue,
1501 FX_BOOL bSetting, 1501 bool bSetting,
1502 XFA_ATTRIBUTE eAttribute) { 1502 XFA_ATTRIBUTE eAttribute) {
1503 if (bSetting) { 1503 if (bSetting) {
1504 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1504 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1505 } else { 1505 } else {
1506 CFX_WideString wsNameSpace; 1506 CFX_WideString wsNameSpace;
1507 TryNamespace(wsNameSpace); 1507 TryNamespace(wsNameSpace);
1508 pValue->SetString(FX_UTF8Encode(wsNameSpace).AsStringC()); 1508 pValue->SetString(FX_UTF8Encode(wsNameSpace).AsStringC());
1509 } 1509 }
1510 } 1510 }
1511 1511
1512 void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, 1512 void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue,
1513 FX_BOOL bSetting, 1513 bool bSetting,
1514 XFA_ATTRIBUTE eAttribute) { 1514 XFA_ATTRIBUTE eAttribute) {
1515 if (bSetting) { 1515 if (bSetting) {
1516 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1516 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1517 } else { 1517 } else {
1518 pValue->Assign( 1518 pValue->Assign(
1519 m_pDocument->GetScriptContext()->GetJSValueFromMap(GetModelNode())); 1519 m_pDocument->GetScriptContext()->GetJSValueFromMap(GetModelNode()));
1520 } 1520 }
1521 } 1521 }
1522 1522
1523 void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, 1523 void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue,
1524 FX_BOOL bSetting, 1524 bool bSetting,
1525 XFA_ATTRIBUTE eAttribute) { 1525 XFA_ATTRIBUTE eAttribute) {
1526 if (bSetting) 1526 if (bSetting)
1527 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1527 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1528 else 1528 else
1529 pValue->SetBoolean(IsContainerNode()); 1529 pValue->SetBoolean(IsContainerNode());
1530 } 1530 }
1531 1531
1532 void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, 1532 void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue,
1533 FX_BOOL bSetting, 1533 bool bSetting,
1534 XFA_ATTRIBUTE eAttribute) { 1534 XFA_ATTRIBUTE eAttribute) {
1535 if (bSetting) { 1535 if (bSetting) {
1536 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1536 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1537 } else { 1537 } else {
1538 if (GetElementType() == XFA_Element::Subform) { 1538 if (GetElementType() == XFA_Element::Subform) {
1539 pValue->SetBoolean(FALSE); 1539 pValue->SetBoolean(false);
1540 return; 1540 return;
1541 } 1541 }
1542 CFX_WideString strValue; 1542 CFX_WideString strValue;
1543 pValue->SetBoolean(!TryContent(strValue) || strValue.IsEmpty()); 1543 pValue->SetBoolean(!TryContent(strValue) || strValue.IsEmpty());
1544 } 1544 }
1545 } 1545 }
1546 1546
1547 void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, 1547 void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue,
1548 FX_BOOL bSetting, 1548 bool bSetting,
1549 XFA_ATTRIBUTE eAttribute) { 1549 XFA_ATTRIBUTE eAttribute) {
1550 if (bSetting) { 1550 if (bSetting) {
1551 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1551 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1552 } else { 1552 } else {
1553 CXFA_NodeArray properts; 1553 CXFA_NodeArray properts;
1554 int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty); 1554 int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty);
1555 if (iSize > 0) { 1555 if (iSize > 0) {
1556 pValue->Assign( 1556 pValue->Assign(
1557 m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0])); 1557 m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0]));
1558 } 1558 }
(...skipping 26 matching lines...) Expand all
1585 wsNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC()); 1585 wsNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC());
1586 } 1586 }
1587 CFX_WideString wsNodeNameSpace; 1587 CFX_WideString wsNodeNameSpace;
1588 TryNamespace(wsNodeNameSpace); 1588 TryNamespace(wsNodeNameSpace);
1589 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 1589 CFXJSE_Value* pValue = pArguments->GetReturnValue();
1590 if (pValue) 1590 if (pValue)
1591 pValue->SetBoolean(wsNodeNameSpace == wsNameSpace); 1591 pValue->SetBoolean(wsNodeNameSpace == wsNameSpace);
1592 } 1592 }
1593 1593
1594 void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue, 1594 void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue,
1595 FX_BOOL bSetting, 1595 bool bSetting,
1596 XFA_ATTRIBUTE eAttribute) {} 1596 XFA_ATTRIBUTE eAttribute) {}
1597 1597
1598 void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, 1598 void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue,
1599 FX_BOOL bSetting, 1599 bool bSetting,
1600 XFA_ATTRIBUTE eAttribute) {} 1600 XFA_ATTRIBUTE eAttribute) {}
1601 1601
1602 void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue, 1602 void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue,
1603 FX_BOOL bSetting, 1603 bool bSetting,
1604 XFA_ATTRIBUTE eAttribute) { 1604 XFA_ATTRIBUTE eAttribute) {
1605 if (bSetting) { 1605 if (bSetting) {
1606 SetInteger(eAttribute, pValue->ToInteger(), true); 1606 SetInteger(eAttribute, pValue->ToInteger(), true);
1607 } else { 1607 } else {
1608 pValue->SetInteger(GetInteger(eAttribute)); 1608 pValue->SetInteger(GetInteger(eAttribute));
1609 } 1609 }
1610 } 1610 }
1611 1611
1612 void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue, 1612 void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue,
1613 FX_BOOL bSetting, 1613 bool bSetting,
1614 XFA_ATTRIBUTE eAttribute) { 1614 XFA_ATTRIBUTE eAttribute) {
1615 if (!bSetting) { 1615 if (!bSetting) {
1616 pValue->SetInteger(GetInteger(eAttribute)); 1616 pValue->SetInteger(GetInteger(eAttribute));
1617 } else { 1617 } else {
1618 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1618 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1619 } 1619 }
1620 } 1620 }
1621 1621
1622 void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue, 1622 void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue,
1623 FX_BOOL bSetting, 1623 bool bSetting,
1624 XFA_ATTRIBUTE eAttribute) { 1624 XFA_ATTRIBUTE eAttribute) {
1625 if (bSetting) { 1625 if (bSetting) {
1626 SetBoolean(eAttribute, pValue->ToBoolean(), true); 1626 SetBoolean(eAttribute, pValue->ToBoolean(), true);
1627 } else { 1627 } else {
1628 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); 1628 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0");
1629 } 1629 }
1630 } 1630 }
1631 1631
1632 void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, 1632 void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue,
1633 FX_BOOL bSetting, 1633 bool bSetting,
1634 XFA_ATTRIBUTE eAttribute) { 1634 XFA_ATTRIBUTE eAttribute) {
1635 if (!bSetting) { 1635 if (!bSetting) {
1636 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); 1636 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0");
1637 } else { 1637 } else {
1638 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1638 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1639 } 1639 }
1640 } 1640 }
1641 1641
1642 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( 1642 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage(
1643 XFA_ATTRIBUTE eAttribute, 1643 XFA_ATTRIBUTE eAttribute,
1644 FX_BOOL bScriptModify) { 1644 bool bScriptModify) {
1645 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 1645 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
1646 if (!pLayoutPro) 1646 if (!pLayoutPro)
1647 return; 1647 return;
1648 1648
1649 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 1649 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
1650 if (!pNotify) 1650 if (!pNotify)
1651 return; 1651 return;
1652 1652
1653 uint32_t dwPacket = GetPacketID(); 1653 uint32_t dwPacket = GetPacketID();
1654 if (!(dwPacket & XFA_XDPPACKET_Form)) { 1654 if (!(dwPacket & XFA_XDPPACKET_Form)) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 1786
1787 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); 1787 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
1788 } 1788 }
1789 if (pParent) { 1789 if (pParent) {
1790 pLayoutPro->AddChangedContainer(pParent); 1790 pLayoutPro->AddChangedContainer(pParent);
1791 } 1791 }
1792 } 1792 }
1793 } 1793 }
1794 1794
1795 void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue, 1795 void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue,
1796 FX_BOOL bSetting, 1796 bool bSetting,
1797 XFA_ATTRIBUTE eAttribute) { 1797 XFA_ATTRIBUTE eAttribute) {
1798 if (bSetting) { 1798 if (bSetting) {
1799 CFX_WideString wsValue = pValue->ToWideString(); 1799 CFX_WideString wsValue = pValue->ToWideString();
1800 SetAttribute(eAttribute, wsValue.AsStringC(), true); 1800 SetAttribute(eAttribute, wsValue.AsStringC(), true);
1801 if (eAttribute == XFA_ATTRIBUTE_Use && 1801 if (eAttribute == XFA_ATTRIBUTE_Use &&
1802 GetElementType() == XFA_Element::Desc) { 1802 GetElementType() == XFA_Element::Desc) {
1803 CXFA_Node* pTemplateNode = 1803 CXFA_Node* pTemplateNode =
1804 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); 1804 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template));
1805 CXFA_Node* pProtoRoot = 1805 CXFA_Node* pProtoRoot =
1806 pTemplateNode->GetFirstChildByClass(XFA_Element::Subform) 1806 pTemplateNode->GetFirstChildByClass(XFA_Element::Subform)
(...skipping 24 matching lines...) Expand all
1831 pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID.AsStringC()); 1831 pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID.AsStringC());
1832 } 1832 }
1833 if (pProtoNode) { 1833 if (pProtoNode) {
1834 CXFA_Node* pHeadChild = GetNodeItem(XFA_NODEITEM_FirstChild); 1834 CXFA_Node* pHeadChild = GetNodeItem(XFA_NODEITEM_FirstChild);
1835 while (pHeadChild) { 1835 while (pHeadChild) {
1836 CXFA_Node* pSibling = 1836 CXFA_Node* pSibling =
1837 pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); 1837 pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling);
1838 RemoveChild(pHeadChild); 1838 RemoveChild(pHeadChild);
1839 pHeadChild = pSibling; 1839 pHeadChild = pSibling;
1840 } 1840 }
1841 CXFA_Node* pProtoForm = pProtoNode->CloneTemplateToForm(TRUE); 1841 CXFA_Node* pProtoForm = pProtoNode->CloneTemplateToForm(true);
1842 pHeadChild = pProtoForm->GetNodeItem(XFA_NODEITEM_FirstChild); 1842 pHeadChild = pProtoForm->GetNodeItem(XFA_NODEITEM_FirstChild);
1843 while (pHeadChild) { 1843 while (pHeadChild) {
1844 CXFA_Node* pSibling = 1844 CXFA_Node* pSibling =
1845 pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); 1845 pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling);
1846 pProtoForm->RemoveChild(pHeadChild); 1846 pProtoForm->RemoveChild(pHeadChild);
1847 InsertChild(pHeadChild); 1847 InsertChild(pHeadChild);
1848 pHeadChild = pSibling; 1848 pHeadChild = pSibling;
1849 } 1849 }
1850 m_pDocument->RemovePurgeNode(pProtoForm); 1850 m_pDocument->RemovePurgeNode(pProtoForm);
1851 delete pProtoForm; 1851 delete pProtoForm;
1852 } 1852 }
1853 } 1853 }
1854 } else { 1854 } else {
1855 CFX_WideString wsValue; 1855 CFX_WideString wsValue;
1856 GetAttribute(eAttribute, wsValue); 1856 GetAttribute(eAttribute, wsValue);
1857 pValue->SetString( 1857 pValue->SetString(
1858 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); 1858 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
1859 } 1859 }
1860 } 1860 }
1861 1861
1862 void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, 1862 void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue,
1863 FX_BOOL bSetting, 1863 bool bSetting,
1864 XFA_ATTRIBUTE eAttribute) { 1864 XFA_ATTRIBUTE eAttribute) {
1865 if (!bSetting) { 1865 if (!bSetting) {
1866 CFX_WideString wsValue; 1866 CFX_WideString wsValue;
1867 GetAttribute(eAttribute, wsValue); 1867 GetAttribute(eAttribute, wsValue);
1868 pValue->SetString( 1868 pValue->SetString(
1869 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); 1869 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
1870 } else { 1870 } else {
1871 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1871 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1872 } 1872 }
1873 } 1873 }
1874 1874
1875 void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { 1875 void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) {
1876 int32_t argc = pArguments->GetLength(); 1876 int32_t argc = pArguments->GetLength();
1877 if ((argc == 0) || (argc == 1)) { 1877 if ((argc == 0) || (argc == 1)) {
1878 pArguments->GetReturnValue()->SetBoolean(FALSE); 1878 pArguments->GetReturnValue()->SetBoolean(false);
1879 } else { 1879 } else {
1880 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute"); 1880 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute");
1881 } 1881 }
1882 } 1882 }
1883 1883
1884 void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { 1884 void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) {
1885 int32_t argc = pArguments->GetLength(); 1885 int32_t argc = pArguments->GetLength();
1886 if (argc == 0) { 1886 if (argc == 0) {
1887 } else { 1887 } else {
1888 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore"); 1888 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore");
1889 } 1889 }
1890 } 1890 }
1891 1891
1892 void CXFA_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue, 1892 void CXFA_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue,
1893 FX_BOOL bSetting, 1893 bool bSetting,
1894 XFA_ATTRIBUTE eAttribute) {} 1894 XFA_ATTRIBUTE eAttribute) {}
1895 1895
1896 void CXFA_Node::Script_Delta_SavedValue(CFXJSE_Value* pValue, 1896 void CXFA_Node::Script_Delta_SavedValue(CFXJSE_Value* pValue,
1897 FX_BOOL bSetting, 1897 bool bSetting,
1898 XFA_ATTRIBUTE eAttribute) {} 1898 XFA_ATTRIBUTE eAttribute) {}
1899 1899
1900 void CXFA_Node::Script_Delta_Target(CFXJSE_Value* pValue, 1900 void CXFA_Node::Script_Delta_Target(CFXJSE_Value* pValue,
1901 FX_BOOL bSetting, 1901 bool bSetting,
1902 XFA_ATTRIBUTE eAttribute) {} 1902 XFA_ATTRIBUTE eAttribute) {}
1903 1903
1904 void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue, 1904 void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue,
1905 FX_BOOL bSetting, 1905 bool bSetting,
1906 XFA_SOM_MESSAGETYPE iMessageType) { 1906 XFA_SOM_MESSAGETYPE iMessageType) {
1907 CXFA_WidgetData* pWidgetData = GetWidgetData(); 1907 CXFA_WidgetData* pWidgetData = GetWidgetData();
1908 if (!pWidgetData) { 1908 if (!pWidgetData) {
1909 return; 1909 return;
1910 } 1910 }
1911 FX_BOOL bNew = FALSE; 1911 bool bNew = false;
1912 CXFA_Validate validate = pWidgetData->GetValidate(); 1912 CXFA_Validate validate = pWidgetData->GetValidate();
1913 if (!validate) { 1913 if (!validate) {
1914 validate = pWidgetData->GetValidate(TRUE); 1914 validate = pWidgetData->GetValidate(true);
1915 bNew = TRUE; 1915 bNew = true;
1916 } 1916 }
1917 if (bSetting) { 1917 if (bSetting) {
1918 switch (iMessageType) { 1918 switch (iMessageType) {
1919 case XFA_SOM_ValidationMessage: 1919 case XFA_SOM_ValidationMessage:
1920 validate.SetScriptMessageText(pValue->ToWideString()); 1920 validate.SetScriptMessageText(pValue->ToWideString());
1921 break; 1921 break;
1922 case XFA_SOM_FormatMessage: 1922 case XFA_SOM_FormatMessage:
1923 validate.SetFormatMessageText(pValue->ToWideString()); 1923 validate.SetFormatMessageText(pValue->ToWideString());
1924 break; 1924 break;
1925 case XFA_SOM_MandatoryMessage: 1925 case XFA_SOM_MandatoryMessage:
(...skipping 22 matching lines...) Expand all
1948 validate.GetNullMessageText(wsMessage); 1948 validate.GetNullMessageText(wsMessage);
1949 break; 1949 break;
1950 default: 1950 default:
1951 break; 1951 break;
1952 } 1952 }
1953 pValue->SetString(FX_UTF8Encode(wsMessage).AsStringC()); 1953 pValue->SetString(FX_UTF8Encode(wsMessage).AsStringC());
1954 } 1954 }
1955 } 1955 }
1956 1956
1957 void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue, 1957 void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue,
1958 FX_BOOL bSetting, 1958 bool bSetting,
1959 XFA_ATTRIBUTE eAttribute) { 1959 XFA_ATTRIBUTE eAttribute) {
1960 Script_Som_Message(pValue, bSetting, XFA_SOM_ValidationMessage); 1960 Script_Som_Message(pValue, bSetting, XFA_SOM_ValidationMessage);
1961 } 1961 }
1962 1962
1963 void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue, 1963 void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue,
1964 FX_BOOL bSetting, 1964 bool bSetting,
1965 XFA_ATTRIBUTE eAttribute) { 1965 XFA_ATTRIBUTE eAttribute) {
1966 if (bSetting) { 1966 if (bSetting) {
1967 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1967 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1968 } else { 1968 } else {
1969 CXFA_WidgetData* pWidgetData = GetWidgetData(); 1969 CXFA_WidgetData* pWidgetData = GetWidgetData();
1970 if (!pWidgetData) { 1970 if (!pWidgetData) {
1971 pValue->SetInteger(0); 1971 pValue->SetInteger(0);
1972 return; 1972 return;
1973 } 1973 }
1974 pValue->SetInteger(pWidgetData->CountChoiceListItems(TRUE)); 1974 pValue->SetInteger(pWidgetData->CountChoiceListItems(true));
1975 } 1975 }
1976 } 1976 }
1977 1977
1978 void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, 1978 void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
1979 FX_BOOL bSetting, 1979 bool bSetting,
1980 XFA_ATTRIBUTE eAttribute) { 1980 XFA_ATTRIBUTE eAttribute) {
1981 XFA_Element eType = GetElementType(); 1981 XFA_Element eType = GetElementType();
1982 if (eType == XFA_Element::Field) { 1982 if (eType == XFA_Element::Field) {
1983 Script_Field_DefaultValue(pValue, bSetting, eAttribute); 1983 Script_Field_DefaultValue(pValue, bSetting, eAttribute);
1984 return; 1984 return;
1985 } 1985 }
1986 if (eType == XFA_Element::Draw) { 1986 if (eType == XFA_Element::Draw) {
1987 Script_Draw_DefaultValue(pValue, bSetting, eAttribute); 1987 Script_Draw_DefaultValue(pValue, bSetting, eAttribute);
1988 return; 1988 return;
1989 } 1989 }
(...skipping 26 matching lines...) Expand all
2016 break; 2016 break;
2017 } 2017 }
2018 pContainerWidgetData = nullptr; 2018 pContainerWidgetData = nullptr;
2019 } 2019 }
2020 } else if (GetPacketID() == XFA_XDPPACKET_Form) { 2020 } else if (GetPacketID() == XFA_XDPPACKET_Form) {
2021 pContainerWidgetData = GetContainerWidgetData(); 2021 pContainerWidgetData = GetContainerWidgetData();
2022 } 2022 }
2023 if (pContainerWidgetData) { 2023 if (pContainerWidgetData) {
2024 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); 2024 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue);
2025 } 2025 }
2026 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); 2026 SetScriptContent(wsNewValue, wsFormatValue, true, true);
2027 } else { 2027 } else {
2028 CFX_WideString content = GetScriptContent(TRUE); 2028 CFX_WideString content = GetScriptContent(true);
2029 if (content.IsEmpty() && eType != XFA_Element::Text && 2029 if (content.IsEmpty() && eType != XFA_Element::Text &&
2030 eType != XFA_Element::SubmitUrl) { 2030 eType != XFA_Element::SubmitUrl) {
2031 pValue->SetNull(); 2031 pValue->SetNull();
2032 } else if (eType == XFA_Element::Integer) { 2032 } else if (eType == XFA_Element::Integer) {
2033 pValue->SetInteger(FXSYS_wtoi(content.c_str())); 2033 pValue->SetInteger(FXSYS_wtoi(content.c_str()));
2034 } else if (eType == XFA_Element::Float || eType == XFA_Element::Decimal) { 2034 } else if (eType == XFA_Element::Float || eType == XFA_Element::Decimal) {
2035 CFX_Decimal decimal(content.AsStringC()); 2035 CFX_Decimal decimal(content.AsStringC());
2036 pValue->SetFloat((FX_FLOAT)(double)decimal); 2036 pValue->SetFloat((FX_FLOAT)(double)decimal);
2037 } else { 2037 } else {
2038 pValue->SetString( 2038 pValue->SetString(
2039 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); 2039 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
2040 } 2040 }
2041 } 2041 }
2042 } 2042 }
2043 2043
2044 void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, 2044 void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue,
2045 FX_BOOL bSetting, 2045 bool bSetting,
2046 XFA_ATTRIBUTE eAttribute) { 2046 XFA_ATTRIBUTE eAttribute) {
2047 if (bSetting) { 2047 if (bSetting) {
2048 ThrowException(XFA_IDS_INVAlID_PROP_SET); 2048 ThrowException(XFA_IDS_INVAlID_PROP_SET);
2049 return; 2049 return;
2050 } 2050 }
2051 CFX_WideString content = GetScriptContent(TRUE); 2051 CFX_WideString content = GetScriptContent(true);
2052 if (content.IsEmpty()) { 2052 if (content.IsEmpty()) {
2053 pValue->SetNull(); 2053 pValue->SetNull();
2054 } else { 2054 } else {
2055 pValue->SetString( 2055 pValue->SetString(
2056 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); 2056 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
2057 } 2057 }
2058 } 2058 }
2059 2059
2060 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, 2060 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue,
2061 FX_BOOL bSetting, 2061 bool bSetting,
2062 XFA_ATTRIBUTE eAttribute) { 2062 XFA_ATTRIBUTE eAttribute) {
2063 if (bSetting) { 2063 if (bSetting) {
2064 CFX_ByteString newValue; 2064 CFX_ByteString newValue;
2065 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined()))) 2065 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
2066 newValue = pValue->ToString(); 2066 newValue = pValue->ToString();
2067 2067
2068 int32_t iValue = FXSYS_atoi(newValue.c_str()); 2068 int32_t iValue = FXSYS_atoi(newValue.c_str());
2069 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1"); 2069 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1");
2070 CFX_WideString wsFormatValue(wsNewValue); 2070 CFX_WideString wsFormatValue(wsNewValue);
2071 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); 2071 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData();
2072 if (pContainerWidgetData) { 2072 if (pContainerWidgetData) {
2073 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); 2073 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue);
2074 } 2074 }
2075 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); 2075 SetScriptContent(wsNewValue, wsFormatValue, true, true);
2076 } else { 2076 } else {
2077 CFX_WideString wsValue = GetScriptContent(TRUE); 2077 CFX_WideString wsValue = GetScriptContent(true);
2078 pValue->SetBoolean(wsValue == FX_WSTRC(L"1")); 2078 pValue->SetBoolean(wsValue == FX_WSTRC(L"1"));
2079 } 2079 }
2080 } 2080 }
2081 2081
2082 void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, 2082 void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue,
2083 FX_BOOL bSetting, 2083 bool bSetting,
2084 XFA_ATTRIBUTE eAttribute) { 2084 XFA_ATTRIBUTE eAttribute) {
2085 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2085 CXFA_WidgetData* pWidgetData = GetWidgetData();
2086 if (!pWidgetData) { 2086 if (!pWidgetData) {
2087 return; 2087 return;
2088 } 2088 }
2089 CXFA_Border border = pWidgetData->GetBorder(TRUE); 2089 CXFA_Border border = pWidgetData->GetBorder(true);
2090 int32_t iSize = border.CountEdges(); 2090 int32_t iSize = border.CountEdges();
2091 if (bSetting) { 2091 if (bSetting) {
2092 int32_t r = 0; 2092 int32_t r = 0;
2093 int32_t g = 0; 2093 int32_t g = 0;
2094 int32_t b = 0; 2094 int32_t b = 0;
2095 StrToRGB(pValue->ToWideString(), r, g, b); 2095 StrToRGB(pValue->ToWideString(), r, g, b);
2096 FX_ARGB rgb = ArgbEncode(100, r, g, b); 2096 FX_ARGB rgb = ArgbEncode(100, r, g, b);
2097 for (int32_t i = 0; i < iSize; ++i) { 2097 for (int32_t i = 0; i < iSize; ++i) {
2098 CXFA_Edge edge = border.GetEdge(i); 2098 CXFA_Edge edge = border.GetEdge(i);
2099 edge.SetColor(rgb); 2099 edge.SetColor(rgb);
2100 } 2100 }
2101 } else { 2101 } else {
2102 CXFA_Edge edge = border.GetEdge(0); 2102 CXFA_Edge edge = border.GetEdge(0);
2103 FX_ARGB color = edge.GetColor(); 2103 FX_ARGB color = edge.GetColor();
2104 int32_t a, r, g, b; 2104 int32_t a, r, g, b;
2105 ArgbDecode(color, a, r, g, b); 2105 ArgbDecode(color, a, r, g, b);
2106 CFX_WideString strColor; 2106 CFX_WideString strColor;
2107 strColor.Format(L"%d,%d,%d", r, g, b); 2107 strColor.Format(L"%d,%d,%d", r, g, b);
2108 pValue->SetString(FX_UTF8Encode(strColor).AsStringC()); 2108 pValue->SetString(FX_UTF8Encode(strColor).AsStringC());
2109 } 2109 }
2110 } 2110 }
2111 2111
2112 void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, 2112 void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue,
2113 FX_BOOL bSetting, 2113 bool bSetting,
2114 XFA_ATTRIBUTE eAttribute) { 2114 XFA_ATTRIBUTE eAttribute) {
2115 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2115 CXFA_WidgetData* pWidgetData = GetWidgetData();
2116 if (!pWidgetData) { 2116 if (!pWidgetData) {
2117 return; 2117 return;
2118 } 2118 }
2119 CXFA_Border border = pWidgetData->GetBorder(TRUE); 2119 CXFA_Border border = pWidgetData->GetBorder(true);
2120 int32_t iSize = border.CountEdges(); 2120 int32_t iSize = border.CountEdges();
2121 CFX_WideString wsThickness; 2121 CFX_WideString wsThickness;
2122 if (bSetting) { 2122 if (bSetting) {
2123 wsThickness = pValue->ToWideString(); 2123 wsThickness = pValue->ToWideString();
2124 for (int32_t i = 0; i < iSize; ++i) { 2124 for (int32_t i = 0; i < iSize; ++i) {
2125 CXFA_Edge edge = border.GetEdge(i); 2125 CXFA_Edge edge = border.GetEdge(i);
2126 CXFA_Measurement thickness(wsThickness.AsStringC()); 2126 CXFA_Measurement thickness(wsThickness.AsStringC());
2127 edge.SetMSThickness(thickness); 2127 edge.SetMSThickness(thickness);
2128 } 2128 }
2129 } else { 2129 } else {
2130 CXFA_Edge edge = border.GetEdge(0); 2130 CXFA_Edge edge = border.GetEdge(0);
2131 CXFA_Measurement thickness = edge.GetMSThickness(); 2131 CXFA_Measurement thickness = edge.GetMSThickness();
2132 thickness.ToString(wsThickness); 2132 thickness.ToString(wsThickness);
2133 pValue->SetString(FX_UTF8Encode(wsThickness).AsStringC()); 2133 pValue->SetString(FX_UTF8Encode(wsThickness).AsStringC());
2134 } 2134 }
2135 } 2135 }
2136 2136
2137 void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, 2137 void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue,
2138 FX_BOOL bSetting, 2138 bool bSetting,
2139 XFA_ATTRIBUTE eAttribute) { 2139 XFA_ATTRIBUTE eAttribute) {
2140 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2140 CXFA_WidgetData* pWidgetData = GetWidgetData();
2141 if (!pWidgetData) { 2141 if (!pWidgetData) {
2142 return; 2142 return;
2143 } 2143 }
2144 CXFA_Border border = pWidgetData->GetBorder(TRUE); 2144 CXFA_Border border = pWidgetData->GetBorder(true);
2145 CXFA_Fill borderfill = border.GetFill(TRUE); 2145 CXFA_Fill borderfill = border.GetFill(true);
2146 CXFA_Node* pNode = borderfill.GetNode(); 2146 CXFA_Node* pNode = borderfill.GetNode();
2147 if (!pNode) { 2147 if (!pNode) {
2148 return; 2148 return;
2149 } 2149 }
2150 if (bSetting) { 2150 if (bSetting) {
2151 int32_t r; 2151 int32_t r;
2152 int32_t g; 2152 int32_t g;
2153 int32_t b; 2153 int32_t b;
2154 StrToRGB(pValue->ToWideString(), r, g, b); 2154 StrToRGB(pValue->ToWideString(), r, g, b);
2155 FX_ARGB color = ArgbEncode(0xff, r, g, b); 2155 FX_ARGB color = ArgbEncode(0xff, r, g, b);
2156 borderfill.SetColor(color); 2156 borderfill.SetColor(color);
2157 } else { 2157 } else {
2158 FX_ARGB color = borderfill.GetColor(); 2158 FX_ARGB color = borderfill.GetColor();
2159 int32_t a; 2159 int32_t a;
2160 int32_t r; 2160 int32_t r;
2161 int32_t g; 2161 int32_t g;
2162 int32_t b; 2162 int32_t b;
2163 ArgbDecode(color, a, r, g, b); 2163 ArgbDecode(color, a, r, g, b);
2164 CFX_WideString wsColor; 2164 CFX_WideString wsColor;
2165 wsColor.Format(L"%d,%d,%d", r, g, b); 2165 wsColor.Format(L"%d,%d,%d", r, g, b);
2166 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); 2166 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC());
2167 } 2167 }
2168 } 2168 }
2169 2169
2170 void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue, 2170 void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue,
2171 FX_BOOL bSetting, 2171 bool bSetting,
2172 XFA_ATTRIBUTE eAttribute) { 2172 XFA_ATTRIBUTE eAttribute) {
2173 if (!bSetting) { 2173 if (!bSetting) {
2174 CXFA_Node* pDataNode = GetBindData(); 2174 CXFA_Node* pDataNode = GetBindData();
2175 if (pDataNode) { 2175 if (pDataNode) {
2176 pValue->Assign( 2176 pValue->Assign(
2177 m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode)); 2177 m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode));
2178 } else { 2178 } else {
2179 pValue->SetNull(); 2179 pValue->SetNull();
2180 } 2180 }
2181 } else { 2181 } else {
2182 ThrowException(XFA_IDS_INVAlID_PROP_SET); 2182 ThrowException(XFA_IDS_INVAlID_PROP_SET);
2183 } 2183 }
2184 } 2184 }
2185 2185
2186 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, 2186 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
2187 FX_BOOL bSetting, 2187 bool bSetting,
2188 XFA_ATTRIBUTE eAttribute) { 2188 XFA_ATTRIBUTE eAttribute) {
2189 if (bSetting) { 2189 if (bSetting) {
2190 if (pValue && pValue->IsString()) { 2190 if (pValue && pValue->IsString()) {
2191 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2191 CXFA_WidgetData* pWidgetData = GetWidgetData();
2192 ASSERT(pWidgetData); 2192 ASSERT(pWidgetData);
2193 XFA_Element uiType = pWidgetData->GetUIType(); 2193 XFA_Element uiType = pWidgetData->GetUIType();
2194 if (uiType == XFA_Element::Text) { 2194 if (uiType == XFA_Element::Text) {
2195 CFX_WideString wsNewValue = pValue->ToWideString(); 2195 CFX_WideString wsNewValue = pValue->ToWideString();
2196 CFX_WideString wsFormatValue(wsNewValue); 2196 CFX_WideString wsFormatValue(wsNewValue);
2197 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); 2197 SetScriptContent(wsNewValue, wsFormatValue, true, true);
2198 } 2198 }
2199 } 2199 }
2200 } else { 2200 } else {
2201 CFX_WideString content = GetScriptContent(TRUE); 2201 CFX_WideString content = GetScriptContent(true);
2202 if (content.IsEmpty()) { 2202 if (content.IsEmpty()) {
2203 pValue->SetNull(); 2203 pValue->SetNull();
2204 } else { 2204 } else {
2205 pValue->SetString( 2205 pValue->SetString(
2206 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); 2206 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
2207 } 2207 }
2208 } 2208 }
2209 } 2209 }
2210 2210
2211 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, 2211 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue,
2212 FX_BOOL bSetting, 2212 bool bSetting,
2213 XFA_ATTRIBUTE eAttribute) { 2213 XFA_ATTRIBUTE eAttribute) {
2214 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2214 CXFA_WidgetData* pWidgetData = GetWidgetData();
2215 if (!pWidgetData) { 2215 if (!pWidgetData) {
2216 return; 2216 return;
2217 } 2217 }
2218 if (bSetting) { 2218 if (bSetting) {
2219 if (pValue && pValue->IsNull()) { 2219 if (pValue && pValue->IsNull()) {
2220 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; 2220 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
2221 pWidgetData->m_bIsNull = TRUE; 2221 pWidgetData->m_bIsNull = true;
2222 } else { 2222 } else {
2223 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; 2223 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
2224 pWidgetData->m_bIsNull = FALSE; 2224 pWidgetData->m_bIsNull = false;
2225 } 2225 }
2226 CFX_WideString wsNewText; 2226 CFX_WideString wsNewText;
2227 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined()))) 2227 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
2228 wsNewText = pValue->ToWideString(); 2228 wsNewText = pValue->ToWideString();
2229 2229
2230 CXFA_Node* pUIChild = pWidgetData->GetUIChild(); 2230 CXFA_Node* pUIChild = pWidgetData->GetUIChild();
2231 if (pUIChild->GetElementType() == XFA_Element::NumericEdit) { 2231 if (pUIChild->GetElementType() == XFA_Element::NumericEdit) {
2232 int32_t iLeadDigits = 0; 2232 int32_t iLeadDigits = 0;
2233 int32_t iFracDigits = 0; 2233 int32_t iFracDigits = 0;
2234 pWidgetData->GetLeadDigits(iLeadDigits); 2234 pWidgetData->GetLeadDigits(iLeadDigits);
2235 pWidgetData->GetFracDigits(iFracDigits); 2235 pWidgetData->GetFracDigits(iFracDigits);
2236 wsNewText = 2236 wsNewText =
2237 pWidgetData->NumericLimit(wsNewText, iLeadDigits, iFracDigits); 2237 pWidgetData->NumericLimit(wsNewText, iLeadDigits, iFracDigits);
2238 } 2238 }
2239 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); 2239 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData();
2240 CFX_WideString wsFormatText(wsNewText); 2240 CFX_WideString wsFormatText(wsNewText);
2241 if (pContainerWidgetData) { 2241 if (pContainerWidgetData) {
2242 pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText); 2242 pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText);
2243 } 2243 }
2244 SetScriptContent(wsNewText, wsFormatText, true, TRUE); 2244 SetScriptContent(wsNewText, wsFormatText, true, true);
2245 } else { 2245 } else {
2246 CFX_WideString content = GetScriptContent(TRUE); 2246 CFX_WideString content = GetScriptContent(true);
2247 if (content.IsEmpty()) { 2247 if (content.IsEmpty()) {
2248 pValue->SetNull(); 2248 pValue->SetNull();
2249 } else { 2249 } else {
2250 CXFA_Node* pUIChild = pWidgetData->GetUIChild(); 2250 CXFA_Node* pUIChild = pWidgetData->GetUIChild();
2251 CXFA_Value defVal = pWidgetData->GetFormValue(); 2251 CXFA_Value defVal = pWidgetData->GetFormValue();
2252 CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild); 2252 CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild);
2253 if (pNode && pNode->GetElementType() == XFA_Element::Decimal) { 2253 if (pNode && pNode->GetElementType() == XFA_Element::Decimal) {
2254 if (pUIChild->GetElementType() == XFA_Element::NumericEdit && 2254 if (pUIChild->GetElementType() == XFA_Element::NumericEdit &&
2255 (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) { 2255 (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) {
2256 pValue->SetString( 2256 pValue->SetString(
2257 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); 2257 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
2258 } else { 2258 } else {
2259 CFX_Decimal decimal(content.AsStringC()); 2259 CFX_Decimal decimal(content.AsStringC());
2260 pValue->SetFloat((FX_FLOAT)(double)decimal); 2260 pValue->SetFloat((FX_FLOAT)(double)decimal);
2261 } 2261 }
2262 } else if (pNode && pNode->GetElementType() == XFA_Element::Integer) { 2262 } else if (pNode && pNode->GetElementType() == XFA_Element::Integer) {
2263 pValue->SetInteger(FXSYS_wtoi(content.c_str())); 2263 pValue->SetInteger(FXSYS_wtoi(content.c_str()));
2264 } else if (pNode && pNode->GetElementType() == XFA_Element::Boolean) { 2264 } else if (pNode && pNode->GetElementType() == XFA_Element::Boolean) {
2265 pValue->SetBoolean(FXSYS_wtoi(content.c_str()) == 0 ? FALSE : TRUE); 2265 pValue->SetBoolean(FXSYS_wtoi(content.c_str()) == 0 ? false : true);
2266 } else if (pNode && pNode->GetElementType() == XFA_Element::Float) { 2266 } else if (pNode && pNode->GetElementType() == XFA_Element::Float) {
2267 CFX_Decimal decimal(content.AsStringC()); 2267 CFX_Decimal decimal(content.AsStringC());
2268 pValue->SetFloat((FX_FLOAT)(double)decimal); 2268 pValue->SetFloat((FX_FLOAT)(double)decimal);
2269 } else { 2269 } else {
2270 pValue->SetString( 2270 pValue->SetString(
2271 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); 2271 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
2272 } 2272 }
2273 } 2273 }
2274 } 2274 }
2275 } 2275 }
2276 2276
2277 void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue, 2277 void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue,
2278 FX_BOOL bSetting, 2278 bool bSetting,
2279 XFA_ATTRIBUTE eAttribute) { 2279 XFA_ATTRIBUTE eAttribute) {
2280 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2280 CXFA_WidgetData* pWidgetData = GetWidgetData();
2281 if (!pWidgetData) { 2281 if (!pWidgetData) {
2282 return; 2282 return;
2283 } 2283 }
2284 if (bSetting) { 2284 if (bSetting) {
2285 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Edit); 2285 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Edit);
2286 } else { 2286 } else {
2287 CFX_WideString wsValue; 2287 CFX_WideString wsValue;
2288 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); 2288 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit);
2289 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); 2289 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
2290 } 2290 }
2291 } 2291 }
2292 2292
2293 void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, 2293 void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue,
2294 FX_BOOL bSetting, 2294 bool bSetting,
2295 XFA_ATTRIBUTE eAttribute) { 2295 XFA_ATTRIBUTE eAttribute) {
2296 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2296 CXFA_WidgetData* pWidgetData = GetWidgetData();
2297 if (!pWidgetData) { 2297 if (!pWidgetData) {
2298 return; 2298 return;
2299 } 2299 }
2300 CXFA_Font font = pWidgetData->GetFont(TRUE); 2300 CXFA_Font font = pWidgetData->GetFont(true);
2301 CXFA_Node* pNode = font.GetNode(); 2301 CXFA_Node* pNode = font.GetNode();
2302 if (!pNode) { 2302 if (!pNode) {
2303 return; 2303 return;
2304 } 2304 }
2305 if (bSetting) { 2305 if (bSetting) {
2306 int32_t r; 2306 int32_t r;
2307 int32_t g; 2307 int32_t g;
2308 int32_t b; 2308 int32_t b;
2309 StrToRGB(pValue->ToWideString(), r, g, b); 2309 StrToRGB(pValue->ToWideString(), r, g, b);
2310 FX_ARGB color = ArgbEncode(0xff, r, g, b); 2310 FX_ARGB color = ArgbEncode(0xff, r, g, b);
2311 font.SetColor(color); 2311 font.SetColor(color);
2312 } else { 2312 } else {
2313 FX_ARGB color = font.GetColor(); 2313 FX_ARGB color = font.GetColor();
2314 int32_t a; 2314 int32_t a;
2315 int32_t r; 2315 int32_t r;
2316 int32_t g; 2316 int32_t g;
2317 int32_t b; 2317 int32_t b;
2318 ArgbDecode(color, a, r, g, b); 2318 ArgbDecode(color, a, r, g, b);
2319 CFX_WideString wsColor; 2319 CFX_WideString wsColor;
2320 wsColor.Format(L"%d,%d,%d", r, g, b); 2320 wsColor.Format(L"%d,%d,%d", r, g, b);
2321 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); 2321 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC());
2322 } 2322 }
2323 } 2323 }
2324 2324
2325 void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue, 2325 void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue,
2326 FX_BOOL bSetting, 2326 bool bSetting,
2327 XFA_ATTRIBUTE eAttribute) { 2327 XFA_ATTRIBUTE eAttribute) {
2328 Script_Som_Message(pValue, bSetting, XFA_SOM_FormatMessage); 2328 Script_Som_Message(pValue, bSetting, XFA_SOM_FormatMessage);
2329 } 2329 }
2330 2330
2331 void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, 2331 void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue,
2332 FX_BOOL bSetting, 2332 bool bSetting,
2333 XFA_ATTRIBUTE eAttribute) { 2333 XFA_ATTRIBUTE eAttribute) {
2334 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2334 CXFA_WidgetData* pWidgetData = GetWidgetData();
2335 if (!pWidgetData) { 2335 if (!pWidgetData) {
2336 return; 2336 return;
2337 } 2337 }
2338 if (bSetting) { 2338 if (bSetting) {
2339 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Display); 2339 pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Display);
2340 } else { 2340 } else {
2341 CFX_WideString wsValue; 2341 CFX_WideString wsValue;
2342 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); 2342 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display);
2343 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); 2343 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
2344 } 2344 }
2345 } 2345 }
2346 2346
2347 void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, 2347 void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue,
2348 FX_BOOL bSetting, 2348 bool bSetting,
2349 XFA_ATTRIBUTE eAttribute) { 2349 XFA_ATTRIBUTE eAttribute) {
2350 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2350 CXFA_WidgetData* pWidgetData = GetWidgetData();
2351 if (!pWidgetData) { 2351 if (!pWidgetData) {
2352 return; 2352 return;
2353 } 2353 }
2354 CXFA_Validate validate = pWidgetData->GetValidate(TRUE); 2354 CXFA_Validate validate = pWidgetData->GetValidate(true);
2355 if (bSetting) { 2355 if (bSetting) {
2356 validate.SetNullTest(pValue->ToWideString()); 2356 validate.SetNullTest(pValue->ToWideString());
2357 } else { 2357 } else {
2358 int32_t iValue = validate.GetNullTest(); 2358 int32_t iValue = validate.GetNullTest();
2359 const XFA_ATTRIBUTEENUMINFO* pInfo = 2359 const XFA_ATTRIBUTEENUMINFO* pInfo =
2360 GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue); 2360 GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue);
2361 CFX_WideString wsValue; 2361 CFX_WideString wsValue;
2362 if (pInfo) 2362 if (pInfo)
2363 wsValue = pInfo->pName; 2363 wsValue = pInfo->pName;
2364 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); 2364 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
2365 } 2365 }
2366 } 2366 }
2367 2367
2368 void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue, 2368 void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue,
2369 FX_BOOL bSetting, 2369 bool bSetting,
2370 XFA_ATTRIBUTE eAttribute) { 2370 XFA_ATTRIBUTE eAttribute) {
2371 Script_Som_Message(pValue, bSetting, XFA_SOM_MandatoryMessage); 2371 Script_Som_Message(pValue, bSetting, XFA_SOM_MandatoryMessage);
2372 } 2372 }
2373 2373
2374 void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, 2374 void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue,
2375 FX_BOOL bSetting, 2375 bool bSetting,
2376 XFA_ATTRIBUTE eAttribute) { 2376 XFA_ATTRIBUTE eAttribute) {
2377 if (bSetting) { 2377 if (bSetting) {
2378 ThrowException(XFA_IDS_INVAlID_PROP_SET); 2378 ThrowException(XFA_IDS_INVAlID_PROP_SET);
2379 } else { 2379 } else {
2380 pValue->SetNull(); 2380 pValue->SetNull();
2381 } 2381 }
2382 } 2382 }
2383 2383
2384 void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, 2384 void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue,
2385 FX_BOOL bSetting, 2385 bool bSetting,
2386 XFA_ATTRIBUTE eAttribute) { 2386 XFA_ATTRIBUTE eAttribute) {
2387 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2387 CXFA_WidgetData* pWidgetData = GetWidgetData();
2388 if (!pWidgetData) { 2388 if (!pWidgetData) {
2389 return; 2389 return;
2390 } 2390 }
2391 if (bSetting) { 2391 if (bSetting) {
2392 int32_t iIndex = pValue->ToInteger(); 2392 int32_t iIndex = pValue->ToInteger();
2393 if (iIndex == -1) { 2393 if (iIndex == -1) {
2394 pWidgetData->ClearAllSelections(); 2394 pWidgetData->ClearAllSelections();
2395 return; 2395 return;
2396 } 2396 }
2397 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); 2397 pWidgetData->SetItemState(iIndex, true, true, true, true);
2398 } else { 2398 } else {
2399 pValue->SetInteger(pWidgetData->GetSelectedItem()); 2399 pValue->SetInteger(pWidgetData->GetSelectedItem());
2400 } 2400 }
2401 } 2401 }
2402 2402
2403 void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { 2403 void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) {
2404 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2404 CXFA_WidgetData* pWidgetData = GetWidgetData();
2405 if (!pWidgetData) { 2405 if (!pWidgetData) {
2406 return; 2406 return;
2407 } 2407 }
2408 pWidgetData->DeleteItem(-1, TRUE); 2408 pWidgetData->DeleteItem(-1, true);
2409 } 2409 }
2410 2410
2411 void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { 2411 void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) {
2412 int32_t argc = pArguments->GetLength(); 2412 int32_t argc = pArguments->GetLength();
2413 if (argc == 1) { 2413 if (argc == 1) {
2414 CFX_ByteString eventString = pArguments->GetUTF8String(0); 2414 CFX_ByteString eventString = pArguments->GetUTF8String(0);
2415 int32_t iRet = execSingleEventByName( 2415 int32_t iRet = execSingleEventByName(
2416 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), 2416 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
2417 XFA_Element::Field); 2417 XFA_Element::Field);
2418 if (eventString == "validate") { 2418 if (eventString == "validate") {
2419 pArguments->GetReturnValue()->SetBoolean( 2419 pArguments->GetReturnValue()->SetBoolean(
2420 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2420 (iRet == XFA_EVENTERROR_Error) ? false : true);
2421 } 2421 }
2422 } else { 2422 } else {
2423 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); 2423 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
2424 } 2424 }
2425 } 2425 }
2426 2426
2427 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { 2427 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) {
2428 int32_t argc = pArguments->GetLength(); 2428 int32_t argc = pArguments->GetLength();
2429 if (argc == 0) { 2429 if (argc == 0) {
2430 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 2430 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2431 if (!pNotify) { 2431 if (!pNotify) {
2432 return; 2432 return;
2433 } 2433 }
2434 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, FALSE, FALSE); 2434 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, false, false);
2435 } else { 2435 } else {
2436 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); 2436 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
2437 } 2437 }
2438 } 2438 }
2439 2439
2440 void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { 2440 void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) {
2441 int32_t iLength = pArguments->GetLength(); 2441 int32_t iLength = pArguments->GetLength();
2442 if (iLength != 1) { 2442 if (iLength != 1) {
2443 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem"); 2443 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem");
2444 return; 2444 return;
2445 } 2445 }
2446 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2446 CXFA_WidgetData* pWidgetData = GetWidgetData();
2447 if (!pWidgetData) { 2447 if (!pWidgetData) {
2448 return; 2448 return;
2449 } 2449 }
2450 int32_t iIndex = pArguments->GetInt32(0); 2450 int32_t iIndex = pArguments->GetInt32(0);
2451 FX_BOOL bValue = pWidgetData->DeleteItem(iIndex, TRUE, TRUE); 2451 bool bValue = pWidgetData->DeleteItem(iIndex, true, true);
2452 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 2452 CFXJSE_Value* pValue = pArguments->GetReturnValue();
2453 if (pValue) 2453 if (pValue)
2454 pValue->SetBoolean(bValue); 2454 pValue->SetBoolean(bValue);
2455 } 2455 }
2456 2456
2457 void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { 2457 void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) {
2458 int32_t iLength = pArguments->GetLength(); 2458 int32_t iLength = pArguments->GetLength();
2459 if (iLength != 1) { 2459 if (iLength != 1) {
2460 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem"); 2460 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem");
2461 return; 2461 return;
2462 } 2462 }
2463 int32_t iIndex = pArguments->GetInt32(0); 2463 int32_t iIndex = pArguments->GetInt32(0);
2464 if (iIndex < 0) { 2464 if (iIndex < 0) {
2465 pArguments->GetReturnValue()->SetNull(); 2465 pArguments->GetReturnValue()->SetNull();
2466 return; 2466 return;
2467 } 2467 }
2468 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2468 CXFA_WidgetData* pWidgetData = GetWidgetData();
2469 if (!pWidgetData) { 2469 if (!pWidgetData) {
2470 pArguments->GetReturnValue()->SetNull(); 2470 pArguments->GetReturnValue()->SetNull();
2471 return; 2471 return;
2472 } 2472 }
2473 CFX_WideString wsValue; 2473 CFX_WideString wsValue;
2474 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, TRUE); 2474 bool bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, true);
2475 if (bHasItem) { 2475 if (bHasItem) {
2476 pArguments->GetReturnValue()->SetString( 2476 pArguments->GetReturnValue()->SetString(
2477 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); 2477 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
2478 } else { 2478 } else {
2479 pArguments->GetReturnValue()->SetNull(); 2479 pArguments->GetReturnValue()->SetNull();
2480 } 2480 }
2481 } 2481 }
2482 2482
2483 void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { 2483 void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) {
2484 int32_t iLength = pArguments->GetLength(); 2484 int32_t iLength = pArguments->GetLength();
(...skipping 18 matching lines...) Expand all
2503 int32_t iLength = pArguments->GetLength(); 2503 int32_t iLength = pArguments->GetLength();
2504 if (iLength != 1) { 2504 if (iLength != 1) {
2505 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getItemState"); 2505 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getItemState");
2506 return; 2506 return;
2507 } 2507 }
2508 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2508 CXFA_WidgetData* pWidgetData = GetWidgetData();
2509 if (!pWidgetData) { 2509 if (!pWidgetData) {
2510 return; 2510 return;
2511 } 2511 }
2512 int32_t iIndex = pArguments->GetInt32(0); 2512 int32_t iIndex = pArguments->GetInt32(0);
2513 FX_BOOL bValue = pWidgetData->GetItemState(iIndex); 2513 bool bValue = pWidgetData->GetItemState(iIndex);
2514 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 2514 CFXJSE_Value* pValue = pArguments->GetReturnValue();
2515 if (pValue) 2515 if (pValue)
2516 pValue->SetBoolean(bValue); 2516 pValue->SetBoolean(bValue);
2517 } 2517 }
2518 2518
2519 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { 2519 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) {
2520 int32_t argc = pArguments->GetLength(); 2520 int32_t argc = pArguments->GetLength();
2521 if (argc == 0) { 2521 if (argc == 0) {
2522 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 2522 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2523 if (!pNotify) { 2523 if (!pNotify) {
2524 return; 2524 return;
2525 } 2525 }
2526 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); 2526 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, false, false);
2527 } else { 2527 } else {
2528 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 2528 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
2529 } 2529 }
2530 } 2530 }
2531 2531
2532 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} 2532 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {}
2533 2533
2534 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { 2534 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) {
2535 int32_t iLength = pArguments->GetLength(); 2535 int32_t iLength = pArguments->GetLength();
2536 if (iLength != 1) { 2536 if (iLength != 1) {
2537 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getDisplayItem"); 2537 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getDisplayItem");
2538 return; 2538 return;
2539 } 2539 }
2540 int32_t iIndex = pArguments->GetInt32(0); 2540 int32_t iIndex = pArguments->GetInt32(0);
2541 if (iIndex < 0) { 2541 if (iIndex < 0) {
2542 pArguments->GetReturnValue()->SetNull(); 2542 pArguments->GetReturnValue()->SetNull();
2543 return; 2543 return;
2544 } 2544 }
2545 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2545 CXFA_WidgetData* pWidgetData = GetWidgetData();
2546 if (!pWidgetData) { 2546 if (!pWidgetData) {
2547 pArguments->GetReturnValue()->SetNull(); 2547 pArguments->GetReturnValue()->SetNull();
2548 return; 2548 return;
2549 } 2549 }
2550 CFX_WideString wsValue; 2550 CFX_WideString wsValue;
2551 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, FALSE); 2551 bool bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, false);
2552 if (bHasItem) { 2552 if (bHasItem) {
2553 pArguments->GetReturnValue()->SetString( 2553 pArguments->GetReturnValue()->SetString(
2554 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); 2554 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
2555 } else { 2555 } else {
2556 pArguments->GetReturnValue()->SetNull(); 2556 pArguments->GetReturnValue()->SetNull();
2557 } 2557 }
2558 } 2558 }
2559 2559
2560 void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { 2560 void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) {
2561 int32_t iLength = pArguments->GetLength(); 2561 int32_t iLength = pArguments->GetLength();
2562 if (iLength != 2) { 2562 if (iLength != 2) {
2563 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setItemState"); 2563 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setItemState");
2564 return; 2564 return;
2565 } 2565 }
2566 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2566 CXFA_WidgetData* pWidgetData = GetWidgetData();
2567 if (!pWidgetData) 2567 if (!pWidgetData)
2568 return; 2568 return;
2569 2569
2570 int32_t iIndex = pArguments->GetInt32(0); 2570 int32_t iIndex = pArguments->GetInt32(0);
2571 if (pArguments->GetInt32(1) != 0) { 2571 if (pArguments->GetInt32(1) != 0) {
2572 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); 2572 pWidgetData->SetItemState(iIndex, true, true, true, true);
2573 } else { 2573 } else {
2574 if (pWidgetData->GetItemState(iIndex)) 2574 if (pWidgetData->GetItemState(iIndex))
2575 pWidgetData->SetItemState(iIndex, FALSE, true, TRUE, TRUE); 2575 pWidgetData->SetItemState(iIndex, false, true, true, true);
2576 } 2576 }
2577 } 2577 }
2578 2578
2579 void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { 2579 void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) {
2580 int32_t iLength = pArguments->GetLength(); 2580 int32_t iLength = pArguments->GetLength();
2581 if (iLength < 1 || iLength > 2) { 2581 if (iLength < 1 || iLength > 2) {
2582 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addItem"); 2582 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addItem");
2583 return; 2583 return;
2584 } 2584 }
2585 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2585 CXFA_WidgetData* pWidgetData = GetWidgetData();
2586 if (!pWidgetData) { 2586 if (!pWidgetData) {
2587 return; 2587 return;
2588 } 2588 }
2589 CFX_WideString wsLabel; 2589 CFX_WideString wsLabel;
2590 CFX_WideString wsValue; 2590 CFX_WideString wsValue;
2591 if (iLength >= 1) { 2591 if (iLength >= 1) {
2592 CFX_ByteString bsLabel = pArguments->GetUTF8String(0); 2592 CFX_ByteString bsLabel = pArguments->GetUTF8String(0);
2593 wsLabel = CFX_WideString::FromUTF8(bsLabel.AsStringC()); 2593 wsLabel = CFX_WideString::FromUTF8(bsLabel.AsStringC());
2594 } 2594 }
2595 if (iLength >= 2) { 2595 if (iLength >= 2) {
2596 CFX_ByteString bsValue = pArguments->GetUTF8String(1); 2596 CFX_ByteString bsValue = pArguments->GetUTF8String(1);
2597 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); 2597 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
2598 } 2598 }
2599 pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); 2599 pWidgetData->InsertItem(wsLabel, wsValue, -1, true);
2600 } 2600 }
2601 2601
2602 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { 2602 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) {
2603 int32_t argc = pArguments->GetLength(); 2603 int32_t argc = pArguments->GetLength();
2604 if (argc == 0) { 2604 if (argc == 0) {
2605 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 2605 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2606 if (!pNotify) { 2606 if (!pNotify) {
2607 pArguments->GetReturnValue()->SetBoolean(FALSE); 2607 pArguments->GetReturnValue()->SetBoolean(false);
2608 } else { 2608 } else {
2609 int32_t iRet = 2609 int32_t iRet =
2610 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); 2610 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, false, false);
2611 pArguments->GetReturnValue()->SetBoolean( 2611 pArguments->GetReturnValue()->SetBoolean(
2612 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2612 (iRet == XFA_EVENTERROR_Error) ? false : true);
2613 } 2613 }
2614 } else { 2614 } else {
2615 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 2615 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
2616 } 2616 }
2617 } 2617 }
2618 2618
2619 void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, 2619 void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue,
2620 FX_BOOL bSetting, 2620 bool bSetting,
2621 XFA_ATTRIBUTE eAttribute) { 2621 XFA_ATTRIBUTE eAttribute) {
2622 if (!bSetting) { 2622 if (!bSetting) {
2623 } else { 2623 } else {
2624 ThrowException(XFA_IDS_INVAlID_PROP_SET); 2624 ThrowException(XFA_IDS_INVAlID_PROP_SET);
2625 } 2625 }
2626 } 2626 }
2627 2627
2628 void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, 2628 void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue,
2629 FX_BOOL bSetting, 2629 bool bSetting,
2630 XFA_ATTRIBUTE eAttribute) { 2630 XFA_ATTRIBUTE eAttribute) {
2631 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2631 CXFA_WidgetData* pWidgetData = GetWidgetData();
2632 if (!pWidgetData) { 2632 if (!pWidgetData) {
2633 return; 2633 return;
2634 } 2634 }
2635 if (bSetting) { 2635 if (bSetting) {
2636 pWidgetData->SetSelectedMemberByValue(pValue->ToWideString().AsStringC(), 2636 pWidgetData->SetSelectedMemberByValue(pValue->ToWideString().AsStringC(),
2637 true, TRUE, TRUE); 2637 true, true, true);
2638 } else { 2638 } else {
2639 CFX_WideString wsValue = GetScriptContent(TRUE); 2639 CFX_WideString wsValue = GetScriptContent(true);
2640 XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); 2640 XFA_VERSION curVersion = GetDocument()->GetCurVersionMode();
2641 if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { 2641 if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) {
2642 pValue->SetNull(); 2642 pValue->SetNull();
2643 } else { 2643 } else {
2644 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); 2644 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
2645 } 2645 }
2646 } 2646 }
2647 } 2647 }
2648 2648
2649 void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, 2649 void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue,
2650 FX_BOOL bSetting, 2650 bool bSetting,
2651 XFA_ATTRIBUTE eAttribute) {} 2651 XFA_ATTRIBUTE eAttribute) {}
2652 2652
2653 void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { 2653 void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) {
2654 int32_t argc = pArguments->GetLength(); 2654 int32_t argc = pArguments->GetLength();
2655 if (argc == 1) { 2655 if (argc == 1) {
2656 CFX_ByteString eventString = pArguments->GetUTF8String(0); 2656 CFX_ByteString eventString = pArguments->GetUTF8String(0);
2657 execSingleEventByName( 2657 execSingleEventByName(
2658 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), 2658 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
2659 XFA_Element::ExclGroup); 2659 XFA_Element::ExclGroup);
2660 } else { 2660 } else {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 } else { 2716 } else {
2717 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 2717 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
2718 } 2718 }
2719 } 2719 }
2720 2720
2721 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { 2721 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) {
2722 int32_t argc = pArguments->GetLength(); 2722 int32_t argc = pArguments->GetLength();
2723 if (argc == 0) { 2723 if (argc == 0) {
2724 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 2724 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2725 if (!pNotify) { 2725 if (!pNotify) {
2726 pArguments->GetReturnValue()->SetBoolean(FALSE); 2726 pArguments->GetReturnValue()->SetBoolean(false);
2727 } else { 2727 } else {
2728 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 2728 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
2729 pArguments->GetReturnValue()->SetBoolean( 2729 pArguments->GetReturnValue()->SetBoolean(
2730 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2730 (iRet == XFA_EVENTERROR_Error) ? false : true);
2731 } 2731 }
2732 } else { 2732 } else {
2733 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 2733 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
2734 } 2734 }
2735 } 2735 }
2736 2736
2737 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, 2737 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue,
2738 FX_BOOL bSetting, 2738 bool bSetting,
2739 XFA_ATTRIBUTE eAttribute) { 2739 XFA_ATTRIBUTE eAttribute) {
2740 if (bSetting) { 2740 if (bSetting) {
2741 int32_t iTo = pValue->ToInteger(); 2741 int32_t iTo = pValue->ToInteger();
2742 int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); 2742 int32_t iFrom = Subform_and_SubformSet_InstanceIndex();
2743 CXFA_Node* pManagerNode = nullptr; 2743 CXFA_Node* pManagerNode = nullptr;
2744 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; 2744 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
2745 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { 2745 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
2746 if (pNode->GetElementType() == XFA_Element::InstanceManager) { 2746 if (pNode->GetElementType() == XFA_Element::InstanceManager) {
2747 pManagerNode = pNode; 2747 pManagerNode = pNode;
2748 break; 2748 break;
(...skipping 15 matching lines...) Expand all
2764 pFromInstance->GetElementType() == XFA_Element::Subform) { 2764 pFromInstance->GetElementType() == XFA_Element::Subform) {
2765 pNotify->RunSubformIndexChange(pFromInstance); 2765 pNotify->RunSubformIndexChange(pFromInstance);
2766 } 2766 }
2767 } 2767 }
2768 } else { 2768 } else {
2769 pValue->SetInteger(Subform_and_SubformSet_InstanceIndex()); 2769 pValue->SetInteger(Subform_and_SubformSet_InstanceIndex());
2770 } 2770 }
2771 } 2771 }
2772 2772
2773 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, 2773 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue,
2774 FX_BOOL bSetting, 2774 bool bSetting,
2775 XFA_ATTRIBUTE eAttribute) { 2775 XFA_ATTRIBUTE eAttribute) {
2776 if (!bSetting) { 2776 if (!bSetting) {
2777 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); 2777 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name);
2778 CXFA_Node* pInstanceMgr = nullptr; 2778 CXFA_Node* pInstanceMgr = nullptr;
2779 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; 2779 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
2780 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { 2780 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
2781 if (pNode->GetElementType() == XFA_Element::InstanceManager) { 2781 if (pNode->GetElementType() == XFA_Element::InstanceManager) {
2782 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); 2782 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name);
2783 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && 2783 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' &&
2784 wsInstMgrName.Mid(1) == wsName) { 2784 wsInstMgrName.Mid(1) == wsName) {
2785 pInstanceMgr = pNode; 2785 pInstanceMgr = pNode;
2786 } 2786 }
2787 break; 2787 break;
2788 } 2788 }
2789 } 2789 }
2790 if (pInstanceMgr) { 2790 if (pInstanceMgr) {
2791 pValue->Assign( 2791 pValue->Assign(
2792 m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); 2792 m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr));
2793 } else { 2793 } else {
2794 pValue->SetNull(); 2794 pValue->SetNull();
2795 } 2795 }
2796 } else { 2796 } else {
2797 ThrowException(XFA_IDS_INVAlID_PROP_SET); 2797 ThrowException(XFA_IDS_INVAlID_PROP_SET);
2798 } 2798 }
2799 } 2799 }
2800 2800
2801 void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue, 2801 void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue,
2802 FX_BOOL bSetting, 2802 bool bSetting,
2803 XFA_ATTRIBUTE eAttribute) { 2803 XFA_ATTRIBUTE eAttribute) {
2804 if (bSetting) { 2804 if (bSetting) {
2805 SetCData(XFA_ATTRIBUTE_Locale, pValue->ToWideString(), true, TRUE); 2805 SetCData(XFA_ATTRIBUTE_Locale, pValue->ToWideString(), true, true);
2806 } else { 2806 } else {
2807 CFX_WideString wsLocaleName; 2807 CFX_WideString wsLocaleName;
2808 GetLocaleName(wsLocaleName); 2808 GetLocaleName(wsLocaleName);
2809 pValue->SetString( 2809 pValue->SetString(
2810 FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength()) 2810 FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength())
2811 .AsStringC()); 2811 .AsStringC());
2812 } 2812 }
2813 } 2813 }
2814 2814
2815 void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { 2815 void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 } else { 2848 } else {
2849 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 2849 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
2850 } 2850 }
2851 } 2851 }
2852 2852
2853 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { 2853 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) {
2854 int32_t argc = pArguments->GetLength(); 2854 int32_t argc = pArguments->GetLength();
2855 if (argc == 0) { 2855 if (argc == 0) {
2856 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 2856 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
2857 if (!pNotify) { 2857 if (!pNotify) {
2858 pArguments->GetReturnValue()->SetBoolean(FALSE); 2858 pArguments->GetReturnValue()->SetBoolean(false);
2859 } else { 2859 } else {
2860 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 2860 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
2861 pArguments->GetReturnValue()->SetBoolean( 2861 pArguments->GetReturnValue()->SetBoolean(
2862 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 2862 (iRet == XFA_EVENTERROR_Error) ? false : true);
2863 } 2863 }
2864 } else { 2864 } else {
2865 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 2865 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
2866 } 2866 }
2867 } 2867 }
2868 2868
2869 void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { 2869 void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) {
2870 int32_t argc = pArguments->GetLength(); 2870 int32_t argc = pArguments->GetLength();
2871 if (argc == 0) { 2871 if (argc == 0) {
2872 } else { 2872 } else {
(...skipping 11 matching lines...) Expand all
2884 } else { 2884 } else {
2885 break; 2885 break;
2886 } 2886 }
2887 } 2887 }
2888 return index; 2888 return index;
2889 } 2889 }
2890 2890
2891 void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { 2891 void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) {
2892 int32_t argc = pArguments->GetLength(); 2892 int32_t argc = pArguments->GetLength();
2893 if (argc == 1) { 2893 if (argc == 1) {
2894 pArguments->GetReturnValue()->SetBoolean(TRUE); 2894 pArguments->GetReturnValue()->SetBoolean(true);
2895 } else { 2895 } else {
2896 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); 2896 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes");
2897 } 2897 }
2898 } 2898 }
2899 2899
2900 void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { 2900 void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) {
2901 int32_t argc = pArguments->GetLength(); 2901 int32_t argc = pArguments->GetLength();
2902 if (argc == 0) { 2902 if (argc == 0) {
2903 m_pDocument->DoDataRemerge(TRUE); 2903 m_pDocument->DoDataRemerge(true);
2904 } else { 2904 } else {
2905 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); 2905 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge");
2906 } 2906 }
2907 } 2907 }
2908 2908
2909 void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { 2909 void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) {
2910 int32_t argc = pArguments->GetLength(); 2910 int32_t argc = pArguments->GetLength();
2911 if (argc == 0) { 2911 if (argc == 0) {
2912 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2912 CXFA_WidgetData* pWidgetData = GetWidgetData();
2913 if (!pWidgetData) { 2913 if (!pWidgetData) {
2914 pArguments->GetReturnValue()->SetBoolean(FALSE); 2914 pArguments->GetReturnValue()->SetBoolean(false);
2915 } else { 2915 } else {
2916 pArguments->GetReturnValue()->SetBoolean(TRUE); 2916 pArguments->GetReturnValue()->SetBoolean(true);
2917 } 2917 }
2918 } else { 2918 } else {
2919 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); 2919 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
2920 } 2920 }
2921 } 2921 }
2922 2922
2923 void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { 2923 void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
2924 int32_t argc = pArguments->GetLength(); 2924 int32_t argc = pArguments->GetLength();
2925 if ((argc > 0) && (argc < 4)) { 2925 if ((argc > 0) && (argc < 4)) {
2926 CFX_WideString strTagName; 2926 CFX_WideString strTagName;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); 2959 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
2960 } 2960 }
2961 } 2961 }
2962 } else { 2962 } else {
2963 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode"); 2963 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode");
2964 } 2964 }
2965 } 2965 }
2966 2966
2967 void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { 2967 void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) {
2968 if (pArguments->GetLength() == 1) { 2968 if (pArguments->GetLength() == 1) {
2969 pArguments->GetReturnValue()->SetBoolean(TRUE); 2969 pArguments->GetReturnValue()->SetBoolean(true);
2970 } else { 2970 } else {
2971 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); 2971 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate");
2972 } 2972 }
2973 } 2973 }
2974 2974
2975 void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { 2975 void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) {
2976 int32_t argc = pArguments->GetLength(); 2976 int32_t argc = pArguments->GetLength();
2977 if (argc == 0) { 2977 if (argc == 0) {
2978 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2978 CXFA_WidgetData* pWidgetData = GetWidgetData();
2979 if (!pWidgetData) { 2979 if (!pWidgetData) {
2980 pArguments->GetReturnValue()->SetBoolean(FALSE); 2980 pArguments->GetReturnValue()->SetBoolean(false);
2981 } else { 2981 } else {
2982 pArguments->GetReturnValue()->SetBoolean(TRUE); 2982 pArguments->GetReturnValue()->SetBoolean(true);
2983 } 2983 }
2984 } else { 2984 } else {
2985 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 2985 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
2986 } 2986 }
2987 } 2987 }
2988 2988
2989 void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { 2989 void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) {
2990 int32_t argc = pArguments->GetLength(); 2990 int32_t argc = pArguments->GetLength();
2991 if (argc == 0) { 2991 if (argc == 0) {
2992 CXFA_WidgetData* pWidgetData = GetWidgetData(); 2992 CXFA_WidgetData* pWidgetData = GetWidgetData();
2993 if (!pWidgetData) { 2993 if (!pWidgetData) {
2994 pArguments->GetReturnValue()->SetBoolean(FALSE); 2994 pArguments->GetReturnValue()->SetBoolean(false);
2995 } else { 2995 } else {
2996 pArguments->GetReturnValue()->SetBoolean(TRUE); 2996 pArguments->GetReturnValue()->SetBoolean(true);
2997 } 2997 }
2998 } else { 2998 } else {
2999 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 2999 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
3000 } 3000 }
3001 } 3001 }
3002 3002
3003 void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { 3003 void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) {
3004 int32_t argc = pArguments->GetLength(); 3004 int32_t argc = pArguments->GetLength();
3005 if (argc == 0) { 3005 if (argc == 0) {
3006 CXFA_WidgetData* pWidgetData = GetWidgetData(); 3006 CXFA_WidgetData* pWidgetData = GetWidgetData();
3007 if (!pWidgetData) { 3007 if (!pWidgetData) {
3008 pArguments->GetReturnValue()->SetBoolean(FALSE); 3008 pArguments->GetReturnValue()->SetBoolean(false);
3009 } else { 3009 } else {
3010 pArguments->GetReturnValue()->SetBoolean(TRUE); 3010 pArguments->GetReturnValue()->SetBoolean(true);
3011 } 3011 }
3012 } else { 3012 } else {
3013 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate"); 3013 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate");
3014 } 3014 }
3015 } 3015 }
3016 3016
3017 void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, 3017 void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue,
3018 FX_BOOL bSetting, 3018 bool bSetting,
3019 XFA_ATTRIBUTE eAttribute) { 3019 XFA_ATTRIBUTE eAttribute) {
3020 if (bSetting) { 3020 if (bSetting) {
3021 ThrowException(XFA_IDS_INVAlID_PROP_SET); 3021 ThrowException(XFA_IDS_INVAlID_PROP_SET);
3022 return; 3022 return;
3023 } 3023 }
3024 CXFA_Occur nodeOccur(GetOccurNode()); 3024 CXFA_Occur nodeOccur(GetOccurNode());
3025 pValue->SetInteger(nodeOccur.GetMax()); 3025 pValue->SetInteger(nodeOccur.GetMax());
3026 } 3026 }
3027 3027
3028 void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, 3028 void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue,
3029 FX_BOOL bSetting, 3029 bool bSetting,
3030 XFA_ATTRIBUTE eAttribute) { 3030 XFA_ATTRIBUTE eAttribute) {
3031 if (bSetting) { 3031 if (bSetting) {
3032 ThrowException(XFA_IDS_INVAlID_PROP_SET); 3032 ThrowException(XFA_IDS_INVAlID_PROP_SET);
3033 return; 3033 return;
3034 } 3034 }
3035 CXFA_Occur nodeOccur(GetOccurNode()); 3035 CXFA_Occur nodeOccur(GetOccurNode());
3036 pValue->SetInteger(nodeOccur.GetMin()); 3036 pValue->SetInteger(nodeOccur.GetMin());
3037 } 3037 }
3038 3038
3039 void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, 3039 void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue,
3040 FX_BOOL bSetting, 3040 bool bSetting,
3041 XFA_ATTRIBUTE eAttribute) { 3041 XFA_ATTRIBUTE eAttribute) {
3042 if (bSetting) { 3042 if (bSetting) {
3043 int32_t iDesired = pValue->ToInteger(); 3043 int32_t iDesired = pValue->ToInteger();
3044 InstanceManager_SetInstances(iDesired); 3044 InstanceManager_SetInstances(iDesired);
3045 } else { 3045 } else {
3046 pValue->SetInteger(GetCount(this)); 3046 pValue->SetInteger(GetCount(this));
3047 } 3047 }
3048 } 3048 }
3049 3049
3050 void CXFA_Node::Script_InstanceManager_MoveInstance( 3050 void CXFA_Node::Script_InstanceManager_MoveInstance(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 InstanceManager_SetInstances(iDesired); 3122 InstanceManager_SetInstances(iDesired);
3123 } 3123 }
3124 3124
3125 void CXFA_Node::Script_InstanceManager_AddInstance( 3125 void CXFA_Node::Script_InstanceManager_AddInstance(
3126 CFXJSE_Arguments* pArguments) { 3126 CFXJSE_Arguments* pArguments) {
3127 int32_t argc = pArguments->GetLength(); 3127 int32_t argc = pArguments->GetLength();
3128 if ((argc != 0) && (argc != 1)) { 3128 if ((argc != 0) && (argc != 1)) {
3129 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance"); 3129 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance");
3130 return; 3130 return;
3131 } 3131 }
3132 FX_BOOL fFlags = TRUE; 3132 bool fFlags = true;
3133 if (argc == 1) { 3133 if (argc == 1) {
3134 fFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; 3134 fFlags = pArguments->GetInt32(0) == 0 ? false : true;
3135 } 3135 }
3136 int32_t iCount = GetCount(this); 3136 int32_t iCount = GetCount(this);
3137 CXFA_Occur nodeOccur(GetOccurNode()); 3137 CXFA_Occur nodeOccur(GetOccurNode());
3138 int32_t iMax = nodeOccur.GetMax(); 3138 int32_t iMax = nodeOccur.GetMax();
3139 if (iMax >= 0 && iCount >= iMax) { 3139 if (iMax >= 0 && iCount >= iMax) {
3140 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); 3140 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max");
3141 return; 3141 return;
3142 } 3142 }
3143 CXFA_Node* pNewInstance = CreateInstance(this, fFlags); 3143 CXFA_Node* pNewInstance = CreateInstance(this, fFlags);
3144 InsertItem(this, pNewInstance, iCount, iCount, FALSE); 3144 InsertItem(this, pNewInstance, iCount, iCount, false);
3145 pArguments->GetReturnValue()->Assign( 3145 pArguments->GetReturnValue()->Assign(
3146 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); 3146 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance));
3147 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 3147 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3148 if (!pNotify) { 3148 if (!pNotify) {
3149 return; 3149 return;
3150 } 3150 }
3151 pNotify->RunNodeInitialize(pNewInstance); 3151 pNotify->RunNodeInitialize(pNewInstance);
3152 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3152 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
3153 if (!pLayoutPro) { 3153 if (!pLayoutPro) {
3154 return; 3154 return;
3155 } 3155 }
3156 pLayoutPro->AddChangedContainer( 3156 pLayoutPro->AddChangedContainer(
3157 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); 3157 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
3158 } 3158 }
3159 3159
3160 void CXFA_Node::Script_InstanceManager_InsertInstance( 3160 void CXFA_Node::Script_InstanceManager_InsertInstance(
3161 CFXJSE_Arguments* pArguments) { 3161 CFXJSE_Arguments* pArguments) {
3162 int32_t argc = pArguments->GetLength(); 3162 int32_t argc = pArguments->GetLength();
3163 if ((argc != 1) && (argc != 2)) { 3163 if ((argc != 1) && (argc != 2)) {
3164 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insertInstance"); 3164 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insertInstance");
3165 return; 3165 return;
3166 } 3166 }
3167 int32_t iIndex = pArguments->GetInt32(0); 3167 int32_t iIndex = pArguments->GetInt32(0);
3168 FX_BOOL bBind = FALSE; 3168 bool bBind = false;
3169 if (argc == 2) { 3169 if (argc == 2) {
3170 bBind = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; 3170 bBind = pArguments->GetInt32(1) == 0 ? false : true;
3171 } 3171 }
3172 CXFA_Occur nodeOccur(GetOccurNode()); 3172 CXFA_Occur nodeOccur(GetOccurNode());
3173 int32_t iCount = GetCount(this); 3173 int32_t iCount = GetCount(this);
3174 if (iIndex < 0 || iIndex > iCount) { 3174 if (iIndex < 0 || iIndex > iCount) {
3175 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); 3175 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS);
3176 return; 3176 return;
3177 } 3177 }
3178 int32_t iMax = nodeOccur.GetMax(); 3178 int32_t iMax = nodeOccur.GetMax();
3179 if (iMax >= 0 && iCount >= iMax) { 3179 if (iMax >= 0 && iCount >= iMax) {
3180 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); 3180 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max");
3181 return; 3181 return;
3182 } 3182 }
3183 CXFA_Node* pNewInstance = CreateInstance(this, bBind); 3183 CXFA_Node* pNewInstance = CreateInstance(this, bBind);
3184 InsertItem(this, pNewInstance, iIndex, iCount, TRUE); 3184 InsertItem(this, pNewInstance, iIndex, iCount, true);
3185 pArguments->GetReturnValue()->Assign( 3185 pArguments->GetReturnValue()->Assign(
3186 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); 3186 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance));
3187 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 3187 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3188 if (!pNotify) { 3188 if (!pNotify) {
3189 return; 3189 return;
3190 } 3190 }
3191 pNotify->RunNodeInitialize(pNewInstance); 3191 pNotify->RunNodeInitialize(pNewInstance);
3192 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3192 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
3193 if (!pLayoutPro) { 3193 if (!pLayoutPro) {
3194 return; 3194 return;
(...skipping 28 matching lines...) Expand all
3223 CXFA_Node* pPrevSibling = 3223 CXFA_Node* pPrevSibling =
3224 (iDesired == 0) ? this : GetItem(this, iDesired - 1); 3224 (iDesired == 0) ? this : GetItem(this, iDesired - 1);
3225 while (iCount > iDesired) { 3225 while (iCount > iDesired) {
3226 CXFA_Node* pRemoveInstance = 3226 CXFA_Node* pRemoveInstance =
3227 pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling); 3227 pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling);
3228 if (pRemoveInstance->GetElementType() != XFA_Element::Subform && 3228 if (pRemoveInstance->GetElementType() != XFA_Element::Subform &&
3229 pRemoveInstance->GetElementType() != XFA_Element::SubformSet) { 3229 pRemoveInstance->GetElementType() != XFA_Element::SubformSet) {
3230 continue; 3230 continue;
3231 } 3231 }
3232 if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) { 3232 if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) {
3233 ASSERT(FALSE); 3233 ASSERT(false);
3234 break; 3234 break;
3235 } 3235 }
3236 if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { 3236 if (pRemoveInstance->GetNameHash() == dInstanceNameHash) {
3237 RemoveItem(this, pRemoveInstance); 3237 RemoveItem(this, pRemoveInstance);
3238 iCount--; 3238 iCount--;
3239 } 3239 }
3240 } 3240 }
3241 } else if (iDesired > iCount) { 3241 } else if (iDesired > iCount) {
3242 while (iCount < iDesired) { 3242 while (iCount < iDesired) {
3243 CXFA_Node* pNewInstance = CreateInstance(this, TRUE); 3243 CXFA_Node* pNewInstance = CreateInstance(this, true);
3244 InsertItem(this, pNewInstance, iCount, iCount, FALSE); 3244 InsertItem(this, pNewInstance, iCount, iCount, false);
3245 iCount++; 3245 iCount++;
3246 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 3246 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3247 if (!pNotify) { 3247 if (!pNotify) {
3248 return 0; 3248 return 0;
3249 } 3249 }
3250 pNotify->RunNodeInitialize(pNewInstance); 3250 pNotify->RunNodeInitialize(pNewInstance);
3251 } 3251 }
3252 } 3252 }
3253 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3253 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
3254 if (pLayoutPro) { 3254 if (pLayoutPro) {
3255 pLayoutPro->AddChangedContainer( 3255 pLayoutPro->AddChangedContainer(
3256 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); 3256 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
3257 } 3257 }
3258 return 0; 3258 return 0;
3259 } 3259 }
3260 3260
3261 int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { 3261 int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) {
3262 int32_t iCount = GetCount(this); 3262 int32_t iCount = GetCount(this);
3263 if (iFrom > iCount || iTo > iCount - 1) { 3263 if (iFrom > iCount || iTo > iCount - 1) {
3264 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); 3264 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS);
3265 return 1; 3265 return 1;
3266 } 3266 }
3267 if (iFrom < 0 || iTo < 0 || iFrom == iTo) { 3267 if (iFrom < 0 || iTo < 0 || iFrom == iTo) {
3268 return 0; 3268 return 0;
3269 } 3269 }
3270 CXFA_Node* pMoveInstance = GetItem(this, iFrom); 3270 CXFA_Node* pMoveInstance = GetItem(this, iFrom);
3271 RemoveItem(this, pMoveInstance, FALSE); 3271 RemoveItem(this, pMoveInstance, false);
3272 InsertItem(this, pMoveInstance, iTo, iCount - 1, TRUE); 3272 InsertItem(this, pMoveInstance, iTo, iCount - 1, true);
3273 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); 3273 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
3274 if (pLayoutPro) { 3274 if (pLayoutPro) {
3275 pLayoutPro->AddChangedContainer( 3275 pLayoutPro->AddChangedContainer(
3276 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); 3276 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
3277 } 3277 }
3278 return 0; 3278 return 0;
3279 } 3279 }
3280 3280
3281 void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue, 3281 void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue,
3282 FX_BOOL bSetting, 3282 bool bSetting,
3283 XFA_ATTRIBUTE eAttribute) { 3283 XFA_ATTRIBUTE eAttribute) {
3284 CXFA_Occur occur(this); 3284 CXFA_Occur occur(this);
3285 if (bSetting) { 3285 if (bSetting) {
3286 int32_t iMax = pValue->ToInteger(); 3286 int32_t iMax = pValue->ToInteger();
3287 occur.SetMax(iMax); 3287 occur.SetMax(iMax);
3288 } else { 3288 } else {
3289 pValue->SetInteger(occur.GetMax()); 3289 pValue->SetInteger(occur.GetMax());
3290 } 3290 }
3291 } 3291 }
3292 3292
3293 void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue, 3293 void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue,
3294 FX_BOOL bSetting, 3294 bool bSetting,
3295 XFA_ATTRIBUTE eAttribute) { 3295 XFA_ATTRIBUTE eAttribute) {
3296 CXFA_Occur occur(this); 3296 CXFA_Occur occur(this);
3297 if (bSetting) { 3297 if (bSetting) {
3298 int32_t iMin = pValue->ToInteger(); 3298 int32_t iMin = pValue->ToInteger();
3299 occur.SetMin(iMin); 3299 occur.SetMin(iMin);
3300 } else { 3300 } else {
3301 pValue->SetInteger(occur.GetMin()); 3301 pValue->SetInteger(occur.GetMin());
3302 } 3302 }
3303 } 3303 }
3304 3304
(...skipping 20 matching lines...) Expand all
3325 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 3325 ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3326 } 3326 }
3327 } else { 3327 } else {
3328 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); 3328 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes");
3329 } 3329 }
3330 } 3330 }
3331 3331
3332 void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { 3332 void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) {
3333 int32_t argc = pArguments->GetLength(); 3333 int32_t argc = pArguments->GetLength();
3334 if (argc == 0) { 3334 if (argc == 0) {
3335 m_pDocument->DoDataRemerge(TRUE); 3335 m_pDocument->DoDataRemerge(true);
3336 } else { 3336 } else {
3337 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); 3337 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge");
3338 } 3338 }
3339 } 3339 }
3340 3340
3341 void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { 3341 void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) {
3342 int32_t argc = pArguments->GetLength(); 3342 int32_t argc = pArguments->GetLength();
3343 if (argc == 0) { 3343 if (argc == 0) {
3344 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 3344 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3345 if (!pNotify) { 3345 if (!pNotify) {
(...skipping 15 matching lines...) Expand all
3361 int32_t argc = pArguments->GetLength(); 3361 int32_t argc = pArguments->GetLength();
3362 if (argc == 1) { 3362 if (argc == 1) {
3363 const bool bScriptFlags = pArguments->GetInt32(0) != 0; 3363 const bool bScriptFlags = pArguments->GetInt32(0) != 0;
3364 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 3364 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3365 if (!pNotify) { 3365 if (!pNotify) {
3366 return; 3366 return;
3367 } 3367 }
3368 if (bScriptFlags) { 3368 if (bScriptFlags) {
3369 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); 3369 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
3370 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 3370 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
3371 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, TRUE); 3371 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, true);
3372 } else { 3372 } else {
3373 } 3373 }
3374 } else { 3374 } else {
3375 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); 3375 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate");
3376 } 3376 }
3377 } 3377 }
3378 3378
3379 void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { 3379 void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) {
3380 int32_t argc = pArguments->GetLength(); 3380 int32_t argc = pArguments->GetLength();
3381 if (argc == 0) { 3381 if (argc == 0) {
3382 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 3382 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3383 if (!pNotify) { 3383 if (!pNotify) {
3384 return; 3384 return;
3385 } 3385 }
3386 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); 3386 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
3387 } else { 3387 } else {
3388 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); 3388 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
3389 } 3389 }
3390 } 3390 }
3391 3391
3392 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { 3392 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) {
3393 int32_t argc = pArguments->GetLength(); 3393 int32_t argc = pArguments->GetLength();
3394 if (argc == 0) { 3394 if (argc == 0) {
3395 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 3395 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
3396 if (!pNotify) { 3396 if (!pNotify) {
3397 pArguments->GetReturnValue()->SetBoolean(FALSE); 3397 pArguments->GetReturnValue()->SetBoolean(false);
3398 } else { 3398 } else {
3399 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); 3399 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
3400 pArguments->GetReturnValue()->SetBoolean( 3400 pArguments->GetReturnValue()->SetBoolean(
3401 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); 3401 (iRet == XFA_EVENTERROR_Error) ? false : true);
3402 } 3402 }
3403 } else { 3403 } else {
3404 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); 3404 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
3405 } 3405 }
3406 } 3406 }
3407 3407
3408 void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue, 3408 void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue,
3409 FX_BOOL bSetting, 3409 bool bSetting,
3410 XFA_ATTRIBUTE eAttribute) { 3410 XFA_ATTRIBUTE eAttribute) {
3411 if (bSetting) { 3411 if (bSetting) {
3412 SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringC()); 3412 SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringC());
3413 } else { 3413 } else {
3414 CFX_WideString wsChecksum; 3414 CFX_WideString wsChecksum;
3415 GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE); 3415 GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, false);
3416 pValue->SetString( 3416 pValue->SetString(
3417 FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC()); 3417 FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC());
3418 } 3418 }
3419 } 3419 }
3420 3420
3421 void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { 3421 void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) {
3422 int32_t argc = pArguments->GetLength(); 3422 int32_t argc = pArguments->GetLength();
3423 if (argc == 1) { 3423 if (argc == 1) {
3424 CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); 3424 CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0);
3425 CFX_WideString wsAttributeValue; 3425 CFX_WideString wsAttributeValue;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3466 pXMLElement->RemoveAttribute(wsName.c_str()); 3466 pXMLElement->RemoveAttribute(wsName.c_str());
3467 } 3467 }
3468 } 3468 }
3469 pArguments->GetReturnValue()->SetNull(); 3469 pArguments->GetReturnValue()->SetNull();
3470 } else { 3470 } else {
3471 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"removeAttribute"); 3471 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"removeAttribute");
3472 } 3472 }
3473 } 3473 }
3474 3474
3475 void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, 3475 void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue,
3476 FX_BOOL bSetting, 3476 bool bSetting,
3477 XFA_ATTRIBUTE eAttribute) { 3477 XFA_ATTRIBUTE eAttribute) {
3478 if (bSetting) { 3478 if (bSetting) {
3479 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); 3479 CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
3480 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { 3480 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
3481 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); 3481 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
3482 pXMLElement->SetTextData(pValue->ToWideString()); 3482 pXMLElement->SetTextData(pValue->ToWideString());
3483 } 3483 }
3484 } else { 3484 } else {
3485 CFX_WideString wsTextData; 3485 CFX_WideString wsTextData;
3486 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); 3486 CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3623 3623
3624 void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) { 3624 void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) {
3625 int32_t argc = pArguments->GetLength(); 3625 int32_t argc = pArguments->GetLength();
3626 if (argc == 0) { 3626 if (argc == 0) {
3627 } else { 3627 } else {
3628 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"hasDataChanged"); 3628 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"hasDataChanged");
3629 } 3629 }
3630 } 3630 }
3631 3631
3632 void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue, 3632 void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue,
3633 FX_BOOL bSetting, 3633 bool bSetting,
3634 XFA_ATTRIBUTE eAttribute) {} 3634 XFA_ATTRIBUTE eAttribute) {}
3635 3635
3636 void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue, 3636 void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue,
3637 FX_BOOL bSetting, 3637 bool bSetting,
3638 XFA_ATTRIBUTE eAttribute) { 3638 XFA_ATTRIBUTE eAttribute) {
3639 if (!bSetting) { 3639 if (!bSetting) {
3640 CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject(); 3640 CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject();
3641 ASSERT(pThis); 3641 ASSERT(pThis);
3642 pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis)); 3642 pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis));
3643 } 3643 }
3644 } 3644 }
3645 3645
3646 void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue, 3646 void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue,
3647 FX_BOOL bSetting, 3647 bool bSetting,
3648 XFA_ATTRIBUTE eAttribute) {} 3648 XFA_ATTRIBUTE eAttribute) {}
3649 3649
3650 void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, 3650 void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue,
3651 FX_BOOL bSetting, 3651 bool bSetting,
3652 XFA_ATTRIBUTE eAttribute) {} 3652 XFA_ATTRIBUTE eAttribute) {}
3653 3653
3654 void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue, 3654 void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue,
3655 FX_BOOL bSetting, 3655 bool bSetting,
3656 XFA_ATTRIBUTE eAttribute) {} 3656 XFA_ATTRIBUTE eAttribute) {}
3657 3657
3658 void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue, 3658 void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue,
3659 FX_BOOL bSetting, 3659 bool bSetting,
3660 XFA_ATTRIBUTE eAttribute) { 3660 XFA_ATTRIBUTE eAttribute) {
3661 if (bSetting) { 3661 if (bSetting) {
3662 ThrowException(XFA_IDS_INVAlID_PROP_SET); 3662 ThrowException(XFA_IDS_INVAlID_PROP_SET);
3663 return; 3663 return;
3664 } 3664 }
3665 pValue->SetString(FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC()); 3665 pValue->SetString(FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC());
3666 } 3666 }
3667 3667
3668 void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue, 3668 void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue,
3669 FX_BOOL bSetting, 3669 bool bSetting,
3670 XFA_ATTRIBUTE eAttribute) {} 3670 XFA_ATTRIBUTE eAttribute) {}
3671 3671
3672 FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { 3672 bool CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit) {
3673 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 3673 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
3674 return HasMapModuleKey(pKey, bCanInherit); 3674 return HasMapModuleKey(pKey, bCanInherit);
3675 } 3675 }
3676 3676
3677 FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, 3677 bool CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr,
3678 const CFX_WideStringC& wsValue, 3678 const CFX_WideStringC& wsValue,
3679 bool bNotify) { 3679 bool bNotify) {
3680 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); 3680 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr);
3681 if (!pAttr) 3681 if (!pAttr)
3682 return FALSE; 3682 return false;
3683 3683
3684 XFA_ATTRIBUTETYPE eType = pAttr->eType; 3684 XFA_ATTRIBUTETYPE eType = pAttr->eType;
3685 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { 3685 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) {
3686 const XFA_NOTSUREATTRIBUTE* pNotsure = 3686 const XFA_NOTSUREATTRIBUTE* pNotsure =
3687 XFA_GetNotsureAttribute(GetElementType(), pAttr->eName); 3687 XFA_GetNotsureAttribute(GetElementType(), pAttr->eName);
3688 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; 3688 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata;
3689 } 3689 }
3690 switch (eType) { 3690 switch (eType) {
3691 case XFA_ATTRIBUTETYPE_Enum: { 3691 case XFA_ATTRIBUTETYPE_Enum: {
3692 const XFA_ATTRIBUTEENUMINFO* pEnum = XFA_GetAttributeEnumByName(wsValue); 3692 const XFA_ATTRIBUTEENUMINFO* pEnum = XFA_GetAttributeEnumByName(wsValue);
3693 return SetEnum(pAttr->eName, 3693 return SetEnum(pAttr->eName,
3694 pEnum ? pEnum->eName 3694 pEnum ? pEnum->eName
3695 : (XFA_ATTRIBUTEENUM)(intptr_t)(pAttr->pDefValue), 3695 : (XFA_ATTRIBUTEENUM)(intptr_t)(pAttr->pDefValue),
3696 bNotify); 3696 bNotify);
3697 } break; 3697 } break;
3698 case XFA_ATTRIBUTETYPE_Cdata: 3698 case XFA_ATTRIBUTETYPE_Cdata:
3699 return SetCData(pAttr->eName, CFX_WideString(wsValue), bNotify); 3699 return SetCData(pAttr->eName, CFX_WideString(wsValue), bNotify);
3700 case XFA_ATTRIBUTETYPE_Boolean: 3700 case XFA_ATTRIBUTETYPE_Boolean:
3701 return SetBoolean(pAttr->eName, wsValue != FX_WSTRC(L"0"), bNotify); 3701 return SetBoolean(pAttr->eName, wsValue != FX_WSTRC(L"0"), bNotify);
3702 case XFA_ATTRIBUTETYPE_Integer: 3702 case XFA_ATTRIBUTETYPE_Integer:
3703 return SetInteger(pAttr->eName, 3703 return SetInteger(pAttr->eName,
3704 FXSYS_round(FXSYS_wcstof(wsValue.c_str(), 3704 FXSYS_round(FXSYS_wcstof(wsValue.c_str(),
3705 wsValue.GetLength(), nullptr)), 3705 wsValue.GetLength(), nullptr)),
3706 bNotify); 3706 bNotify);
3707 case XFA_ATTRIBUTETYPE_Measure: 3707 case XFA_ATTRIBUTETYPE_Measure:
3708 return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify); 3708 return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify);
3709 default: 3709 default:
3710 break; 3710 break;
3711 } 3711 }
3712 return FALSE; 3712 return false;
3713 } 3713 }
3714 3714
3715 FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr, 3715 bool CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr,
3716 CFX_WideString& wsValue, 3716 CFX_WideString& wsValue,
3717 FX_BOOL bUseDefault) { 3717 bool bUseDefault) {
3718 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); 3718 const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr);
3719 if (!pAttr) { 3719 if (!pAttr) {
3720 return FALSE; 3720 return false;
3721 } 3721 }
3722 XFA_ATTRIBUTETYPE eType = pAttr->eType; 3722 XFA_ATTRIBUTETYPE eType = pAttr->eType;
3723 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { 3723 if (eType == XFA_ATTRIBUTETYPE_NOTSURE) {
3724 const XFA_NOTSUREATTRIBUTE* pNotsure = 3724 const XFA_NOTSUREATTRIBUTE* pNotsure =
3725 XFA_GetNotsureAttribute(GetElementType(), pAttr->eName); 3725 XFA_GetNotsureAttribute(GetElementType(), pAttr->eName);
3726 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; 3726 eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata;
3727 } 3727 }
3728 switch (eType) { 3728 switch (eType) {
3729 case XFA_ATTRIBUTETYPE_Enum: { 3729 case XFA_ATTRIBUTETYPE_Enum: {
3730 XFA_ATTRIBUTEENUM eValue; 3730 XFA_ATTRIBUTEENUM eValue;
3731 if (!TryEnum(pAttr->eName, eValue, bUseDefault)) { 3731 if (!TryEnum(pAttr->eName, eValue, bUseDefault)) {
3732 return FALSE; 3732 return false;
3733 } 3733 }
3734 wsValue = GetAttributeEnumByID(eValue)->pName; 3734 wsValue = GetAttributeEnumByID(eValue)->pName;
3735 return TRUE; 3735 return true;
3736 } break; 3736 } break;
3737 case XFA_ATTRIBUTETYPE_Cdata: { 3737 case XFA_ATTRIBUTETYPE_Cdata: {
3738 CFX_WideStringC wsValueC; 3738 CFX_WideStringC wsValueC;
3739 if (!TryCData(pAttr->eName, wsValueC, bUseDefault)) { 3739 if (!TryCData(pAttr->eName, wsValueC, bUseDefault)) {
3740 return FALSE; 3740 return false;
3741 } 3741 }
3742 wsValue = wsValueC; 3742 wsValue = wsValueC;
3743 return TRUE; 3743 return true;
3744 } break; 3744 } break;
3745 case XFA_ATTRIBUTETYPE_Boolean: { 3745 case XFA_ATTRIBUTETYPE_Boolean: {
3746 FX_BOOL bValue; 3746 bool bValue;
3747 if (!TryBoolean(pAttr->eName, bValue, bUseDefault)) { 3747 if (!TryBoolean(pAttr->eName, bValue, bUseDefault)) {
3748 return FALSE; 3748 return false;
3749 } 3749 }
3750 wsValue = bValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0"); 3750 wsValue = bValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0");
3751 return TRUE; 3751 return true;
3752 } break; 3752 } break;
3753 case XFA_ATTRIBUTETYPE_Integer: { 3753 case XFA_ATTRIBUTETYPE_Integer: {
3754 int32_t iValue; 3754 int32_t iValue;
3755 if (!TryInteger(pAttr->eName, iValue, bUseDefault)) { 3755 if (!TryInteger(pAttr->eName, iValue, bUseDefault)) {
3756 return FALSE; 3756 return false;
3757 } 3757 }
3758 wsValue.Format(L"%d", iValue); 3758 wsValue.Format(L"%d", iValue);
3759 return TRUE; 3759 return true;
3760 } break; 3760 } break;
3761 case XFA_ATTRIBUTETYPE_Measure: { 3761 case XFA_ATTRIBUTETYPE_Measure: {
3762 CXFA_Measurement mValue; 3762 CXFA_Measurement mValue;
3763 if (!TryMeasure(pAttr->eName, mValue, bUseDefault)) { 3763 if (!TryMeasure(pAttr->eName, mValue, bUseDefault)) {
3764 return FALSE; 3764 return false;
3765 } 3765 }
3766 mValue.ToString(wsValue); 3766 mValue.ToString(wsValue);
3767 return TRUE; 3767 return true;
3768 } break; 3768 } break;
3769 default: 3769 default:
3770 break; 3770 break;
3771 } 3771 }
3772 return FALSE; 3772 return false;
3773 } 3773 }
3774 3774
3775 FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr, 3775 bool CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr,
3776 const CFX_WideStringC& wsValue, 3776 const CFX_WideStringC& wsValue,
3777 bool bNotify) { 3777 bool bNotify) {
3778 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue); 3778 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue);
3779 if (pAttributeInfo) { 3779 if (pAttributeInfo) {
3780 return SetAttribute(pAttributeInfo->eName, wsValue, bNotify); 3780 return SetAttribute(pAttributeInfo->eName, wsValue, bNotify);
3781 } 3781 }
3782 void* pKey = GetMapKey_Custom(wsAttr); 3782 void* pKey = GetMapKey_Custom(wsAttr);
3783 SetMapModuleString(pKey, wsValue); 3783 SetMapModuleString(pKey, wsValue);
3784 return TRUE; 3784 return true;
3785 } 3785 }
3786 3786
3787 FX_BOOL CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr, 3787 bool CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr,
3788 CFX_WideString& wsValue, 3788 CFX_WideString& wsValue,
3789 FX_BOOL bUseDefault) { 3789 bool bUseDefault) {
3790 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsAttr); 3790 const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsAttr);
3791 if (pAttributeInfo) { 3791 if (pAttributeInfo) {
3792 return GetAttribute(pAttributeInfo->eName, wsValue, bUseDefault); 3792 return GetAttribute(pAttributeInfo->eName, wsValue, bUseDefault);
3793 } 3793 }
3794 void* pKey = GetMapKey_Custom(wsAttr); 3794 void* pKey = GetMapKey_Custom(wsAttr);
3795 CFX_WideStringC wsValueC; 3795 CFX_WideStringC wsValueC;
3796 if (GetMapModuleString(pKey, wsValueC)) { 3796 if (GetMapModuleString(pKey, wsValueC)) {
3797 wsValue = wsValueC; 3797 wsValue = wsValueC;
3798 } 3798 }
3799 return TRUE; 3799 return true;
3800 } 3800 }
3801 3801
3802 FX_BOOL CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) { 3802 bool CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) {
3803 void* pKey = GetMapKey_Custom(wsAttr); 3803 void* pKey = GetMapKey_Custom(wsAttr);
3804 RemoveMapModuleKey(pKey); 3804 RemoveMapModuleKey(pKey);
3805 return TRUE; 3805 return true;
3806 } 3806 }
3807 3807
3808 FX_BOOL CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr, 3808 bool CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr,
3809 FX_BOOL& bValue, 3809 bool& bValue,
3810 FX_BOOL bUseDefault) { 3810 bool bUseDefault) {
3811 void* pValue = nullptr; 3811 void* pValue = nullptr;
3812 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue)) 3812 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue))
3813 return FALSE; 3813 return false;
3814 bValue = !!pValue; 3814 bValue = !!pValue;
3815 return TRUE; 3815 return true;
3816 } 3816 }
3817 3817
3818 FX_BOOL CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr, 3818 bool CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr,
3819 int32_t& iValue, 3819 int32_t& iValue,
3820 FX_BOOL bUseDefault) { 3820 bool bUseDefault) {
3821 void* pValue = nullptr; 3821 void* pValue = nullptr;
3822 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue)) 3822 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue))
3823 return FALSE; 3823 return false;
3824 iValue = (int32_t)(uintptr_t)pValue; 3824 iValue = (int32_t)(uintptr_t)pValue;
3825 return TRUE; 3825 return true;
3826 } 3826 }
3827 3827
3828 FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, 3828 bool CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr,
3829 XFA_ATTRIBUTEENUM& eValue, 3829 XFA_ATTRIBUTEENUM& eValue,
3830 FX_BOOL bUseDefault) { 3830 bool bUseDefault) {
3831 void* pValue = nullptr; 3831 void* pValue = nullptr;
3832 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) 3832 if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue))
3833 return FALSE; 3833 return false;
3834 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; 3834 eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue;
3835 return TRUE; 3835 return true;
3836 } 3836 }
3837 3837
3838 FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, 3838 bool CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr,
3839 CXFA_Measurement mValue, 3839 CXFA_Measurement mValue,
3840 bool bNotify) { 3840 bool bNotify) {
3841 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 3841 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
3842 OnChanging(eAttr, bNotify); 3842 OnChanging(eAttr, bNotify);
3843 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); 3843 SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement));
3844 OnChanged(eAttr, bNotify, FALSE); 3844 OnChanged(eAttr, bNotify, false);
3845 return TRUE; 3845 return true;
3846 } 3846 }
3847 3847
3848 FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, 3848 bool CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr,
3849 CXFA_Measurement& mValue, 3849 CXFA_Measurement& mValue,
3850 FX_BOOL bUseDefault) const { 3850 bool bUseDefault) const {
3851 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 3851 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
3852 void* pValue; 3852 void* pValue;
3853 int32_t iBytes; 3853 int32_t iBytes;
3854 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { 3854 if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) {
3855 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); 3855 FXSYS_memcpy(&mValue, pValue, sizeof(mValue));
3856 return TRUE; 3856 return true;
3857 } 3857 }
3858 if (bUseDefault && 3858 if (bUseDefault &&
3859 XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, 3859 XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr,
3860 XFA_ATTRIBUTETYPE_Measure, m_ePacket)) { 3860 XFA_ATTRIBUTETYPE_Measure, m_ePacket)) {
3861 FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); 3861 FXSYS_memcpy(&mValue, pValue, sizeof(mValue));
3862 return TRUE; 3862 return true;
3863 } 3863 }
3864 return FALSE; 3864 return false;
3865 } 3865 }
3866 3866
3867 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { 3867 CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const {
3868 CXFA_Measurement mValue; 3868 CXFA_Measurement mValue;
3869 return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); 3869 return TryMeasure(eAttr, mValue, true) ? mValue : CXFA_Measurement();
3870 } 3870 }
3871 3871
3872 FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, 3872 bool CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr,
3873 const CFX_WideString& wsValue, 3873 const CFX_WideString& wsValue,
3874 bool bNotify, 3874 bool bNotify,
3875 FX_BOOL bScriptModify) { 3875 bool bScriptModify) {
3876 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 3876 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
3877 OnChanging(eAttr, bNotify); 3877 OnChanging(eAttr, bNotify);
3878 if (eAttr == XFA_ATTRIBUTE_Value) { 3878 if (eAttr == XFA_ATTRIBUTE_Value) {
3879 CFX_WideString* pClone = new CFX_WideString(wsValue); 3879 CFX_WideString* pClone = new CFX_WideString(wsValue);
3880 SetUserData(pKey, pClone, &deleteWideStringCallBack); 3880 SetUserData(pKey, pClone, &deleteWideStringCallBack);
3881 } else { 3881 } else {
3882 SetMapModuleString(pKey, wsValue.AsStringC()); 3882 SetMapModuleString(pKey, wsValue.AsStringC());
3883 if (eAttr == XFA_ATTRIBUTE_Name) 3883 if (eAttr == XFA_ATTRIBUTE_Name)
3884 UpdateNameHash(); 3884 UpdateNameHash();
3885 } 3885 }
3886 OnChanged(eAttr, bNotify, bScriptModify); 3886 OnChanged(eAttr, bNotify, bScriptModify);
3887 3887
3888 if (!IsNeedSavingXMLNode() || eAttr == XFA_ATTRIBUTE_QualifiedName || 3888 if (!IsNeedSavingXMLNode() || eAttr == XFA_ATTRIBUTE_QualifiedName ||
3889 eAttr == XFA_ATTRIBUTE_BindingNode) { 3889 eAttr == XFA_ATTRIBUTE_BindingNode) {
3890 return TRUE; 3890 return true;
3891 } 3891 }
3892 3892
3893 if (eAttr == XFA_ATTRIBUTE_Name && 3893 if (eAttr == XFA_ATTRIBUTE_Name &&
3894 (m_elementType == XFA_Element::DataValue || 3894 (m_elementType == XFA_Element::DataValue ||
3895 m_elementType == XFA_Element::DataGroup)) { 3895 m_elementType == XFA_Element::DataGroup)) {
3896 return TRUE; 3896 return true;
3897 } 3897 }
3898 3898
3899 if (eAttr == XFA_ATTRIBUTE_Value) { 3899 if (eAttr == XFA_ATTRIBUTE_Value) {
3900 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); 3900 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType();
3901 switch (eXMLType) { 3901 switch (eXMLType) {
3902 case FDE_XMLNODE_Element: 3902 case FDE_XMLNODE_Element:
3903 if (IsAttributeInXML()) { 3903 if (IsAttributeInXML()) {
3904 static_cast<CFDE_XMLElement*>(m_pXMLNode) 3904 static_cast<CFDE_XMLElement*>(m_pXMLNode)
3905 ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)), 3905 ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)),
3906 wsValue); 3906 wsValue);
3907 } else { 3907 } else {
3908 FX_BOOL bDeleteChildren = TRUE; 3908 bool bDeleteChildren = true;
3909 if (GetPacketID() == XFA_XDPPACKET_Datasets) { 3909 if (GetPacketID() == XFA_XDPPACKET_Datasets) {
3910 for (CXFA_Node* pChildDataNode = 3910 for (CXFA_Node* pChildDataNode =
3911 GetNodeItem(XFA_NODEITEM_FirstChild); 3911 GetNodeItem(XFA_NODEITEM_FirstChild);
3912 pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem( 3912 pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
3913 XFA_NODEITEM_NextSibling)) { 3913 XFA_NODEITEM_NextSibling)) {
3914 CXFA_NodeArray formNodes; 3914 CXFA_NodeArray formNodes;
3915 if (pChildDataNode->GetBindItems(formNodes) > 0) { 3915 if (pChildDataNode->GetBindItems(formNodes) > 0) {
3916 bDeleteChildren = FALSE; 3916 bDeleteChildren = false;
3917 break; 3917 break;
3918 } 3918 }
3919 } 3919 }
3920 } 3920 }
3921 if (bDeleteChildren) { 3921 if (bDeleteChildren) {
3922 static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren(); 3922 static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren();
3923 } 3923 }
3924 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsValue); 3924 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsValue);
3925 } 3925 }
3926 break; 3926 break;
3927 case FDE_XMLNODE_Text: 3927 case FDE_XMLNODE_Text:
3928 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsValue); 3928 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsValue);
3929 break; 3929 break;
3930 default: 3930 default:
3931 ASSERT(0); 3931 ASSERT(0);
3932 } 3932 }
3933 return TRUE; 3933 return true;
3934 } 3934 }
3935 3935
3936 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); 3936 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr);
3937 if (pInfo) { 3937 if (pInfo) {
3938 ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element); 3938 ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element);
3939 CFX_WideString wsAttrName = pInfo->pName; 3939 CFX_WideString wsAttrName = pInfo->pName;
3940 if (pInfo->eName == XFA_ATTRIBUTE_ContentType) { 3940 if (pInfo->eName == XFA_ATTRIBUTE_ContentType) {
3941 wsAttrName = FX_WSTRC(L"xfa:") + wsAttrName; 3941 wsAttrName = FX_WSTRC(L"xfa:") + wsAttrName;
3942 } 3942 }
3943 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue); 3943 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue);
3944 } 3944 }
3945 return TRUE; 3945 return true;
3946 } 3946 }
3947 3947
3948 FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, 3948 bool CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue,
3949 const CFX_WideString& wsXMLValue, 3949 const CFX_WideString& wsXMLValue,
3950 bool bNotify, 3950 bool bNotify,
3951 FX_BOOL bScriptModify) { 3951 bool bScriptModify) {
3952 void* pKey = GetMapKey_Element(GetElementType(), XFA_ATTRIBUTE_Value); 3952 void* pKey = GetMapKey_Element(GetElementType(), XFA_ATTRIBUTE_Value);
3953 OnChanging(XFA_ATTRIBUTE_Value, bNotify); 3953 OnChanging(XFA_ATTRIBUTE_Value, bNotify);
3954 CFX_WideString* pClone = new CFX_WideString(wsValue); 3954 CFX_WideString* pClone = new CFX_WideString(wsValue);
3955 SetUserData(pKey, pClone, &deleteWideStringCallBack); 3955 SetUserData(pKey, pClone, &deleteWideStringCallBack);
3956 OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); 3956 OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify);
3957 if (IsNeedSavingXMLNode()) { 3957 if (IsNeedSavingXMLNode()) {
3958 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); 3958 FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType();
3959 switch (eXMLType) { 3959 switch (eXMLType) {
3960 case FDE_XMLNODE_Element: 3960 case FDE_XMLNODE_Element:
3961 if (IsAttributeInXML()) { 3961 if (IsAttributeInXML()) {
3962 static_cast<CFDE_XMLElement*>(m_pXMLNode) 3962 static_cast<CFDE_XMLElement*>(m_pXMLNode)
3963 ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)), 3963 ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)),
3964 wsXMLValue); 3964 wsXMLValue);
3965 } else { 3965 } else {
3966 FX_BOOL bDeleteChildren = TRUE; 3966 bool bDeleteChildren = true;
3967 if (GetPacketID() == XFA_XDPPACKET_Datasets) { 3967 if (GetPacketID() == XFA_XDPPACKET_Datasets) {
3968 for (CXFA_Node* pChildDataNode = 3968 for (CXFA_Node* pChildDataNode =
3969 GetNodeItem(XFA_NODEITEM_FirstChild); 3969 GetNodeItem(XFA_NODEITEM_FirstChild);
3970 pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem( 3970 pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
3971 XFA_NODEITEM_NextSibling)) { 3971 XFA_NODEITEM_NextSibling)) {
3972 CXFA_NodeArray formNodes; 3972 CXFA_NodeArray formNodes;
3973 if (pChildDataNode->GetBindItems(formNodes) > 0) { 3973 if (pChildDataNode->GetBindItems(formNodes) > 0) {
3974 bDeleteChildren = FALSE; 3974 bDeleteChildren = false;
3975 break; 3975 break;
3976 } 3976 }
3977 } 3977 }
3978 } 3978 }
3979 if (bDeleteChildren) { 3979 if (bDeleteChildren) {
3980 static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren(); 3980 static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren();
3981 } 3981 }
3982 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsXMLValue); 3982 static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsXMLValue);
3983 } 3983 }
3984 break; 3984 break;
3985 case FDE_XMLNODE_Text: 3985 case FDE_XMLNODE_Text:
3986 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsXMLValue); 3986 static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsXMLValue);
3987 break; 3987 break;
3988 default: 3988 default:
3989 ASSERT(0); 3989 ASSERT(0);
3990 } 3990 }
3991 } 3991 }
3992 return TRUE; 3992 return true;
3993 } 3993 }
3994 3994
3995 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, 3995 bool CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr,
3996 CFX_WideString& wsValue, 3996 CFX_WideString& wsValue,
3997 FX_BOOL bUseDefault, 3997 bool bUseDefault,
3998 FX_BOOL bProto) { 3998 bool bProto) {
3999 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 3999 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
4000 if (eAttr == XFA_ATTRIBUTE_Value) { 4000 if (eAttr == XFA_ATTRIBUTE_Value) {
4001 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); 4001 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto);
4002 if (pStr) { 4002 if (pStr) {
4003 wsValue = *pStr; 4003 wsValue = *pStr;
4004 return TRUE; 4004 return true;
4005 } 4005 }
4006 } else { 4006 } else {
4007 CFX_WideStringC wsValueC; 4007 CFX_WideStringC wsValueC;
4008 if (GetMapModuleString(pKey, wsValueC)) { 4008 if (GetMapModuleString(pKey, wsValueC)) {
4009 wsValue = wsValueC; 4009 wsValue = wsValueC;
4010 return TRUE; 4010 return true;
4011 } 4011 }
4012 } 4012 }
4013 if (!bUseDefault) { 4013 if (!bUseDefault) {
4014 return FALSE; 4014 return false;
4015 } 4015 }
4016 void* pValue = nullptr; 4016 void* pValue = nullptr;
4017 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, 4017 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr,
4018 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { 4018 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) {
4019 wsValue = (const FX_WCHAR*)pValue; 4019 wsValue = (const FX_WCHAR*)pValue;
4020 return TRUE; 4020 return true;
4021 } 4021 }
4022 return FALSE; 4022 return false;
4023 } 4023 }
4024 4024
4025 FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, 4025 bool CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr,
4026 CFX_WideStringC& wsValue, 4026 CFX_WideStringC& wsValue,
4027 FX_BOOL bUseDefault, 4027 bool bUseDefault,
4028 FX_BOOL bProto) { 4028 bool bProto) {
4029 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 4029 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
4030 if (eAttr == XFA_ATTRIBUTE_Value) { 4030 if (eAttr == XFA_ATTRIBUTE_Value) {
4031 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); 4031 CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto);
4032 if (pStr) { 4032 if (pStr) {
4033 wsValue = pStr->AsStringC(); 4033 wsValue = pStr->AsStringC();
4034 return TRUE; 4034 return true;
4035 } 4035 }
4036 } else { 4036 } else {
4037 if (GetMapModuleString(pKey, wsValue)) { 4037 if (GetMapModuleString(pKey, wsValue)) {
4038 return TRUE; 4038 return true;
4039 } 4039 }
4040 } 4040 }
4041 if (!bUseDefault) { 4041 if (!bUseDefault) {
4042 return FALSE; 4042 return false;
4043 } 4043 }
4044 void* pValue = nullptr; 4044 void* pValue = nullptr;
4045 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, 4045 if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr,
4046 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { 4046 XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) {
4047 wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue; 4047 wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue;
4048 return TRUE; 4048 return true;
4049 } 4049 }
4050 return FALSE; 4050 return false;
4051 } 4051 }
4052 4052
4053 FX_BOOL CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr, 4053 bool CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr,
4054 void* pData, 4054 void* pData,
4055 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { 4055 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
4056 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 4056 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
4057 return SetUserData(pKey, pData, pCallbackInfo); 4057 return SetUserData(pKey, pData, pCallbackInfo);
4058 } 4058 }
4059 4059
4060 FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { 4060 bool CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) {
4061 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 4061 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
4062 pData = GetUserData(pKey); 4062 pData = GetUserData(pKey);
4063 return !!pData; 4063 return !!pData;
4064 } 4064 }
4065 4065
4066 FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, 4066 bool CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr,
4067 XFA_ATTRIBUTETYPE eType, 4067 XFA_ATTRIBUTETYPE eType,
4068 void* pValue, 4068 void* pValue,
4069 bool bNotify) { 4069 bool bNotify) {
4070 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 4070 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
4071 OnChanging(eAttr, bNotify); 4071 OnChanging(eAttr, bNotify);
4072 SetMapModuleValue(pKey, pValue); 4072 SetMapModuleValue(pKey, pValue);
4073 OnChanged(eAttr, bNotify, FALSE); 4073 OnChanged(eAttr, bNotify, false);
4074 if (IsNeedSavingXMLNode()) { 4074 if (IsNeedSavingXMLNode()) {
4075 ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element); 4075 ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element);
4076 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); 4076 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr);
4077 if (pInfo) { 4077 if (pInfo) {
4078 switch (eType) { 4078 switch (eType) {
4079 case XFA_ATTRIBUTETYPE_Enum: 4079 case XFA_ATTRIBUTETYPE_Enum:
4080 static_cast<CFDE_XMLElement*>(m_pXMLNode) 4080 static_cast<CFDE_XMLElement*>(m_pXMLNode)
4081 ->SetString( 4081 ->SetString(
4082 pInfo->pName, 4082 pInfo->pName,
4083 GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) 4083 GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue)
4084 ->pName); 4084 ->pName);
4085 break; 4085 break;
4086 case XFA_ATTRIBUTETYPE_Boolean: 4086 case XFA_ATTRIBUTETYPE_Boolean:
4087 static_cast<CFDE_XMLElement*>(m_pXMLNode) 4087 static_cast<CFDE_XMLElement*>(m_pXMLNode)
4088 ->SetString(pInfo->pName, pValue ? L"1" : L"0"); 4088 ->SetString(pInfo->pName, pValue ? L"1" : L"0");
4089 break; 4089 break;
4090 case XFA_ATTRIBUTETYPE_Integer: 4090 case XFA_ATTRIBUTETYPE_Integer:
4091 static_cast<CFDE_XMLElement*>(m_pXMLNode) 4091 static_cast<CFDE_XMLElement*>(m_pXMLNode)
4092 ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue); 4092 ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue);
4093 break; 4093 break;
4094 default: 4094 default:
4095 ASSERT(0); 4095 ASSERT(0);
4096 } 4096 }
4097 } 4097 }
4098 } 4098 }
4099 return TRUE; 4099 return true;
4100 } 4100 }
4101 4101
4102 FX_BOOL CXFA_Node::GetValue(XFA_ATTRIBUTE eAttr, 4102 bool CXFA_Node::GetValue(XFA_ATTRIBUTE eAttr,
4103 XFA_ATTRIBUTETYPE eType, 4103 XFA_ATTRIBUTETYPE eType,
4104 FX_BOOL bUseDefault, 4104 bool bUseDefault,
4105 void*& pValue) { 4105 void*& pValue) {
4106 void* pKey = GetMapKey_Element(GetElementType(), eAttr); 4106 void* pKey = GetMapKey_Element(GetElementType(), eAttr);
4107 if (GetMapModuleValue(pKey, pValue)) { 4107 if (GetMapModuleValue(pKey, pValue)) {
4108 return TRUE; 4108 return true;
4109 } 4109 }
4110 if (!bUseDefault) { 4110 if (!bUseDefault) {
4111 return FALSE; 4111 return false;
4112 } 4112 }
4113 return XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, eType, 4113 return XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, eType,
4114 m_ePacket); 4114 m_ePacket);
4115 } 4115 }
4116 4116
4117 FX_BOOL CXFA_Node::SetUserData(void* pKey, 4117 bool CXFA_Node::SetUserData(void* pKey,
4118 void* pData, 4118 void* pData,
4119 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { 4119 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
4120 SetMapModuleBuffer(pKey, &pData, sizeof(void*), 4120 SetMapModuleBuffer(pKey, &pData, sizeof(void*),
4121 pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); 4121 pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData);
4122 return TRUE; 4122 return true;
4123 } 4123 }
4124 4124
4125 FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { 4125 bool CXFA_Node::TryUserData(void* pKey, void*& pData, bool bProtoAlso) {
4126 int32_t iBytes = 0; 4126 int32_t iBytes = 0;
4127 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { 4127 if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) {
4128 return FALSE; 4128 return false;
4129 } 4129 }
4130 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); 4130 return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes);
4131 } 4131 }
4132 4132
4133 FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, 4133 bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
4134 const CFX_WideString& wsXMLValue, 4134 const CFX_WideString& wsXMLValue,
4135 bool bNotify, 4135 bool bNotify,
4136 FX_BOOL bScriptModify, 4136 bool bScriptModify,
4137 FX_BOOL bSyncData) { 4137 bool bSyncData) {
4138 CXFA_Node* pNode = nullptr; 4138 CXFA_Node* pNode = nullptr;
4139 CXFA_Node* pBindNode = nullptr; 4139 CXFA_Node* pBindNode = nullptr;
4140 switch (GetObjectType()) { 4140 switch (GetObjectType()) {
4141 case XFA_ObjectType::ContainerNode: { 4141 case XFA_ObjectType::ContainerNode: {
4142 if (XFA_FieldIsMultiListBox(this)) { 4142 if (XFA_FieldIsMultiListBox(this)) {
4143 CXFA_Node* pValue = GetProperty(0, XFA_Element::Value); 4143 CXFA_Node* pValue = GetProperty(0, XFA_Element::Value);
4144 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); 4144 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
4145 ASSERT(pChildValue); 4145 ASSERT(pChildValue);
4146 pChildValue->SetCData(XFA_ATTRIBUTE_ContentType, L"text/xml"); 4146 pChildValue->SetCData(XFA_ATTRIBUTE_ContentType, L"text/xml");
4147 pChildValue->SetScriptContent(wsContent, wsContent, bNotify, 4147 pChildValue->SetScriptContent(wsContent, wsContent, bNotify,
4148 bScriptModify, FALSE); 4148 bScriptModify, false);
4149 CXFA_Node* pBind = GetBindData(); 4149 CXFA_Node* pBind = GetBindData();
4150 if (bSyncData && pBind) { 4150 if (bSyncData && pBind) {
4151 CFX_WideStringArray wsSaveTextArray; 4151 CFX_WideStringArray wsSaveTextArray;
4152 int32_t iSize = 0; 4152 int32_t iSize = 0;
4153 if (!wsContent.IsEmpty()) { 4153 if (!wsContent.IsEmpty()) {
4154 int32_t iStart = 0; 4154 int32_t iStart = 0;
4155 int32_t iLength = wsContent.GetLength(); 4155 int32_t iLength = wsContent.GetLength();
4156 int32_t iEnd = wsContent.Find(L'\n', iStart); 4156 int32_t iEnd = wsContent.Find(L'\n', iStart);
4157 iEnd = (iEnd == -1) ? iLength : iEnd; 4157 iEnd = (iEnd == -1) ? iLength : iEnd;
4158 while (iEnd >= iStart) { 4158 while (iEnd >= iStart) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4193 while (iDelNodes-- > 0) { 4193 while (iDelNodes-- > 0) {
4194 pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild)); 4194 pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild));
4195 } 4195 }
4196 } 4196 }
4197 int32_t i = 0; 4197 int32_t i = 0;
4198 for (CXFA_Node* pValueNode = 4198 for (CXFA_Node* pValueNode =
4199 pBind->GetNodeItem(XFA_NODEITEM_FirstChild); 4199 pBind->GetNodeItem(XFA_NODEITEM_FirstChild);
4200 pValueNode; pValueNode = pValueNode->GetNodeItem( 4200 pValueNode; pValueNode = pValueNode->GetNodeItem(
4201 XFA_NODEITEM_NextSibling)) { 4201 XFA_NODEITEM_NextSibling)) {
4202 pValueNode->SetAttributeValue(wsSaveTextArray[i], 4202 pValueNode->SetAttributeValue(wsSaveTextArray[i],
4203 wsSaveTextArray[i], FALSE); 4203 wsSaveTextArray[i], false);
4204 i++; 4204 i++;
4205 } 4205 }
4206 } 4206 }
4207 CXFA_NodeArray nodeArray; 4207 CXFA_NodeArray nodeArray;
4208 pBind->GetBindItems(nodeArray); 4208 pBind->GetBindItems(nodeArray);
4209 for (int32_t i = 0; i < nodeArray.GetSize(); i++) { 4209 for (int32_t i = 0; i < nodeArray.GetSize(); i++) {
4210 if (nodeArray[i] != this) { 4210 if (nodeArray[i] != this) {
4211 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, 4211 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify,
4212 bScriptModify, FALSE); 4212 bScriptModify, false);
4213 } 4213 }
4214 } 4214 }
4215 } 4215 }
4216 break; 4216 break;
4217 } else if (GetElementType() == XFA_Element::ExclGroup) { 4217 } else if (GetElementType() == XFA_Element::ExclGroup) {
4218 pNode = this; 4218 pNode = this;
4219 } else { 4219 } else {
4220 CXFA_Node* pValue = GetProperty(0, XFA_Element::Value); 4220 CXFA_Node* pValue = GetProperty(0, XFA_Element::Value);
4221 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); 4221 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
4222 ASSERT(pChildValue); 4222 ASSERT(pChildValue);
4223 pChildValue->SetScriptContent(wsContent, wsContent, bNotify, 4223 pChildValue->SetScriptContent(wsContent, wsContent, bNotify,
4224 bScriptModify, FALSE); 4224 bScriptModify, false);
4225 } 4225 }
4226 pBindNode = GetBindData(); 4226 pBindNode = GetBindData();
4227 if (pBindNode && bSyncData) { 4227 if (pBindNode && bSyncData) {
4228 pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify, 4228 pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify,
4229 bScriptModify, FALSE); 4229 bScriptModify, false);
4230 CXFA_NodeArray nodeArray; 4230 CXFA_NodeArray nodeArray;
4231 pBindNode->GetBindItems(nodeArray); 4231 pBindNode->GetBindItems(nodeArray);
4232 for (int32_t i = 0; i < nodeArray.GetSize(); i++) { 4232 for (int32_t i = 0; i < nodeArray.GetSize(); i++) {
4233 if (nodeArray[i] != this) { 4233 if (nodeArray[i] != this) {
4234 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, true, 4234 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, true,
4235 FALSE); 4235 false);
4236 } 4236 }
4237 } 4237 }
4238 } 4238 }
4239 pBindNode = nullptr; 4239 pBindNode = nullptr;
4240 break; 4240 break;
4241 } 4241 }
4242 case XFA_ObjectType::ContentNode: { 4242 case XFA_ObjectType::ContentNode: {
4243 CFX_WideString wsContentType; 4243 CFX_WideString wsContentType;
4244 if (GetElementType() == XFA_Element::ExData) { 4244 if (GetElementType() == XFA_Element::ExData) {
4245 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); 4245 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false);
4246 if (wsContentType == FX_WSTRC(L"text/html")) { 4246 if (wsContentType == FX_WSTRC(L"text/html")) {
4247 wsContentType = FX_WSTRC(L""); 4247 wsContentType = FX_WSTRC(L"");
4248 SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType.AsStringC()); 4248 SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType.AsStringC());
4249 } 4249 }
4250 } 4250 }
4251 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); 4251 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild);
4252 if (!pContentRawDataNode) { 4252 if (!pContentRawDataNode) {
4253 pContentRawDataNode = CreateSamePacketNode( 4253 pContentRawDataNode = CreateSamePacketNode(
4254 (wsContentType == FX_WSTRC(L"text/xml")) ? XFA_Element::Sharpxml 4254 (wsContentType == FX_WSTRC(L"text/xml")) ? XFA_Element::Sharpxml
4255 : XFA_Element::Sharptext); 4255 : XFA_Element::Sharptext);
(...skipping 12 matching lines...) Expand all
4268 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); 4268 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent);
4269 if (pParent) { 4269 if (pParent) {
4270 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); 4270 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
4271 } 4271 }
4272 if (pParent && pParent->GetElementType() == XFA_Element::Value) { 4272 if (pParent && pParent->GetElementType() == XFA_Element::Value) {
4273 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); 4273 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
4274 if (pParent && pParent->IsContainerNode()) { 4274 if (pParent && pParent->IsContainerNode()) {
4275 pBindNode = pParent->GetBindData(); 4275 pBindNode = pParent->GetBindData();
4276 if (pBindNode) { 4276 if (pBindNode) {
4277 pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify, 4277 pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify,
4278 bScriptModify, FALSE); 4278 bScriptModify, false);
4279 } 4279 }
4280 } 4280 }
4281 } 4281 }
4282 } 4282 }
4283 break; 4283 break;
4284 default: 4284 default:
4285 if (GetElementType() == XFA_Element::DataValue) { 4285 if (GetElementType() == XFA_Element::DataValue) {
4286 pNode = this; 4286 pNode = this;
4287 pBindNode = this; 4287 pBindNode = this;
4288 } 4288 }
4289 break; 4289 break;
4290 } 4290 }
4291 if (pNode) { 4291 if (pNode) {
4292 SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify); 4292 SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify);
4293 if (pBindNode && bSyncData) { 4293 if (pBindNode && bSyncData) {
4294 CXFA_NodeArray nodeArray; 4294 CXFA_NodeArray nodeArray;
4295 pBindNode->GetBindItems(nodeArray); 4295 pBindNode->GetBindItems(nodeArray);
4296 for (int32_t i = 0; i < nodeArray.GetSize(); i++) { 4296 for (int32_t i = 0; i < nodeArray.GetSize(); i++) {
4297 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, 4297 nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify,
4298 bScriptModify, FALSE); 4298 bScriptModify, false);
4299 } 4299 }
4300 } 4300 }
4301 return TRUE; 4301 return true;
4302 } 4302 }
4303 return FALSE; 4303 return false;
4304 } 4304 }
4305 4305
4306 FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent, 4306 bool CXFA_Node::SetContent(const CFX_WideString& wsContent,
4307 const CFX_WideString& wsXMLValue, 4307 const CFX_WideString& wsXMLValue,
4308 bool bNotify, 4308 bool bNotify,
4309 FX_BOOL bScriptModify, 4309 bool bScriptModify,
4310 FX_BOOL bSyncData) { 4310 bool bSyncData) {
4311 return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, 4311 return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify,
4312 bSyncData); 4312 bSyncData);
4313 } 4313 }
4314 4314
4315 CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { 4315 CFX_WideString CXFA_Node::GetScriptContent(bool bScriptModify) {
4316 CFX_WideString wsContent; 4316 CFX_WideString wsContent;
4317 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); 4317 return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString();
4318 } 4318 }
4319 4319
4320 CFX_WideString CXFA_Node::GetContent() { 4320 CFX_WideString CXFA_Node::GetContent() {
4321 return GetScriptContent(); 4321 return GetScriptContent();
4322 } 4322 }
4323 4323
4324 FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, 4324 bool CXFA_Node::TryContent(CFX_WideString& wsContent,
4325 FX_BOOL bScriptModify, 4325 bool bScriptModify,
4326 FX_BOOL bProto) { 4326 bool bProto) {
4327 CXFA_Node* pNode = nullptr; 4327 CXFA_Node* pNode = nullptr;
4328 switch (GetObjectType()) { 4328 switch (GetObjectType()) {
4329 case XFA_ObjectType::ContainerNode: 4329 case XFA_ObjectType::ContainerNode:
4330 if (GetElementType() == XFA_Element::ExclGroup) { 4330 if (GetElementType() == XFA_Element::ExclGroup) {
4331 pNode = this; 4331 pNode = this;
4332 } else { 4332 } else {
4333 CXFA_Node* pValue = GetChild(0, XFA_Element::Value); 4333 CXFA_Node* pValue = GetChild(0, XFA_Element::Value);
4334 if (!pValue) { 4334 if (!pValue) {
4335 return FALSE; 4335 return false;
4336 } 4336 }
4337 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); 4337 CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
4338 if (pChildValue && XFA_FieldIsMultiListBox(this)) { 4338 if (pChildValue && XFA_FieldIsMultiListBox(this)) {
4339 pChildValue->SetAttribute(XFA_ATTRIBUTE_ContentType, 4339 pChildValue->SetAttribute(XFA_ATTRIBUTE_ContentType,
4340 FX_WSTRC(L"text/xml")); 4340 FX_WSTRC(L"text/xml"));
4341 } 4341 }
4342 return pChildValue 4342 return pChildValue
4343 ? pChildValue->TryContent(wsContent, bScriptModify, bProto) 4343 ? pChildValue->TryContent(wsContent, bScriptModify, bProto)
4344 : FALSE; 4344 : false;
4345 } 4345 }
4346 break; 4346 break;
4347 case XFA_ObjectType::ContentNode: { 4347 case XFA_ObjectType::ContentNode: {
4348 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); 4348 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild);
4349 if (!pContentRawDataNode) { 4349 if (!pContentRawDataNode) {
4350 XFA_Element element = XFA_Element::Sharptext; 4350 XFA_Element element = XFA_Element::Sharptext;
4351 if (GetElementType() == XFA_Element::ExData) { 4351 if (GetElementType() == XFA_Element::ExData) {
4352 CFX_WideString wsContentType; 4352 CFX_WideString wsContentType;
4353 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); 4353 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false);
4354 if (wsContentType == FX_WSTRC(L"text/html")) { 4354 if (wsContentType == FX_WSTRC(L"text/html")) {
4355 element = XFA_Element::SharpxHTML; 4355 element = XFA_Element::SharpxHTML;
4356 } else if (wsContentType == FX_WSTRC(L"text/xml")) { 4356 } else if (wsContentType == FX_WSTRC(L"text/xml")) {
4357 element = XFA_Element::Sharpxml; 4357 element = XFA_Element::Sharpxml;
4358 } 4358 }
4359 } 4359 }
4360 pContentRawDataNode = CreateSamePacketNode(element); 4360 pContentRawDataNode = CreateSamePacketNode(element);
4361 InsertChild(pContentRawDataNode); 4361 InsertChild(pContentRawDataNode);
4362 } 4362 }
4363 return pContentRawDataNode->TryContent(wsContent, bScriptModify, bProto); 4363 return pContentRawDataNode->TryContent(wsContent, bScriptModify, bProto);
4364 } 4364 }
4365 case XFA_ObjectType::NodeC: 4365 case XFA_ObjectType::NodeC:
4366 case XFA_ObjectType::NodeV: 4366 case XFA_ObjectType::NodeV:
4367 case XFA_ObjectType::TextNode: 4367 case XFA_ObjectType::TextNode:
4368 pNode = this; 4368 pNode = this;
4369 default: 4369 default:
4370 if (GetElementType() == XFA_Element::DataValue) { 4370 if (GetElementType() == XFA_Element::DataValue) {
4371 pNode = this; 4371 pNode = this;
4372 } 4372 }
4373 break; 4373 break;
4374 } 4374 }
4375 if (pNode) { 4375 if (pNode) {
4376 if (bScriptModify) { 4376 if (bScriptModify) {
4377 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 4377 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
4378 if (pScriptContext) { 4378 if (pScriptContext) {
4379 m_pDocument->GetScriptContext()->AddNodesOfRunScript(this); 4379 m_pDocument->GetScriptContext()->AddNodesOfRunScript(this);
4380 } 4380 }
4381 } 4381 }
4382 return TryCData(XFA_ATTRIBUTE_Value, wsContent, FALSE, bProto); 4382 return TryCData(XFA_ATTRIBUTE_Value, wsContent, false, bProto);
4383 } 4383 }
4384 return FALSE; 4384 return false;
4385 } 4385 }
4386 4386
4387 CXFA_Node* CXFA_Node::GetModelNode() { 4387 CXFA_Node* CXFA_Node::GetModelNode() {
4388 switch (GetPacketID()) { 4388 switch (GetPacketID()) {
4389 case XFA_XDPPACKET_XDP: 4389 case XFA_XDPPACKET_XDP:
4390 return m_pDocument->GetRoot(); 4390 return m_pDocument->GetRoot();
4391 case XFA_XDPPACKET_Config: 4391 case XFA_XDPPACKET_Config:
4392 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); 4392 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config));
4393 case XFA_XDPPACKET_Template: 4393 case XFA_XDPPACKET_Template:
4394 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); 4394 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template));
4395 case XFA_XDPPACKET_Form: 4395 case XFA_XDPPACKET_Form:
4396 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); 4396 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form));
4397 case XFA_XDPPACKET_Datasets: 4397 case XFA_XDPPACKET_Datasets:
4398 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); 4398 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets));
4399 case XFA_XDPPACKET_LocaleSet: 4399 case XFA_XDPPACKET_LocaleSet:
4400 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_LocaleSet)); 4400 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_LocaleSet));
4401 case XFA_XDPPACKET_ConnectionSet: 4401 case XFA_XDPPACKET_ConnectionSet:
4402 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_ConnectionSet)); 4402 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_ConnectionSet));
4403 case XFA_XDPPACKET_SourceSet: 4403 case XFA_XDPPACKET_SourceSet:
4404 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_SourceSet)); 4404 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_SourceSet));
4405 case XFA_XDPPACKET_Xdc: 4405 case XFA_XDPPACKET_Xdc:
4406 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Xdc)); 4406 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Xdc));
4407 default: 4407 default:
4408 return this; 4408 return this;
4409 } 4409 }
4410 } 4410 }
4411 4411
4412 FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { 4412 bool CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) {
4413 wsNamespace.clear(); 4413 wsNamespace.clear();
4414 if (IsModelNode() || GetElementType() == XFA_Element::Packet) { 4414 if (IsModelNode() || GetElementType() == XFA_Element::Packet) {
4415 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); 4415 CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
4416 if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) { 4416 if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) {
4417 return FALSE; 4417 return false;
4418 } 4418 }
4419 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace); 4419 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace);
4420 return TRUE; 4420 return true;
4421 } else if (GetPacketID() == XFA_XDPPACKET_Datasets) { 4421 } else if (GetPacketID() == XFA_XDPPACKET_Datasets) {
4422 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); 4422 CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
4423 if (!pXMLNode) { 4423 if (!pXMLNode) {
4424 return FALSE; 4424 return false;
4425 } 4425 }
4426 if (pXMLNode->GetType() != FDE_XMLNODE_Element) { 4426 if (pXMLNode->GetType() != FDE_XMLNODE_Element) {
4427 return TRUE; 4427 return true;
4428 } 4428 }
4429 if (GetElementType() == XFA_Element::DataValue && 4429 if (GetElementType() == XFA_Element::DataValue &&
4430 GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) { 4430 GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) {
4431 return XFA_FDEExtension_ResolveNamespaceQualifier( 4431 return XFA_FDEExtension_ResolveNamespaceQualifier(
4432 static_cast<CFDE_XMLElement*>(pXMLNode), 4432 static_cast<CFDE_XMLElement*>(pXMLNode),
4433 GetCData(XFA_ATTRIBUTE_QualifiedName), wsNamespace); 4433 GetCData(XFA_ATTRIBUTE_QualifiedName), wsNamespace);
4434 } 4434 }
4435 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace); 4435 static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace);
4436 return TRUE; 4436 return true;
4437 } else { 4437 } else {
4438 CXFA_Node* pModelNode = GetModelNode(); 4438 CXFA_Node* pModelNode = GetModelNode();
4439 return pModelNode->TryNamespace(wsNamespace); 4439 return pModelNode->TryNamespace(wsNamespace);
4440 } 4440 }
4441 } 4441 }
4442 4442
4443 CXFA_Node* CXFA_Node::GetProperty(int32_t index, 4443 CXFA_Node* CXFA_Node::GetProperty(int32_t index,
4444 XFA_Element eProperty, 4444 XFA_Element eProperty,
4445 FX_BOOL bCreateProperty) { 4445 bool bCreateProperty) {
4446 XFA_Element eType = GetElementType(); 4446 XFA_Element eType = GetElementType();
4447 uint32_t dwPacket = GetPacketID(); 4447 uint32_t dwPacket = GetPacketID();
4448 const XFA_PROPERTY* pProperty = 4448 const XFA_PROPERTY* pProperty =
4449 XFA_GetPropertyOfElement(eType, eProperty, dwPacket); 4449 XFA_GetPropertyOfElement(eType, eProperty, dwPacket);
4450 if (!pProperty || index >= pProperty->uOccur) 4450 if (!pProperty || index >= pProperty->uOccur)
4451 return nullptr; 4451 return nullptr;
4452 4452
4453 CXFA_Node* pNode = m_pChild; 4453 CXFA_Node* pNode = m_pChild;
4454 int32_t iCount = 0; 4454 int32_t iCount = 0;
4455 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 4455 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
(...skipping 22 matching lines...) Expand all
4478 for (; iCount <= index; iCount++) { 4478 for (; iCount <= index; iCount++) {
4479 pNewNode = m_pDocument->CreateNode(pPacket, eProperty); 4479 pNewNode = m_pDocument->CreateNode(pPacket, eProperty);
4480 if (!pNewNode) 4480 if (!pNewNode)
4481 return nullptr; 4481 return nullptr;
4482 InsertChild(pNewNode, nullptr); 4482 InsertChild(pNewNode, nullptr);
4483 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true); 4483 pNewNode->SetFlag(XFA_NodeFlag_Initialized, true);
4484 } 4484 }
4485 return pNewNode; 4485 return pNewNode;
4486 } 4486 }
4487 4487
4488 int32_t CXFA_Node::CountChildren(XFA_Element eType, FX_BOOL bOnlyChild) { 4488 int32_t CXFA_Node::CountChildren(XFA_Element eType, bool bOnlyChild) {
4489 CXFA_Node* pNode = m_pChild; 4489 CXFA_Node* pNode = m_pChild;
4490 int32_t iCount = 0; 4490 int32_t iCount = 0;
4491 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 4491 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
4492 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { 4492 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) {
4493 if (bOnlyChild) { 4493 if (bOnlyChild) {
4494 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( 4494 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(
4495 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); 4495 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN);
4496 if (pProperty) { 4496 if (pProperty) {
4497 continue; 4497 continue;
4498 } 4498 }
4499 } 4499 }
4500 iCount++; 4500 iCount++;
4501 } 4501 }
4502 } 4502 }
4503 return iCount; 4503 return iCount;
4504 } 4504 }
4505 4505
4506 CXFA_Node* CXFA_Node::GetChild(int32_t index, 4506 CXFA_Node* CXFA_Node::GetChild(int32_t index,
4507 XFA_Element eType, 4507 XFA_Element eType,
4508 FX_BOOL bOnlyChild) { 4508 bool bOnlyChild) {
4509 ASSERT(index > -1); 4509 ASSERT(index > -1);
4510 CXFA_Node* pNode = m_pChild; 4510 CXFA_Node* pNode = m_pChild;
4511 int32_t iCount = 0; 4511 int32_t iCount = 0;
4512 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 4512 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
4513 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { 4513 if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) {
4514 if (bOnlyChild) { 4514 if (bOnlyChild) {
4515 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( 4515 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(
4516 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); 4516 GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN);
4517 if (pProperty) { 4517 if (pProperty) {
4518 continue; 4518 continue;
4519 } 4519 }
4520 } 4520 }
4521 iCount++; 4521 iCount++;
4522 if (iCount > index) { 4522 if (iCount > index) {
4523 return pNode; 4523 return pNode;
4524 } 4524 }
4525 } 4525 }
4526 } 4526 }
4527 return nullptr; 4527 return nullptr;
4528 } 4528 }
4529 4529
4530 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { 4530 int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) {
4531 ASSERT(!pNode->m_pNext); 4531 ASSERT(!pNode->m_pNext);
4532 pNode->m_pParent = this; 4532 pNode->m_pParent = this;
4533 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); 4533 bool ret = m_pDocument->RemovePurgeNode(pNode);
4534 ASSERT(ret); 4534 ASSERT(ret);
4535 (void)ret; // Avoid unused variable warning. 4535 (void)ret; // Avoid unused variable warning.
4536 4536
4537 if (!m_pChild || index == 0) { 4537 if (!m_pChild || index == 0) {
4538 if (index > 0) { 4538 if (index > 0) {
4539 return -1; 4539 return -1;
4540 } 4540 }
4541 pNode->m_pNext = m_pChild; 4541 pNode->m_pNext = m_pChild;
4542 m_pChild = pNode; 4542 m_pChild = pNode;
4543 index = 0; 4543 index = 0;
(...skipping 23 matching lines...) Expand all
4567 pNotify->OnChildAdded(this); 4567 pNotify->OnChildAdded(this);
4568 4568
4569 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { 4569 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) {
4570 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); 4570 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent));
4571 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); 4571 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index);
4572 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); 4572 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode);
4573 } 4573 }
4574 return index; 4574 return index;
4575 } 4575 }
4576 4576
4577 FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { 4577 bool CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) {
4578 if (!pNode || pNode->m_pParent || 4578 if (!pNode || pNode->m_pParent ||
4579 (pBeforeNode && pBeforeNode->m_pParent != this)) { 4579 (pBeforeNode && pBeforeNode->m_pParent != this)) {
4580 ASSERT(false); 4580 ASSERT(false);
4581 return FALSE; 4581 return false;
4582 } 4582 }
4583 FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode); 4583 bool ret = m_pDocument->RemovePurgeNode(pNode);
4584 ASSERT(ret); 4584 ASSERT(ret);
4585 (void)ret; // Avoid unused variable warning. 4585 (void)ret; // Avoid unused variable warning.
4586 4586
4587 int32_t nIndex = -1; 4587 int32_t nIndex = -1;
4588 pNode->m_pParent = this; 4588 pNode->m_pParent = this;
4589 if (!m_pChild || pBeforeNode == m_pChild) { 4589 if (!m_pChild || pBeforeNode == m_pChild) {
4590 pNode->m_pNext = m_pChild; 4590 pNode->m_pNext = m_pChild;
4591 m_pChild = pNode; 4591 m_pChild = pNode;
4592 nIndex = 0; 4592 nIndex = 0;
4593 } else if (!pBeforeNode) { 4593 } else if (!pBeforeNode) {
(...skipping 17 matching lines...) Expand all
4611 pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren); 4611 pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren);
4612 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 4612 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4613 if (pNotify) 4613 if (pNotify)
4614 pNotify->OnChildAdded(this); 4614 pNotify->OnChildAdded(this);
4615 4615
4616 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { 4616 if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) {
4617 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); 4617 ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent));
4618 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); 4618 m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex);
4619 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); 4619 pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode);
4620 } 4620 }
4621 return TRUE; 4621 return true;
4622 } 4622 }
4623 4623
4624 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { 4624 CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() {
4625 if (!m_pParent) { 4625 if (!m_pParent) {
4626 return nullptr; 4626 return nullptr;
4627 } 4627 }
4628 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; 4628 for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling;
4629 pSibling = pSibling->m_pNext) { 4629 pSibling = pSibling->m_pNext) {
4630 if (pSibling->m_pNext == this) { 4630 if (pSibling->m_pNext == this) {
4631 return pSibling; 4631 return pSibling;
4632 } 4632 }
4633 } 4633 }
4634 return nullptr; 4634 return nullptr;
4635 } 4635 }
4636 4636
4637 FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { 4637 bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) {
4638 if (!pNode || pNode->m_pParent != this) { 4638 if (!pNode || pNode->m_pParent != this) {
4639 ASSERT(FALSE); 4639 ASSERT(false);
4640 return FALSE; 4640 return false;
4641 } 4641 }
4642 if (m_pChild == pNode) { 4642 if (m_pChild == pNode) {
4643 m_pChild = pNode->m_pNext; 4643 m_pChild = pNode->m_pNext;
4644 if (m_pLastChild == pNode) { 4644 if (m_pLastChild == pNode) {
4645 m_pLastChild = pNode->m_pNext; 4645 m_pLastChild = pNode->m_pNext;
4646 } 4646 }
4647 pNode->m_pNext = nullptr; 4647 pNode->m_pNext = nullptr;
4648 pNode->m_pParent = nullptr; 4648 pNode->m_pParent = nullptr;
4649 } else { 4649 } else {
4650 CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling(); 4650 CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling();
(...skipping 13 matching lines...) Expand all
4664 ASSERT(pNode->m_pXMLNode == m_pXMLNode && 4664 ASSERT(pNode->m_pXMLNode == m_pXMLNode &&
4665 m_pXMLNode->GetType() == FDE_XMLNODE_Element); 4665 m_pXMLNode->GetType() == FDE_XMLNODE_Element);
4666 if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { 4666 if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) {
4667 CFDE_XMLElement* pXMLElement = 4667 CFDE_XMLElement* pXMLElement =
4668 static_cast<CFDE_XMLElement*>(pNode->m_pXMLNode); 4668 static_cast<CFDE_XMLElement*>(pNode->m_pXMLNode);
4669 CFX_WideStringC wsAttributeName = 4669 CFX_WideStringC wsAttributeName =
4670 pNode->GetCData(XFA_ATTRIBUTE_QualifiedName); 4670 pNode->GetCData(XFA_ATTRIBUTE_QualifiedName);
4671 pXMLElement->RemoveAttribute(wsAttributeName.c_str()); 4671 pXMLElement->RemoveAttribute(wsAttributeName.c_str());
4672 } 4672 }
4673 CFX_WideString wsName; 4673 CFX_WideString wsName;
4674 pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); 4674 pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, false);
4675 CFDE_XMLElement* pNewXMLElement = new CFDE_XMLElement(wsName); 4675 CFDE_XMLElement* pNewXMLElement = new CFDE_XMLElement(wsName);
4676 CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); 4676 CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value);
4677 if (!wsValue.IsEmpty()) { 4677 if (!wsValue.IsEmpty()) {
4678 pNewXMLElement->SetTextData(CFX_WideString(wsValue)); 4678 pNewXMLElement->SetTextData(CFX_WideString(wsValue));
4679 } 4679 }
4680 pNode->m_pXMLNode = pNewXMLElement; 4680 pNode->m_pXMLNode = pNewXMLElement;
4681 pNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); 4681 pNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown);
4682 } else { 4682 } else {
4683 m_pXMLNode->RemoveChildNode(pNode->m_pXMLNode); 4683 m_pXMLNode->RemoveChildNode(pNode->m_pXMLNode);
4684 } 4684 }
4685 pNode->SetFlag(XFA_NodeFlag_OwnXMLNode, false); 4685 pNode->SetFlag(XFA_NodeFlag_OwnXMLNode, false);
4686 } 4686 }
4687 return TRUE; 4687 return true;
4688 } 4688 }
4689 4689
4690 CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { 4690 CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const {
4691 return GetFirstChildByName(FX_HashCode_GetW(wsName, false)); 4691 return GetFirstChildByName(FX_HashCode_GetW(wsName, false));
4692 } 4692 }
4693 4693
4694 CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const { 4694 CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const {
4695 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; 4695 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
4696 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 4696 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
4697 if (pNode->GetNameHash() == dwNameHash) { 4697 if (pNode->GetNameHash() == dwNameHash) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4807 pNotify->OnNodeReady(this); 4807 pNotify->OnNodeReady(this);
4808 } 4808 }
4809 } 4809 }
4810 m_uNodeFlags |= dwFlag; 4810 m_uNodeFlags |= dwFlag;
4811 } 4811 }
4812 4812
4813 void CXFA_Node::ClearFlag(uint32_t dwFlag) { 4813 void CXFA_Node::ClearFlag(uint32_t dwFlag) {
4814 m_uNodeFlags &= ~dwFlag; 4814 m_uNodeFlags &= ~dwFlag;
4815 } 4815 }
4816 4816
4817 FX_BOOL CXFA_Node::IsAttributeInXML() { 4817 bool CXFA_Node::IsAttributeInXML() {
4818 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; 4818 return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData;
4819 } 4819 }
4820 4820
4821 void CXFA_Node::OnRemoved(bool bNotify) { 4821 void CXFA_Node::OnRemoved(bool bNotify) {
4822 if (!bNotify) 4822 if (!bNotify)
4823 return; 4823 return;
4824 4824
4825 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 4825 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4826 if (pNotify) 4826 if (pNotify)
4827 pNotify->OnChildRemoved(); 4827 pNotify->OnChildRemoved();
4828 } 4828 }
4829 4829
4830 void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify) { 4830 void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify) {
4831 if (bNotify && IsInitialized()) { 4831 if (bNotify && IsInitialized()) {
4832 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 4832 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4833 if (pNotify) { 4833 if (pNotify) {
4834 pNotify->OnValueChanging(this, eAttr); 4834 pNotify->OnValueChanging(this, eAttr);
4835 } 4835 }
4836 } 4836 }
4837 } 4837 }
4838 4838
4839 void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, 4839 void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr,
4840 bool bNotify, 4840 bool bNotify,
4841 FX_BOOL bScriptModify) { 4841 bool bScriptModify) {
4842 if (bNotify && IsInitialized()) { 4842 if (bNotify && IsInitialized()) {
4843 Script_Attribute_SendAttributeChangeMessage(eAttr, bScriptModify); 4843 Script_Attribute_SendAttributeChangeMessage(eAttr, bScriptModify);
4844 } 4844 }
4845 } 4845 }
4846 4846
4847 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, 4847 int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName,
4848 XFA_Element eType) { 4848 XFA_Element eType) {
4849 int32_t iRet = XFA_EVENTERROR_NotExist; 4849 int32_t iRet = XFA_EVENTERROR_NotExist;
4850 const XFA_ExecEventParaInfo* eventParaInfo = 4850 const XFA_ExecEventParaInfo* eventParaInfo =
4851 GetEventParaInfoByName(wsEventName); 4851 GetEventParaInfoByName(wsEventName);
4852 if (eventParaInfo) { 4852 if (eventParaInfo) {
4853 uint32_t validFlags = eventParaInfo->m_validFlags; 4853 uint32_t validFlags = eventParaInfo->m_validFlags;
4854 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 4854 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
4855 if (!pNotify) { 4855 if (!pNotify) {
4856 return iRet; 4856 return iRet;
4857 } 4857 }
4858 if (validFlags == 1) { 4858 if (validFlags == 1) {
4859 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType); 4859 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType);
4860 } else if (validFlags == 2) { 4860 } else if (validFlags == 2) {
4861 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4861 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4862 FALSE, FALSE); 4862 false, false);
4863 } else if (validFlags == 3) { 4863 } else if (validFlags == 3) {
4864 if (eType == XFA_Element::Subform) { 4864 if (eType == XFA_Element::Subform) {
4865 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4865 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4866 FALSE, FALSE); 4866 false, false);
4867 } 4867 }
4868 } else if (validFlags == 4) { 4868 } else if (validFlags == 4) {
4869 if (eType == XFA_Element::ExclGroup || eType == XFA_Element::Field) { 4869 if (eType == XFA_Element::ExclGroup || eType == XFA_Element::Field) {
4870 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); 4870 CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
4871 if (pParentNode && 4871 if (pParentNode &&
4872 pParentNode->GetElementType() == XFA_Element::ExclGroup) { 4872 pParentNode->GetElementType() == XFA_Element::ExclGroup) {
4873 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4873 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4874 FALSE, FALSE); 4874 false, false);
4875 } 4875 }
4876 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4876 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4877 FALSE, FALSE); 4877 false, false);
4878 } 4878 }
4879 } else if (validFlags == 5) { 4879 } else if (validFlags == 5) {
4880 if (eType == XFA_Element::Field) { 4880 if (eType == XFA_Element::Field) {
4881 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4881 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4882 FALSE, FALSE); 4882 false, false);
4883 } 4883 }
4884 } else if (validFlags == 6) { 4884 } else if (validFlags == 6) {
4885 CXFA_WidgetData* pWidgetData = GetWidgetData(); 4885 CXFA_WidgetData* pWidgetData = GetWidgetData();
4886 if (pWidgetData) { 4886 if (pWidgetData) {
4887 CXFA_Node* pUINode = pWidgetData->GetUIChild(); 4887 CXFA_Node* pUINode = pWidgetData->GetUIChild();
4888 if (pUINode->m_elementType == XFA_Element::Signature) { 4888 if (pUINode->m_elementType == XFA_Element::Signature) {
4889 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4889 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4890 FALSE, FALSE); 4890 false, false);
4891 } 4891 }
4892 } 4892 }
4893 } else if (validFlags == 7) { 4893 } else if (validFlags == 7) {
4894 CXFA_WidgetData* pWidgetData = GetWidgetData(); 4894 CXFA_WidgetData* pWidgetData = GetWidgetData();
4895 if (pWidgetData) { 4895 if (pWidgetData) {
4896 CXFA_Node* pUINode = pWidgetData->GetUIChild(); 4896 CXFA_Node* pUINode = pWidgetData->GetUIChild();
4897 if ((pUINode->m_elementType == XFA_Element::ChoiceList) && 4897 if ((pUINode->m_elementType == XFA_Element::ChoiceList) &&
4898 (!pWidgetData->IsListBox())) { 4898 (!pWidgetData->IsListBox())) {
4899 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, 4899 iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
4900 FALSE, FALSE); 4900 false, false);
4901 } 4901 }
4902 } 4902 }
4903 } 4903 }
4904 } 4904 }
4905 return iRet; 4905 return iRet;
4906 } 4906 }
4907 4907
4908 void CXFA_Node::UpdateNameHash() { 4908 void CXFA_Node::UpdateNameHash() {
4909 const XFA_NOTSUREATTRIBUTE* pNotsure = 4909 const XFA_NOTSUREATTRIBUTE* pNotsure =
4910 XFA_GetNotsureAttribute(GetElementType(), XFA_ATTRIBUTE_Name); 4910 XFA_GetNotsureAttribute(GetElementType(), XFA_ATTRIBUTE_Name);
4911 CFX_WideStringC wsName; 4911 CFX_WideStringC wsName;
4912 if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) { 4912 if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) {
4913 wsName = GetCData(XFA_ATTRIBUTE_Name); 4913 wsName = GetCData(XFA_ATTRIBUTE_Name);
4914 m_dwNameHash = FX_HashCode_GetW(wsName, false); 4914 m_dwNameHash = FX_HashCode_GetW(wsName, false);
4915 } else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) { 4915 } else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) {
4916 wsName = GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName; 4916 wsName = GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName;
4917 m_dwNameHash = FX_HashCode_GetW(wsName, false); 4917 m_dwNameHash = FX_HashCode_GetW(wsName, false);
4918 } 4918 }
4919 } 4919 }
4920 4920
4921 CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { 4921 CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() {
4922 if (!m_pXMLNode) { 4922 if (!m_pXMLNode) {
4923 CFX_WideString wsTag(GetCData(XFA_ATTRIBUTE_Name)); 4923 CFX_WideString wsTag(GetCData(XFA_ATTRIBUTE_Name));
4924 m_pXMLNode = new CFDE_XMLElement(wsTag); 4924 m_pXMLNode = new CFDE_XMLElement(wsTag);
4925 SetFlag(XFA_NodeFlag_OwnXMLNode, false); 4925 SetFlag(XFA_NodeFlag_OwnXMLNode, false);
4926 } 4926 }
4927 return m_pXMLNode; 4927 return m_pXMLNode;
4928 } 4928 }
4929 4929
4930 FX_BOOL CXFA_Node::IsNeedSavingXMLNode() { 4930 bool CXFA_Node::IsNeedSavingXMLNode() {
4931 return m_pXMLNode && (GetPacketID() == XFA_XDPPACKET_Datasets || 4931 return m_pXMLNode && (GetPacketID() == XFA_XDPPACKET_Datasets ||
4932 GetElementType() == XFA_Element::Xfa); 4932 GetElementType() == XFA_Element::Xfa);
4933 } 4933 }
4934 4934
4935 XFA_MAPMODULEDATA* CXFA_Node::CreateMapModuleData() { 4935 XFA_MAPMODULEDATA* CXFA_Node::CreateMapModuleData() {
4936 if (!m_pMapModuleData) 4936 if (!m_pMapModuleData)
4937 m_pMapModuleData = new XFA_MAPMODULEDATA; 4937 m_pMapModuleData = new XFA_MAPMODULEDATA;
4938 return m_pMapModuleData; 4938 return m_pMapModuleData;
4939 } 4939 }
4940 4940
4941 XFA_MAPMODULEDATA* CXFA_Node::GetMapModuleData() const { 4941 XFA_MAPMODULEDATA* CXFA_Node::GetMapModuleData() const {
4942 return m_pMapModuleData; 4942 return m_pMapModuleData;
4943 } 4943 }
4944 4944
4945 void CXFA_Node::SetMapModuleValue(void* pKey, void* pValue) { 4945 void CXFA_Node::SetMapModuleValue(void* pKey, void* pValue) {
4946 XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); 4946 XFA_MAPMODULEDATA* pModule = CreateMapModuleData();
4947 pModule->m_ValueMap.SetAt(pKey, pValue); 4947 pModule->m_ValueMap.SetAt(pKey, pValue);
4948 } 4948 }
4949 4949
4950 FX_BOOL CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) { 4950 bool CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) {
4951 CXFA_Node* pNode = this; 4951 CXFA_Node* pNode = this;
4952 while (pNode) { 4952 while (pNode) {
4953 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); 4953 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData();
4954 if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) { 4954 if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) {
4955 return TRUE; 4955 return true;
4956 } 4956 }
4957 pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets 4957 pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets
4958 ? pNode->GetTemplateNode() 4958 ? pNode->GetTemplateNode()
4959 : nullptr; 4959 : nullptr;
4960 } 4960 }
4961 return FALSE; 4961 return false;
4962 } 4962 }
4963 4963
4964 void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) { 4964 void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) {
4965 SetMapModuleBuffer(pKey, (void*)wsValue.c_str(), 4965 SetMapModuleBuffer(pKey, (void*)wsValue.c_str(),
4966 wsValue.GetLength() * sizeof(FX_WCHAR)); 4966 wsValue.GetLength() * sizeof(FX_WCHAR));
4967 } 4967 }
4968 4968
4969 FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) { 4969 bool CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) {
4970 void* pValue; 4970 void* pValue;
4971 int32_t iBytes; 4971 int32_t iBytes;
4972 if (!GetMapModuleBuffer(pKey, pValue, iBytes)) { 4972 if (!GetMapModuleBuffer(pKey, pValue, iBytes)) {
4973 return FALSE; 4973 return false;
4974 } 4974 }
4975 wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR)); 4975 wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR));
4976 return TRUE; 4976 return true;
4977 } 4977 }
4978 4978
4979 void CXFA_Node::SetMapModuleBuffer( 4979 void CXFA_Node::SetMapModuleBuffer(
4980 void* pKey, 4980 void* pKey,
4981 void* pValue, 4981 void* pValue,
4982 int32_t iBytes, 4982 int32_t iBytes,
4983 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { 4983 XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
4984 XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); 4984 XFA_MAPMODULEDATA* pModule = CreateMapModuleData();
4985 XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey]; 4985 XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey];
4986 if (!pBuffer) { 4986 if (!pBuffer) {
4987 pBuffer = 4987 pBuffer =
4988 (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes); 4988 (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes);
4989 } else if (pBuffer->iBytes != iBytes) { 4989 } else if (pBuffer->iBytes != iBytes) {
4990 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { 4990 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) {
4991 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); 4991 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData());
4992 } 4992 }
4993 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer, 4993 pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer,
4994 sizeof(XFA_MAPDATABLOCK) + iBytes); 4994 sizeof(XFA_MAPDATABLOCK) + iBytes);
4995 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { 4995 } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) {
4996 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); 4996 pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData());
4997 } 4997 }
4998 if (!pBuffer) 4998 if (!pBuffer)
4999 return; 4999 return;
5000 5000
5001 pBuffer->pCallbackInfo = pCallbackInfo; 5001 pBuffer->pCallbackInfo = pCallbackInfo;
5002 pBuffer->iBytes = iBytes; 5002 pBuffer->iBytes = iBytes;
5003 FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes); 5003 FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes);
5004 } 5004 }
5005 5005
5006 FX_BOOL CXFA_Node::GetMapModuleBuffer(void* pKey, 5006 bool CXFA_Node::GetMapModuleBuffer(void* pKey,
5007 void*& pValue, 5007 void*& pValue,
5008 int32_t& iBytes, 5008 int32_t& iBytes,
5009 FX_BOOL bProtoAlso) const { 5009 bool bProtoAlso) const {
5010 XFA_MAPDATABLOCK* pBuffer = nullptr; 5010 XFA_MAPDATABLOCK* pBuffer = nullptr;
5011 const CXFA_Node* pNode = this; 5011 const CXFA_Node* pNode = this;
5012 while (pNode) { 5012 while (pNode) {
5013 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); 5013 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData();
5014 if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) { 5014 if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) {
5015 break; 5015 break;
5016 } 5016 }
5017 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) 5017 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets)
5018 ? pNode->GetTemplateNode() 5018 ? pNode->GetTemplateNode()
5019 : nullptr; 5019 : nullptr;
5020 } 5020 }
5021 if (!pBuffer) { 5021 if (!pBuffer) {
5022 return FALSE; 5022 return false;
5023 } 5023 }
5024 pValue = pBuffer->GetData(); 5024 pValue = pBuffer->GetData();
5025 iBytes = pBuffer->iBytes; 5025 iBytes = pBuffer->iBytes;
5026 return TRUE; 5026 return true;
5027 } 5027 }
5028 5028
5029 FX_BOOL CXFA_Node::HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso) { 5029 bool CXFA_Node::HasMapModuleKey(void* pKey, bool bProtoAlso) {
5030 CXFA_Node* pNode = this; 5030 CXFA_Node* pNode = this;
5031 while (pNode) { 5031 while (pNode) {
5032 void* pVal; 5032 void* pVal;
5033 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); 5033 XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData();
5034 if (pModule && 5034 if (pModule &&
5035 (pModule->m_ValueMap.Lookup(pKey, pVal) || 5035 (pModule->m_ValueMap.Lookup(pKey, pVal) ||
5036 pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) { 5036 pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) {
5037 return TRUE; 5037 return true;
5038 } 5038 }
5039 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) 5039 pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets)
5040 ? pNode->GetTemplateNode() 5040 ? pNode->GetTemplateNode()
5041 : nullptr; 5041 : nullptr;
5042 } 5042 }
5043 return FALSE; 5043 return false;
5044 } 5044 }
5045 5045
5046 void CXFA_Node::RemoveMapModuleKey(void* pKey) { 5046 void CXFA_Node::RemoveMapModuleKey(void* pKey) {
5047 XFA_MAPMODULEDATA* pModule = GetMapModuleData(); 5047 XFA_MAPMODULEDATA* pModule = GetMapModuleData();
5048 if (!pModule) 5048 if (!pModule)
5049 return; 5049 return;
5050 5050
5051 if (pKey) { 5051 if (pKey) {
5052 XFA_MAPDATABLOCK* pBuffer = nullptr; 5052 XFA_MAPDATABLOCK* pBuffer = nullptr;
5053 pModule->m_BufferMap.Lookup(pKey, pBuffer); 5053 pModule->m_BufferMap.Lookup(pKey, pBuffer);
(...skipping 16 matching lines...) Expand all
5070 } 5070 }
5071 FX_Free(pBuffer); 5071 FX_Free(pBuffer);
5072 } 5072 }
5073 } 5073 }
5074 pModule->m_BufferMap.RemoveAll(); 5074 pModule->m_BufferMap.RemoveAll();
5075 pModule->m_ValueMap.RemoveAll(); 5075 pModule->m_ValueMap.RemoveAll();
5076 delete pModule; 5076 delete pModule;
5077 } 5077 }
5078 } 5078 }
5079 5079
5080 void CXFA_Node::MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr) { 5080 void CXFA_Node::MergeAllData(void* pDstModule, bool bUseSrcAttr) {
5081 XFA_MAPMODULEDATA* pDstModuleData = 5081 XFA_MAPMODULEDATA* pDstModuleData =
5082 static_cast<CXFA_Node*>(pDstModule)->CreateMapModuleData(); 5082 static_cast<CXFA_Node*>(pDstModule)->CreateMapModuleData();
5083 XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData(); 5083 XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData();
5084 if (!pSrcModuleData) { 5084 if (!pSrcModuleData) {
5085 return; 5085 return;
5086 } 5086 }
5087 FX_POSITION psValue = pSrcModuleData->m_ValueMap.GetStartPosition(); 5087 FX_POSITION psValue = pSrcModuleData->m_ValueMap.GetStartPosition();
5088 while (psValue) { 5088 while (psValue) {
5089 void* pKey; 5089 void* pKey;
5090 void* pValue; 5090 void* pValue;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5131 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) { 5131 if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) {
5132 pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData()); 5132 pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData());
5133 } 5133 }
5134 } 5134 }
5135 } 5135 }
5136 5136
5137 void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { 5137 void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) {
5138 if (!pDstModule) { 5138 if (!pDstModule) {
5139 return; 5139 return;
5140 } 5140 }
5141 FX_BOOL bNeedMove = TRUE; 5141 bool bNeedMove = true;
5142 if (!pKey) { 5142 if (!pKey) {
5143 bNeedMove = FALSE; 5143 bNeedMove = false;
5144 } 5144 }
5145 if (pDstModule->GetElementType() != GetElementType()) { 5145 if (pDstModule->GetElementType() != GetElementType()) {
5146 bNeedMove = FALSE; 5146 bNeedMove = false;
5147 } 5147 }
5148 XFA_MAPMODULEDATA* pSrcModuleData = nullptr; 5148 XFA_MAPMODULEDATA* pSrcModuleData = nullptr;
5149 XFA_MAPMODULEDATA* pDstModuleData = nullptr; 5149 XFA_MAPMODULEDATA* pDstModuleData = nullptr;
5150 if (bNeedMove) { 5150 if (bNeedMove) {
5151 pSrcModuleData = GetMapModuleData(); 5151 pSrcModuleData = GetMapModuleData();
5152 if (!pSrcModuleData) { 5152 if (!pSrcModuleData) {
5153 bNeedMove = FALSE; 5153 bNeedMove = false;
5154 } 5154 }
5155 pDstModuleData = pDstModule->CreateMapModuleData(); 5155 pDstModuleData = pDstModule->CreateMapModuleData();
5156 } 5156 }
5157 if (bNeedMove) { 5157 if (bNeedMove) {
5158 void* pBufferBlockData = pSrcModuleData->m_BufferMap.GetValueAt(pKey); 5158 void* pBufferBlockData = pSrcModuleData->m_BufferMap.GetValueAt(pKey);
5159 if (pBufferBlockData) { 5159 if (pBufferBlockData) {
5160 pSrcModuleData->m_BufferMap.RemoveKey(pKey); 5160 pSrcModuleData->m_BufferMap.RemoveKey(pKey);
5161 pDstModuleData->m_BufferMap.RemoveKey(pKey); 5161 pDstModuleData->m_BufferMap.RemoveKey(pKey);
5162 pDstModuleData->m_BufferMap.SetAt(pKey, 5162 pDstModuleData->m_BufferMap.SetAt(pKey,
5163 (XFA_MAPDATABLOCK*)pBufferBlockData); 5163 (XFA_MAPDATABLOCK*)pBufferBlockData);
5164 } 5164 }
5165 } 5165 }
5166 if (pDstModule->IsNodeV()) { 5166 if (pDstModule->IsNodeV()) {
5167 CFX_WideString wsValue = pDstModule->GetScriptContent(FALSE); 5167 CFX_WideString wsValue = pDstModule->GetScriptContent(false);
5168 CFX_WideString wsFormatValue(wsValue); 5168 CFX_WideString wsFormatValue(wsValue);
5169 CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData(); 5169 CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData();
5170 if (pWidgetData) { 5170 if (pWidgetData) {
5171 pWidgetData->GetFormatDataValue(wsValue, wsFormatValue); 5171 pWidgetData->GetFormatDataValue(wsValue, wsFormatValue);
5172 } 5172 }
5173 pDstModule->SetScriptContent(wsValue, wsFormatValue, true, TRUE); 5173 pDstModule->SetScriptContent(wsValue, wsFormatValue, true, true);
5174 } 5174 }
5175 } 5175 }
5176 5176
5177 void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule, 5177 void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule,
5178 CXFA_Node* pDstModule, 5178 CXFA_Node* pDstModule,
5179 void* pKey, 5179 void* pKey,
5180 FX_BOOL bRecursive) { 5180 bool bRecursive) {
5181 if (!pSrcModule || !pDstModule || !pKey) { 5181 if (!pSrcModule || !pDstModule || !pKey) {
5182 return; 5182 return;
5183 } 5183 }
5184 if (bRecursive) { 5184 if (bRecursive) {
5185 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); 5185 CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild);
5186 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); 5186 CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild);
5187 for (; pSrcChild && pDstChild; 5187 for (; pSrcChild && pDstChild;
5188 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), 5188 pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling),
5189 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 5189 pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
5190 MoveBufferMapData(pSrcChild, pDstChild, pKey, TRUE); 5190 MoveBufferMapData(pSrcChild, pDstChild, pKey, true);
5191 } 5191 }
5192 } 5192 }
5193 pSrcModule->MoveBufferMapData(pDstModule, pKey); 5193 pSrcModule->MoveBufferMapData(pDstModule, pKey);
5194 } 5194 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_measurement.cpp ('k') | xfa/fxfa/parser/cxfa_nodehelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698